Skip to content

Commit 560c124

Browse files
author
Peter Steinberger
committed
fix(qa): authenticate summaries and bound native scenario commands
1 parent 12297b7 commit 560c124

8 files changed

Lines changed: 320 additions & 57 deletions

File tree

‎extensions/qa-lab/src/cli.runtime.test.ts‎

Lines changed: 107 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ describe("qa cli runtime", () => {
314314
watchUrl: "http://127.0.0.1:43124",
315315
});
316316
runQaMultipass.mockResolvedValue({
317-
outputDir: "/tmp/multipass",
318-
reportPath: "/tmp/multipass/qa-suite-report.md",
319-
summaryPath: "/tmp/multipass/qa-suite-summary.json",
320-
hostLogPath: "/tmp/multipass/multipass-host.log",
321-
bootstrapLogPath: "/tmp/multipass/multipass-guest-bootstrap.log",
322-
guestScriptPath: "/tmp/multipass/multipass-guest-run.sh",
317+
outputDir: suiteArtifactsDir,
318+
reportPath: suiteReportPath,
319+
summaryPath: suiteSummaryPath,
320+
hostLogPath: path.join(suiteArtifactsDir, "multipass-host.log"),
321+
bootstrapLogPath: path.join(suiteArtifactsDir, "multipass-guest-bootstrap.log"),
322+
guestScriptPath: path.join(suiteArtifactsDir, "multipass-guest-run.sh"),
323323
vmName: "openclaw-qa-test",
324324
scenarioIds: ["channel-chat-baseline"],
325325
});
@@ -464,9 +464,7 @@ describe("qa cli runtime", () => {
464464
}
465465
});
466466

