## 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
111 lines
3.3 KiB
PHP
111 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Support\Ui\EnterpriseDetail\FactPresentation;
|
|
|
|
it('suppresses duplicate fact values when the badge already says the same thing', function (): void {
|
|
expect(FactPresentation::value([
|
|
'label' => 'Status',
|
|
'value' => 'Completed',
|
|
'badge' => [
|
|
'label' => 'Completed',
|
|
'color' => 'success',
|
|
],
|
|
]))->toBeNull();
|
|
});
|
|
|
|
it('suppresses boolean fact values when the badge carries the same enabled state', function (): void {
|
|
expect(FactPresentation::value([
|
|
'label' => 'Security enabled',
|
|
'value' => 'Yes',
|
|
'badge' => [
|
|
'label' => 'Enabled',
|
|
'color' => 'success',
|
|
],
|
|
]))->toBeNull();
|
|
|
|
expect(FactPresentation::value([
|
|
'label' => 'Mail enabled',
|
|
'value' => 'No',
|
|
'badge' => [
|
|
'label' => 'Disabled',
|
|
'color' => 'gray',
|
|
],
|
|
]))->toBeNull();
|
|
});
|
|
|
|
it('keeps the fact value when it adds context beyond the badge label', function (): void {
|
|
expect(FactPresentation::value([
|
|
'label' => 'Completed',
|
|
'value' => 'Completed 2 minutes ago',
|
|
'badge' => [
|
|
'label' => 'Completed',
|
|
'color' => 'success',
|
|
],
|
|
]))->toBe('Completed 2 minutes ago');
|
|
});
|
|
|
|
it('renders shared header facts without duplicating text already carried by a badge', function (): void {
|
|
$html = view('filament.infolists.entries.enterprise-detail.header', [
|
|
'header' => [
|
|
'title' => 'Backup detail',
|
|
'statusBadges' => [],
|
|
'primaryActions' => [],
|
|
'keyFacts' => [[
|
|
'label' => 'Status',
|
|
'value' => 'Completed',
|
|
'badge' => [
|
|
'label' => 'Completed',
|
|
'color' => 'success',
|
|
],
|
|
]],
|
|
],
|
|
])->render();
|
|
|
|
expect(substr_count($html, 'Completed'))->toBe(1);
|
|
});
|
|
|
|
it('renders shared section facts without duplicating text already carried by a badge', function (): void {
|
|
$html = view('filament.infolists.entries.enterprise-detail.section-items', [
|
|
'items' => [[
|
|
'label' => 'Status',
|
|
'value' => 'Completed',
|
|
'badge' => [
|
|
'label' => 'Completed',
|
|
'color' => 'success',
|
|
],
|
|
]],
|
|
])->render();
|
|
|
|
expect(substr_count($html, 'Completed'))->toBe(1);
|
|
});
|
|
|
|
it('renders boolean facts without showing both yes-no text and enabled-disabled badges', function (): void {
|
|
$html = view('filament.infolists.entries.enterprise-detail.section-items', [
|
|
'items' => [
|
|
[
|
|
'label' => 'Security enabled',
|
|
'value' => 'Yes',
|
|
'badge' => [
|
|
'label' => 'Enabled',
|
|
'color' => 'success',
|
|
],
|
|
],
|
|
[
|
|
'label' => 'Mail enabled',
|
|
'value' => 'No',
|
|
'badge' => [
|
|
'label' => 'Disabled',
|
|
'color' => 'gray',
|
|
],
|
|
],
|
|
],
|
|
])->render();
|
|
|
|
expect($html)->not->toContain('>Yes</span>')
|
|
->and($html)->not->toContain('>No</span>')
|
|
->and(substr_count($html, 'Enabled'))->toBe(1)
|
|
->and(substr_count($html, 'Disabled'))->toBe(1);
|
|
});
|