[quality] test: cover harvestPortalContributors in scripts/fetch-portal-contributors.js - #1235
Open
kubestellar-hive[bot] wants to merge 1 commit into
Open
[quality] test: cover harvestPortalContributors in scripts/fetch-portal-contributors.js#1235kubestellar-hive[bot] wants to merge 1 commit into
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
…utors.js scripts/fetch-portal-contributors.js sat at 32.38% line / 60.00% function coverage: only the four pure helpers (isIgnoredContributor, calculateActivityWindow, formatActivityWindowLabel, filterUniqueContributors) were exercised. The 95-line harvestPortalContributors routine that actually produces static/data/portal-contributors.json — and the module-private githubJson/githubPages pagination helpers it drives — had no assertions at all. Adds 17 cases to scripts/fetch-portal-contributors.test.js, driven through a stubbed global fetch: - payload shape: generatedAt, activityWindowSince, activityWindowLabel, bluefinPulseUrl, and a custom windowDays - repository selection: org listing plus the ublue-os/bluefin and ublue-os/bluefin-lts fallbacks, forks and nameless repos skipped, fallbacks de-duplicated against the org listing - pagination: per_page=100 page walk, '&' separator on the type=all URL, short-page termination, non-array page termination, and the three-page cap on commit history - since= filter carries the activity window - contributor filtering: bots, authorless commits, empty logins, synthesised html_url, and de-duplication of one person across repos - degradation: org listing failure still yields the fallback repos, a single failing repo does not discard the others (Promise.allSettled), and a Discussions outage leaves commit contributors intact - discussion authors inside the window are added, stale and undated ones are not - the twelve-person limit and the unavailable=true empty payload Raises scripts/fetch-portal-contributors.js to 75.00% line / 95.74% branch / 89.47% function coverage. Tests only; no production code changed. Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
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 17 unit tests covering
harvestPortalContributorsinscripts/fetch-portal-contributors.js, plus the module-privategithubJson/githubPagespagination helpers it drives. Tests only — no production code is changed.Exact ground this PR claims
scripts/fetch-portal-contributors.test.js(only file in the diff)harvestPortalContributors, andgithubJson/githubPagestransitivelyscripts/fetch-portal-contributors.jscoverage — documentation issue [quality] coverage-gap: scripts/fetch-portal-contributors.js harvestPortalContributors (95 lines, 32% line coverage) #1234Why
scripts/fetch-portal-contributors.jswas the worst-covered file inscripts/at 32.38% line / 75.00% branch / 60.00% function. The existing test file covered only the four pure helpers (isIgnoredContributor,calculateActivityWindow,formatActivityWindowLabel,filterUniqueContributors). The 95-line routine that actually producesstatic/data/portal-contributors.jsonhad no assertions.What is covered
Driven through a stubbed
globalThis.fetch, restored in afinallyblock:generatedAt,activityWindowSince,activityWindowLabel,bluefinPulseUrl, and a customwindowDaysublue-os/bluefinandublue-os/bluefin-ltsfallbacks, forks and nameless repos skipped, fallbacks de-duplicated against the org listingper_page=100page walk, the&separator required because?type=allis already present, short-page termination, non-array page termination, and the three-page cap on commit historysince=activity-window filter on every commit requesthtml_url, and de-duplication of one person across reposPromise.allSettled), and a Discussions outage leaves commit contributors intactunavailable: trueempty payloadResult
npm run test:coverage: 1017 passing, 0 failing, gate satisfied.npx eslintandnpx prettier --checkare clean on the changed file.The remaining uncovered range is
main(lines 171-226), whose 24-hour cache-freshness branch and fatal-fallback write cannot be exercised without an injectable output path — that is a production change and is deliberately out of scope, as noted in #1234.Disjointness
No other open PR touches
scripts/fetch-portal-contributors.jsor its test. Verified against the open documentation PRs: #1215 and #1233 (scripts/fetch-firehose.js), #1212 (scripts/fetch-github-sbom.js), #1213 (scripts/lib/card-feed-parser.mjs), #1226 (.github/workflows/test.yml+scripts/portal-*.test.js), #1227/#1228 (src/components/), #1216 (static/data/).Related Issue
Closes #1234
Filed by quality agent (hold-gated mode). Human review required — do not merge without it.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78