TenantAtlas/tests/Unit/Support/Ui/EnterpriseDetail/EnterpriseDetailBuilderTest.php
ahmido 1b88d28739 feat: consolidate operation naming surfaces (#202)
## Summary
- align operator-visible OperationRun terminology to canonical `Operations` / `Operation` labels across shared links, notifications, verification/onboarding surfaces, summary widgets, and monitoring/detail pages
- add the Spec 171 planning artifacts under `specs/171-operations-naming-consolidation/`
- close the remaining tenant dashboard and admin copy drift found during browser smoke validation

## Validation
- `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail artisan test --compact tests/Unit/Support/RelatedNavigationResolverTest.php tests/Unit/Support/References/RelatedContextReferenceAdapterTest.php tests/Feature/OpsUx/NotificationViewRunLinkTest.php tests/Feature/Guards/ActionSurfaceContractTest.php tests/Feature/Operations/TenantlessOperationRunViewerTest.php tests/Feature/Filament/BackupSetResolvedReferencePresentationTest.php tests/Feature/Filament/TenantVerificationReportWidgetTest.php tests/Feature/Onboarding/OnboardingVerificationTest.php tests/Feature/Onboarding/OnboardingVerificationClustersTest.php tests/Feature/Onboarding/OnboardingVerificationV1_5UxTest.php tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.php tests/Feature/Filament/WorkspaceOverviewContentTest.php tests/Feature/Filament/RecentOperationsSummaryWidgetTest.php tests/Feature/Monitoring/OperationLifecycleAggregateVisibilityTest.php tests/Feature/System/Spec114/OpsTriageActionsTest.php tests/Feature/System/Spec114/OpsFailuresViewTest.php tests/Feature/System/Spec114/OpsStuckViewTest.php`
- `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail artisan test --compact tests/Browser/OnboardingDraftRefreshTest.php`
- `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail bin pint --dirty --format agent`

## Notes
- no schema or route renames
- Filament / Livewire surface behavior stays within the existing admin and tenant panels
- OperationRunResource remains excluded from global search

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #202
2026-03-30 22:51:06 +00:00

89 lines
3.5 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\Ui\EnterpriseDetail\DetailSectionData;
use App\Support\Ui\EnterpriseDetail\EnterpriseDetailBuilder;
use App\Support\Ui\EnterpriseDetail\PageActionData;
use App\Support\Ui\EnterpriseDetail\SummaryHeaderData;
use App\Support\Ui\EnterpriseDetail\SupportingCardData;
use App\Support\Ui\EnterpriseDetail\TechnicalDetailData;
it('requires a summary header before building a page payload', function (): void {
expect(fn (): \App\Support\Ui\EnterpriseDetail\EnterpriseDetailPageData => EnterpriseDetailBuilder::make('operation_run', 'workspace-context')
->build())
->toThrow(LogicException::class, 'Enterprise detail pages require a summary header.');
});
it('filters invisible and empty sections before returning the page payload', function (): void {
$page = EnterpriseDetailBuilder::make('operation_run', 'workspace-context')
->header(new SummaryHeaderData(
title: 'Policy sync',
statusBadges: [['label' => 'Completed', 'color' => 'gray']],
keyFacts: [['label' => 'Operation', 'value' => '#44']],
primaryActions: [
new PageActionData(label: 'Open operation', url: '/admin/operations/44'),
new PageActionData(label: 'Hidden', url: '/admin/operations/hidden', visible: false),
],
))
->decisionZone([
'title' => 'Decision',
'facts' => [['label' => 'Outcome', 'value' => 'Succeeded']],
'primaryNextStep' => ['text' => 'No action needed.', 'source' => 'none_required'],
])
->addSection(
new DetailSectionData(
id: 'counts',
kind: 'current_status',
title: 'Counts',
items: [['label' => 'Processed', 'value' => '10']],
),
new DetailSectionData(
id: 'hidden',
kind: 'domain_detail',
title: 'Hidden',
items: [['label' => 'Ignored', 'value' => '1']],
visible: false,
),
new DetailSectionData(
id: 'empty',
kind: 'domain_detail',
title: 'Empty',
),
)
->addSupportingCard(
new SupportingCardData(
kind: 'timestamps',
title: 'Timing',
items: [['label' => 'Completed', 'value' => '2026-03-10 09:00']],
),
new SupportingCardData(
kind: 'empty',
title: 'Ignored',
),
)
->addTechnicalSection(
new TechnicalDetailData(
title: 'Context',
entries: [['label' => 'Hash', 'value' => 'abc123']],
),
new TechnicalDetailData(
title: 'Skipped',
visible: false,
entries: [['label' => 'Ignored', 'value' => '1']],
),
)
->build()
->toArray();
expect($page['header']['primaryActions'])->toHaveCount(1)
->and($page['decisionZone'])->not->toBeNull()
->and($page['decisionZone']['title'])->toBe('Decision')
->and($page['mainSections'])->toHaveCount(1)
->and($page['mainSections'][0]['title'])->toBe('Counts')
->and($page['supportingGroups'])->toHaveCount(1)
->and($page['supportingGroups'][0]['title'])->toBe('Timing')
->and($page['technicalSections'])->toHaveCount(1)
->and($page['technicalSections'][0]['title'])->toBe('Context');
});