<?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();

    $this->actingAs($user)
        ->get(BackupSetResource::getUrl('index', tenant: $tenant))
        ->assertOk()
        ->assertSee('Created by')
        ->assertSee($visibleSet->name)
        ->assertDontSee($hiddenSet->name);
});
