Skip to content

test: cover scripts/collect-radar-reports.mjs offline (tests/collect-radar-reports.test.mjs) [quality] - #407

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/test-collect-radar-reports
Sep 21, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/test-collect-radar-reports

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/collect-radar-reports.test.mjs, the first test of any kind for scripts/collect-radar-reports.mjs — the only writer of data/radar-reports.json, which backs /resources/radar-reports.

The script did not appear in the node --test --experimental-test-coverage report at all because nothing loaded it. The new file drives it through the existing tests/helpers-script-sandbox.mjs harness (runScriptInSandbox), so the run is fully offline and deterministic — no new test infrastructure and no network.

The headline case is summary preservation. cncf.io publishes no excerpt for these reports, so each entry carries a hand-written summary that the script re-attaches across refreshes by matching report id. The test seeds a prior data/radar-reports.json into the sandbox and asserts that a real summary survives, that a blank one falls back to the placeholder, and that an id no longer published upstream is dropped — so a regression can no longer silently overwrite maintainer prose with Summary needed.

Eight tests covering, in scripts/collect-radar-reports.mjs:

  • Summary preservation across a refresh, placeholder fallback, and stale-id drop.
  • The lf-report-type lookup for the term with slug === 'radar', its hard-fail guard when cncf.io stops exposing that term, and apiUrl built from the resolved term id rather than a hard-coded one.
  • fetchAllPages — x-wp-totalpages pagination across two pages, the empty-batch stop, the status === 400 && page > 1 break, and genuine failures (500 on the posts request, 400 on the first taxonomy page) that must exit non-zero and write no output.
  • decodeEntities (&, &, ’, –, —), slug fallback for a blank or missing title.rendered, null publishedAt, the emitted envelope, the stdout count line, and the newest-first publishedAt sort.

Tests only; no production file is touched. node --test tests/collect-radar-reports.test.mjs passes 8/8 on node v26.8.2. Output is prettier-formatted.

Related Issue

Closes #406 — that issue asks for exactly one deliverable, tests/collect-radar-reports.test.mjs, and this PR lands it in full. Nothing is left for it to track.

Disjoint from every open hold-gated PR: #216 covers scripts/import-architectures.mjs, #225 covers coverage reporting for fixture-sandbox runs (this PR adds a consumer of that harness, not a change to it), #291 covers check:links, and #195/#212/#266 are security fixes to the architecture import path. It is also disjoint from its sibling #405, which covers scripts/collect-case-studies.mjs in a separate file for a separate issue. No file, function, or issue cluster overlaps.


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5

scripts/collect-radar-reports.mjs is the only writer of data/radar-reports.json
and had no test file at all. The riskiest untested path is summary
preservation: cncf.io publishes no excerpt for these reports, so each entry
carries a hand-written summary that the script re-attaches across refreshes by
report id, and a regression there would silently replace maintainer prose with
the placeholder.

Add tests/collect-radar-reports.test.mjs, driving the script through the
existing runScriptInSandbox harness with a prior data/radar-reports.json
seeded as a sandbox fixture so the preservation path runs for real. Coverage:
summary preservation and placeholder fallback, the lf-report-type radar term
lookup and its hard-fail guard, apiUrl built from the resolved term id,
x-wp-totalpages pagination, the empty-batch stop, the 400-past-the-last-page
break against a genuine API error, HTML entity decoding, slug fallback for a
blank title, null publishedAt, and the newest-first sort.

Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

@mrbobbytables
mrbobbytables added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit 69cb736 Sep 21, 2026
2 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-collect-radar-reports branch September 25, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] scripts/collect-radar-reports.mjs has zero unit coverage (hand-written summaries can be silently discarded)

1 participant