TenantAtlas/tests/Feature/Filament/BackupSetGraphSafetyTest.php
2026-02-20 12:45:02 +01:00

41 lines
1.2 KiB
PHP

<?php
use App\Filament\Resources\BackupSetResource;
use App\Models\BackupSet;
use App\Models\Tenant;
test('backup sets index renders without touching graph', function () {
$tenant = Tenant::factory()->create();
$otherTenant = Tenant::factory()->create();
[$user] = createUserWithTenant($tenant);
$user->tenants()->syncWithoutDetaching([
$otherTenant->getKey() => ['role' => 'owner'],
]);
$visibleSet = BackupSet::factory()->create([
'tenant_id' => $tenant->getKey(),
'name' => 'visible-backup-set',
]);
$hiddenSet = BackupSet::factory()->create([
'tenant_id' => $otherTenant->getKey(),
'name' => 'hidden-backup-set',
]);
bindFailHardGraphClient();
$response = $this->actingAs($user)
->get(BackupSetResource::getUrl('index', tenant: $tenant))
->assertOk()
->assertSee('Created by');
$content = (string) $response->getContent();
preg_match('/<tbody[^>]*>(.*?)<\\/tbody>/is', $content, $tbodyMatch);
$tableCellText = html_entity_decode(strip_tags((string) ($tbodyMatch[1] ?? '')));
expect($tableCellText)
->toContain($visibleSet->name)
->not->toContain($hiddenSet->name);
});