browser()->timeout(60_000); it('Spec338 smokes environment origin operations link contract uses environment_id and avoids Filament internals', function (): void { $fixture = Spec322Harness::fixture(); Spec322Harness::authenticate($this, $fixture['user'], $fixture['workspace'], $fixture['environmentA']); $page = visit(EnvironmentDashboard::getUrl(panel: 'admin', tenant: $fixture['environmentA'])) ->waitForText($fixture['environmentA']->name) ->assertScript('Array.from(document.querySelectorAll("a[href*=\"/operations\"]")).some((element) => element.href.includes("environment_id=") && !element.href.includes("tableFilters"))', true) ->assertNoJavaScriptErrors() ->assertNoConsoleLogs(); $page->script('(() => { const link = Array.from(document.querySelectorAll("a[href*=\\"/operations\\"]")) .find((element) => element.href.includes("environment_id=") && ! element.href.includes("tableFilters")); if (! link) { return; } window.location.assign(link.href); })()'); Spec322Harness::assertFilteredWorkspaceHub($page, $fixture['environmentA']); }); it('Spec338 smokes clearing environment context from environment evidence surface redirects to Evidence Overview hub', function (): void { $fixture = Spec322Harness::fixture(); Spec322Harness::authenticate($this, $fixture['user'], $fixture['workspace'], $fixture['environmentA']); $overviewPath = json_encode((string) parse_url(route('admin.evidence.overview'), PHP_URL_PATH), JSON_THROW_ON_ERROR); $page = visit(EvidenceSnapshotResource::getUrl('index', tenant: $fixture['environmentA'], panel: 'admin')) ->waitForText('Evidence') ->assertNoJavaScriptErrors() ->assertNoConsoleLogs(); $page ->assertScript('document.querySelector(\'form[action*="/admin/clear-environment-context"]\') instanceof HTMLFormElement', true) ->script('document.querySelector(\'form[action*="/admin/clear-environment-context"]\').submit();'); $page ->waitForText('Evidence Overview') ->assertDontSee(__('localization.shell.no_environment_selected')) ->assertScript("window.location.pathname === {$overviewPath}", true) ->assertNoJavaScriptErrors() ->assertNoConsoleLogs(); });