Files
rea/tests/boundary/cli/finishAnalysisCommand.test.ts
morluto 93c620c3e7 fix(browser): own transport cleanup through finalization
Own CDP transports from admission through observed close, retain failed
owners for retry, and keep active peers separate from pending cleanup.
Preserve primary errors and completed facts through final cancellation.
Forward passive Electron CLI cancellation and dispose browser, runtime and
scenario owners from CLI and MCP shutdown.

Refs #4255, #4256, #4257
2026-10-16 06:46:26 +08:00

54 lines
1.5 KiB
TypeScript

import { expect, it } from "vitest";
import { finishAnalysisCommand } from "../../../src/cli/finishAnalysisCommand.js";
import { AnalysisOutputError } from "../../../src/domain/analysisErrorCore.js";
import { err, ok } from "../../../src/domain/result.js";
import { scriptCaptureEvidenceFixture } from "../../fixtures/webScriptCapture.js";
it("returns completed partial Evidence when cancellation arrives during close", async () => {
const evidence = scriptCaptureEvidenceFixture();
const controller = new AbortController();
const result = await finishAnalysisCommand(
async () => ok(evidence),
{
close: async () => {
controller.abort(new Error("cancelled during close"));
},
},
"fixture-provider",
"capture_browser_scenario",
undefined,
controller.signal,
);
expect(result).toMatchObject({
code: "cancelled",
details: { partial_observation: { evidence_id: evidence.evidence_id } },
});
});
it("preserves the primary operation error when cancellation arrives during close", async () => {
const controller = new AbortController();
const result = await finishAnalysisCommand(
async () =>
err(new AnalysisOutputError("inspect_web_page", "primary failure")),
{
close: async () => {
controller.abort();
},
},
"fixture-provider",
"inspect_web_page",
undefined,
controller.signal,
);
expect(result).toMatchObject({
code: "unreadable_output",
details: {
reason: "primary failure",
operation: "inspect_web_page",
},
});
});