Repository navigation
test: regression coverage for add-frontmatter glob crash - #392
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
…ntmatter scripts/add-frontmatter.mjs imports 'glob', but that package was dropped from devDependencies when the repo cleaned up during the Astro + Starlight migration. The script has crashed with ERR_MODULE_NOT_FOUND on startup ever since, and nothing caught it because the script has zero unit or end-to-end coverage. Restore the glob devDependency and add a black-box regression suite (scripts/add-frontmatter.test.mjs) that runs the script against fixture docs/ directories in a temp cwd and asserts on the frontmatter it writes, plus a guard that the script starts up without the missing dependency. Widen the test:unit glob to also pick up scripts/**/*.test.mjs so this suite actually runs. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
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. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
✅ Deploy Preview for cncf-techdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
7777afd
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
There was a problem hiding this comment.
Verified this end-to-end against the tree. Looks correct to me.
- Confirmed the bug:
main'spackage.jsonhas noglobdevDependency, whilescripts/add-frontmatter.mjs:2doesimport { glob } from 'glob', so the script crashes withERR_MODULE_NOT_FOUNDexactly as #391 describes. - Read
scripts/add-frontmatter.mjsagainst each assertion inscripts/add-frontmatter.test.mjs: the four fixture cases (no frontmatter, frontmatter without title, colon-quoted title, no-heading no-op) match the script's actual behaviour (processFile, lines 15–81), including the title-insertion-above-existing-keys ordering at line 60. - Ran
npm ci && npm run test:uniton the PR head (7777afd): all 21 tests pass, including the 5 new ones, so the widenedtest:unitglob inpackage.jsondoes pick upscripts/**/*.test.mjs. - The fixture tests run the script with
cwdset to a fresh temp dir, so they can't touch real repo docs.
One non-blocking suggestion: the startup-guard test (add-frontmatter.test.mjs:37) runs the script with cwd: tmpdir(). If a docs/ or analyses/ directory ever exists at the OS temp root, the script would mutate real files there. Using a fresh mkdtemp dir for that test too (as the other tests do) would make it fully hermetic. Fine to land as-is.
This matches the scope of #391's recommendation with no unrelated changes (the 80 lockfile lines are the glob@14 subtree). Approval itself is a maintainer's call.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
Test Improvement
scripts/add-frontmatter.mjsimportsglob, but that package was dropped frompackage.jsondevDependencies during an earlier cleanup, leaving the script crashing immediately withERR_MODULE_NOT_FOUNDand zero test coverage in either direction.This PR:
glob(^14.0.5) to devDependencies so the script is runnable again.scripts/add-frontmatter.test.mjs, a black-box regression suite that runs the script against fixturedocs/files in a temp cwd and asserts on the frontmatter it writes (no heading, no frontmatter, frontmatter without a title, title containing:), plus a guard that the script starts up without the missing dependency.test:unitglob to also pick upscripts/**/*.test.mjsso this new suite actually runs undernpm run test:unit.Verified locally: removing
globfromnode_modulesreproduces the exactERR_MODULE_NOT_FOUNDcrash and fails all 5 new tests; reinstalling it makes all 21 unit tests (16 existing + 5 new) pass.Related Issue
Fixes #391
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88