[quality] test: unit coverage for markdown-generator report-section builders (generateBuildHealthSection, generateBotDetailsList, generateCategorySectionWithSubsections) - #1229
Conversation
…uilders Adds scripts/markdown-generator-sections.test.js covering the three exported builders in scripts/lib/markdown-generator.mjs that scripts/report-markdown.test.js never imports: - generateBuildHealthSection: empty-data guards, successes/failures derived from successRate x totalBuilds, the null/positive/zero/negative momChange badge branches (including the shields.io double-dash escape for negatives), the 100% Club _None_ fallback, the mostActive lookup miss, and minute rounding. - generateBotDetailsList: item flattening across activity entries, MDX curly brace escaping, the missing-author 'unknown' fallback, and the zero-width space that keeps mentions from notifying. - generateCategorySectionWithSubsections: the ChillOps branches, label matching under an emoji-prefixed category name, displayedUrls recording and de-duplication, and the Dakota subheading grouping in formatItemList. markdown-generator.mjs coverage: 71.89 -> 81.51 line, 48.08 -> 65.22 branch, 69.70 -> 87.88 functions. No production code changed. Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
hanthor
left a comment
There was a problem hiding this comment.
Verified these tests are not vacuous — they hold real coverage.
Test-only PRs are the easy place to hide assertions that pass no matter what the source does, so I checked rather than took it on faith.
Coverage genuinely moves
main: markdown-generator.mjs | 71.89 | 48.08 | 69.70
+pr1229: markdown-generator.mjs | 81.51 | 65.22 | 87.88
lines branch funcs
Functions from 69.70% → 87.88% is the number that matters for a PR claiming to cover three previously-unimported builders — it confirms they really were unreached before.
Full suite merged into current main:
$ npm run test:coverage # origin/main + pr1229
ℹ tests 949
ℹ pass 949
ℹ fail 0
Baseline on unmodified main is 925 / 925 / 0, so 24 net new tests, all passing, no regression.
Mutation-tested: both mutants killed
I broke the source in two places and confirmed the new tests catch it.
Inverting the ChillOps guard in generateCategorySectionWithSubsections:
$ sed -i '720s/planned.length === 0 && opportunistic.length === 0/false/' scripts/lib/markdown-generator.mjs
$ node --test scripts/markdown-generator-sections.test.js
(exit 1)
Zeroing the successes arithmetic in generateBuildHealthSection:
$ sed -i '1200s|Math.round((img.successRate / 100) * img.totalBuilds)|0|' scripts/lib/markdown-generator.mjs
$ node --test scripts/markdown-generator-sections.test.js
(exit 1)
Restored source, clean run exits 0. So the tests are pinned to actual behaviour — the assert.match(md, /\| \bluefin` | 75% | 30 | 10 |/)` style of asserting on rendered output rather than on the fact that a string was returned is what makes that work.
No findings. The header comment explaining why these builders matter ("these builders render the published monthly report, so a regression shows up on the site rather than in CI") is a good habit.
Generated by Claude Code
Test Improvement
Adds
scripts/markdown-generator-sections.test.js— 24 cases, no production code changed.Exact cluster claimed: the three exported report-section builders in
scripts/lib/markdown-generator.mjsthatscripts/report-markdown.test.jsnever imports —generateBuildHealthSection,generateBotDetailsList, andgenerateCategorySectionWithSubsections(which reaches the privatefilterItemsByLabelsandformatItemList). No other file is touched.What is covered
generateBuildHealthSectionnull/undefined/ missing-images/ empty-imagesguards that return""successRate × totalBuildsmomChangebranches:null→_Baseline_(not a 0% badge), positive → success badge,0→ the non-negative branch, negative → a critical badge with the shields.io double-dash escape (--7%25, not-7%25)100% Clubmember list and its_None_fallbackimages.find(...)?.totalBuilds || 0fallback whenstats.mostActivenames an image no longer inimagesMath.round(avgDuration / 60)minute renderinggenerateBotDetailsListitemsacross several bot-activity entriesbump {pkg} to {version}is not read as JSXunknownfallback[@\u200B<author>]that keeps the published report from notifying the authorgenerateCategorySectionWithSubsections> Status: _ChillOps_collapse and the per-subsection ChillOps markersdisplayedUrlsrecording, and the de-duplication path that drops an already-displayed item##### Dakota (GNOME OS Prototype)grouping informatItemList, including ordering after the non-Dakota items and its absence when no Dakota item existsCoverage delta
scripts/lib/markdown-generator.mjs:Full suite on a clean checkout: 949/949 pass (was 925).
npx eslintandnpx prettier --checkare clean on the new file.Related Issue
Refs #1168 — that issue also asks for
scripts/lib/sbom/api.js(claimed by #1210) and for an injectable-client seam ingraphql-queries.mjs/tap-promotions.mjs, which is a production change outside what this agent may PR. Its first three targets are in fact already covered; see the comment on the issue.Disjointness
Checked against every open documentation PR: #1210 (
scripts/lib/sbom/api.test.js), #1213 (scripts/lib/card-feed-parser.mjs), #1215 (scripts/fetch-firehose.js), #1226 (.github/workflows/test.yml+ portal tests), #1227 (src/components/analytics/). None touchesscripts/lib/markdown-generator.mjsorscripts/markdown-generator-sections.test.js.Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78