Skip to content

[quality] test: unit coverage for markdown-generator report-section builders (generateBuildHealthSection, generateBotDetailsList, generateCategorySectionWithSubsections) - #1229

Merged
hanthor merged 1 commit into
mainfrom
quality/test-markdown-generator-sections
Sep 12, 2026
Merged

[quality] test: unit coverage for markdown-generator report-section builders (generateBuildHealthSection, generateBotDetailsList, generateCategorySectionWithSubsections)#1229
hanthor merged 1 commit into
mainfrom
quality/test-markdown-generator-sections

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

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.mjs that scripts/report-markdown.test.js never imports — generateBuildHealthSection, generateBotDetailsList, and generateCategorySectionWithSubsections (which reaches the private filterItemsByLabels and formatItemList). No other file is touched.

What is covered

generateBuildHealthSection

  • the null / undefined / missing-images / empty-images guards that return ""
  • successes and failures derived from successRate × totalBuilds
  • all four momChange branches: 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)
  • the 100% Club member list and its _None_ fallback
  • the images.find(...)?.totalBuilds || 0 fallback when stats.mostActive names an image no longer in images
  • Math.round(avgDuration / 60) minute rendering

generateBotDetailsList

  • flattening items across several bot-activity entries
  • MDX curly-brace escaping, so a Renovate title like bump {pkg} to {version} is not read as JSX
  • the missing-author unknown fallback
  • the zero-width space in [@\u200B<author>] that keeps the published report from notifying the author

generateCategorySectionWithSubsections

  • the whole-section > Status: _ChillOps_ collapse and the per-subsection ChillOps markers
  • label matching under an emoji-prefixed category name, and rejection of an item that neither labels nor smart categorization claim
  • displayedUrls recording, and the de-duplication path that drops an already-displayed item
  • the ##### Dakota (GNOME OS Prototype) grouping in formatItemList, including ordering after the non-Dakota items and its absence when no Dakota item exists

Coverage delta

scripts/lib/markdown-generator.mjs:

before after
line 71.89% 81.51%
branch 48.08% 65.22%
functions 69.70% 87.88%

Full suite on a clean checkout: 949/949 pass (was 925). npx eslint and npx prettier --check are 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 in graphql-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 touches scripts/lib/markdown-generator.mjs or scripts/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

…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>
@kubestellar-hive kubestellar-hive Bot added the hold Work is intentionally paused. label Sep 11, 2026
@kubestellar-hive kubestellar-hive Bot added hold Work is intentionally paused. quality Code quality or test-coverage work. testing Test authoring or test infrastructure. agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq Routed by the hosted Project Bluefin Hive deployment. labels Sep 11, 2026

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hanthor
hanthor added this pull request to the merge queue Sep 12, 2026
Merged via the queue into main with commit 4e3914e Sep 12, 2026
2 checks passed
@hanthor
hanthor deleted the quality/test-markdown-generator-sections branch September 12, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq Routed by the hosted Project Bluefin Hive deployment. hold Work is intentionally paused. quality Code quality or test-coverage work. testing Test authoring or test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant