<?php

use App\Filament\Pages\InventoryCoverage;
use App\Filament\Pages\InventoryLanding;
use App\Models\Tenant;
use App\Models\User;

uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);

test('inventory landing and coverage pages load for a tenant', function () {
    $tenant = Tenant::factory()->create();

    $user = User::factory()->create();
    $user->tenants()->syncWithoutDetaching([
        $tenant->getKey() => ['role' => 'owner'],
    ]);

    $this->actingAs($user)
        ->get(InventoryLanding::getUrl(tenant: $tenant))
        ->assertOk()
        ->assertSee('Run Inventory Sync');

    $this->actingAs($user)
        ->get(InventoryCoverage::getUrl(tenant: $tenant))
        ->assertOk()
        ->assertSee('Coverage')
        ->assertSee('Policies')
        ->assertSee('Foundations')
        ->assertSee('Dependencies')
        ->assertSee('✅');
});
