mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 14:58:09 +00:00
fix(test): require passing Telegram evidence reports
This commit is contained in:
@@ -372,11 +372,14 @@ export function writeTelegramEvidence(rawArgs = process.argv.slice(2)) {
|
||||
if (!existsSync(observedPath)) {
|
||||
throw new Error(`Missing Telegram observed messages: ${observedPath}`);
|
||||
}
|
||||
const summary = readJson(summaryPath);
|
||||
const pass = summary.counts?.failed === 0 && Number(summary.counts?.total ?? 0) > 0;
|
||||
if (!existsSync(reportPath)) {
|
||||
if (pass) {
|
||||
throw new Error(`Missing Telegram QA report for passing summary: ${reportPath}`);
|
||||
}
|
||||
writeFileSync(reportPath, "# Mantis Telegram Live QA\n\nTelegram QA report was unavailable.\n");
|
||||
}
|
||||
|
||||
const summary = readJson(summaryPath);
|
||||
const observedMessages = readJson(observedPath);
|
||||
const transcriptHtml = renderTelegramEvidenceHtml({ observedMessages, summary });
|
||||
writeFileSync(path.join(outputDir, "telegram-live-transcript.html"), transcriptHtml, "utf8");
|
||||
|
||||
@@ -18,7 +18,7 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function makeTelegramOutput() {
|
||||
function makeTelegramOutput({ includeReport = true, summary = {} } = {}) {
|
||||
const dir = mkdtempSync(path.join(tmpdir(), "mantis-telegram-evidence-test-"));
|
||||
tempDirs.push(dir);
|
||||
mkdirSync(dir, { recursive: true });
|
||||
@@ -40,6 +40,7 @@ function makeTelegramOutput() {
|
||||
rttMs: 1234,
|
||||
},
|
||||
],
|
||||
...summary,
|
||||
}),
|
||||
);
|
||||
writeFileSync(
|
||||
@@ -55,7 +56,9 @@ function makeTelegramOutput() {
|
||||
},
|
||||
]),
|
||||
);
|
||||
writeFileSync(path.join(dir, "telegram-qa-report.md"), "# Telegram QA\n\npass\n");
|
||||
if (includeReport) {
|
||||
writeFileSync(path.join(dir, "telegram-qa-report.md"), "# Telegram QA\n\npass\n");
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
@@ -120,6 +123,39 @@ describe("scripts/mantis/build-telegram-evidence", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not fabricate a required report artifact for passing Telegram summaries", () => {
|
||||
const dir = makeTelegramOutput({ includeReport: false });
|
||||
|
||||
expect(() => writeTelegramEvidence(["--output-dir", dir])).toThrow(
|
||||
"Missing Telegram QA report for passing summary",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps a placeholder report for failing Telegram summaries", () => {
|
||||
const dir = makeTelegramOutput({
|
||||
includeReport: false,
|
||||
summary: {
|
||||
counts: { total: 1, passed: 0, failed: 1 },
|
||||
scenarios: [
|
||||
{
|
||||
details: "Timed out.",
|
||||
id: "telegram-status-command",
|
||||
status: "fail",
|
||||
title: "Telegram status command reply",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const result = writeTelegramEvidence(["--output-dir", dir]);
|
||||
|
||||
expect(result.manifest.comparison.pass).toBe(false);
|
||||
expect(readFileSync(path.join(dir, "telegram-qa-report.md"), "utf8")).toContain(
|
||||
"Telegram QA report was unavailable",
|
||||
);
|
||||
expect(loadEvidenceManifest(result.manifestPath).comparison.pass).toBe(false);
|
||||
});
|
||||
|
||||
it("marks the comparison failed when any Telegram scenario fails", () => {
|
||||
const manifest = buildTelegramEvidenceManifest({
|
||||
candidateRef: "main",
|
||||
|
||||
Reference in New Issue
Block a user