artisan('db:seed'); }); test('dashboard renders for authenticated admin', function () { $this->actingAsAdmin() ->get('/') ->assertOk() ->assertInertia(fn (Assert $page) => $page ->component('Dashboard') ->has('widgets') ); }); test('dashboard hides user management widgets from roles without the permission', function () { $this->be(UserFactory::user()->create()); $components = widgetComponents($this->get('/')->assertOk()); $this->assertNotContains('StatWidget', $components); $this->assertNotContains('RegistrationHistoryWidget', $components); $this->assertNotContains('LatestRegistrationsWidget', $components); $this->assertNotContains('ApprovalNoticeWidget', $components); $this->assertContains('UserActionsWidget', $components); }); test('dashboard shows user management widgets to roles holding the permission', function () { $this->be(UserFactory::withPermissions('users.manage')->create()); $components = widgetComponents($this->get('/')->assertOk()); $this->assertContains('StatWidget', $components); $this->assertContains('RegistrationHistoryWidget', $components); $this->assertContains('LatestRegistrationsWidget', $components); }); /** * @return array */ function widgetComponents(TestResponse $response): array { return array_column($response->viewData('page')['props']['widgets'], 'component'); } test('dashboard redirects guest to login', function () { $this->get('/')->assertRedirect('login'); }); test('dashboard flashes success when email verified session is set', function () { $this->actingAsAdmin() ->withSession(['verified' => true]) ->get('/') ->assertOk() ->assertSessionHas('success', __('E-Mail verified successfully.')); });