Repository navigation
test: cover BUILD_ENV=production editUrl/url wiring in e2e link-rewrite suite - #428
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
…te suite docusaurus.config.ts's isProd-dependent branches (production site url vs DEPLOY_PRIME_URL/localhost fallback; editUrl set on both docs plugins in production, undefined otherwise) are 100% unit-covered via lib/docusaurusConfigBuildContext.test.mts, but no real docusaurus build in e2e/linkRewrite.test.mjs ever ran with BUILD_ENV=production -- the actual Netlify production context (npm run build:production never sets BUILD_ENV, so getBuildContext.ts defaults to 'production'). A wiring regression there would pass every existing unit and e2e test and only surface on the live site. 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 at head f861e93 against the tree and the live production site. The build setup is sound (BUILD_ENV=production with DEPLOY_PRIME_URL cleared does reproduce the Netlify production context per lib/getBuildContext.ts:14-16), the docs-page and og:url assertions match both the config and the live site. One real problem, left as a line comment: the analyses-page assertion enshrines an edit URL that 404s.
Root cause is pre-existing, in unchanged code: docusaurus.config.ts:92 sets the analyses plugin's editUrl to ${repo}/tree/main/analyses, but Docusaurus appends the content path itself — observable on the docs plugin, where editUrl: ${repo}/tree/main (line 71) renders tree/main/docs/assistance.md on the live site. The analyses plugin therefore renders tree/main/analyses/analyses/2023/backstage/index.md, which returns 404 on GitHub (the file is at analyses/2023/backstage/index.md, HTTP 301→200). Line 92 should be ${repo}/tree/main, with lib/docusaurusConfigBuildContext.test.mts and this new assertion updated to the single-analyses URL. Fixing the config here (or first) keeps this PR's own rationale intact — a test meant to stop bad edit links from "surfacing on the live site" shouldn't assert the one that already has.
Minor, no action needed: this PR and #426 both append a describe block to the end of e2e/linkRewrite.test.mjs, so whichever lands second needs a trivial rebase; each new block also adds a full docusaurus build to test:e2e runtime.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
| it('renders the GitHub edit-this-page link for an analyses page', async () => { | ||
| const html = await readFile( | ||
| path.join(outDir, 'analyses/2023/backstage/index.html'), | ||
| 'utf-8', | ||
| ); | ||
| assert.match( | ||
| html, | ||
| /href="https:\/\/github\.com\/cncf\/techdocs\/tree\/main\/analyses\/analyses\/2023\/backstage\/index\.md"/, | ||
| ); |
There was a problem hiding this comment.
This assertion locks in a broken link. The doubled analyses/analyses/ path is what production currently renders (verified on the live site), but it 404s on GitHub — the file lives at analyses/2023/backstage/index.md. Mechanism: docusaurus.config.ts:92 sets editUrl: ${repo}/tree/main/analyses, and Docusaurus appends the plugin content path on top (compare the docs plugin: editUrl: ${repo}/tree/main at line 71 renders tree/main/docs/assistance.md). Consequence: every analyses page's "edit this page" link is dead, and this test would fail the eventual fix. Suggest fixing line 92 to ${repo}/tree/main in this PR (plus the config-value assertion in lib/docusaurusConfigBuildContext.test.mts) and asserting the single-analyses URL here.
Test Improvement
docusaurus.config.ts'sisProd-dependent branches (production siteurlvs.DEPLOY_PRIME_URL/localhost fallback;editUrlset on both docs plugins in production,undefinedotherwise) are 100% unit-covered vialib/docusaurusConfigBuildContext.test.mts, but no realdocusaurus buildine2e/linkRewrite.test.mjsever ran withBUILD_ENV=production— the actual Netlify production context (npm run build:productionnever setsBUILD_ENV, sogetBuildContext.tsdefaults to'production').This adds a third
describeblock toe2e/linkRewrite.test.mjswith its own realdocusaurus build(BUILD_ENV=production,DEPLOY_PRIME_URLcleared), asserting the rendered HTML contains the GitHub edit-this-page link on both a docs page and an analyses page, and thatindex.html'sog:urlmeta tag is the production domain (https://cncf-techdocs.netlify.app/).No production code changed — test-only addition to
e2e/linkRewrite.test.mjs.Verified locally:
npm run test:e2e(6 tests across both describe blocks pass),npx prettier --check e2e/linkRewrite.test.mjs,npx cspell -c .cspell.yml e2e/linkRewrite.test.mjs.Files/functions touched: only
e2e/linkRewrite.test.mjs(new describe block, no changes to the existing dev-build block). Disjoint from #426 (adds a deploy-preview build describe block to the same file) and #427 (package.json coverage-gate exclude flag + scripts/coverage-thresholds.test.mjs).Related Issue
Refs #425 (this PR adds e2e coverage for the BUILD_ENV=production branch only; #425's original deploy-preview branch/repo wiring gap is addressed separately by PR #426, which remains open, so this PR intentionally leaves #425 open)
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88