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
30 changes: 30 additions & 0 deletions src/reporters/github/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,36 @@ describe("buildViewModel", () => {
expect(output).toContain("cost 42 · no index suggestion");
});

test("renders multiple new queries as separate list items (#158)", () => {
const ctx = makeContext({
comparison: makeComparison({
newQueries: [
{
hash: "new-sessions",
query: 'SELECT "id" FROM "sessions"',
formattedQuery: 'SELECT "id" FROM "sessions"',
nudges: [], tags: [], tableReferences: [],
optimization: { state: "no_improvement_found", cost: 1, indexesUsed: ["sessions_pkey"] },
},
{
hash: "new-item-watches",
query: 'SELECT "id" FROM "item_watches"',
formattedQuery: 'SELECT "id" FROM "item_watches"',
nudges: [], tags: [], tableReferences: [],
optimization: { state: "no_improvement_found", cost: 1, indexesUsed: ["item_watches_pkey"] },
},
],
}),
});
const output = renderTemplate(ctx);
// trimBlocks strips the newline after a trailing block tag, which used to
// glue consecutive bullets together (`… no index suggestion- SELECT …`).
expect(output).not.toMatch(/no index suggestion-\s*<code>/);
expect(output).toContain(
'no index suggestion\n- <code>SELECT "id" FROM "item_watches"</code>',
);
});

test("regressions surface in displayRegressed", () => {
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 @@ -83,7 +83,7 @@

{% for q in displayNewQueries %}
{% set link = queryLinks[q.hash] %}
- {% if link %}[<code>{{ q.queryPreview }}</code>]({{ link }}){% else %}<code>{{ q.queryPreview }}</code>{% endif %}{% if q.costLabel %}<br>{{ q.costLabel }} · no index suggestion{% endif %}
- {% if link %}[<code>{{ q.queryPreview }}</code>]({{ link }}){% else %}<code>{{ q.queryPreview }}</code>{% endif %}{% if q.costLabel %}<br>{{ q.costLabel }} · no index suggestion{% endif %}{{""}}
{% endfor %}
{% endif %}

Expand Down
Loading