[quality] test: black-box coverage for scripts/fetch-registry-data.js — new scripts/fetch-registry-data.test.js only - #1263
Open
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
scripts/fetch-registry-data.js was the only file under scripts/ with no test reference at all, despite running on every build via the fetch-data:independent npm script. It is a top-level-await entry script with no exports, so it is covered as a black box: each case copies it into a throwaway tree mirroring the repo layout (scripts/ next to static/data/) so a test run can never overwrite the checked-in static/data/registry-data.json, and runs it under --import with a stub globalThis.fetch. 13 cases pin the 24h mtime cache and its --force bypass, projectbluefin entry selection against decoy orgs, and the four fail-open paths (non-ok HTTP, thrown fetch, unparseable JSON, missing entry) that write null and exit 0 — including the branch that preserves stale-but-real data instead of clobbering it. No production code is changed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> 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
scripts/fetch-registry-data.test.js— 13node:testcases coveringscripts/fetch-registry-data.js, which was the only file underscripts/with no test reference at all.Exact ground this PR claims: the single new file
scripts/fetch-registry-data.test.js, covering the entry scriptscripts/fetch-registry-data.js. No production file is modified, and no other script, lib module, or workflow is touched.Why it needed covering
package.jsonwires the script asfetch-registry-dataand includes it infetch-data:independent, so it runs on everynpm run build. Its outputstatic/data/registry-data.jsonfeedssrc/components/HiveFactoryDashboard.tsx. All four of its failure paths writenullandprocess.exit(0), so a permanently broken registry fetch degrades the dashboard while CI stays green.How it is tested
The script is a top-level-await ESM entry point with no exports, so it is exercised as a black box. Each case copies it into a throwaway tmp tree that mirrors the repo layout (
scripts/next tostatic/data/) — that makes it runnable and guarantees a test run can never write over the checked-instatic/data/registry-data.json— then runs it undernode --import <preload>with a stubglobalThis.fetchthat records the requested URL.Cases:
projectbluefinentry, hits the expected registry URL, logsacmmLevel/modeprojectbluefinrather thanhives[0], with decoy orgs ahead of itnullwhen there is no matching org, and when the payload has nohiveskeynull--forcerefetches even when the cache is freshpackage.jsonstill wires the script intofetch-data:independentVerified: all 13 pass, and a mutation swapping the org
findforhives[0]fails 3 of them, so the suite is not vacuous.prettier --checkis clean and the file is picked up by the existingscripts/**/*.test.jsglob innpm test.Related Issue
Closes #1262
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.78