65 lines
2.2 KiB
PHP
65 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\BaselineSnapshotResource;
|
|
use App\Models\BaselineProfile;
|
|
use App\Models\BaselineSnapshot;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('shows snapshot fidelity counts and gap state on list and view pages', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'readonly');
|
|
|
|
$profile = BaselineProfile::factory()->active()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
]);
|
|
|
|
$complete = BaselineSnapshot::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'baseline_profile_id' => (int) $profile->getKey(),
|
|
'captured_at' => now()->subHour(),
|
|
'summary_jsonb' => [
|
|
'total_items' => 5,
|
|
'fidelity_counts' => ['content' => 5, 'meta' => 0],
|
|
'gaps' => ['count' => 0, 'by_reason' => []],
|
|
],
|
|
]);
|
|
|
|
$withGaps = BaselineSnapshot::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'baseline_profile_id' => (int) $profile->getKey(),
|
|
'captured_at' => now()->subMinutes(10),
|
|
'summary_jsonb' => [
|
|
'total_items' => 5,
|
|
'fidelity_counts' => ['content' => 3, 'meta' => 2],
|
|
'gaps' => ['count' => 2, 'by_reason' => ['meta_fallback' => 2]],
|
|
],
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(BaselineSnapshotResource::getUrl(panel: 'admin'))
|
|
->assertOk()
|
|
->assertSee('Complete')
|
|
->assertSee('Captured with gaps')
|
|
->assertSee('Content 5, Meta 0')
|
|
->assertSee('Content 3, Meta 2');
|
|
|
|
$this->actingAs($user)
|
|
->get(BaselineSnapshotResource::getUrl('view', ['record' => $withGaps], panel: 'admin'))
|
|
->assertOk()
|
|
->assertSee('Captured with gaps')
|
|
->assertSee('Content 3, Meta 2')
|
|
->assertSee('Evidence gaps')
|
|
->assertSee('2');
|
|
|
|
$this->actingAs($user)
|
|
->get(BaselineSnapshotResource::getUrl('view', ['record' => $complete], panel: 'admin'))
|
|
->assertOk()
|
|
->assertSee('Complete')
|
|
->assertSee('Content 5, Meta 0')
|
|
->assertSee('Evidence gaps')
|
|
->assertSee('0');
|
|
});
|