Skip to content

Commit 00a0d96

Browse files
IdrisGitEtienneLescot
authored andcommitted
test(mcp): pin that a failed start's reason reaches the client
FakeRunners can now name a record start's failure. Assert the startRecording tool error carries that reason, so the forwarding above the runner stays honest.
1 parent b4e6a59 commit 00a0d96

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎electron/mcp/media-tools.test.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { RecordingCompletion } from "./recording-completion";
3333
class FakeRunners {
3434
readonly started: CliRequest[] = [];
3535
recordStarts = true;
36+
/** The `run.done` error a failed record start reports, when `recordStarts` is false. */
37+
recordStartError: string | undefined;
3638
/** The webcam the next take records beside the screen, if any. */
3739
webcam: { path: string; offsetMs: number } | null = null;
3840
results: Partial<Record<CliRequest["kind"], CliDoneResult>> = {};
@@ -92,7 +94,10 @@ class FakeRunners {
9294
} else if (this.recordStarts) {
9395
queueMicrotask(() => handlers.onLog?.("info", "Recording started"));
9496
} else {
95-
finish({ success: false, error: "Recording did not start within 30s" });
97+
finish({
98+
success: false,
99+
error: this.recordStartError ?? "Recording did not start within 30s",
100+
});
96101
}
97102
return { window, done, close };
98103
}
@@ -407,6 +412,17 @@ describe("recording", () => {
407412
expect((await call("stopRecording")).isError).toBe(true);
408413
});
409414

415+
it("carries the recorder's own failure reason to the client", async () => {
416+
runners.recordStarts = false;
417+
const reason =
418+
'The ScreenCast portal does not advertise METADATA cursor mode, so real cursor positions cannot be obtained on this session. Retry with "cursor": "system" to record with the system cursor baked in.';
419+
runners.recordStartError = reason;
420+
const started = await call("startRecording", { display: 1 });
421+
expect(started.isError).toBe(true);
422+
expect(textOf(started)).toContain(reason);
423+
expect((await call("stopRecording")).isError).toBe(true);
424+
});
425+
410426
it("saves a take once when two stops arrive together", async () => {
411427
await call("startRecording", { window: "My App" });
412428
const [first, second] = await Promise.all([call("stopRecording"), call("stopRecording")]);

0 commit comments

Comments
 (0)