TenantAtlas/apps/platform/tests/Browser/Spec322AlertsAuditNoDriftSmokeTest.php
ahmido ec4ff1074c Spec 322: add browser no-drift regression guards (#379)
## Summary
- add the Spec 322 artifact set for the browser no-drift regression guard
- add Feature navigation guards for admin surface scope, environment CTA URLs, and legacy alias rejection
- add Browser smoke coverage for workspace hubs, environment-owned surfaces, workspace-owned analysis surfaces, and alerts/audit flows
- add the Spec 322 browser support harness used by the new smoke coverage

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test tests/Feature/Navigation/Spec322AdminSurfaceScopeContractTest.php tests/Feature/Navigation/Spec322LegacyQueryAliasGuardTest.php tests/Feature/Navigation/Spec322EnvironmentCtaUrlContractTest.php --compact`
- `cd apps/platform && ./vendor/bin/sail artisan test tests/Browser/Spec322WorkspaceHubNoDriftSmokeTest.php tests/Browser/Spec322EnvironmentOwnedSurfaceSmokeTest.php tests/Browser/Spec322WorkspaceOwnedAnalysisSmokeTest.php tests/Browser/Spec322AlertsAuditNoDriftSmokeTest.php --compact`
- `cd apps/platform && ./vendor/bin/sail pint --dirty`
- `git diff --check`

## Notes
- a broader filtered regression run still reports existing Baseline Compare feature-test failures outside this diff

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #379
2026-05-17 11:34:31 +00:00

92 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Resources\AlertDeliveryResource;
use App\Filament\Resources\AlertDestinationResource;
use App\Filament\Resources\AlertRuleResource;
use Tests\Browser\Support\Spec322WorkspaceEnvironmentBrowserHarness as Spec322Harness;
pest()->browser()->timeout(45_000);
it('Spec322 smokes alerts overview and alert deliveries no drift behavior', function (): void {
$fixture = Spec322Harness::fixture();
Spec322Harness::authenticate($this, $fixture['user'], $fixture['workspace'], $fixture['environmentA']);
Spec322Harness::assertWorkspaceOnly(
visit(route('filament.admin.alerts'))->waitForText('Alerts'),
null,
$fixture['environmentA']->name,
);
$filteredAlerts = visit(route('filament.admin.alerts', [
'environment_id' => (int) $fixture['environmentA']->getKey(),
]));
Spec322Harness::assertFilteredWorkspaceHub($filteredAlerts, $fixture['environmentA'], 'Sent');
$page = visit(AlertDeliveryResource::getUrl('index', [
'environment_id' => (int) $fixture['environmentA']->getKey(),
], panel: 'admin'));
Spec322Harness::assertFilteredWorkspaceHub($page, $fixture['environmentA'], 'Sent');
Spec322Harness::clearWorkspaceHubEnvironmentFilter($page);
Spec322Harness::assertWorkspaceOnly($page, 'Sent', $fixture['environmentA']->name);
$page->script('window.location.reload();');
Spec322Harness::assertWorkspaceOnly($page, 'Sent', $fixture['environmentA']->name);
$page->script('window.history.back();');
Spec322Harness::assertFilteredWorkspaceHub($page, $fixture['environmentA'], 'Sent');
$page->script('window.history.forward();');
Spec322Harness::assertWorkspaceOnly($page, 'Sent', $fixture['environmentA']->name);
});
it('Spec322 smokes audit log filtered and clean entries without shell drift', function (): void {
$fixture = Spec322Harness::fixture();
Spec322Harness::authenticate($this, $fixture['user'], $fixture['workspace'], $fixture['environmentA']);
Spec322Harness::assertFilteredWorkspaceHub(
visit(route('admin.monitoring.audit-log', [
'environment_id' => (int) $fixture['environmentA']->getKey(),
])),
$fixture['environmentA'],
'Spec322 browser audit B',
);
$page = visit(route('admin.monitoring.audit-log'));
Spec322Harness::assertWorkspaceOnly($page, 'Spec322 browser audit B', $fixture['environmentA']->name);
$page->script('window.location.reload();');
Spec322Harness::assertWorkspaceOnly($page, 'Spec322 browser audit B', $fixture['environmentA']->name);
});
it('Spec322 smokes alert configuration surfaces ignore stray environment filters', function (): void {
$fixture = Spec322Harness::fixture();
Spec322Harness::authenticate($this, $fixture['user'], $fixture['workspace'], $fixture['environmentA']);
$configurationUrls = [
AlertRuleResource::getUrl('index', [
'environment_id' => (int) $fixture['environmentA']->getKey(),
], panel: 'admin'),
AlertDestinationResource::getUrl('index', [
'environment_id' => (int) $fixture['environmentA']->getKey(),
], panel: 'admin'),
];
foreach ($configurationUrls as $url) {
visit($url)
->waitForText(__('localization.shell.no_environment_selected'))
->assertDontSee('Environment filter:')
->assertNoJavaScriptErrors()
->assertNoConsoleLogs();
}
});