Files
rea/tests/fixtures/optionalObservationProviders.ts
morluto 63bf91405c refactor!: enforce canonical evidence and provider boundaries
Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership.

Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers.

BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
2026-10-09 20:18:52 +08:00

75 lines
2.9 KiB
TypeScript

import type { BrowserObservationPort } from "../../src/application/BrowserObservationPort.js";
import type { JavaScriptRuntimeObservationPort } from "../../src/application/javascript/JavaScriptRuntimeObservationPort.js";
import { CDP_BROWSER_PROVIDER_IDENTITY } from "../../src/browser/providerIdentities.js";
import { V8_INSPECTOR_PROVIDER_IDENTITY } from "../../src/inspector/providerIdentity.js";
import { createBrowserScenarioProvider } from "../../src/composition/browserScenario.js";
import { createElectronObservationProvider } from "../../src/composition/electronObservation.js";
import { createElectronScenarioProvider } from "../../src/composition/electronScenario.js";
import type { OptionalObservationFactories } from "../../src/composition/optionalObservationProviders.js";
import { AnalysisCapabilityUnavailableError } from "../../src/domain/analysisErrorCore.js";
import { err, ok } from "../../src/domain/result.js";
const unselected = async () =>
err(
new AnalysisCapabilityUnavailableError(
"recording-fixture",
"unselected",
"This fixture implements target listing only",
),
);
/** Recording ports exercise application composition without claiming real engines. */
export const optionalObservationFactories = (
calls: string[],
): OptionalObservationFactories => {
const browser: BrowserObservationPort = {
identity: () => CDP_BROWSER_PROVIDER_IDENTITY,
listTargets: async () => {
calls.push("browser");
return ok({
browser: {
product: "Recording browser",
protocol_version: "1.3",
revision: "fixture",
user_agent: "fixture",
js_version: "fixture",
},
targets: [],
excluded: { disallowed_origin: 0, unsupported_url: 0, non_page: 0 },
limitations: ["Recording port; no real browser was connected."],
});
},
inspectPage: unselected,
analyzeBundle: unselected,
observeSession: unselected,
discoverWebMcpTools: unselected,
compareCaptures: unselected,
captureScreenshot: unselected,
compareScreenshots: unselected,
};
const runtime: JavaScriptRuntimeObservationPort = {
identity: () => V8_INSPECTOR_PROVIDER_IDENTITY,
listTargets: async () => {
calls.push("runtime");
return ok({
runtime: {
product: "Recording Node.js",
protocol_version: "1.0",
v8_version: null,
},
targets: [],
excluded: { unsupported_location: 0, unconnectable: 0 },
limitations: ["Recording port; no real Inspector was connected."],
});
},
observe: unselected,
};
return {
browserObservation: async () => browser,
browserScenarioCapture: async () => createBrowserScenarioProvider({}),
electronObservation: async () => createElectronObservationProvider(),
electronActiveObservation: async () => createElectronScenarioProvider({}),
javascriptRuntimeObservation: async () => runtime,
};
};