Skip to content

Commit e66d7c5

Browse files
authored
fix(qa): index scenario execution paths (#127185)
1 parent 17d1204 commit e66d7c5

2 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎extensions/qa-lab/src/coverage-report.test.ts‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,103 @@ describe("qa coverage report", () => {
405405
expect(report).not.toContain("### Unknown Scenario Coverage IDs");
406406
});
407407

408+
it.each(["script", "vitest", "playwright"] as const)(
409+
"finds %s scenarios by execution paths outside their code refs",
410+
(executionKind) => {
411+
const executionPath = `test/producers/${executionKind}-only.ts`;
412+
const scenario = scenarioWithCoverage({
413+
primary: [TEST_EXECUTABLE_COVERAGE_ID],
414+
executionKind,
415+
executionPath,
416+
});
417+
418+
expect(findQaScenarioMatches([scenario], executionPath)).toMatchObject([
419+
{ id: scenario.id, executionKind, executionPath },
420+
]);
421+
},
422+
);
423+
424+
it("finds every shared execution-path owner in deterministic scenario order", () => {
425+
const executionPath = "test/producers/shared-evidence.ts";
426+
const scenario = scenarioWithCoverage({
427+
primary: [TEST_EXECUTABLE_COVERAGE_ID],
428+
executionKind: "script",
429+
executionPath,
430+
});
431+
const scenarios = [
432+
{ ...scenario, id: "zulu-owner" },
433+
{ ...scenario, id: "alpha-owner" },
434+
];
435+
436+
expect(findQaScenarioMatches(scenarios, executionPath).map(({ id }) => id)).toStrictEqual([
437+
"alpha-owner",
438+
"zulu-owner",
439+
]);
440+
});
441+
442+
it("normalizes portable execution-path query separators", () => {
443+
const executionPath = "test/producers/windows-evidence.ts";
444+
const scenario = scenarioWithCoverage({
445+
primary: [TEST_EXECUTABLE_COVERAGE_ID],
446+
executionKind: "script",
447+
executionPath,
448+
});
449+
450+
expect(findQaScenarioMatches([scenario], executionPath.replaceAll("/", "\\"))).toMatchObject([
451+
{ id: scenario.id, executionPath },
452+
]);
453+
});
454+
455+
it("finds every cataloged native scenario by its authoritative execution path", () => {
456+
const scenarios = readQaScenarioPack().scenarios;
457+
for (const scenario of scenarios) {
458+
if (scenario.execution.kind !== "flow") {
459+
expect(
460+
findQaScenarioMatches(scenarios, scenario.execution.path).map(({ id }) => id),
461+
scenario.id,
462+
).toContain(scenario.id);
463+
}
464+
}
465+
});
466+
467+
it.each([
468+
["name", "metadata-proof"],
469+
["title", "scenario-title"],
470+
["tag", "scenario-category"],
471+
["coverage", TEST_EXECUTABLE_COVERAGE_ID],
472+
["code reference", "src/metadata/code-reference.ts"],
473+
["documentation reference", "docs/metadata/reference.md"],
474+
["source path", "qa/scenarios/metadata/flow-proof.yaml"],
475+
["capability", "scenario-capability"],
476+
] as const)("preserves existing flow scenario matching by %s", (_field, query) => {
477+
const scenario = {
478+
...scenarioWithCoverage({
479+
primary: [TEST_EXECUTABLE_COVERAGE_ID],
480+
sourcePath: "qa/scenarios/metadata/flow-proof.yaml",
481+
}),
482+
id: "metadata-proof",
483+
title: "scenario-title",
484+
category: "scenario-category",
485+
capabilities: ["scenario-capability"],
486+
codeRefs: ["src/metadata/code-reference.ts"],
487+
docsRefs: ["docs/metadata/reference.md"],
488+
};
489+
490+
expect(findQaScenarioMatches([scenario], query).map(({ id }) => id)).toStrictEqual([
491+
scenario.id,
492+
]);
493+
});
494+
495+
it.each([
496+
["Gateway loopback and LAN access", "docker-gateway-network"],
497+
["qa-lab", "docker-gateway-network"],
498+
["runtime", "clawhub-marketplace-list"],
499+
] as const)("does not broaden ordinary metadata query %s", (query, unrelatedScenarioId) => {
500+
const matches = findQaScenarioMatches(readQaScenarioPack().scenarios, query);
501+
502+
expect(matches.map(({ id }) => id)).not.toContain(unrelatedScenarioId);
503+
});
504+
408505
it("renders Playwright matches as qa suite targets", () => {
409506
const matches = findQaScenarioMatches(
410507
readQaScenarioPack().scenarios,

‎extensions/qa-lab/src/coverage-report.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
normalizeOptionalString as stringifyConfigValue,
44
normalizeStringEntriesLower,
55
} from "openclaw/plugin-sdk/string-coerce-runtime";
6+
import { isRepoRootRelativeRef } from "./cli-paths.js";
67
import type { QaSeedScenarioWithSource } from "./scenario-catalog.js";
78
import {
89
readQaScorecardTaxonomyReport,
@@ -168,7 +169,18 @@ export function findQaScenarioMatches(
168169
return scenarios
169170
.filter((scenario) => {
170171
const haystack = scenarioSearchText(scenario);
171-
return tokens.every((token) => haystack.includes(token));
172+
return tokens.every((token) => {
173+
if (haystack.includes(token)) {
174+
return true;
175+
}
176+
const executionPathQuery = token.replaceAll("\\", "/");
177+
return (
178+
executionPathQuery.includes("/") &&
179+
isRepoRootRelativeRef(executionPathQuery) &&
180+
scenario.execution.kind !== "flow" &&
181+
normalizeSearchText(scenario.execution.path).includes(executionPathQuery)
182+
);
183+
});
172184
})
173185
.map(summarizeScenarioSearchMatch)
174186
.toSorted((left, right) => left.id.localeCompare(right.id));

0 commit comments

Comments
 (0)