Skip to content

test: cover .mdx link rewriting in the real e2e build - #441

Merged
nate-double-u merged 5 commits into
mainfrom
quality/test-e2e-mdx-link-rewrite
Nov 24, 2026
Merged

nate-double-u merged 5 commits into
mainfrom
quality/test-e2e-mdx-link-rewrite

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds a describe block to e2e/linkRewrite.test.mjs (production build rewrites .mdx link destinations end-to-end) that:

  1. Writes two temporary .mdx fixtures into the real content tree (one under analyses/2024/keda/ exercising rewriteHref()'s cross-plugin isCrossPage .mdx-stripping branch, one under docs/analysis/ exercising the site-absolute SITE_ABSOLUTE_MD_RE .mdx-stripping branch)
  2. Runs a real docusaurus build
  3. Asserts both rewritten hrefs in the output HTML
  4. Deletes both fixtures in after(), so no content change survives the test run

Both .mdx branches in lib/remarkRewriteLinks/index.ts were already 100% unit-covered (lib/remarkRewriteLinks/index.test.mts), but no suite exercised them against a real build, since this repo's docs//analyses/ content is entirely .md. A regression confined to .mdx handling would have passed every existing unit and e2e test.

Verified locally: npm run test:e2e passes (14/14), npm run test:coverage still reports 100/100/100/100 across all files, and git status is 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

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>
@hivecommons-hive hivecommons-hive Bot added the ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge. label Nov 21, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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 outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

The hive's work on this PR is done. Hive will keep the ready-for-review label until a maintainer reviews the PR and removes it; it blocks merging the same way hold does. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@netlify

netlify Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit 614c70b
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6b046d1e7b40fdcdee8031a3
😎 Deploy Preview https://deploy-preview-441--cncf-techdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts strips .mdx in the cross-plugin isCrossPage block (lines 100-103) and in the SITE_ABSOLUTE_MD_RE block (lines 111-115), and no .mdx file exists anywhere under docs/ or analyses/, so no prior e2e build could reach either branch.
  • The fixture hrefs match the intended regexes: ../../docs/analysis/criteria.mdx matches CROSS_PLUGIN_RE (the match is textual, independent of actual directory depth) and /docs/analysis/criteria.mdx matches SITE_ABSOLUTE_MD_RE. Both rewrite to /docs/analysis/criteria/, which exists as docs/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, and e2e/ 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 removes outDir; 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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Merge-order note: this PR and #441/#444 (the other) both add tests to e2e/linkRewrite.test.mjs from the same base and will textually conflict (confirmed with git merge-tree). Recommended order: land #441 first (larger diff, 82 insertions), then rebase #444 (78 insertions) on top, since rebasing the smaller diff is the cheaper reconciliation.

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: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 4a3c592

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 .mdx links.
  • 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

Comment thread e2e/linkRewrite.test.mjs Resolved
@nate-double-u

Copy link
Copy Markdown
Member

/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>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Looked at Copilot's review. It was correct: the docs/analysis fixture page's autogenerated sidebar entry and pagination-nav link both independently render href="/docs/analysis/criteria/" (from sidebars.ts:17), so the whole-page assert.match on just the href could pass even if the fixture's own .mdx rewrite were broken. Verified this by building the fixtures locally and inspecting the generated HTML.

Fixed in commit 39ca3a5 (pushed to this branch): both assertions now also require the criteria anchor text, which only appears in the fixture's own paragraph. npm run test:e2e still passes 14/14.

Replied with details on the specific review thread as well.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .mdx strip at lib/remarkRewriteLinks/index.ts:100-101 and the site-absolute .mdx strip at index.ts:111-112 (SITE_ABSOLUTE_MD_RE already matches .mdx?, line 51). All other content under docs/ and analyses/ 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.md exists), so the build's broken-link check stays green.
  • Cleanup is sound: node:test runs after() even when before() throws, and both unlink calls swallow ENOENT, so a failed build cannot leave fixtures in the working tree.
  • The suite reuses this file's established pattern (own mkdtemp outDir, BUILD_ENV: 'dev', cleared DEPLOY_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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the added real-build .mdx link-rewriting coverage.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@nate-double-u
nate-double-u merged commit 7dc5dd4 into main Nov 24, 2026
10 checks passed
@nate-double-u
nate-double-u deleted the quality/test-e2e-mdx-link-rewrite branch November 24, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] remarkRewriteLinks .mdx stripping branches unit-covered but not exercised end-to-end

2 participants