TenantAtlas/tests/Feature/OpsUx/OperationCatalogCoverageTest.php
ahmido bd6df1f343 055-ops-ux-rollout (#64)
Kurzbeschreibung

Implementiert Feature 055 — Ops‑UX Constitution Rollout v1.3.0.
Behebt: globales BulkOperationProgress-Widget benötigt keinen manuellen Refresh mehr; ETA/Elapsed aktualisieren korrekt; Widget verschwindet automatisch.
Verbesserungen: zuverlässiges polling (Alpine factory + Livewire fallback), sofortiger Enqueue‑Signal-Dispatch, Failure‑Message‑Sanitization, neue Guard‑ und Regressionstests, Specs/Tasks aktualisiert.
Was geändert wurde (Auszug)

InventoryLanding.php
bulk-operation-progress.blade.php
OperationUxPresenter.php
SyncRestoreRunToOperationRun.php
PolicyResource.php
PolicyVersionResource.php
RestoreRunResource.php
tests/Feature/OpsUx/* (PollerRegistration, TerminalNotificationFailureMessageTest, CanonicalViewRunLinksTest, OperationCatalogCoverageTest, UnknownOperationTypeLabelTest)
InventorySyncButtonTest.php
tasks.md
Tests

Neue Tests hinzugefügt; php artisan test --group=ops-ux lokal grün (alle relevanten Tests laufen).
How to verify manually

Auf Branch wechseln: 055-ops-ux-rollout
In Filament: Inventory → Sync (oder relevante Bulk‑Aktion) auslösen.
Beobachten: Progress‑Widget erscheint sofort, ETA/Elapsed aktualisiert, Widget verschwindet nach Fertigstellung ohne Browser‑Refresh.
Optional: ./vendor/bin/sail exec app php artisan test --filter=OpsUx oder php artisan test --group=ops-ux
Besonderheiten / Hinweise

Einzelne, synchrone Policy‑Actions (ignore/restore/PolicyVersion single archive/restore/forceDelete) sind absichtlich inline und erzeugen kein OperationRun. Bulk‑Aktionen und restore.execute werden als Runs modelliert. Wenn gewünscht, kann ich die inline‑Actions auf OperationRunService umstellen, damit sie in Monitoring → Operations sichtbar werden.
Remote: Branch ist bereits gepusht (origin/055-ops-ux-rollout). PR kann in Gitea erstellt werden.
Links

Specs & tasks: tasks.md
Monitoring page: Operations.php

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #64
2026-01-18 14:50:15 +00:00

62 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\OperationCatalog;
use Illuminate\Support\Facades\File;
it('fails fast if any code-produced operation type is not registered in OperationCatalog', function (): void {
$knownTypes = array_keys(OperationCatalog::labels());
$files = File::allFiles(app_path());
$discoveredTypes = [];
foreach ($files as $file) {
$path = $file->getRealPath();
if (! is_string($path)) {
continue;
}
// Skip the catalog itself to avoid tautology.
if (str_ends_with($path, '/Support/OperationCatalog.php')) {
continue;
}
$contents = File::get($path);
// Capture common patterns where operation type strings are produced in code.
// Example: ensureRun(type: 'inventory.sync', ...)
if (preg_match_all("/(?:\btype\s*:\s*|\btype\b\s*=>\s*)'([a-z0-9_]+\.[a-z0-9_]+)'/i", $contents, $matches)) {
foreach ($matches[1] as $type) {
$discoveredTypes[] = $type;
}
}
// Example: if ($run->type === 'inventory.sync')
if (preg_match_all("/\btype\s*(?:===|!==|==|!=)\s*'([a-z0-9_]+\.[a-z0-9_]+)'/i", $contents, $matches)) {
foreach ($matches[1] as $type) {
$discoveredTypes[] = $type;
}
}
// Example: in_array($run->type, ['a.b', 'c.d'], true)
if (preg_match_all("/\bin_array\([^\)]*\[([^\]]+)\]/i", $contents, $matches)) {
foreach ($matches[1] as $list) {
if (preg_match_all("/'([a-z0-9_]+\.[a-z0-9_]+)'/i", $list, $inner)) {
foreach ($inner[1] as $type) {
$discoveredTypes[] = $type;
}
}
}
}
}
$discoveredTypes = array_values(array_unique($discoveredTypes));
$unknownTypes = array_values(array_diff($discoveredTypes, $knownTypes));
expect($unknownTypes)
->toBeEmpty();
})->group('ops-ux');