From c52d42d4471c7a22f5b44e2d7f8a2b1965574295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 11 May 2026 06:51:22 +0300 Subject: [PATCH] =?UTF-8?q?fix(supplier):=20Plan=203=20final=20review=20C-?= =?UTF-8?q?1=20+=20I-2=20=E2=80=94=20TestCase=20autowire=20+=20lock=20TTL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C-1: PlaywrightBridgeTest + RefreshSupplierSessionJobTest swap line order - uses(TestCase::class) was BEFORE use Tests\TestCase → Pest resolved to non-existent \TestCase → file-load fatal → 6 tests NEVER ran since 71c999b. - Fix: import BEFORE uses() call (pattern matches 3 working files в same dir). - Misdiagnosis correction: ранее "pao stream_filter" symptoms attributed to laravel/pao env quirk были фактически C-1. Full suite parallel: 617 tests / 614 passed / 3 skipped / 0 failed. I-2: RefreshSupplierSessionJob lock TTL bump 30s → 90s - PlaywrightBridge::TIMEOUT_SECONDS=75s. Lock TTL 30s → auto-expiry while real chromium boot+login still в процессе → concurrent refresh race. - Fix: lock(name, 90)->block(95, ...) — exceeds PlaywrightBridge timeout. Baseline regenerated после C-1 fix (stale entries removed, fresh Mockery type errors captured). Verification: - tests/Unit/Supplier/: 30/30 pass (was 22/30 — 6 не запускались, 2 skip) - Full parallel suite: 617/614+3 skipped/0 failed - PHPStan: 0 errors. Pint: clean. Final code-review (subagent verdict pre-C-1): "Ready to merge, with C-1 fix". После этого commit'а — verdict satisfied. Issues defer-to-post-merge per reviewer (follow-up tracking в memory): - I-1 onOneServer (multi-server scaling; gated на Б-1 production) - I-3 save_orphan recovery path (rare DB-write fail during HTTP success) - I-4 region_mode='exclude' regions_reverse passthrough - I-5 #4 acceptance criterion deferred until Task 1 closes --- .../Supplier/RefreshSupplierSessionJob.php | 7 ++- app/phpstan-baseline.neon | 44 ++----------------- .../Unit/Supplier/PlaywrightBridgeTest.php | 4 +- .../RefreshSupplierSessionJobTest.php | 4 +- 4 files changed, 13 insertions(+), 46 deletions(-) diff --git a/app/app/Jobs/Supplier/RefreshSupplierSessionJob.php b/app/app/Jobs/Supplier/RefreshSupplierSessionJob.php index 87435b93..c6140b4c 100644 --- a/app/app/Jobs/Supplier/RefreshSupplierSessionJob.php +++ b/app/app/Jobs/Supplier/RefreshSupplierSessionJob.php @@ -42,10 +42,13 @@ class RefreshSupplierSessionJob implements ShouldQueue public function handle(PlaywrightBridge $bridge): void { + // Lock TTL must exceed PlaywrightBridge::TIMEOUT_SECONDS (75s) to prevent + // auto-expiry while real chromium boot+login still в процессе → concurrent + // refresh race. Block timeout slightly higher. Final review I-2 fix. /** @var LockProvider $lockStore */ $lockStore = Cache::store('redis'); - $lockStore->lock('supplier:session:refresh', 30) - ->block(35, function () use ($bridge) { + $lockStore->lock('supplier:session:refresh', 90) + ->block(95, function () use ($bridge) { $session = $bridge->refreshSession( login: (string) config('services.supplier.login'), password: (string) config('services.supplier.password'), diff --git a/app/phpstan-baseline.neon b/app/phpstan-baseline.neon index c8c830a1..2e10381e 100644 --- a/app/phpstan-baseline.neon +++ b/app/phpstan-baseline.neon @@ -955,20 +955,8 @@ parameters: path: tests/Unit/ExampleTest.php - - message: '#^Call to method shouldReceive\(\) on an unknown class ProcessFactory\.$#' - identifier: class.notFound - count: 1 - path: tests/Unit/Supplier/PlaywrightBridgeTest.php - - - - message: '#^Class TestCase not found\.$#' - identifier: class.notFound - count: 1 - path: tests/Unit/Supplier/PlaywrightBridgeTest.php - - - - message: '#^PHPDoc tag @var for variable \$factoryMock contains unknown class ProcessFactory\.$#' - identifier: class.notFound + message: '#^Call to an undefined method App\\Services\\Supplier\\ProcessFactory\:\:shouldReceive\(\)\.$#' + identifier: method.notFound count: 1 path: tests/Unit/Supplier/PlaywrightBridgeTest.php @@ -979,32 +967,8 @@ parameters: path: tests/Unit/Supplier/PlaywrightBridgeTest.php - - message: '#^Parameter \#1 \$processFactory of class App\\Services\\Supplier\\PlaywrightBridge constructor expects App\\Services\\Supplier\\ProcessFactory, ProcessFactory given\.$#' - identifier: argument.type - count: 1 - path: tests/Unit/Supplier/PlaywrightBridgeTest.php - - - - message: '#^Call to method shouldReceive\(\) on an unknown class PlaywrightBridge\.$#' - identifier: class.notFound - count: 2 - path: tests/Unit/Supplier/RefreshSupplierSessionJobTest.php - - - - message: '#^Class TestCase not found\.$#' - identifier: class.notFound - count: 1 - path: tests/Unit/Supplier/RefreshSupplierSessionJobTest.php - - - - message: '#^PHPDoc tag @var for variable \$bridge contains unknown class PlaywrightBridge\.$#' - identifier: class.notFound - count: 2 - path: tests/Unit/Supplier/RefreshSupplierSessionJobTest.php - - - - message: '#^Parameter \#1 \$bridge of method App\\Jobs\\Supplier\\RefreshSupplierSessionJob\:\:handle\(\) expects App\\Services\\Supplier\\PlaywrightBridge, PlaywrightBridge given\.$#' - identifier: argument.type + message: '#^Call to an undefined method App\\Services\\Supplier\\PlaywrightBridge\:\:shouldReceive\(\)\.$#' + identifier: method.notFound count: 2 path: tests/Unit/Supplier/RefreshSupplierSessionJobTest.php diff --git a/app/tests/Unit/Supplier/PlaywrightBridgeTest.php b/app/tests/Unit/Supplier/PlaywrightBridgeTest.php index 16ca394d..166025f1 100644 --- a/app/tests/Unit/Supplier/PlaywrightBridgeTest.php +++ b/app/tests/Unit/Supplier/PlaywrightBridgeTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -uses(TestCase::class); - use App\Exceptions\Supplier\SupplierAuthException; use App\Services\Supplier\PlaywrightBridge; use App\Services\Supplier\ProcessFactory; use Tests\TestCase; use Tests\Unit\Supplier\Stubs\StubPlaywrightProcessHandle; +uses(TestCase::class); + test('PlaywrightBridge passes credentials via stdin not argv', function () { $stubHandle = new StubPlaywrightProcessHandle( successful: true, diff --git a/app/tests/Unit/Supplier/RefreshSupplierSessionJobTest.php b/app/tests/Unit/Supplier/RefreshSupplierSessionJobTest.php index ab2250aa..67088f0d 100644 --- a/app/tests/Unit/Supplier/RefreshSupplierSessionJobTest.php +++ b/app/tests/Unit/Supplier/RefreshSupplierSessionJobTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -uses(TestCase::class); - use App\Exceptions\Supplier\SupplierAuthException; use App\Jobs\Supplier\RefreshSupplierSessionJob; use App\Services\Supplier\PlaywrightBridge; use Illuminate\Support\Facades\Cache; use Tests\TestCase; +uses(TestCase::class); + beforeEach(function () { config([ 'services.supplier.login' => 'test_login',