Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/reporters/github/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<code>SELECT "id" FROM "sessions"</code><br>cost 1\n- <code>SELECT "id" FROM "item_watches"</code>',
);
});

test("new query without a recommendation is still listed (Site#3287 follow-up)", () => {
const ctx = makeContext({
comparison: makeComparison({
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/github/success.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<summary>{{ displayTestOriginExcluded.length }} test-origin quer{{ "ies" if displayTestOriginExcluded.length != 1 else "y" }} excluded from the gate</summary>

{% for q in displayTestOriginExcluded %}
- <code>{{ q.queryPreview }}</code>{% if q.costLabel %}<br>{{ q.costLabel }}{% endif %}
- <code>{{ q.queryPreview }}</code>{% if q.costLabel %}<br>{{ q.costLabel }}{% endif %}{{""}}
{% endfor %}
</details>
{% endif %}
Expand Down
Loading