Repository navigation
test: cover .mdx link rewriting in the real e2e build - #441
Conversation
rewriteHref()'s two .mdx-specific stripping branches (cross-plugin isCrossPage and SITE_ABSOLUTE_MD_RE) were 100% unit-covered but never exercised against a real Docusaurus build, since this repo's docs/ and analyses/ content is entirely .md. Add a describe block that writes temporary .mdx fixtures into the content tree, builds, asserts the rewritten href, then removes the fixtures. 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.
Read the plugin source and the fixtures against it; this looks correct to me.
Verified against the tree at head 1df6e89:
- Both claimed gaps are real branches:
lib/remarkRewriteLinks/index.tsstrips.mdxin the cross-pluginisCrossPageblock (lines 100-103) and in theSITE_ABSOLUTE_MD_REblock (lines 111-115), and no.mdxfile exists anywhere underdocs/oranalyses/, so no prior e2e build could reach either branch. - The fixture hrefs match the intended regexes:
../../docs/analysis/criteria.mdxmatchesCROSS_PLUGIN_RE(the match is textual, independent of actual directory depth) and/docs/analysis/criteria.mdxmatchesSITE_ABSOLUTE_MD_RE. Both rewrite to/docs/analysis/criteria/, which exists asdocs/analysis/criteria.md, so the build's broken-link check passes only when the rewrite fires - which is the regression signal the suite is for. - Build invocation (
BUILD_ENV: 'dev',DEPLOY_PRIME_URL: '') matches the existing suites in the same file, ande2e/has a single test file so suites run sequentially; the fixtures cannot leak into another suite's build. after()unlinks both fixtures with.catch(() => {})and removesoutDir; worst case on a crashed build is two untracked files, no committed content change.
The diff does exactly what the PR body and #440 describe, with no scope creep. Recommending merge to a maintainer; I have not approved (that signature is a human's).
-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
Merge-order note: this PR and #441/#444 (the other) both add tests to No action needed from a human beyond normal review order; this is a heads-up so whichever lands second isn't surprised by the conflict. 🐝 Hive Agent: |
There was a problem hiding this comment.
Read the diff against lib/remarkRewriteLinks/index.ts at merge-base. The two assertions hit exactly the previously build-untested branches: the cross-plugin .mdx strip at index.ts:100-101 (fixture link ../../docs/analysis/criteria.mdx matches CROSS_PLUGIN_RE and rewrites to /docs/analysis/criteria/) and the site-absolute .mdx strip at index.ts:111-112. The rewrite target /docs/analysis/criteria/ is a real page (docs/analysis/criteria.md), so the assertion checks a resolvable link, not just string surgery. Fixture cleanup is in after hooks with .catch(() => {}), which node:test runs even on build failure, so no .mdx fixture survives a failed run. Looks correct to me.
Merge-order note, not a defect: #444 also appends a describe block after line 257 of this file, so whichever of #441/#444 lands second needs a trivial rebase. The two PRs cover different gaps and are not duplicates.
-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
There was a problem hiding this comment.
🟡 Changes recommended
The whole-page assertion can pass on an unrelated sidebar link while the fixture’s .mdx link remains incorrectly rewritten, and build checks only warn about broken links.
1 open issue
What changed in this PR
Adds real-build coverage for .mdx link rewriting in the existing end-to-end suite, addressing the coverage gap described in #440 without changing application code.
Changes:
- Creates temporary fixtures for cross-plugin and site-absolute
.mdxlinks. - Runs a Docusaurus build and checks the rewritten destinations in generated HTML.
- Removes fixtures and build output after the suite.
| File | Description |
|---|---|
e2e/linkRewrite.test.mjs |
Adds .mdx fixtures, production-build assertions, and cleanup hooks. |
Review effort: Balanced
|
/hive have a look at copilot's review |
The site-absolute fixture page also carries an autogenerated sidebar entry and a pagination-nav link that both resolve to /docs/analysis/criteria/, independent of the fixture paragraph's own rewritten link. A whole-page href match could therefore pass even if the fixture's own .mdx link rewrite were broken. Match the anchor text together with the href so the assertion targets the fixture's own link. Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Looked at Copilot's review. It was correct: the Fixed in commit 39ca3a5 (pushed to this branch): both assertions now also require the Replied with details on the specific review thread as well. 🐝 Hive Agent: |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read the plugin source and the existing e2e suite, not just the diff. This looks correct to me.
Verified against the tree at 614c70b:
- The two new fixtures do exercise exactly the two previously build-untested branches: the cross-plugin
.mdxstrip atlib/remarkRewriteLinks/index.ts:100-101and the site-absolute.mdxstrip atindex.ts:111-112(SITE_ABSOLUTE_MD_REalready matches.mdx?, line 51). All other content underdocs/andanalyses/is.md, so the PR body's claim that no existing e2e run hits these branches checks out. - Both fixture links rewrite to
/docs/analysis/criteria/, which is a real route (docs/analysis/criteria.mdexists), so the build's broken-link check stays green. - Cleanup is sound: node:test runs
after()even whenbefore()throws, and bothunlinkcalls swallow ENOENT, so a failed build cannot leave fixtures in the working tree. - The suite reuses this file's established pattern (own
mkdtempoutDir,BUILD_ENV: 'dev', clearedDEPLOY_PRIME_URL), so no drift from the surrounding suites.
One observation, not a defect: the cross-plugin fixture's ../../docs/analysis/criteria.mdx is one ../ short of the true filesystem path from analyses/2024/keda/; it still exercises the intended branch because CROSS_PLUGIN_RE matches any ../ depth textually, and the fixture never lands on GitHub.
Note for a maintainer: this test (like the rest of test:e2e) is not run by any CI workflow, so the green checks here do not execute it - the author's local 14/14 run is the evidence. That is the pre-existing gap tracked around #390, not something this PR introduces.
I am not able to approve; a maintainer's sign-off is still needed.
-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

Test Improvement
Adds a describe block to
e2e/linkRewrite.test.mjs(production build rewrites .mdx link destinations end-to-end) that:.mdxfixtures into the real content tree (one underanalyses/2024/keda/exercisingrewriteHref()'s cross-pluginisCrossPage.mdx-stripping branch, one underdocs/analysis/exercising the site-absoluteSITE_ABSOLUTE_MD_RE.mdx-stripping branch)docusaurus buildhrefs in the output HTMLafter(), so no content change survives the test runBoth
.mdxbranches inlib/remarkRewriteLinks/index.tswere already 100% unit-covered (lib/remarkRewriteLinks/index.test.mts), but no suite exercised them against a real build, since this repo'sdocs//analyses/content is entirely.md. A regression confined to.mdxhandling would have passed every existing unit and e2e test.Verified locally:
npm run test:e2epasses (14/14),npm run test:coveragestill reports 100/100/100/100 across all files, andgit statusis clean after the run (fixtures are not committed).Related Issue
Fixes #440
Filed by quality agent (hold-gated mode). Human review required.
-- hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88