test: tighten process send-key assertions

This commit is contained in:
Peter Steinberger
2026-05-09 16:35:10 +01:00
parent 988a8f009d
commit 78099d2820

View File

@@ -12,6 +12,12 @@ function createWritableStdinStub(): WritableStdin {
};
}
function expectTextContent(content: unknown, text: string) {
const part = content as { type?: string; text?: string } | undefined;
expect(part?.type).toBe("text");
expect(part?.text).toContain(text);
}
test("process send-keys fails loud for unknown cursor mode when arrows depend on it", async () => {
const result = await handleProcessSendKeys({
sessionId: "sess-unknown-mode",
@@ -25,11 +31,8 @@ test("process send-keys fails loud for unknown cursor mode when arrows depend on
keys: ["up"],
});
expect(result.details).toMatchObject({ status: "failed" });
expect(result.content[0]).toMatchObject({
type: "text",
text: expect.stringContaining("cursor key mode is not known yet"),
});
expect((result.details as { status?: string }).status).toBe("failed");
expectTextContent(result.content[0], "cursor key mode is not known yet");
});
test("process send-keys still sends non-cursor keys while mode is unknown", async () => {
@@ -45,5 +48,5 @@ test("process send-keys still sends non-cursor keys while mode is unknown", asyn
keys: ["Enter"],
});
expect(result.details).toMatchObject({ status: "running" });
expect((result.details as { status?: string }).status).toBe("running");
});