TenantAtlas/tests/Feature/Filament/BackupSetEnterpriseDetailPageTest.php
ahmido e840007127 feat: add backup quality truth surfaces (#211)
## Summary
- add a shared backup-quality resolver and summary model for backup sets, backup items, policy versions, and restore selection
- surface backup-quality truth across Filament backup-set, policy-version, and restore-wizard entry points
- add focused Pest coverage and the full Spec Kit artifact set for spec 176

## Testing
- focused backup-quality verification and integrated-browser smoke coverage were completed during implementation
- degraded browser smoke path was validated with temporary seeded records and then cleaned up again
- the workspace already has a prior `vendor/bin/sail artisan test --compact` run exiting non-zero; that full-suite failure was not reworked as part of this PR

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #211
2026-04-07 11:39:40 +00:00

111 lines
3.6 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Resources\BackupSetResource;
use App\Models\BackupSet;
use App\Models\OperationRun;
use Filament\Facades\Filament;
it('renders backup sets with lifecycle summary, related context, and secondary technical detail', function (): void {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$this->actingAs($user);
Filament::setTenant($tenant, true);
$backupSet = BackupSet::factory()->create([
'tenant_id' => (int) $tenant->getKey(),
'name' => 'Nightly backup',
'item_count' => 12,
'created_by' => 'owner@example.test',
'metadata' => [
'policy_types' => ['deviceConfiguration'],
'include_assignments' => true,
],
]);
\App\Models\BackupItem::factory()->for($backupSet)->for($tenant)->create([
'payload' => [],
'metadata' => [
'source' => 'metadata_only',
'assignments_fetch_failed' => true,
'integrity_warning' => 'Protected values are intentionally hidden.',
],
'assignments' => [],
]);
$run = OperationRun::factory()->for($tenant)->create([
'workspace_id' => (int) $tenant->workspace_id,
'type' => 'backup_set.add_policies',
'context' => [
'backup_set_id' => (int) $backupSet->getKey(),
],
]);
$this->get(BackupSetResource::getUrl('view', ['record' => $backupSet], tenant: $tenant))
->assertOk()
->assertSee('Backup quality')
->assertSee('1 degraded item')
->assertSee('1 metadata-only')
->assertSee('1 assignment issue')
->assertSee('1 integrity warning')
->assertSee('Timing')
->assertSee('Archive')
->assertSee('More')
->assertSee('/admin/operations/'.$run->getKey(), false)
->assertDontSee('Related record')
->assertDontSee('>Completed</span>', false)
->assertSeeInOrder(['Nightly backup', 'Backup quality', 'Lifecycle overview', 'Related context', 'Technical detail']);
});
it('keeps operations context and technical empty states readable for sparse backup sets', function (): void {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$this->actingAs($user);
Filament::setTenant($tenant, true);
$backupSet = BackupSet::factory()->create([
'tenant_id' => (int) $tenant->getKey(),
'name' => 'Sparse backup',
'item_count' => 0,
'metadata' => [],
]);
$this->get(BackupSetResource::getUrl('view', ['record' => $backupSet], tenant: $tenant))
->assertOk()
->assertSee('No items captured')
->assertSee('No backup metadata was recorded for this backup set.')
->assertSee('Metadata keys')
->assertDontSee('Related record');
});
it('keeps backup quality counts visible for archived backup sets', function (): void {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$this->actingAs($user);
Filament::setTenant($tenant, true);
$backupSet = BackupSet::factory()->create([
'tenant_id' => (int) $tenant->getKey(),
'name' => 'Archived backup',
'item_count' => 1,
]);
$item = \App\Models\BackupItem::factory()->for($backupSet)->for($tenant)->create([
'payload' => [],
'metadata' => [
'source' => 'metadata_only',
],
'assignments' => [],
]);
$item->delete();
$backupSet->delete();
$this->get(BackupSetResource::getUrl('view', ['record' => $backupSet], tenant: $tenant))
->assertOk()
->assertSee('Archived')
->assertSee('1 degraded item')
->assertSee('1 metadata-only');
});