From 59cc58d52d24ab7f6a172200dcdb707ca582219e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Mon, 13 Jul 2026 22:43:51 -0400 Subject: [PATCH] fix(reporter): stop test-origin bullets gluing onto the cost line The test-origin-excluded row ended with a trailing `{% endif %}`. With nunjucks `trimBlocks: true`, the newline after that tag is stripped, so each query's `cost N` line ran straight into the next bullet ("cost 1- SELECT ..."). Append the same `{{""}}` guard the other rows already use so the newline survives. --- src/reporters/github/github.test.ts | 23 +++++++++++++++++++++++ src/reporters/github/success.md.j2 | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/reporters/github/github.test.ts b/src/reporters/github/github.test.ts index c2833e6..6d7edef 100644 --- a/src/reporters/github/github.test.ts +++ b/src/reporters/github/github.test.ts @@ -204,6 +204,29 @@ describe("buildViewModel", () => { expect(vm.displayTestOriginExcluded[0].queryPreview).toBe("SELECT * FROM t"); }); + test("multiple test-origin excluded queries each start a new bullet (trimBlocks glue)", () => { + // trimBlocks eats the newline after the row's trailing `{% endif %}`; without + // the `{{""}}` guard the next bullet glues onto the prior cost line ("cost 1- SELECT…"). + const excluded = (hash: string, table: string) => ({ + hash, + query: `SELECT "id" FROM "${table}"`, + formattedQuery: `SELECT "id" FROM "${table}"`, + nudges: [], tags: [], tableReferences: [], + optimization: { state: "no_improvement_found" as const, cost: 1, indexesUsed: [] }, + }); + const ctx = makeContext({ + comparison: makeComparison({ + testOriginExcluded: [excluded("t1", "sessions"), excluded("t2", "item_watches")], + }), + }); + const output = renderTemplate(ctx); + + expect(output).not.toMatch(/cost 1- /); + expect(output).toContain( + 'SELECT "id" FROM "sessions"
cost 1\n- SELECT "id" FROM "item_watches"', + ); + }); + test("new query without a recommendation is still listed (Site#3287 follow-up)", () => { const ctx = makeContext({ comparison: makeComparison({ diff --git a/src/reporters/github/success.md.j2 b/src/reporters/github/success.md.j2 index 424e1a1..06b86cc 100644 --- a/src/reporters/github/success.md.j2 +++ b/src/reporters/github/success.md.j2 @@ -91,7 +91,7 @@ {{ displayTestOriginExcluded.length }} test-origin quer{{ "ies" if displayTestOriginExcluded.length != 1 else "y" }} excluded from the gate {% for q in displayTestOriginExcluded %} -- {{ q.queryPreview }}{% if q.costLabel %}
{{ q.costLabel }}{% endif %} +- {{ q.queryPreview }}{% if q.costLabel %}
{{ q.costLabel }}{% endif %}{{""}} {% endfor %} {% endif %}