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', 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'); });