get(route('dashboard')); $response->assertRedirect(route('login')); }); test('authenticated users can visit the dashboard', function () { $user = User::factory()->create(); $this->actingAs($user); $response = $this->get(route('dashboard')); $response->assertOk(); }); test('the dashboard computes certificate stats for the user', function () { $user = User::factory()->create(['reminder_months_before' => 1]); Certificate::factory()->for($user)->create(['expires_at' => today()->addYear()]); // valid Certificate::factory()->for($user)->create(['expires_at' => today()->addWeeks(2)]); // expiring soon Certificate::factory()->for($user)->expired()->create(); // expired $this->actingAs($user); Livewire::test('pages::dashboard') ->assertSet('stats', fn ($stats) => $stats['total'] === 3 && $stats['valid'] === 1 && $stats['expiringSoon'] === 1 && $stats['expired'] === 1); }); test('the dashboard only reflects the authenticated user data', function () { $user = User::factory()->create(); Certificate::factory()->for($user)->create(['title' => 'My Certificate', 'expires_at' => today()->addWeek()]); $other = User::factory()->create(); Certificate::factory()->for($other)->create(['title' => 'Someone Elses', 'expires_at' => today()->addWeek()]); $this->actingAs($user); $this->get(route('dashboard')) ->assertOk() ->assertSee('My Certificate') ->assertDontSee('Someone Elses'); }); test('the dashboard shows an empty state with no certificates', function () { $this->actingAs(User::factory()->create()); $this->get(route('dashboard')) ->assertOk() ->assertSee('No certificates yet'); });