From 1df6e8998b1d7acf9e133d7453cdcaf0a1235070 Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:51:03 -0500 Subject: [PATCH 1/3] test: cover .mdx link rewriting in the real e2e build 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> --- e2e/linkRewrite.test.mjs | 83 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/e2e/linkRewrite.test.mjs b/e2e/linkRewrite.test.mjs index c7bff49c..7ace6869 100644 --- a/e2e/linkRewrite.test.mjs +++ b/e2e/linkRewrite.test.mjs @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; import { execFileSync } from 'node:child_process'; -import { mkdtemp, readFile, rm } from 'node:fs/promises'; +import { mkdtemp, readFile, rm, unlink, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import path from 'node:path'; import url from 'node:url'; @@ -257,3 +257,84 @@ describe('deploy-preview build wires branch/repo detection into the rewritten .c assert.doesNotMatch(html, /\/blob\/main\//); }); }); + +// `lib/remarkRewriteLinks/index.test.mts` unit-tests the `.mdx`-specific +// stripping branches in isolation ("maps (../)+docs/.../foo.mdx to +// /docs/.../foo/" and "strips .mdx from site-absolute /docs/.../foo.mdx"), +// but no suite asserted either branch against a real build: this repo's +// docs/analyses content is entirely `.md`, so every other e2e build in this +// file only exercises the `.md` half of `isCrossPage`'s and +// `SITE_ABSOLUTE_MD_RE`'s branches. A regression confined to the `.mdx` +// stripping logic (e.g. an `endsWith('.mdx')` check that silently fell +// through to the `.md` slice length) would pass every existing suite. This +// suite writes temporary `.mdx` fixtures into the real content tree so the +// genuine Docusaurus build picks them up, removing them afterward so no +// content change survives the test run. +describe('production build rewrites .mdx link destinations end-to-end', () => { + const crossPluginFixture = path.join( + repoRoot, + 'analyses/2024/keda/e2e-mdx-fixture.mdx', + ); + const siteAbsoluteFixture = path.join( + repoRoot, + 'docs/analysis/e2e-mdx-fixture.mdx', + ); + let outDir; + + before(async () => { + await writeFile( + crossPluginFixture, + [ + '---', + 'title: E2E .mdx cross-plugin fixture', + '---', + '', + '# E2E .mdx cross-plugin fixture', + '', + 'See [criteria](../../docs/analysis/criteria.mdx) for details.', + '', + ].join('\n'), + ); + await writeFile( + siteAbsoluteFixture, + [ + '---', + 'title: E2E .mdx site-absolute fixture', + '---', + '', + '# E2E .mdx site-absolute fixture', + '', + 'See [criteria](/docs/analysis/criteria.mdx) for details.', + '', + ].join('\n'), + ); + outDir = await mkdtemp(path.join(tmpdir(), 'techdocs-e2e-mdx-')); + execFileSync('npx', ['docusaurus', 'build', '--out-dir', outDir], { + cwd: repoRoot, + env: { ...process.env, BUILD_ENV: 'dev', DEPLOY_PRIME_URL: '' }, + stdio: 'inherit', + }); + }); + + after(async () => { + await unlink(crossPluginFixture).catch(() => {}); + await unlink(siteAbsoluteFixture).catch(() => {}); + if (outDir) await rm(outDir, { recursive: true, force: true }); + }); + + it('maps a cross-plugin .mdx link to a trailing slash without the extension', async () => { + const html = await readFile( + path.join(outDir, 'analyses/2024/keda/e2e-mdx-fixture/index.html'), + 'utf-8', + ); + assert.match(html, /href="\/docs\/analysis\/criteria\/"/); + }); + + it('strips .mdx from a site-absolute /docs link to a trailing slash', async () => { + const html = await readFile( + path.join(outDir, 'docs/analysis/e2e-mdx-fixture/index.html'), + 'utf-8', + ); + assert.match(html, /href="\/docs\/analysis\/criteria\/"/); + }); +}); From 39ca3a55a1d3035fa3d9cf3e698ffc42a9f39fbe Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:41:10 -0500 Subject: [PATCH 2/3] test: scope e2e .mdx link assertions to the fixture's own anchor 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> --- e2e/linkRewrite.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/linkRewrite.test.mjs b/e2e/linkRewrite.test.mjs index 7ace6869..bb4f6447 100644 --- a/e2e/linkRewrite.test.mjs +++ b/e2e/linkRewrite.test.mjs @@ -327,7 +327,7 @@ describe('production build rewrites .mdx link destinations end-to-end', () => { path.join(outDir, 'analyses/2024/keda/e2e-mdx-fixture/index.html'), 'utf-8', ); - assert.match(html, /href="\/docs\/analysis\/criteria\/"/); + assert.match(html, /criteria<\/a>/); }); it('strips .mdx from a site-absolute /docs link to a trailing slash', async () => { @@ -335,6 +335,6 @@ describe('production build rewrites .mdx link destinations end-to-end', () => { path.join(outDir, 'docs/analysis/e2e-mdx-fixture/index.html'), 'utf-8', ); - assert.match(html, /href="\/docs\/analysis\/criteria\/"/); + assert.match(html, /criteria<\/a>/); }); }); From 614c70b441d864322a5eff6ecf6996a0341cd339 Mon Sep 17 00:00:00 2001 From: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:43:04 -0500 Subject: [PATCH 3/3] style: fix prettier formatting in e2e/linkRewrite.test.mjs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- e2e/linkRewrite.test.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/e2e/linkRewrite.test.mjs b/e2e/linkRewrite.test.mjs index bb4f6447..03069482 100644 --- a/e2e/linkRewrite.test.mjs +++ b/e2e/linkRewrite.test.mjs @@ -327,7 +327,10 @@ describe('production build rewrites .mdx link destinations end-to-end', () => { path.join(outDir, 'analyses/2024/keda/e2e-mdx-fixture/index.html'), 'utf-8', ); - assert.match(html, /criteria<\/a>/); + assert.match( + html, + /criteria<\/a>/, + ); }); it('strips .mdx from a site-absolute /docs link to a trailing slash', async () => { @@ -335,6 +338,9 @@ describe('production build rewrites .mdx link destinations end-to-end', () => { path.join(outDir, 'docs/analysis/e2e-mdx-fixture/index.html'), 'utf-8', ); - assert.match(html, /criteria<\/a>/); + assert.match( + html, + /criteria<\/a>/, + ); }); });