Files
reverse-engineering-anything/tests/acceptance/browser/browserScenarioLaunchFailure.test.ts
T
morluto c7fa6af8a3 test: fail loudly on setup refusals and assert exact MCP refusal and linkage facts (#15368)
* test(mcp): assert exact refusal, identity and Evidence linkage facts

Replace isError-only, expect.any and oracle-mirror checks in MCP and CLI workflow tests with the exact code, reason, subject identity and Evidence links the producers report. The capability-unavailable unknowns test now opens its target, so it exercises the path it names instead of NoBinaryOpenError.

* test: fail loudly on setup refusals, unrecorded paths and zombie liveness

Three shared helpers remove weakness classes from the suite:

- callOk (tests/support/mcp/toolResult.ts) fails at the setup step when a
  tool used as fixture setup refuses. It replaces the build-computer copy
  and the unchecked open_binary calls. serverUnknownsMcp's
  capability-unavailable test passed only because open_binary failed: its
  fixture refused health, and NoBinaryOpenError has the same "unavailable"
  category. The fixture now answers health, and the test asserts
  capability_unavailable for procedure_pseudo_code.
- expectRemoved (tests/support/expectRemoved.ts) throws when no path was
  recorded; access(list[0] ?? "") passed because "" is also ENOENT.
- expectProcessRunning checks ps state instead of signal 0, which still
  reaches a zombie that REA wrongly signalled.

Also asserts the open target before and after an ordinary close, the
written overwrite snapshot, and the comparison's links, status and
supporting unknown.

* test(mcp): compare delivered recovery with its owning projection
2026-12-01 02:26:44 +00:00

61 lines
2.1 KiB
TypeScript

import { chmod, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
cliTest.skipIf(process.platform === "win32")(
"retains the selected browser and its startup failure through the CLI",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-browser-launch-");
const executable = join(root, "selected-browser");
const secret = "explicit-browser-startup-secret";
await writeFile(
executable,
`#!/bin/sh\nprintf 'fixture startup failure ${secret}\\n' >&2\nexit 42\n`,
);
await chmod(executable, 0o700);
for (const [path, marker] of [
[executable, "fixture startup failure"],
[join(root, "missing-browser"), "doesn't exist"],
] as const) {
const scenario = {
browser: { mode: "launch", executable_path: path },
start_url: { url: "http://127.0.0.1:1/" },
secrets: [
{
secret_id: "credential",
environment_variable: "BROWSER_FIXTURE_SECRET",
},
],
actions: [
{ step_id: "wait", action: "wait_for_timeout", duration_ms: 1 },
],
};
const response = await cli.run({
arguments: [
"capture-browser-scenario",
JSON.stringify(scenario),
"--json",
],
environment: { BROWSER_FIXTURE_SECRET: secret },
});
expect(response.exitCode, response.stdout + response.stderr).toBe(1);
expect(response.stdout).not.toContain(secret);
expect(response.json).toMatchObject({
code: "execution_failure",
category: "execution_failure",
retryable: false,
details: {
provider_id: "rea-playwright-browser-scenario",
operation: "capture_browser_scenario",
diagnostics: {
executable_path: path,
startup_error: expect.stringContaining(marker),
},
},
});
}
},
);