fix(electron): attribute unresolved paths to selected inputs
Resolve each caller-selected Electron path once at the application boundary, collect field-specific failures with original causes, and pass canonical paths directly to the provider. Update direct provider consumers and route the real verifier through the shared application workflow. Validation: public CLI/MCP invalid-path acceptance, canonicalization boundary, provider tests, and cancellation/cleanup checks. Live Electron launch was not verified. This does not address the separate Playwright launch-rejection crash in #2269. Fixes #2272
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { expect } from "vitest";
|
||||
|
||||
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
cliTest(
|
||||
"reports every unresolved Electron path through CLI and MCP without launching",
|
||||
async ({ cli }) => {
|
||||
const root = await createTestTempDirectory("rea-electron-invalid-paths-");
|
||||
const application = join(root, "main.js");
|
||||
await writeFile(application, "module.exports = {};\n");
|
||||
const missing = {
|
||||
executable_path: join(root, "missing-electron"),
|
||||
application_path: join(root, "missing-application"),
|
||||
application_root: join(root, "missing-root"),
|
||||
};
|
||||
const requestPath = join(root, "input.json");
|
||||
await writeFile(requestPath, JSON.stringify(missing));
|
||||
const response = await cli.run({
|
||||
arguments: ["capture-electron-scenario", requestPath, "--format", "json"],
|
||||
environment: { REA_LOG_LEVEL: "silent" },
|
||||
});
|
||||
expect(response.exitCode).toBe(1);
|
||||
const expectedIssues = Object.entries(missing).map(([field, path]) => ({
|
||||
path: [field],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining(path),
|
||||
}));
|
||||
expect(response.json).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: { issues: expectedIssues },
|
||||
});
|
||||
expect(response.stdout).toContain("ENOENT");
|
||||
|
||||
const { call } = await connectLocalToolsMcp();
|
||||
for (const [field, path] of Object.entries(missing)) {
|
||||
const result = await call("capture_electron_scenario", {
|
||||
executable_path: process.execPath,
|
||||
application_path: application,
|
||||
application_root: root,
|
||||
[field]: path,
|
||||
});
|
||||
expect(result.isError).toBe(true);
|
||||
const content = result.content.find((item) => item.type === "text");
|
||||
if (content?.type !== "text") throw new Error("Missing error response");
|
||||
expect(JSON.parse(content.text)).toMatchObject({
|
||||
error: {
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: [
|
||||
{
|
||||
path: [field],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining(path),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(content.text).toContain("ENOENT");
|
||||
}
|
||||
const session = await call("binary_session", {});
|
||||
expect(session.isError, JSON.stringify(session)).not.toBe(true);
|
||||
},
|
||||
);
|
||||
@@ -903,7 +903,7 @@ it.skipIf(process.platform === "win32")(
|
||||
);
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"maps cancellation during native preparation before Electron path resolution",
|
||||
"maps cancellation during native preparation before Electron launch",
|
||||
async () => {
|
||||
const directory = await mkdtemp(
|
||||
join(tmpdir(), "rea-electron-token-abort-test-"),
|
||||
@@ -926,7 +926,10 @@ it.skipIf(process.platform === "win32")(
|
||||
application_path: "/missing/application.js",
|
||||
});
|
||||
captureOutcome = new PlaywrightElectronActiveProvider({})
|
||||
.capture(input, { signal: controller.signal })
|
||||
.capture(
|
||||
{ ...input, application_root: process.cwd() },
|
||||
{ signal: controller.signal },
|
||||
)
|
||||
.then(
|
||||
(value) => ({ state: "result" as const, value }),
|
||||
(cause: unknown) => ({ state: "rejected" as const, cause }),
|
||||
@@ -1053,7 +1056,10 @@ it.skipIf(process.platform === "win32")(
|
||||
application_root: process.cwd(),
|
||||
});
|
||||
captureOutcome = new PlaywrightElectronActiveProvider({})
|
||||
.capture(input, { signal: controller.signal })
|
||||
.capture(
|
||||
{ ...input, application_root: process.cwd() },
|
||||
{ signal: controller.signal },
|
||||
)
|
||||
.then(
|
||||
(value) => ({ state: "result" as const, value }),
|
||||
(cause: unknown) => ({ state: "rejected" as const, cause }),
|
||||
|
||||
Reference in New Issue
Block a user