<?php

use App\Filament\Resources\BackupSetResource\Pages\EditBackupSet;
use App\Filament\Resources\BackupSetResource\RelationManagers\BackupItemsRelationManager;
use App\Models\BackupItem;
use App\Models\BackupSet;
use Filament\Facades\Filament;
use Livewire\Livewire;

it('does not poll the backup items table (prevents modal refresh loops)', function () {
    [$user, $tenant] = createUserWithTenant(role: 'owner');

    $this->actingAs($user);

    $tenant->makeCurrent();
    Filament::setTenant($tenant, true);

    $backupSet = BackupSet::factory()->create([
        'managed_environment_id' => $tenant->id,
        'name' => 'Test backup',
    ]);

    BackupItem::factory()->for($backupSet)->for($tenant)->create();

    Livewire::test(BackupItemsRelationManager::class, [
        'ownerRecord' => $backupSet,
        'pageClass' => EditBackupSet::class,
    ])
        ->assertDontSee('wire:poll');
});
