test(reports): lock CRLF fence-only export changes
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,35 @@ test("CRLF and mixed-newline golden exports remove every JSON chart fence", () =
|
||||
assert.equal((output.match(/```jyotish-chart/g) ?? []).length, 0);
|
||||
assert.equal((output.match(/<svg\b/gi) ?? []).length, 22);
|
||||
assert.deepEqual(ordinaryOutputLeaks(output), []);
|
||||
const selected = buildReportExportBlocks({ markdown });
|
||||
const bodyOutput = joinExportBlocks(selected.filter(block => block.group === "body"));
|
||||
assert.equal(bodyOutput, output);
|
||||
assert.equal(selected.filter(block => block.group === "chart").length, 22);
|
||||
const projected = projectOrdinaryReportMarkdown(markdown);
|
||||
assert.deepEqual(
|
||||
[...output.matchAll(/<svg\b[^>]*>[\s\S]*?<\/svg>/g)].map(match => match[0]),
|
||||
[...projected.matchAll(/<svg\b[^>]*>[\s\S]*?<\/svg>/g)].map(match => match[0]),
|
||||
);
|
||||
// Independent line scanner: only fence lines and their adjacent boundary
|
||||
// whitespace may change; the retired stripper's LF blank-run rule remains.
|
||||
const lines = projected.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
||||
let expected = "";
|
||||
let insideFence = false;
|
||||
for (let index = 0; index < lines.length; index += 1) {
|
||||
const line = lines[index];
|
||||
if (!insideFence && line.trim() === "```jyotish-chart") {
|
||||
expected = expected.replace(/\r?\n[ \t]*$/, "");
|
||||
insideFence = true;
|
||||
} else if (insideFence && line.trim() === "```") {
|
||||
expected += "\n\n";
|
||||
if (index + 1 < lines.length) lines[index + 1] = lines[index + 1].replace(/^[ \t]*/, "");
|
||||
insideFence = false;
|
||||
} else if (!insideFence) {
|
||||
expected += line;
|
||||
}
|
||||
}
|
||||
assert.equal(insideFence, false);
|
||||
assert.equal(output, expected.replace(/\n{3,}/g, "\n\n"), "D14 permits no other prose or newline changes");
|
||||
}
|
||||
});
|
||||
test("all-group export adds charts and tables after unchanged ordinary body", () => {
|
||||
|
||||
Reference in New Issue
Block a user