Skip to content

Commit c8c1f46

Browse files
committed
test: tighten qa lab runtime assertions
1 parent 563bbd3 commit c8c1f46

5 files changed

Lines changed: 36 additions & 39 deletions

File tree

extensions/qa-lab/src/bus-state.test.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,16 @@ describe("qa-bus state", () => {
5252

5353
const snapshot = state.getSnapshot();
5454
expect(snapshot.threads).toHaveLength(1);
55-
expect(snapshot.threads[0]).toMatchObject({
56-
id: thread.id,
57-
conversationId: "qa-room",
58-
title: "QA thread",
59-
});
60-
expect(snapshot.messages[0]).toMatchObject({
61-
id: message.id,
62-
text: "inside thread (edited)",
63-
deleted: true,
64-
reactions: [{ emoji: "eyes", senderId: "alice" }],
65-
});
55+
expect(snapshot.threads[0]?.id).toBe(thread.id);
56+
expect(snapshot.threads[0]?.conversationId).toBe("qa-room");
57+
expect(snapshot.threads[0]?.title).toBe("QA thread");
58+
expect(snapshot.messages[0]?.id).toBe(message.id);
59+
expect(snapshot.messages[0]?.text).toBe("inside thread (edited)");
60+
expect(snapshot.messages[0]?.deleted).toBe(true);
61+
expect(snapshot.messages[0]?.reactions).toHaveLength(1);
62+
expect(snapshot.messages[0]?.reactions[0]?.emoji).toBe("eyes");
63+
expect(snapshot.messages[0]?.reactions[0]?.senderId).toBe("alice");
64+
expect(snapshot.messages[0]?.reactions[0]?.timestamp).toEqual(expect.any(Number));
6665
});
6766

6867
it("waits for a text match and rejects on timeout", async () => {
@@ -156,11 +155,10 @@ describe("qa-bus state", () => {
156155

157156
const readback = state.readMessage({ messageId: outbound.id });
158157
expect(readback.attachments).toHaveLength(1);
159-
expect(readback.attachments?.[0]).toMatchObject({
160-
kind: "image",
161-
fileName: "qa-screenshot.png",
162-
altText: "QA dashboard screenshot",
163-
});
158+
const attachment = readback.attachments?.[0];
159+
expect(attachment?.kind).toBe("image");
160+
expect(attachment?.fileName).toBe("qa-screenshot.png");
161+
expect(attachment?.altText).toBe("QA dashboard screenshot");
164162

165163
const byFilename = state.searchMessages({
166164
query: "screenshot",

extensions/qa-lab/src/qa-channel-transport.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ describe("qa channel transport", () => {
107107
});
108108

109109
expect(transport.capabilities.getNormalizedMessageState().messages).toHaveLength(1);
110-
expect(
111-
await transport.capabilities.readNormalizedMessage({
112-
messageId: inbound.id,
113-
}),
114-
).toMatchObject({
115-
id: inbound.id,
116-
text: "hello from the operator",
110+
const message = await transport.capabilities.readNormalizedMessage({
111+
messageId: inbound.id,
117112
});
113+
expect(message).toBeTruthy();
114+
if (!message) {
115+
throw new Error("expected normalized QA message");
116+
}
117+
expect(message.id).toBe(inbound.id);
118+
expect(message.text).toBe("hello from the operator");
118119
});
119120

120121
it("inherits the shared failure-aware wait helper", async () => {

extensions/qa-lab/src/run-config.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ describe("qa run config", () => {
103103
defaultQaRuntimeModelForMode.mockReturnValue("openai/gpt-5.5");
104104
defaultQaRuntimeModelForMode.mockClear();
105105

106-
expect(createIdleQaRunnerSnapshot(scenarios).selection).toMatchObject({
107-
providerMode: "live-frontier",
108-
primaryModel: "openai/gpt-5.5",
109-
alternateModel: "openai/gpt-5.5",
110-
});
106+
const selection = createIdleQaRunnerSnapshot(scenarios).selection;
107+
expect(selection.providerMode).toBe("live-frontier");
108+
expect(selection.primaryModel).toBe("openai/gpt-5.5");
109+
expect(selection.alternateModel).toBe("openai/gpt-5.5");
111110
expect(defaultQaRuntimeModelForMode).not.toHaveBeenCalled();
112111
});
113112

extensions/qa-lab/src/suite-runtime-agent-session.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ describe("qa suite runtime agent session helpers", () => {
3030
gatewayCall.mockResolvedValueOnce({ key: " session-1 " });
3131

3232
await expect(createSession(env, "Test Session")).resolves.toBe("session-1");
33-
expect(gatewayCall).toHaveBeenCalledWith(
34-
"sessions.create",
35-
{ label: "Test Session" },
36-
expect.objectContaining({ timeoutMs: expect.any(Number) }),
37-
);
33+
const [method, params, options] = gatewayCall.mock.calls[0] ?? [];
34+
expect(method).toBe("sessions.create");
35+
expect(params).toEqual({ label: "Test Session" });
36+
expect(options?.timeoutMs).toEqual(expect.any(Number));
3837
});
3938

4039
it("reads effective tool ids once and drops blanks", async () => {
@@ -54,11 +53,10 @@ describe("qa suite runtime agent session helpers", () => {
5453
});
5554

5655
await expect(readSkillStatus(env)).resolves.toEqual([{ name: "alpha", eligible: true }]);
57-
expect(gatewayCall).toHaveBeenCalledWith(
58-
"skills.status",
59-
{ agentId: "qa" },
60-
expect.objectContaining({ timeoutMs: expect.any(Number) }),
61-
);
56+
const [method, params, options] = gatewayCall.mock.calls[0] ?? [];
57+
expect(method).toBe("skills.status");
58+
expect(params).toEqual({ agentId: "qa" });
59+
expect(options?.timeoutMs).toEqual(expect.any(Number));
6260
});
6361

6462
it("reads the raw qa session store from disk", async () => {

extensions/qa-lab/src/suite-runtime-transport.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ describe("qa suite transport helpers", () => {
224224
senderName: "OpenClaw QA",
225225
});
226226

227-
await expect(pending).resolves.toMatchObject({ text: "done" });
227+
const message = await pending;
228+
expect(message.text).toBe("done");
228229
});
229230
});

0 commit comments

Comments
 (0)