467-
it("keeps direct-suite zero-work validation disabled with --allow-failures", async () => {
468-
const priorExitCode = process.exitCode;
469-
process.exitCode = undefined;
467+
it("rejects direct-suite zero-work summaries even with --allow-failures", async () => {
470468
const optionalScenario = {
471469
name: "Runtime tool fixture — image_generate",
472470
status: "skip" as const,
@@ -490,14 +488,108 @@ describe("qa cli runtime", () => {
490488
}),
491489
);
492490

493-
try {
494-
await runQaSuiteCommand({ repoRoot: "/tmp/openclaw-repo", allowFailures: true });
495-
expect(process.exitCode).toBeUndefined();
496-
} finally {
497-
process.exitCode = priorExitCode;
498-
}
491+
await expect(
492+
runQaSuiteCommand({ repoRoot: "/tmp/openclaw-repo", allowFailures: true }),
493+
).rejects.toThrow("did not include any executed scenarios");
499494
});
500495

496+
it.each([
497+
{ runner: "host" as const, summary: "missing" as const, expected: "Could not read QA summary" },
498+
{
499+
runner: "host" as const,
500+
summary: "malformed" as const,
501+
expected: "Could not parse QA summary",
502+
},
503+
{
504+
runner: "multipass" as const,
505+
summary: "missing" as const,
506+
expected: "Could not read QA summary",
507+
},
508+
{
509+
runner: "multipass" as const,
510+
summary: "malformed" as const,
511+
expected: "Could not parse QA summary",
512+
},
513+
{
514+
runner: "multipass" as const,
515+
summary: "zero-work" as const,
516+
expected: "did not include any executed scenarios",
517+
},
518+
...(["host", "flow", "multipass"] as const).flatMap((runner) => [
519+
{
520+
runner,
521+
summary: "required-skip" as const,
522+
expected: "did not include any executed scenarios",
523+
},
524+
{
525+
runner,
526+
summary: "blocked" as const,
527+
expected: "did not include any executed scenarios",
528+
},
529+
]),
530+
])(
531+
"rejects $summary $runner summaries even with --allow-failures",
532+
async ({ runner, summary, expected }) => {
533+
if (summary === "missing") {
534+
await fs.rm(suiteSummaryPath);
535+
} else if (summary === "malformed") {
536+
await fs.writeFile(suiteSummaryPath, "{not-json", "utf8");
537+
} else if (summary === "zero-work") {
538+
await fs.writeFile(
539+
suiteSummaryPath,
540+
JSON.stringify({
541+
counts: { total: 0, passed: 0, failed: 0, skipped: 0 },
542+
scenarios: [],
543+
}),
544+
"utf8",
545+
);
546+
} else {
547+
await fs.writeFile(
548+
suiteSummaryPath,
549+
JSON.stringify({
550+
counts: {
551+
total: 1,
552+
passed: 0,
553+
failed: 0,
554+
skipped: summary === "required-skip" ? 1 : 0,
555+
},
556+
scenarios: [
557+
{
558+
name: "Required channel scenario",
559+
status: summary === "required-skip" ? "skip" : "blocked",
560+
details: "Required transport unavailable",
561+
},
562+
],
563+
}),
564+
"utf8",
565+
);
566+
}
567+
if (runner === "host" || runner === "flow") {
568+
runQaSuite.mockResolvedValueOnce(
569+
runner === "flow"
570+
? flowSuiteRuntimeResult({
571+
reportPath: suiteReportPath,
572+
summaryPath: suiteSummaryPath,
573+
})
574+
: unifiedSuiteRuntimeResult({
575+
outputDir: suiteArtifactsDir,
576+
reportPath: suiteReportPath,
577+
summaryPath: suiteSummaryPath,
578+
evidencePath: suiteEvidencePath,
579+
}),
580+
);
581+
}
582+
583+
await expect(
584+
runQaSuiteCommand({
585+
repoRoot: "/tmp/openclaw-repo",
586+
...(runner === "multipass" ? { runner } : {}),
587+
allowFailures: true,
588+
}),
589+
).rejects.toThrow(expected);
590+
},
591+
);
592+
501593
it("rejects host-only resource options for Playwright scenarios", async () => {
502594
await expect(
503595
runQaSuiteCommand({

‎extensions/qa-lab/src/cli.runtime.ts‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ async function runQaParityPreflight(params: {
368368
process.stdout.write(`QA parity preflight summary: ${result.summaryPath}\n`);
369369
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
370370
result.summaryPath,
371+
{ requireExecutedScenario: params.allowFailures === true },
371372
);
372373
if (blockingScenarioCount > 0) {
373374
if (params.allowFailures === true) {
@@ -978,19 +979,18 @@ export async function runQaSuiteCommand(opts: QaSuiteCommandOptions) {
978979
process.stdout.write(`QA Multipass summary: ${result.summaryPath}\n`);
979980
process.stdout.write(`QA Multipass host log: ${result.hostLogPath}\n`);
980981
process.stdout.write(`QA Multipass bootstrap log: ${result.bootstrapLogPath}\n`);
981-
if (!allowFailures) {
982-
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
983-
result.summaryPath,
984-
{
985-
optionalScenarioNames: resolveQaReportOnlyOptionalScenarioNames({
986-
scenarioIds,
987-
explicitScenarioSelection: opts.explicitScenarioSelection,
988-
}),
989-
},
990-
);
991-
if (blockingScenarioCount > 0) {
992-
process.exitCode = 1;
993-
}
982+
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
983+
result.summaryPath,
984+
{
985+
optionalScenarioNames: resolveQaReportOnlyOptionalScenarioNames({
986+
scenarioIds,
987+
explicitScenarioSelection: opts.explicitScenarioSelection,
988+
}),
989+
requireExecutedScenario: allowFailures,
990+
},
991+
);
992+
if (!allowFailures && blockingScenarioCount > 0) {
993+
process.exitCode = 1;
994994
}
995995
return result;
996996
}
@@ -1051,19 +1051,18 @@ export async function runQaSuiteCommand(opts: QaSuiteCommandOptions) {
10511051
process.stdout.write(`QA suite report: ${result.reportPath}\n`);
10521052
process.stdout.write(`QA suite evidence: ${result.evidencePath}\n`);
10531053
process.stdout.write(`QA suite summary: ${result.summaryPath}\n`);
1054-
if (!allowFailures) {
1055-
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
1056-
result.summaryPath,
1057-
{
1058-
optionalScenarioNames: resolveQaReportOnlyOptionalScenarioNames({
1059-
scenarioIds,
1060-
explicitScenarioSelection: opts.explicitScenarioSelection,
1061-
}),
1062-
},
1063-
);
1064-
if (blockingScenarioCount > 0) {
1065-
process.exitCode = 1;
1066-
}
1054+
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
1055+
result.summaryPath,
1056+
{
1057+
optionalScenarioNames: resolveQaReportOnlyOptionalScenarioNames({
1058+
scenarioIds,
1059+
explicitScenarioSelection: opts.explicitScenarioSelection,
1060+
}),
1061+
requireExecutedScenario: allowFailures,
1062+
},
1063+
);
1064+
if (!allowFailures && blockingScenarioCount > 0) {
1065+
process.exitCode = 1;
10671066
}
10681067
return result;
10691068
}
@@ -1080,6 +1079,7 @@ export async function runQaSuiteCommand(opts: QaSuiteCommandOptions) {
10801079
scenarioIds,
10811080
explicitScenarioSelection: opts.explicitScenarioSelection,
10821081
}),
1082+
requireExecutedScenario: allowFailures,
10831083
},
10841084
);
10851085
if (!allowFailures && blockingScenarioCount > 0) {

‎extensions/qa-lab/src/live-transports/telegram/cli.runtime.test.ts‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ describe("Telegram live QA scenario gate", () => {
6060
summaryPath,
6161
JSON.stringify({
6262
counts: {
63+
total: 1,
64+
passed: status === "pass" ? 1 : 0,
6365
failed: status === "fail" ? 1 : 0,
6466
skipped: status === "skip" || status === "skipped" ? 1 : 0,
6567
},
@@ -76,6 +78,7 @@ describe("Telegram live QA scenario gate", () => {
7678
delete process.env[SUT_COMMAND_ENV];
7779
tempRoot = mkdtempSync(path.join(tmpdir(), "openclaw-qa-telegram-gate-"));
7880
summaryPath = path.join(tempRoot, "qa-suite-summary.json");
81+
writeSummary("pass");
7982
mocks.resolveTelegramQaScenarioIds.mockReturnValue(["channel-canary"]);
8083
mocks.runQaFlowSuiteFromRuntime.mockResolvedValue({
8184
reportPath: ".artifacts/qa-e2e/telegram/qa-suite-report.md",
@@ -121,7 +124,8 @@ describe("Telegram live QA scenario gate", () => {
121124
expect(process.exitCode).toBeUndefined();
122125
});
123126

124-
it("does not read the summary when failures are explicitly allowed", async () => {
127+
it("permits genuinely executed failed scenarios when failures are explicitly allowed", async () => {
128+
writeSummary("fail");
125129
await runQaTelegramSuite({
126130
repoRoot: "/repo",
127131
providerMode: "mock-openai",
@@ -131,6 +135,43 @@ describe("Telegram live QA scenario gate", () => {
131135
expect(process.exitCode).toBeUndefined();
132136
});
133137

138+
it.each([
139+
{ summary: "missing", expected: "Could not read QA summary" },
140+
{ summary: "malformed", expected: "Could not parse QA summary" },
141+
{ summary: "zero-work", expected: "did not include any executed scenarios" },
142+
{ summary: "required-skip", expected: "did not include any executed scenarios" },
143+
{ summary: "blocked", expected: "did not include any executed scenarios" },
144+
])(
145+
"rejects $summary Telegram summaries even with --allow-failures",
146+
async ({ summary, expected }) => {
147+
if (summary === "missing") {
148+
rmSync(summaryPath);
149+
} else if (summary === "malformed") {
150+
writeFileSync(summaryPath, "{not-json", "utf8");
151+
} else if (summary === "zero-work") {
152+
writeFileSync(
153+
summaryPath,
154+
JSON.stringify({
155+
counts: { total: 0, passed: 0, failed: 0, skipped: 0 },
156+
scenarios: [],
157+
}),
158+
"utf8",
159+
);
160+
} else {
161+
writeSummary(summary === "required-skip" ? "skip" : "blocked");
162+
}
163+
164+
await expect(
165+
runQaTelegramSuite({
166+
repoRoot: "/repo",
167+
providerMode: "mock-openai",
168+
allowFailures: true,
169+
}),
170+
).rejects.toThrow(expected);
171+
expect(process.exitCode).toBeUndefined();
172+
},
173+
);
174+
134175
it("lists only scenarios accepted by its flow runner", async () => {
135176
const write = vi.spyOn(process.stdout, "write").mockImplementation(() => true);
136177
mocks.listTelegramQaScenarios.mockReturnValue([

‎extensions/qa-lab/src/live-transports/telegram/cli.runtime.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,12 @@ export async function runQaTelegramSuite(opts: TelegramQaSuiteOptions) {
199199
report: result.reportPath,
200200
summary: result.summaryPath,
201201
});
202-
if (!runOptions.allowFailures) {
203-
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
204-
result.summaryPath,
205-
);
206-
if (blockingScenarioCount > 0) {
207-
process.exitCode = 1;
208-
}
202+
const blockingScenarioCount = await readQaSuiteFailedOrSkippedScenarioCountFromFile(
203+
result.summaryPath,
204+
{ requireExecutedScenario: runOptions.allowFailures === true },
205+
);
206+
if (!runOptions.allowFailures && blockingScenarioCount > 0) {
207+
process.exitCode = 1;
209208
}
210209
return result;
211210
}

‎extensions/qa-lab/src/suite-summary.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,60 @@ describe("qa suite summary helpers", () => {
9494
).resolves.toBe(1);
9595
});
9696

97+
it.each([
98+
{
99+
name: "required skip",
100+
summary: {
101+
counts: { total: 1, passed: 0, failed: 0, skipped: 1 },
102+
scenarios: [{ name: "required scenario", status: "skip" }],
103+
},
104+
},
105+
{
106+
name: "required skipped",
107+
summary: {
108+
counts: { total: 1, passed: 0, failed: 0, skipped: 1 },
109+
scenarios: [{ name: "required scenario", status: "skipped" }],
110+
},
111+
},
112+
{
113+
name: "blocked scenario",
114+
summary: {
115+
counts: { total: 1, passed: 0, failed: 0, skipped: 0 },
116+
scenarios: [{ name: "required scenario", status: "blocked" }],
117+
},
118+
},
119+
{
120+
name: "blocked evidence",
121+
summary: {
122+
counts: { total: 1, passed: 0, failed: 0, skipped: 0 },
123+
entries: [{ result: { status: "blocked" } }],
124+
},
125+
},
126+
])("requires a completed scenario before tolerating $name", async ({ summary }) => {
127+
await expect(
128+
readSummary(summary, (summaryPath) =>
129+
readQaSuiteFailedOrSkippedScenarioCountFromFile(summaryPath, {
130+
requireExecutedScenario: true,
131+
}),
132+
),
133+
).rejects.toThrow("did not include any executed scenarios");
134+
});
135+
136+
it("still permits a genuinely executed failed scenario in failure-tolerant gates", async () => {
137+
await expect(
138+
readSummary(
139+
{
140+
counts: { total: 1, passed: 0, failed: 1, skipped: 0 },
141+
scenarios: [{ name: "required scenario", status: "fail" }],
142+
},
143+
(summaryPath) =>
144+
readQaSuiteFailedOrSkippedScenarioCountFromFile(summaryPath, {
145+
requireExecutedScenario: true,
146+
}),
147+
),
148+
).resolves.toBe(1);
149+
});
150+
97151
it("rejects a suite containing only catalog-confirmed report-only skips", async () => {
98152
await expect(
99153
readSummary(

0 commit comments

Comments
 (0)