<?php

declare(strict_types=1);

use App\Filament\Pages\Findings\MyFindingsInbox;
use App\Support\Workspaces\WorkspaceContext;
use Filament\Facades\Filament;

it('uses the admin panel home url and shows the overview navigation item', function (): void {
    [$user, $tenant] = createUserWithTenant(role: 'owner');

    $response = $this->actingAs($user)
        ->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
        ->get(route('admin.workspace.home', ['workspace' => $tenant->workspace]))
        ->assertOk()
        ->assertSee('Overview')
        ->assertSee('Switch workspace')
        ->assertSee('Assigned to me')
        ->assertSee('Open my findings');

    expect(Filament::getPanel('admin')->getHomeUrl())->toBe(route('admin.home'));
    expect((string) $response->getContent())->toContain('href="'.route('admin.home').'"');
    expect((string) $response->getContent())->toContain('href="'.MyFindingsInbox::getUrl(panel: 'admin').'"');
});
