set('services.supplier.login', 'u'); config()->set('services.supplier.password', 'p'); config()->set('services.supplier.portal_url', 'https://crm.bp-gr.ru'); }); it('читает баланс кабинета через Playwright-мост', function () { $bridge = Mockery::mock(PlaywrightBridge::class); $bridge->shouldReceive('run')->once()->andReturn(['balance' => 12400, 'currency' => 'RUB']); app()->instance(PlaywrightBridge::class, $bridge); $r = app(SupplierBalanceProvider::class)->fetch(); expect($r->ok)->toBeTrue(); expect($r->balance)->toBe(12400.0); expect($r->serviceKey)->toBe('supplier'); }); it('мост бросил → fail, не пробрасывает исключение', function () { $bridge = Mockery::mock(PlaywrightBridge::class); $bridge->shouldReceive('run')->andThrow(new RuntimeException('exit 2: balance not found')); app()->instance(PlaywrightBridge::class, $bridge); $r = app(SupplierBalanceProvider::class)->fetch(); expect($r->ok)->toBeFalse(); expect($r->error)->toContain('exit 2'); }); it('нет логина → fail без запуска моста', function () { config()->set('services.supplier.login', ''); $bridge = Mockery::mock(PlaywrightBridge::class); $bridge->shouldNotReceive('run'); app()->instance(PlaywrightBridge::class, $bridge); $r = app(SupplierBalanceProvider::class)->fetch(); expect($r->ok)->toBeFalse(); });