test: tighten qa lab runtime assertions

This commit is contained in:
Peter Steinberger
2026-05-11 14:30:08 +01:00
parent 563bbd3df4
commit c8c1f46da1
5 changed files with 36 additions and 39 deletions

View File

@@ -52,17 +52,16 @@ describe("qa-bus state", () => {
const snapshot = state.getSnapshot();
expect(snapshot.threads).toHaveLength(1);
expect(snapshot.threads[0]).toMatchObject({
id: thread.id,
conversationId: "qa-room",
title: "QA thread",
});
expect(snapshot.messages[0]).toMatchObject({
id: message.id,
text: "inside thread (edited)",
deleted: true,
reactions: [{ emoji: "eyes", senderId: "alice" }],
});
expect(snapshot.threads[0]?.id).toBe(thread.id);
expect(snapshot.threads[0]?.conversationId).toBe("qa-room");
expect(snapshot.threads[0]?.title).toBe("QA thread");
expect(snapshot.messages[0]?.id).toBe(message.id);
expect(snapshot.messages[0]?.text).toBe("inside thread (edited)");
expect(snapshot.messages[0]?.deleted).toBe(true);
expect(snapshot.messages[0]?.reactions).toHaveLength(1);
expect(snapshot.messages[0]?.reactions[0]?.emoji).toBe("eyes");
expect(snapshot.messages[0]?.reactions[0]?.senderId).toBe("alice");
expect(snapshot.messages[0]?.reactions[0]?.timestamp).toEqual(expect.any(Number));
});
it("waits for a text match and rejects on timeout", async () => {
@@ -156,11 +155,10 @@ describe("qa-bus state", () => {
const readback = state.readMessage({ messageId: outbound.id });
expect(readback.attachments).toHaveLength(1);
expect(readback.attachments?.[0]).toMatchObject({
kind: "image",
fileName: "qa-screenshot.png",
altText: "QA dashboard screenshot",
});
const attachment = readback.attachments?.[0];
expect(attachment?.kind).toBe("image");
expect(attachment?.fileName).toBe("qa-screenshot.png");
expect(attachment?.altText).toBe("QA dashboard screenshot");
const byFilename = state.searchMessages({
query: "screenshot",

View File

@@ -107,14 +107,15 @@ describe("qa channel transport", () => {
});
expect(transport.capabilities.getNormalizedMessageState().messages).toHaveLength(1);
expect(
await transport.capabilities.readNormalizedMessage({
messageId: inbound.id,
}),
).toMatchObject({
id: inbound.id,
text: "hello from the operator",
const message = await transport.capabilities.readNormalizedMessage({
messageId: inbound.id,
});
expect(message).toBeTruthy();
if (!message) {
throw new Error("expected normalized QA message");
}
expect(message.id).toBe(inbound.id);
expect(message.text).toBe("hello from the operator");
});
it("inherits the shared failure-aware wait helper", async () => {

View File

@@ -103,11 +103,10 @@ describe("qa run config", () => {
defaultQaRuntimeModelForMode.mockReturnValue("openai/gpt-5.5");
defaultQaRuntimeModelForMode.mockClear();
expect(createIdleQaRunnerSnapshot(scenarios).selection).toMatchObject({
providerMode: "live-frontier",
primaryModel: "openai/gpt-5.5",
alternateModel: "openai/gpt-5.5",
});
const selection = createIdleQaRunnerSnapshot(scenarios).selection;
expect(selection.providerMode).toBe("live-frontier");
expect(selection.primaryModel).toBe("openai/gpt-5.5");
expect(selection.alternateModel).toBe("openai/gpt-5.5");
expect(defaultQaRuntimeModelForMode).not.toHaveBeenCalled();
});

View File

@@ -30,11 +30,10 @@ describe("qa suite runtime agent session helpers", () => {
gatewayCall.mockResolvedValueOnce({ key: " session-1 " });
await expect(createSession(env, "Test Session")).resolves.toBe("session-1");
expect(gatewayCall).toHaveBeenCalledWith(
"sessions.create",
{ label: "Test Session" },
expect.objectContaining({ timeoutMs: expect.any(Number) }),
);
const [method, params, options] = gatewayCall.mock.calls[0] ?? [];
expect(method).toBe("sessions.create");
expect(params).toEqual({ label: "Test Session" });
expect(options?.timeoutMs).toEqual(expect.any(Number));
});
it("reads effective tool ids once and drops blanks", async () => {
@@ -54,11 +53,10 @@ describe("qa suite runtime agent session helpers", () => {
});
await expect(readSkillStatus(env)).resolves.toEqual([{ name: "alpha", eligible: true }]);
expect(gatewayCall).toHaveBeenCalledWith(
"skills.status",
{ agentId: "qa" },
expect.objectContaining({ timeoutMs: expect.any(Number) }),
);
const [method, params, options] = gatewayCall.mock.calls[0] ?? [];
expect(method).toBe("skills.status");
expect(params).toEqual({ agentId: "qa" });
expect(options?.timeoutMs).toEqual(expect.any(Number));
});
it("reads the raw qa session store from disk", async () => {

View File

@@ -224,6 +224,7 @@ describe("qa suite transport helpers", () => {
senderName: "OpenClaw QA",
});
await expect(pending).resolves.toMatchObject({ text: "done" });
const message = await pending;
expect(message.text).toBe("done");
});
});