<?php

declare(strict_types=1);

use App\Filament\Resources\FindingResource\Pages\ListFindings;
use App\Models\Finding;
use Filament\Facades\Filament;
use Livewire\Livewire;

it('filters findings by evidence fidelity (content vs meta)', function (string $fidelityToFilter, string $otherFidelity): void {
    [$user, $tenant] = createUserWithTenant(role: 'manager');
    $this->actingAs($user);
    Filament::setTenant($tenant, true);

    $matching = Finding::factory()->for($tenant)->create([
        'status' => Finding::STATUS_NEW,
        'evidence_fidelity' => $fidelityToFilter,
    ]);

    $nonMatching = Finding::factory()->for($tenant)->create([
        'status' => Finding::STATUS_NEW,
        'evidence_fidelity' => $otherFidelity,
    ]);

    Livewire::test(ListFindings::class)
        ->filterTable('evidence_fidelity', $fidelityToFilter)
        ->assertCanSeeTableRecords([$matching])
        ->assertCanNotSeeTableRecords([$nonMatching]);
})->with([
    ['content', 'meta'],
    ['meta', 'content'],
]);
