Expand websocket contract schema validation coverage

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 09:19:44 +00:00
1 parent 9d4acd40c3
commit 2af6a90fab
1 file changed
+35
+35
View File
@@ -43,6 +43,21 @@ describe("wsServerMessageSchema", () => {
).toThrow();
});
it("rejects errors for successful responses", () => {
expect(() =>
wsServerMessageSchema.parse({
type: "response",
id: "req-1",
ok: true,
result: { status: "ok" },
error: {
code: "unexpected",
message: "should-not-be-present",
},
}),
).toThrow();
});
it("accepts typed event channels", () => {
const parsed = wsServerMessageSchema.parse({
type: "event",
@@ -52,6 +67,26 @@ describe("wsServerMessageSchema", () => {
expect(parsed.type).toBe("event");
});
it("rejects unknown event channels", () => {
expect(() =>
wsServerMessageSchema.parse({
type: "event",
channel: "provider:unknown",
payload: {},
}),
).toThrow();
});
it("accepts hello server messages", () => {
const parsed = wsServerMessageSchema.parse({
type: "hello",
version: 1,
launchCwd: "/workspace",
});
expect(parsed.type).toBe("hello");
});
});
describe("ws close metadata", () => {