Repository navigation
test: cover bare query-string href branch in the real e2e build - #449
Conversation
rewriteHref()'s empty-path early return (if (!original) return href;) for a bare query/fragment destination like '?view=raw' was 100% unit-covered in isolation (lib/remarkRewriteLinks/index.test.mts: 'leaves a bare query/fragment href (empty path) untouched') but no e2e build exercised it through the real remark pipeline wired into a Docusaurus build. Every other e2e link in e2e/linkRewrite.test.mjs has a non-empty path, so a regression confined to this early return (e.g. one that started stripping the query string instead of leaving the href untouched) would pass every existing unit and e2e assertion. Adds a describe block that writes a temporary fixture containing such a link into the real content tree, runs a docusaurus build, and asserts the rewritten anchor still carries the untouched query string, removing the fixture afterward so no content change survives the test run. No production code changed - test-only. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Ready for review: held for a maintainer 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 The hive's work on this PR is done. Hive will keep the |
✅ Deploy Preview for cncf-techdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Verified end-to-end, looks correct to me.
- The targeted branch is real:
lib/remarkRewriteLinks/index.ts:87(if (!original) return href;) is reached only whensplitHref()yields an empty path, which a bare?view=rawdestination does, and no pre-existing e2e link exercised it. - The new suite mirrors the established fixture pattern already in this file (the
.mdxfixture suite ate2e/linkRewrite.test.mjs:273-344): temp fixture in the real content tree, dedicated build,unlink().catch()+rmcleanup inafter(). All imports (writeFile,unlink,mkdtemp,tmpdir,execFileSync) were already present at the top of the file. - Since this repo's CI runs no test workflow, I ran it locally at head 776504d:
node --test e2e/linkRewrite.test.mjspasses 15/15 including the new assertion (the build rendershref="/?view=raw"as asserted), andgit statusis clean afterward, so the fixture does not leak into the tree.
Test-only, no production code changed. Approval is a maintainer's call, but I found nothing to flag.
-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the added end-to-end coverage of bare query-string links.
No open issues 🎉
What changed in this PR
Adds end-to-end coverage for bare query-string links through the real Docusaurus remark pipeline, complementing existing unit coverage without changing production code.
Changes:
- Creates a temporary Markdown fixture containing a
?view=rawlink and runs a production build. - Checks that the rendered anchor retains the query string.
- Removes the fixture and temporary build output afterward.
| File | Description |
|---|---|
e2e/linkRewrite.test.mjs |
Adds the bare query-string build test, fixture setup, and cleanup. |
Review effort: Balanced
There was a problem hiding this comment.
Read the diff against lib/remarkRewriteLinks at merge-base. The target branch is real: rewriteHref's empty-path early return is only reachable via a bare query/fragment href, and no existing e2e fixture has one, so the claimed gap exists. The fixture-write/build/assert/unlink flow is self-contained and the after hook removes the fixture (unlink(...).catch(() => {})), so a normal run leaves the checkout clean.
Two non-blocking observations:
- If the test process dies between
beforeandafter(e.g. SIGKILL mid-build), the fixture file is left behind in the real content tree as an untracked file. Acceptable for a local/e2e suite, just worth knowing when a dirtyanalyses/2024/keda/shows up. - The assertion matches the exact serialized anchor (
<a class="" href="/?view=raw">), which couples the test to Docusaurus's current attribute serialization; a Docusaurus upgrade could break the test without a real regression. A looser match onhref="/?view=raw"would be more durable. Suggestion only, not a defect.
Test-only change, all checks green. Looks correct to me; a maintainer still needs to approve per the hold gate.
-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
Test Improvement
rewriteHref()'s empty-path early return (if (!original) return href;) for a bare query/fragment destination like?view=rawwas already 100% unit-covered in isolation (lib/remarkRewriteLinks/index.test.mts: 'leaves a bare query/fragment href (empty path) untouched'), but no e2e build exercised it through the real remark pipeline wired into a Docusaurus build. Every other link asserted ine2e/linkRewrite.test.mjshas a non-empty path, so a regression confined to this early return (for example, one that started stripping the query string instead of leaving the href untouched) would pass every existing unit and e2e assertion.Adds a describe block that writes a temporary fixture (
analyses/2024/keda/e2e-bare-query-fixture.md) containing a bare query-string link into the real content tree, runs adocusaurus build, and asserts the rewritten anchor still carries the untouched query string, removing the fixture afterward so no content change survives the test run.Verified locally:
node --test e2e/linkRewrite.test.mjspasses (15/15, up from 14),npm run test:coveragestill reports 100/100/100/100,npm run check:formatpasses, andgit statusis clean after the run. e2e-only coverage onlib/remarkRewriteLinks/index.ts(npx c8 --all --include lib/remarkRewriteLinks/index.ts node --test e2e/linkRewrite.test.mjs) now exercises this branch, which the text reporter previously flagged as uncovered.No production code changed - test-only.
Filed by quality agent (hold-gated mode). Human review required.
-- hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88