Skip to content

[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
mainfrom
quality/test-fetch-registry-data
Open

kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-fetch-registry-data

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds scripts/fetch-registry-data.test.js — 13 node:test cases covering scripts/fetch-registry-data.js, which was the only file under scripts/ with no test reference at all.

Exact ground this PR claims: the single new file scripts/fetch-registry-data.test.js, covering the entry script scripts/fetch-registry-data.js. No production file is modified, and no other script, lib module, or workflow is touched.

Why it needed covering

package.json wires the script as fetch-registry-data and includes it in fetch-data:independent, so it runs on every npm run build. Its output static/data/registry-data.json feeds src/components/HiveFactoryDashboard.tsx. All four of its failure paths write null and process.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 to static/data/) — that makes it runnable and guarantees a test run can never write over the checked-in static/data/registry-data.json — then runs it under node --import <preload> with a stub globalThis.fetch that records the requested URL.

Cases:

  • writes the projectbluefin entry, hits the expected registry URL, logs acmmLevel/mode
  • selects projectbluefin rather than hives[0], with decoy orgs ahead of it
  • output ends in a newline (diff-clean)
  • writes null when there is no matching org, and when the payload has no hives key
  • non-ok HTTP, a thrown fetch, and unparseable JSON each exit 0 with null
  • the error path preserves existing stale-but-real data instead of clobbering it
  • a <24h cache short-circuits before any network call
  • a >24h cache is refetched and overwritten
  • --force refetches even when the cache is fresh
  • package.json still wires the script into fetch-data:independent

Verified: all 13 pass, and a mutation swapping the org find for hives[0] fails 3 of them, so the suite is not vacuous. prettier --check is clean and the file is picked up by the existing scripts/**/*.test.js glob in npm 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

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>
@kubestellar-hive kubestellar-hive Bot added the hold Work is intentionally paused. label Sep 14, 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 14, 2026
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.

[quality] coverage-gap: scripts/fetch-registry-data.js is the only untested script — build-time registry fetch with four silent fail-open paths

0 participants