TenantAtlas/tests/Unit/Support/Ui/EnterpriseDetail/SectionVisibilityTest.php
2026-03-11 00:05:33 +01:00

54 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\Ui\EnterpriseDetail\EnterpriseDetailSectionFactory;
use App\Support\Ui\EnterpriseDetail\PageActionData;
it('keeps empty-state-backed sections renderable when no items are present', function (): void {
$factory = new EnterpriseDetailSectionFactory;
$section = $factory->factsSection(
id: 'related_context',
kind: 'related_context',
title: 'Related context',
items: [],
emptyState: $factory->emptyState(
title: 'No related context is available for this record.',
description: 'Nothing else is linked yet.',
),
);
expect($section->shouldRender())->toBeTrue()
->and($section->toArray()['emptyState']['title'] ?? null)->toBe('No related context is available for this record.');
});
it('normalizes key facts and badges into reusable section data', function (): void {
$factory = new EnterpriseDetailSectionFactory;
$section = $factory->factsSection(
id: 'summary',
kind: 'core_details',
title: 'Summary',
items: [
$factory->keyFact(
label: 'Status',
value: 'Completed',
badge: $factory->statusBadge('Completed', 'gray'),
),
$factory->keyFact(label: 'Target', value: null),
],
action: new PageActionData(
label: 'Open related record',
placement: 'section',
url: '/admin/baseline-snapshots/1',
),
);
$payload = $section->toArray();
expect($payload['items'][0]['badge']['label'] ?? null)->toBe('Completed')
->and($payload['items'][1]['value'])->toBe('—')
->and($payload['action']['url'] ?? null)->toBe('/admin/baseline-snapshots/1');
});