056-remove-legacy-bulkops #65
@ -145,15 +145,15 @@ ## Phase 6: User Story 4 — Regression-safe by default (Priority: P4)
|
|||||||
|
|
||||||
### Tests for User Story 4
|
### Tests for User Story 4
|
||||||
|
|
||||||
- [ ] T044 [P] [US4] Add catalog coverage guard test in `tests/Feature/OpsUx/OperationCatalogCoverageTest.php`
|
- [x] T044 [P] [US4] Add catalog coverage guard test in `tests/Feature/OpsUx/OperationCatalogCoverageTest.php`
|
||||||
- [ ] T045 [P] [US4] Add canonical “View run” helper usage guard test in `tests/Feature/OpsUx/CanonicalViewRunLinksTest.php`
|
- [x] T045 [P] [US4] Add canonical “View run” helper usage guard test in `tests/Feature/OpsUx/CanonicalViewRunLinksTest.php`
|
||||||
- [ ] T046 [P] [US4] Add unknown-type runtime label test in `tests/Feature/OpsUx/UnknownOperationTypeLabelTest.php`
|
- [x] T046 [P] [US4] Add unknown-type runtime label test in `tests/Feature/OpsUx/UnknownOperationTypeLabelTest.php`
|
||||||
|
|
||||||
### Implementation for User Story 4
|
### Implementation for User Story 4
|
||||||
|
|
||||||
- [x] T047 [US4] Ensure OperationRunResource type label rendering never shows raw type in `app/Filament/Resources/OperationRunResource.php`
|
- [x] T047 [US4] Ensure OperationRunResource type label rendering never shows raw type in `app/Filament/Resources/OperationRunResource.php`
|
||||||
- [x] T048 [US4] Ensure Monitoring Operations page type labels never show raw type in `app/Filament/Pages/Monitoring/Operations.php`
|
- [x] T048 [US4] Ensure Monitoring Operations page type labels never show raw type in `app/Filament/Pages/Monitoring/Operations.php`
|
||||||
- [ ] T049 [US4] Ensure any remaining “View run” links use canonical helper in `app/Support/OperationRunLinks.php`
|
- [x] T049 [US4] Ensure any remaining “View run” links use canonical helper in `app/Support/OperationRunLinks.php`
|
||||||
|
|
||||||
**Checkpoint**: Drift prevention is enforced in CI.
|
**Checkpoint**: Drift prevention is enforced in CI.
|
||||||
|
|
||||||
|
|||||||
31
tests/Feature/OpsUx/CanonicalViewRunLinksTest.php
Normal file
31
tests/Feature/OpsUx/CanonicalViewRunLinksTest.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
|
it('routes all OperationRun view links through OperationRunLinks', function (): void {
|
||||||
|
$files = File::allFiles(app_path());
|
||||||
|
|
||||||
|
$violations = [];
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$path = $file->getRealPath();
|
||||||
|
if (! is_string($path)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationRunLinks is the canonical wrapper.
|
||||||
|
if (str_ends_with($path, '/Support/OperationRunLinks.php')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contents = File::get($path);
|
||||||
|
|
||||||
|
if (preg_match("/\\bOperationRunResource::getUrl\(\\s*'view'/", $contents) === 1) {
|
||||||
|
$violations[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expect($violations)->toBeEmpty();
|
||||||
|
})->group('ops-ux');
|
||||||
61
tests/Feature/OpsUx/OperationCatalogCoverageTest.php
Normal file
61
tests/Feature/OpsUx/OperationCatalogCoverageTest.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?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');
|
||||||
12
tests/Feature/OpsUx/UnknownOperationTypeLabelTest.php
Normal file
12
tests/Feature/OpsUx/UnknownOperationTypeLabelTest.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Support\OperationCatalog;
|
||||||
|
|
||||||
|
it('renders Unknown operation for unknown operation types and never renders raw types', function (): void {
|
||||||
|
$label = OperationCatalog::label('some.new_operation');
|
||||||
|
|
||||||
|
expect($label)->toBe('Unknown operation');
|
||||||
|
expect($label)->not->toContain('some.new_operation');
|
||||||
|
})->group('ops-ux');
|
||||||
Loading…
Reference in New Issue
Block a user