TenantAtlas/tests/Unit/Support/Ui/EnterpriseDetail/SectionVisibilityTest.php
ahmido d4fb886de0 feat: standardize enterprise detail pages (#162)
## Summary
- introduce a shared enterprise-detail composition layer for Filament detail pages
- migrate BackupSet, BaselineSnapshot, EntraGroup, and OperationRun detail screens to the shared summary-first layout
- add regression and unit coverage for section hierarchy, related context, degraded states, and duplicate fact/badge presentation

## Scope
- adds shared support classes under `app/Support/Ui/EnterpriseDetail`
- adds shared enterprise detail Blade partials under `resources/views/filament/infolists/entries/enterprise-detail`
- updates touched Filament resources/pages to use the shared detail shell
- includes Spec 133 artifacts under `specs/133-detail-page-template`

## Notes
- branch: `133-detail-page-template`
- base: `dev`
- commit: `fd294c7`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #162
2026-03-10 23:06:26 +00: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');
});