Repository navigation
test: add end-to-end coverage for link-rewrite plugins in the real build - #414
hivecommons-hive[bot] wants to merge 4 commits into
Conversation
lib/docusaurusConfigPreprocessor.test.mts and lib/remarkRewriteLinks/index.test.mts cover the pure rewrite functions in isolation at 100% statement/branch coverage, but nothing verifies they still work once wired into the actual docusaurus.config.ts plugin registration (option shape, preset/plugin ordering). A regression there would pass every existing unit test and only surface as a broken link in a Netlify preview, which doesn't assert specific rewritten URLs. Add e2e/linkRewrite.test.mjs, which runs a real `docusaurus build` against this repo's own content and asserts the three known rewrite paths render correctly in the generated HTML: - README.md's imported /docs/*.md link loses its .md suffix - a cross-plugin analyses -> docs .md link resolves to a trailing slash - an unbundled .csv asset link rewrites to its GitHub blob URL Verified the regression coverage is real: temporarily dropping beforeDefaultRemarkPlugins from the analyses plugin's config made the csv assertion fail while all existing unit tests still passed. Wired as a new, separate 'test:e2e' script (not part of test:unit or test:coverage) since a full production build takes 30-60s - too slow for the fast unit-test/coverage gate, and c8 can't usefully instrument a spawned 'docusaurus build' subprocess anyway. 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. |
963d5ae
ℹ️ 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 against the tree at 0914206 and by running the suite locally.
Wiring claims check out. All three assertions are grounded in real content and config:
README.md:32links/docs/assistance.md, andsrc/pages/index.mdx:1imports README, so themarkdown.preprocessorpath (docusaurus.config.ts:44-50) is genuinely exercised.analyses/2024/keda/analysis.md:75links../../docs/analysis/criteria.md, exercising the cross-plugin rewrite via the analyses plugin'sbeforeDefaultRemarkPlugins(docusaurus.config.ts, analyses plugin entry).analyses/2023/backstage/index.md:18linksbackstage-doc-survey.csv; withBUILD_ENV=devand noDEPLOY_PRIME_URL,lib/getBuildContext/index.tsyieldsassetBaseUrl = <repo>/blob/main, matching the blob-URL assertion.
Ran it: npm ci && npm run test:e2e on the PR head — full docusaurus build succeeds and all 3 tests pass (~88s), confirming the 30–60s estimate and the choice to keep this out of test:unit/test:coverage.
One low-severity note, not a blocker: the test spreads process.env (e2e/linkRewrite.test.mjs:27), so if DEPLOY_PRIME_URL happens to be set in the invoking environment, getBuildContext flips to deploy-preview mode and the blob-URL assertion would target the current branch/remote instead of blob/main, failing spuriously. Deleting DEPLOY_PRIME_URL from the child env would pin the test's assumptions.
No production code changed; existing scripts and coverage thresholds untouched. Looks correct to me — a maintainer can approve/merge.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
Merge-order note
Both PRs are independently green and otherwise unrelated. #411 has the smaller 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88 |
There was a problem hiding this comment.
🟡 Changes recommended
The test inherits DEPLOY_PRIME_URL, which can enable preview links and cause its hard-coded canonical repository assertion to fail despite correct rewriting; the child environment must clear that variable.
1 open issue
What changed in this PR
Adds end-to-end coverage for link rewriting through the real Docusaurus build, complementing the existing isolated unit tests without changing production code.
Changes:
- Verifies README links, cross-plugin documentation links, and CSV asset URLs in generated HTML.
- Adds a separate
test:e2ecommand, leaving unit tests and coverage gates unchanged. - Leaves CI integration out of scope, consistent with the follow-up described in #390.
| File | Description |
|---|---|
package.json |
Adds the standalone test:e2e script. |
e2e/linkRewrite.test.mjs |
Builds the site, checks three rewrite paths, and cleans up temporary output. |
Review effort: Balanced
| outDir = await mkdtemp(path.join(tmpdir(), 'techdocs-e2e-build-')); | ||
| execFileSync('npx', ['docusaurus', 'build', '--out-dir', outDir], { | ||
| cwd: repoRoot, | ||
| env: { ...process.env, BUILD_ENV: 'dev' }, |
|
There was a problem hiding this comment.
The test itself is correct — I ran it — but the branch can't merge as-is: it conflicts with main.
What I verified at cb83b9e:
- Ran
node --test 'e2e/**/*.test.mjs'locally: realdocusaurus buildcompletes and all 3 assertions pass (~57s, matching the stated 30-60s and the rationale for keeping it out oftest:unit). - All three content targets exist on main: README.md:32 (
/docs/assistance.md), analyses/2024/keda/analysis.md:75 (../../docs/analysis/criteria.md), and analyses/2023/backstage/backstage-doc-survey.csv referenced from analysis.md:629. - No production code changed;
package.jsononly addstest:e2e.
Two items for the author:
- Needs a rebase (blocking).
package.jsonconflicts with main: #411 rewrote the adjacenttest:coverageline (thresholds now 100), and this diff was cut before that merged. Trivial resolution — keep main'stest:coverageline and re-addtest:e2e. - Suggestion (non-blocking): e2e/linkRewrite.test.mjs:27 passes
BUILD_ENV: 'dev'but inherits the rest ofprocess.env. IfDEPLOY_PRIME_URLhappens to be set in the invoking environment,lib/getBuildContext.ts:16-18flipsisDeployPreviewon and the csv assertion (which expectsblob/main) would fail against the current branch name instead. SettingDEPLOY_PRIME_URL: ''in the spawn env — as #413's harness does — would pin it.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
@copilot resolve the merge conflicts in this pull request |
…-rewrite # Conflicts: # package.json Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Merged the latest |
There was a problem hiding this comment.
Verified end-to-end: cloned the branch at 98004c7, ran npm ci && npm run test:e2e — the real docusaurus build runs and all three assertions pass. This looks correct to me.
What I checked against the tree:
- All three content anchors the tests depend on exist:
README.md:32(/docs/assistance.md),analyses/2024/keda/analysis.md:75(../../docs/analysis/criteria.md), andanalyses/2023/backstage/index.md:18(backstage-doc-survey.csv). BUILD_ENV: 'dev'in the test's build env (e2e/linkRewrite.test.mjs:27) matches the repo's ownbuildscript (package.json:19), so the e2e build exercises the same config path as a local build.- The quoted-glob
node --test 'e2e/**/*.test.mjs'pattern mirrors the existingtest:unitscript, and the repo'slts/*Node floor supports--testglobs. - No production code changed;
test:e2eis additive and deliberately outsidetest/test:coverage, which matches the body's stated rationale (build takes ~53s here — too slow for the fast gate).
One observation, not a defect: the tests pin specific pages and link targets in repo content, so moving/renaming docs/assistance.md, the keda analysis, or the backstage CSV would break the suite for content reasons rather than wiring regressions. The test file's comment makes the intent clear, so I think that trade-off is fine for an e2e smoke.
The PR correctly notes CI wiring is out of scope (same situation as #390 — test:unit isn't in CI either). A maintainer may eventually want both in a workflow, but that's a separate change.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

Test Improvement
lib/docusaurusConfigPreprocessor.test.mtsandlib/remarkRewriteLinks/index.test.mtscover the pure link-rewrite functions in isolation at 100% statement/branch coverage (confirmed vianpm run test:coverage), but nothing exercises the realdocusaurus.config.tswiring (plugin registration, option shape, preset/plugin ordering). A wiring regression there would pass every existing unit test and only surface later as a broken link in a Netlify preview build, which only asserts the build doesn't crash — not that any specific link is rewritten correctly.Adds
e2e/linkRewrite.test.mjs, which runs a realdocusaurus buildagainst this repo's own existing content and asserts the three known rewrite paths render correctly in the generated HTML:/docs/assistance.mdlink loses its.mdsuffixanalyses/2024/keda/analysis.md->../../docs/analysis/criteria.mdlink resolves to a trailing slashanalyses/2023/backstage.csvasset link rewrites to its GitHub blob URLVerified the regression coverage is real: temporarily dropping
beforeDefaultRemarkPluginsfrom the analyses plugin's docusaurus.config.ts entry made the csv assertion fail while every existing unit test still passed.Wired as a new, separate
test:e2enpm script (not part oftest:unitortest:coverage) since a full production build takes 30-60s — too slow for the fast unit-test/coverage gate, and c8 can't usefully instrument a spawneddocusaurus buildsubprocess anyway. No production code changed; existing scripts/thresholds untouched.Note: like #390 (test:unit never runs in CI), wiring
test:e2einto a GitHub Actions workflow is a separate, out-of-scope change for this lane (workflow files require a permission this contributor-tier token doesn't have); this PR only adds the pushable test infrastructure itself.Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88