Repository navigation
test: cover scripts/collect-case-studies.mjs offline (tests/collect-case-studies.test.mjs) [quality] - #405
Merged
Conversation
scripts/collect-case-studies.mjs is the only writer of data/case-studies.json and had no test file at all, so none of its pagination, taxonomy resolution or HTML entity decoding was exercised. Add tests/collect-case-studies.test.mjs, driving the script through the existing runScriptInSandbox harness so the run stays offline and deterministic. Coverage: x-wp-totalpages pagination, the empty-batch stop, the 400-past-the-last-page break against a genuine API error, taxonomy id to name resolution with unknown ids dropped, HTML entity decoding, slug fallback for a missing title, null publishedAt, and the organization sort order. Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
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 Hive will automatically remove the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Improvement
Adds
tests/collect-case-studies.test.mjs, the first test of any kind forscripts/collect-case-studies.mjs— the only writer ofdata/case-studies.json, which backs the/resources/case-studiestable.The script did not appear in the
node --test --experimental-test-coveragereport at all because nothing loaded it. The new file drives it through the existingtests/helpers-script-sandbox.mjsharness (runScriptInSandbox), so the run is fully offline and deterministic — no new test infrastructure, no network, no fixtures outside the sandbox tmpdir.Nine tests covering, in
scripts/collect-case-studies.mjs:fetchAllPages—x-wp-totalpagespagination across two pages, and the empty-batch stop.status === 400 && page > 1break (WordPress advertises more pages than it serves) versus a genuine failure: a 400 on page 1 and a 500 both fail the run with thecncf.io API <status>message and write no output file.fetchTermNames/namesFor—lf-project,lf-industryandlf-countryid-to-name resolution, unknown ids dropped rather than emitted as nulls, names sorted independently of incoming id order.decodeEntities—&,&,’,–,—.title.rendered,nullpublishedAtfor a missingdate, the emittedsource/sourceUrl/apiUrl/descriptionenvelope, theCollected N case studiesstdout line, and thelocaleComparesort onorganization.Tests only; no production file is touched.
node --test tests/collect-case-studies.test.mjspasses 9/9 on node v26.8.2, as do the repo-widemodule-imports,workflow-scriptsandvalidator-smoke-coveragecontract tests. Output is prettier-formatted.One caveat worth keeping in the test file: the case-study request embeds
lf-project,lf-industryandlf-countryin its_fieldsquery string, so thelf_case_studyroute must be declared before the taxonomy routes or the harness's ordered substring matcher misroutes it. This is noted in a comment.Related Issue
Closes #404 — that issue asks for exactly one deliverable,
tests/collect-case-studies.test.mjs, and this PR lands it in full. Nothing is left for it to track.Disjoint from the open hold-gated PRs: #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 coverscheck:links, and #195/#212/#266 are security fixes to the architecture import path. 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