fix(electron): identify each unresolved scenario path (#2279)
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
parent
97dc6581f4
commit
ece15ed6a1
|
|
@ -1,3 +1,5 @@
|
|||
import { join } from "node:path";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { describe, expect } from "vitest";
|
||||
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
|
@ -62,3 +64,42 @@ describe("scenario CLI schema diagnostics", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
for (const field of [
|
||||
"executable_path",
|
||||
"application_path",
|
||||
"application_root",
|
||||
] as const) {
|
||||
cliTest(`names the unresolved Electron ${field}`, async ({ cli }) => {
|
||||
const root = await createTestTempDirectory("rea-electron-path-");
|
||||
const missing = join(root, "missing");
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
"capture-electron-scenario",
|
||||
JSON.stringify({
|
||||
executable_path: process.execPath,
|
||||
application_path: root,
|
||||
application_root: root,
|
||||
actions: [],
|
||||
[field]: missing,
|
||||
}),
|
||||
"--json",
|
||||
],
|
||||
environment: { REA_LOG_LEVEL: "silent" },
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.json).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: [
|
||||
{
|
||||
path: [field],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining("ENOENT"),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(result.json)).toContain(missing);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -471,3 +471,49 @@ it("exposes the target-free static JavaScript application workflow", async () =>
|
|||
const evidenceFor = (value: unknown) => {
|
||||
return parseEvidence(value);
|
||||
};
|
||||
|
||||
it("reports every unresolved Electron path without starting a provider", async () => {
|
||||
const root = await createTestTempDirectory("rea-electron-invalid-paths-");
|
||||
const capture = vi.fn();
|
||||
const session = createTestBinarySession(() => {
|
||||
throw new Error("must not start");
|
||||
});
|
||||
const server = createServer(
|
||||
{ kind: "session", session },
|
||||
{
|
||||
electronActiveObservation: {
|
||||
capture,
|
||||
identity: () => ({ id: "test", name: "test", version: "1" }),
|
||||
},
|
||||
},
|
||||
);
|
||||
const client = new Client({ name: "electron-path-test", version: "1" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
resources.push(client, server, session);
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
const fields = ["executable_path", "application_path", "application_root"];
|
||||
const result = await client.callTool({
|
||||
name: "capture_electron_scenario",
|
||||
arguments: {
|
||||
...Object.fromEntries(fields.map((field) => [field, join(root, field)])),
|
||||
actions: [],
|
||||
},
|
||||
});
|
||||
expect(result.isError).toBe(true);
|
||||
expect(parseMcpToolError(result)).toMatchObject({
|
||||
error: {
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: fields.map((field) => ({
|
||||
path: [field],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining("ENOENT"),
|
||||
})),
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(capture).not.toHaveBeenCalled();
|
||||
await client.ping();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue