create(['role' => UserRole::Admin]); $this->actingAs($user, 'backend'); }); it('renders dashboard for authenticated admin', function (): void { /** @var \Tests\TestCase $this */ // WHEN $response = $this->get('/bo'); // THEN expect($response->status())->toBe(200); $response->assertViewIs('bo.dashboard'); $response->assertViewHasAll([ 'employeeCount', 'customersLinkedToEmployeeCount', 'adhesion', 'prevDates', 'statsShop', 'statsCustomer', ]); }); it('renders dashboard with date range filter', function (): void { /** @var \Tests\TestCase $this */ // WHEN $response = $this->get('/bo?start=2026-01-01&end=2026-01-31'); // THEN expect($response->status())->toBe(200); $response->assertViewIs('bo.dashboard'); $response->assertViewHas('prevDates', fn ($prevDates) => $prevDates !== null); }); it('redirects unauthenticated users to login', function (): void { /** @var \Tests\TestCase $this */ // GIVEN Auth::guard('backend')->logout(); // WHEN $response = $this->get('/bo'); // THEN $response->assertRedirect('/bo/login'); }); it('translates shop stat enum labels in fr and en', function (): void { // GIVEN App::setLocale('fr'); $frLabel = __(StatsShopType::nbActiveClients->label()); // WHEN App::setLocale('en'); $enLabel = __(StatsShopType::nbActiveClients->label()); $response = get('/bo?start=2026-01-01&end=2026-01-31'); // THEN expect($frLabel)->toBe('Nombre de clients actifs') ->and($enLabel)->toBe('Number of active customers'); $response->assertOk(); $response->assertSee('Number of active customers'); App::setLocale('fr'); }); });