Skip to content

Commit c77ee5b

Browse files
authored
refactor(qa): remove aggregate test facades (#124147)
1 parent dec4d44 commit c77ee5b

9 files changed

Lines changed: 215 additions & 290 deletions

‎extensions/qa-lab/api.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export {
107107
} from "./src/gateway-child.js";
108108
export {
109109
buildQaSuiteSummaryJson,
110-
qaSuiteProgressTesting,
111110
type QaSuiteResult,
112111
type QaSuiteRunParams,
113112
type QaSuiteScenarioResult,

‎extensions/qa-lab/src/suite-launch.runtime.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
55
import { QaSuiteInfraError } from "./errors.js";
66
import type { QaLabServerHandle } from "./lab-server.types.js";
77
import type { QaTransportAdapter } from "./qa-transport.js";
8+
import { writeQaSuiteArtifacts } from "./suite-artifacts.js";
89
import { makeQaSuiteTestScenario } from "./suite-test-helpers.js";
910
import type { QaSuiteScenarioResult } from "./suite.js";
10-
import { qaSuiteProgressTesting, throwQaSuiteCleanupErrors } from "./suite.js";
11+
import { throwQaSuiteCleanupErrors } from "./suite.js";
1112
import type {
1213
QaTestFileScenario,
1314
QaTestFileScenarioRunResult,
@@ -1307,7 +1308,7 @@ describe("qa suite runtime launcher", () => {
13071308
failedFileName: fileName,
13081309
outputDir,
13091310
publish: async () =>
1310-
await qaSuiteProgressTesting.writeQaSuiteArtifacts({
1311+
await writeQaSuiteArtifacts({
13111312
outputDir,
13121313
startedAt: new Date("2026-08-12T00:00:00.000Z"),
13131314
finishedAt: new Date("2026-08-12T00:01:00.000Z"),

‎extensions/qa-lab/src/suite-runtime-flow.test.ts‎

Lines changed: 137 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Qa Lab tests cover suite runtime flow plugin behavior.
22
import { parseModelRef, resolveModelRefFromString } from "openclaw/plugin-sdk/agent-runtime";
3-
import { describe, expect, it, vi } from "vitest";
3+
import { beforeEach, describe, expect, it, vi } from "vitest";
44

55
const createQaScenarioRuntimeApi = vi.hoisted(() => vi.fn());
66
const runScenarioFlow = vi.hoisted(() => vi.fn(async (params: { api: unknown }) => params.api));
@@ -43,9 +43,74 @@ import { runQaSuiteScenarioDefinition, runQaSuiteScenarioSteps } from "./suite-r
4343
import * as suiteRuntimeGateway from "./suite-runtime-gateway.js";
4444
import * as suiteRuntimeTransport from "./suite-runtime-transport.js";
4545
import type { QaSuiteRuntimeEnv } from "./suite-runtime-types.js";
46+
import { makeQaSuiteTestScenario } from "./suite-test-helpers.js";
4647
import * as webRuntime from "./web-runtime.js";
4748

49+
const qaSuiteRuntimeFlowTestConstants = {
50+
imageUnderstandingPngBase64: "small",
51+
imageUnderstandingLargePngBase64: "large",
52+
imageUnderstandingValidPngBase64: "valid",
53+
};
54+
55+
function createQaSuiteRuntimeFlowTestEnv(
56+
transportOverrides: Partial<QaSuiteRuntimeEnv["transport"]> = {},
57+
) {
58+
return {
59+
lab: { baseUrl: "http://127.0.0.1:4444" },
60+
webSessionIds: new Set<string>(),
61+
gateway: {} as QaSuiteRuntimeEnv["gateway"],
62+
transport: {
63+
id: "qa-channel",
64+
label: "QA Channel",
65+
accountId: "qa-channel",
66+
waitReady: vi.fn(),
67+
createGatewayConfig: vi.fn(),
68+
buildAgentDelivery: vi.fn(),
69+
requiredPluginIds: [],
70+
supportedActions: [],
71+
handleAction: vi.fn(),
72+
createReportNotes: vi.fn(),
73+
reset: vi.fn(),
74+
sendInbound: vi.fn(),
75+
sendNativeCommand: vi.fn(),
76+
waitForNoOutbound: vi.fn(),
77+
waitForOutbound: vi.fn(),
78+
waitForOutboundSequence: vi.fn(),
79+
state: {
80+
reset: vi.fn(),
81+
getSnapshot: vi.fn(),
82+
addInboundMessage: vi.fn(),
83+
addOutboundMessage: vi.fn(),
84+
readMessage: vi.fn(),
85+
searchMessages: vi.fn(),
86+
waitFor: vi.fn(),
87+
},
88+
waitForCondition: vi.fn(),
89+
...transportOverrides,
90+
},
91+
outputDir: "/artifacts",
92+
repoRoot: "/repo",
93+
providerMode: "mock-openai",
94+
primaryModel: "openai/gpt-5.6-luna",
95+
alternateModel: "openai/gpt-5.6-luna-mini",
96+
mock: null,
97+
cfg: {
98+
agents: {
99+
defaults: {
100+
models: {
101+
"anthropic/claude-opus-5": { alias: "opus" },
102+
},
103+
},
104+
},
105+
},
106+
} satisfies Parameters<typeof runQaSuiteScenarioDefinition>[0]["env"];
107+
}
108+
48109
describe("qa suite runtime flow", () => {
110+
beforeEach(() => {
111+
vi.clearAllMocks();
112+
});
113+
49114
it("records intentional scenario skips without running later steps", async () => {
50115
const laterStep = vi.fn();
51116
const result = await runQaSuiteScenarioSteps("requires group credentials", [
@@ -73,54 +138,7 @@ describe("qa suite runtime flow", () => {
73138
});
74139

75140
it("wires the split suite runtime deps into the scenario runtime api", async () => {
76-
const env = {
77-
lab: { baseUrl: "http://127.0.0.1:4444" },
78-
webSessionIds: new Set<string>(),
79-
gateway: {} as QaSuiteRuntimeEnv["gateway"],
80-
transport: {
81-
id: "qa-channel",
82-
label: "QA Channel",
83-
accountId: "qa-channel",
84-
waitReady: vi.fn(),
85-
createGatewayConfig: vi.fn(),
86-
buildAgentDelivery: vi.fn(),
87-
requiredPluginIds: [],
88-
supportedActions: [],
89-
handleAction: vi.fn(),
90-
createReportNotes: vi.fn(),
91-
reset: vi.fn(),
92-
sendInbound: vi.fn(),
93-
sendNativeCommand: vi.fn(),
94-
waitForNoOutbound: vi.fn(),
95-
waitForOutbound: vi.fn(),
96-
waitForOutboundSequence: vi.fn(),
97-
state: {
98-
reset: vi.fn(),
99-
getSnapshot: vi.fn(),
100-
addInboundMessage: vi.fn(),
101-
addOutboundMessage: vi.fn(),
102-
readMessage: vi.fn(),
103-
searchMessages: vi.fn(),
104-
waitFor: vi.fn(),
105-
},
106-
waitForCondition: vi.fn(),
107-
},
108-
outputDir: "/artifacts",
109-
repoRoot: "/repo",
110-
providerMode: "mock-openai",
111-
primaryModel: "openai/gpt-5.6-luna",
112-
alternateModel: "openai/gpt-5.6-luna-mini",
113-
mock: null,
114-
cfg: {
115-
agents: {
116-
defaults: {
117-
models: {
118-
"anthropic/claude-opus-5": { alias: "opus" },
119-
},
120-
},
121-
},
122-
},
123-
} satisfies Parameters<typeof runQaSuiteScenarioDefinition>[0]["env"];
141+
const env = createQaSuiteRuntimeFlowTestEnv();
124142
const scenario = {
125143
id: "session-memory-ranking",
126144
title: "Session memory ranking",
@@ -149,11 +167,7 @@ describe("qa suite runtime flow", () => {
149167
formatErrorMessage,
150168
liveTurnTimeoutMs,
151169
resolveQaLiveTurnTimeoutMs,
152-
constants: {
153-
imageUnderstandingPngBase64: "small",
154-
imageUnderstandingLargePngBase64: "large",
155-
imageUnderstandingValidPngBase64: "valid",
156-
},
170+
constants: qaSuiteRuntimeFlowTestConstants,
157171
});
158172

159173
expect(result).toEqual({ api: "ok" });
@@ -260,4 +274,73 @@ describe("qa suite runtime flow", () => {
260274
expect(webOpenPage).toHaveBeenCalledWith({ url: "https://openclaw.ai", repoRoot: "/repo" });
261275
expect(env.webSessionIds.has("page-1")).toBe(true);
262276
});
277+
278+
it("records live transport preparation as the first shared flow step", async () => {
279+
const prepareFlow = vi.fn(async () => {
280+
throw new Error("setup failed");
281+
});
282+
const env = createQaSuiteRuntimeFlowTestEnv({
283+
label: "Matrix live",
284+
prepareFlow,
285+
});
286+
const scenario = makeQaSuiteTestScenario("matrix-preparation-failure", {
287+
channel: "matrix",
288+
config: { expected: "value" },
289+
});
290+
if (scenario.execution.kind !== "flow") {
291+
throw new Error("expected flow scenario");
292+
}
293+
scenario.execution.timeoutMs = 45_000;
294+
const runScenario = vi.fn(runQaSuiteScenarioSteps);
295+
296+
createQaScenarioRuntimeApi.mockReturnValueOnce({ api: "ok" });
297+
await runQaSuiteScenarioDefinition({
298+
env,
299+
scenario,
300+
runScenario,
301+
splitModelRef: (raw) => parseModelRef(raw, "openai"),
302+
formatErrorMessage: (error) => String(error),
303+
liveTurnTimeoutMs: () => 60_000,
304+
resolveQaLiveTurnTimeoutMs: () => 60_000,
305+
constants: qaSuiteRuntimeFlowTestConstants,
306+
});
307+
308+
expect(createQaScenarioRuntimeApi).toHaveBeenCalledTimes(1);
309+
const capturedCall = createQaScenarioRuntimeApi.mock.calls[0]?.[0];
310+
if (!capturedCall) {
311+
throw new Error("expected QA scenario runtime API call");
312+
}
313+
const capturedDeps = (
314+
capturedCall as {
315+
deps: {
316+
runScenario: Parameters<typeof runQaSuiteScenarioDefinition>[0]["runScenario"];
317+
};
318+
}
319+
).deps;
320+
const scenarioStep = vi.fn(async () => "not reached");
321+
await expect(
322+
capturedDeps.runScenario("Matrix preparation", [{ name: "Scenario", run: scenarioStep }]),
323+
).resolves.toEqual({
324+
name: "Matrix preparation",
325+
status: "fail",
326+
steps: [{ name: "Prepare Matrix live", status: "fail", details: "setup failed" }],
327+
details: "setup failed",
328+
});
329+
330+
expect(runScenario).toHaveBeenCalledWith("Matrix preparation", [
331+
{ name: "Prepare Matrix live", run: expect.any(Function) },
332+
{ name: "Scenario", run: scenarioStep },
333+
]);
334+
expect(prepareFlow).toHaveBeenCalledWith({
335+
config: { expected: "value" },
336+
gateway: env.gateway,
337+
outputDir: "/artifacts",
338+
primaryModel: "openai/gpt-5.6-luna",
339+
scenarioId: "matrix-preparation-failure",
340+
scenarioTitle: "matrix-preparation-failure",
341+
timeoutMs: 45_000,
342+
waitForConfigRestartSettle: expect.any(Function),
343+
});
344+
expect(scenarioStep).not.toHaveBeenCalled();
345+
});
263346
});

‎extensions/qa-lab/src/suite-runtime-flow.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function createQaSuiteScenarioFlowApi(params: QaSuiteScenarioFlowApiParams) {
250250
});
251251
}
252252

253-
export function createQaSuiteScenarioStepRunner(
253+
function createQaSuiteScenarioStepRunner(
254254
env: QaSuiteScenarioFlowEnv,
255255
scenario: QaSeedScenarioWithSource,
256256
vars: Record<string, unknown>,

‎extensions/qa-lab/src/suite-support.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function remapModelRefForForcedRuntime(params: {
121121
return `openai/${split.model}`;
122122
}
123123

124-
export function appendNodeOption(raw: string | undefined, option: string) {
124+
function appendNodeOption(raw: string | undefined, option: string) {
125125
const parts = (raw ?? "").split(/\s+/u).filter(Boolean);
126126
return parts.includes(option) ? parts.join(" ") : [...parts, option].join(" ");
127127
}

0 commit comments

Comments
 (0)