fix(qa): escape tool coverage markdown cells · openclaw/openclaw@c85113e
vincentkoc
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -94,6 +94,35 @@ describe("qa tool coverage report", () => {
|
94 | 94 | ); |
95 | 95 | }); |
96 | 96 | |
| 97 | +it("escapes freeform metadata in the markdown table", () => { |
| 98 | +const report = buildQaToolCoverageReport({ |
| 99 | +scenarios: [ |
| 100 | +makeScenario("tool-read", "read|file", { |
| 101 | +toolCoverage: { |
| 102 | +bucket: "codex-native-workspace", |
| 103 | +expectedLayer: "codex-native-workspace", |
| 104 | +capabilityLayer: "codex-native-workspace", |
| 105 | +required: true, |
| 106 | +tracking: "#80236", |
| 107 | +reason: "tracked | runtime drift", |
| 108 | +codexDefaultImpact: "P2 | default", |
| 109 | +qaImpact: "P1 | confidence", |
| 110 | +action: "fix | backfill", |
| 111 | +}, |
| 112 | +}), |
| 113 | +], |
| 114 | +generatedAt: "2026-05-10T00:00:00.000Z", |
| 115 | +}); |
| 116 | + |
| 117 | +const markdown = renderQaToolCoverageMarkdownReport(report); |
| 118 | + |
| 119 | +expect(markdown).toContain("read\\|file"); |
| 120 | +expect(markdown).toContain("P2 \\| default"); |
| 121 | +expect(markdown).toContain("P1 \\| confidence"); |
| 122 | +expect(markdown).toContain("fix \\| backfill"); |
| 123 | +expect(markdown).toContain("#80236 tracked \\| runtime drift"); |
| 124 | +}); |
| 125 | + |
97 | 126 | it("uses runtime parity summary rows and allows tracked known-broken drift", () => { |
98 | 127 | const report = buildQaToolCoverageReport({ |
99 | 128 | scenarios: [ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -325,9 +325,22 @@ export function renderQaToolCoverageMarkdownReport(report: QaToolCoverageReport)
|
325 | 325 | ]; |
326 | 326 | |
327 | 327 | for (const row of report.rows) { |
328 | | -lines.push( |
329 | | -`| ${row.tool} | ${row.bucket} | ${row.expectedLayer} | ${row.capabilityLayer} | ${row.required ? "yes" : "no"} | ${row.fixtureCount} | ${row.openclaw} | ${row.codex} | ${row.drift} | ${row.codexDefaultImpact ?? ""} | ${row.qaImpact ?? ""} | ${row.action ?? ""} | ${row.tracking ?? ""} |`, |
330 | | -); |
| 328 | +const cells = [ |
| 329 | +row.tool, |
| 330 | +row.bucket, |
| 331 | +row.expectedLayer, |
| 332 | +row.capabilityLayer, |
| 333 | +row.required ? "yes" : "no", |
| 334 | +row.fixtureCount.toString(), |
| 335 | +row.openclaw, |
| 336 | +row.codex, |
| 337 | +row.drift, |
| 338 | +row.codexDefaultImpact ?? "", |
| 339 | +row.qaImpact ?? "", |
| 340 | +row.action ?? "", |
| 341 | +row.tracking ?? "", |
| 342 | +].map(escapeTableCell); |
| 343 | +lines.push(`| ${cells.join(" | ")} |`); |
331 | 344 | } |
332 | 345 | |
333 | 346 | if (report.failures.length > 0) { |
@@ -344,3 +357,7 @@ export function renderQaToolCoverageMarkdownReport(report: QaToolCoverageReport)
|
344 | 357 | |
345 | 358 | return `${lines.join("\n").trimEnd()}\n`; |
346 | 359 | } |
| 360 | + |
| 361 | +function escapeTableCell(value: string): string { |
| 362 | +return value.replace(/\|/gu, "\\|").replace(/\s+/gu, " ").trim(); |
| 363 | +} |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。