<?php

declare(strict_types=1);

use Illuminate\Support\Facades\File;

it('keeps verification tab ownership inside the shared viewer', function (): void {
    $sharedViewer = (string) file_get_contents(resource_path('views/filament/components/verification-report-viewer.blade.php'));

    expect($sharedViewer)
        ->toContain('data-shared-detail-family="verification-report"')
        ->toContain('Verification report tabs');

    $hostViews = [
        resource_path('views/filament/forms/components/managed-environment-onboarding-verification-report.blade.php'),
        resource_path('views/filament/widgets/managed-environment/managed-environment-verification-report.blade.php'),
    ];

    foreach ($hostViews as $path) {
        expect((string) file_get_contents($path))->not->toContain('Verification report tabs');
    }
});

it('keeps policy-settings-standard as a compatibility wrapper only', function (): void {
    $compatibilityView = (string) file_get_contents(resource_path('views/filament/infolists/entries/policy-settings-standard.blade.php'));

    expect($compatibilityView)->toContain('normalized-settings.wrapper');

    $directUsages = collect(File::allFiles(resource_path('views/filament')))
        ->reject(static fn (\SplFileInfo $file): bool => $file->getPathname() === resource_path('views/filament/infolists/entries/policy-settings-standard.blade.php'))
        ->filter(static fn (\SplFileInfo $file): bool => str_contains((string) file_get_contents($file->getPathname()), 'policy-settings-standard'))
        ->map(static fn (\SplFileInfo $file): string => str_replace(resource_path('views/'), '', $file->getPathname()))
        ->values()
        ->all();

    expect($directUsages)->toBe([]);
});
