Repository navigation
test: cover non-GitHub REPOSITORY_URL fallback in the real e2e build - #456
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
normalizeGitHubUrl's final fallback (return undefined, reached when REPOSITORY_URL is set but matches neither the SSH nor HTTPS GitHub regex) was 100% unit-covered in isolation but never exercised by a real docusaurus build. Add an e2e deploy-preview build that sets REPOSITORY_URL to a non-GitHub URL and breaks the git-remote fallback, asserting the rewritten asset link falls back to the hard-coded repo/main instead of the unparseable URL. 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 production path this exercises, not just the diff. The test is correct and covers a genuinely distinct branch:
- With
REPOSITORY_URL=https://gitlab.com/example-org/example-repo,normalizeGitHubUrl(lib/getGitHubRepoUrl.ts:3-13) matches neither the SSH nor HTTPS GitHub regex and returnsundefined, so execution continues past the env branch (lib/getGitHubRepoUrl.ts:19-22) into the git-remote fallback - the exact path the existing suites never reach, since they set REPOSITORY_URL to a GitHub URL or clear it. - Pointing
GIT_DIR/GIT_WORK_TREEat a nonexistent path makesgit remote get-url originthrow, sogetGitHubRepoUrlreturnsundefinedandgetBuildContext.ts:18falls back to the hard-codedrepo. Same mechanism forgetCurrentBranch->main. The asserted URL is exactly whatassetBaseUrlproduces. - This is not a duplicate of the both-fail suite above it (empty
REPOSITORY_URL): that one never callsnormalizeGitHubUrlfrom the env branch. ThedoesNotMatch(/gitlab\.com/)assertion distinguishes the outcomes. - The fixture link exists (
analyses/2023/backstage/index.md:18referencesbackstage-doc-survey.csv), matching the pattern of the sibling suites ine2e/linkRewrite.test.mjs.
One known caveat, not a defect of this PR: no CI workflow runs the test suites (only format/link/spell checks run), so green checks here do not prove this suite executes - it follows the same verified pattern as its siblings, and I confirmed the logic by reading the tree.
Looks correct to me. I cannot approve; leaving that signature to a maintainer.
-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
Merge-order note: this PR and #444/#454/#455/#456 (the others in this set) all add tests to
Recommended order: land #444 first, then rebase #454, #455, and #456 on top individually - rebasing the three small diffs once each onto the restructured file is cheaper than rebasing the large restructuring diff three times. No action needed from a human beyond normal review order; this is a heads-up so whichever lands later isn't surprised by the conflict. 🐝 Hive Agent: |
|
closing to save spend. |
Test Improvement
Adds an e2e deploy-preview build (
e2e/linkRewrite.test.mjs) that setsREPOSITORY_URLto a non-GitHub URL (e.g. a GitLab mirror) and breaks the git-remote fallback (GIT_DIR/GIT_WORK_TREEpointed at a nonexistent path), asserting the rewritten.csvasset link falls back to the hard-codedrepo/maininstead of the unparseable URL.normalizeGitHubUrl's finalreturn undefinedfallback (reached when REPOSITORY_URL is present but matches neither the SSH nor HTTPS GitHub regex) was 100% unit-covered in isolation (lib/getGitHubRepoUrl.test.mts) but never reached by a real build: before this change,npx c8 --all --include lib/getGitHubRepoUrl.ts node --test e2e/linkRewrite.test.mjsreported 93.93% stmt/line for the file; after, it reports 100%.REPOSITORY_URL is an overridable input the production code reads directly, so this exercises the exact same code path a real deploy-preview build would take if Netlify (or a mirror setup) ever populated it with something that isn't github.com-shaped - no fabricated wiring is required.
Related Issue
Refs #451 (tracker issue for e2e/linkRewrite.test.mjs coverage gaps; this PR closes the getGitHubRepoUrl.ts non-GitHub-URL fallback variant folded into it, other variants remain 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