TenantAtlas/tests/Feature/Filament/ResolvedReferenceRenderingSmokeTest.php
2026-03-11 00:05:33 +01:00

96 lines
3.8 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Blade;
it('renders the resolved reference detail partial', function (): void {
$html = Blade::render(
"@include('filament.infolists.entries.resolved-reference-detail', ['reference' => \$reference])",
[
'reference' => [
'primaryLabel' => 'Windows Lockdown',
'secondaryLabel' => 'Version 3',
'stateLabel' => 'Resolved',
'stateColor' => 'success',
'stateIcon' => 'heroicon-m-check-circle',
'stateDescription' => null,
'showStateBadge' => false,
'isLinkable' => true,
'linkTarget' => [
'url' => '/admin/t/1/policy-versions/42',
'actionLabel' => 'View policy version',
'contextBadge' => 'Tenant',
],
'technicalDetail' => [
'displayId' => '42',
'fullId' => '42',
'sourceHint' => 'Captured from drift evidence',
],
],
],
);
expect($html)->toContain('Windows Lockdown')
->and($html)->toContain('Version 3')
->and($html)->not->toContain('Resolved')
->and($html)->toContain('Captured from drift evidence');
});
it('renders related-context actions after badges for both reference and fallback entries', function (): void {
$html = Blade::render(
"@include('filament.infolists.entries.related-context', ['entries' => \$entries])",
[
'entries' => [
[
'label' => 'Run',
'reference' => [
'primaryLabel' => 'Backup set update',
'secondaryLabel' => 'Run #189',
'stateLabel' => 'Resolved',
'stateColor' => 'success',
'stateIcon' => 'heroicon-m-check-circle',
'stateDescription' => null,
'showStateBadge' => false,
'isLinkable' => true,
'linkTarget' => [
'url' => '/admin/operations/189',
'actionLabel' => 'Inspect run',
'contextBadge' => 'Tenant context',
],
'technicalDetail' => [
'displayId' => '189',
'fullId' => '189',
'sourceHint' => null,
],
],
],
[
'label' => 'Operations',
'value' => 'Operations',
'secondaryValue' => 'YPTW2',
'targetUrl' => '/admin/t/demo/operations',
'targetKind' => 'operations',
'availability' => 'available',
'unavailableReason' => null,
'contextBadge' => 'Workspace context',
'priority' => 20,
'actionLabel' => 'Inspect operations',
],
],
],
);
$referenceBadgePosition = strpos($html, 'Tenant context');
$referenceActionPosition = strpos($html, 'Inspect run');
$fallbackBadgePosition = strpos($html, 'Workspace context');
$fallbackActionPosition = strpos($html, 'Inspect operations');
expect($referenceBadgePosition)->not->toBeFalse()
->and($referenceActionPosition)->not->toBeFalse()
->and($fallbackBadgePosition)->not->toBeFalse()
->and($fallbackActionPosition)->not->toBeFalse()
->and($referenceBadgePosition)->toBeLessThan($referenceActionPosition)
->and($fallbackBadgePosition)->toBeLessThan($fallbackActionPosition);
});