test: cover qa scenario wait failure replies

This commit is contained in:
Shakker
2026-04-08 20:39:20 +01:00
committed by Shakker
parent b3f3cfd598
commit a6d76df4f0

View File

@@ -0,0 +1,67 @@
import { describe, expect, it } from "vitest";
import { createQaBusState } from "./bus-state.js";
import { qaSuiteTesting } from "./suite.js";
describe("qa suite failure reply handling", () => {
it("detects classified failure replies before a success-only outbound predicate matches", async () => {
const state = createQaBusState();
state.addOutboundMessage({
to: "dm:qa-operator",
text: "⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.",
senderId: "openclaw",
senderName: "OpenClaw QA",
});
const message = qaSuiteTesting.findFailureOutboundMessage(state);
expect(message?.text).toContain("Something went wrong while processing your request.");
});
it("fails success-only waitForOutboundMessage calls when a classified failure reply arrives first", async () => {
const state = createQaBusState();
const pending = qaSuiteTesting.waitForOutboundMessage(
state,
(candidate) =>
candidate.conversation.id === "qa-operator" &&
candidate.text.includes("Remembered ALPHA-7."),
5_000,
);
state.addOutboundMessage({
to: "dm:qa-operator",
text: '⚠️ No API key found for provider "openai". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.4 (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.4.',
senderId: "openclaw",
senderName: "OpenClaw QA",
});
await expect(pending).rejects.toThrow('No API key found for provider "openai".');
});
it("fails raw scenario waitForCondition calls when a classified failure reply arrives", async () => {
const state = createQaBusState();
const waitForCondition = qaSuiteTesting.createScenarioWaitForCondition(state);
const pending = waitForCondition(
() =>
state
.getSnapshot()
.messages.filter(
(message) =>
message.direction === "outbound" &&
message.conversation.id === "qa-operator" &&
message.text.includes("ALPHA-7"),
)
.at(-1),
5_000,
10,
);
state.addOutboundMessage({
to: "dm:qa-operator",
text: '⚠️ No API key found for provider "openai". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.4 (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.4.',
senderId: "openclaw",
senderName: "OpenClaw QA",
});
await expect(pending).rejects.toThrow('No API key found for provider "openai".');
});
});