seed(DatabaseSeeder::class); } public function test_guest_cannot_resolve_notifications(): void { $this->get(route('notifications.resolve', ['id' => 'some-uuid'])) ->assertRedirect(route('login')); } public function test_user_can_resolve_and_redirect_notification_modularly(): void { $creator = User::factory()->create(); $creator->assignRole('user'); $supportUser = User::factory()->create(); $supportUser->assignRole('Support'); $openStatus = TicketStatus::where('name', 'open')->firstOrFail(); $ticket = Ticket::create([ 'user_id' => $creator->id, 'issue_category' => 'Billing Query', 'status_id' => $openStatus->id, 'assigned_user_id' => $supportUser->id, ]); // Send a notification $supportUser->notify(new TicketAssignedNotification($ticket)); // Retrieve unread notification $notification = $supportUser->unreadNotifications()->firstOrFail(); $this->actingAs($supportUser); // Resolve notification $response = $this->get(route('notifications.resolve', ['id' => $notification->id])); // Should mark as read $this->assertSame(0, $supportUser->unreadNotifications()->count()); // Should redirect modularly to support tickets index page with ticket ID parameter $response->assertRedirect(route('tickets.index', ['ticket' => $ticket->id])); } }