Skip to content

test: cover remaining branches in remarkRewriteLinks - #394

Open
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-remarkrewritelinks-branches
Open

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-remarkrewritelinks-branches

Conversation

@hivecommons-hive

Copy link
Copy Markdown

Test Improvement

lib/remarkRewriteLinks/index.ts had 100% line/function coverage but only 89.74% branch coverage (npx c8 --reporter=text node --experimental-strip-types --test 'lib/**/*.test.mts'). This PR adds 4 unit test cases to lib/remarkRewriteLinks/index.test.mts closing the gap to 100% branch coverage:

  • a bare query/fragment href (e.g. ?view=raw), exercising the empty-path short-circuit
  • a cross-plugin link with no sub-path (../docs), exercising the undefined capture-group case
  • a site-absolute .mdx link, exercising the .mdx branch of the strip-extension ternary
  • running the plugin against a VFile built without a path, exercising the file.path ?? '' fallback

No production code changes. Verified locally: all 20 unit tests pass, npm run check:format is clean, and branch coverage is 100%.

Related Issue

Fixes #393


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88

Branch coverage for lib/remarkRewriteLinks/index.ts was 89.74% (c8
--reporter=text). Adds 4 unit test cases that exercise: a bare
query/fragment href (empty path after split), a cross-plugin link with
no sub-path (undefined capture group), the .mdx branch of the
site-absolute strip-extension ternary, and running the plugin against a
VFile with no path set. Branch coverage is now 100%.

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

Copy link
Copy Markdown
Author

Important

Held for human review 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.

Hive will keep the hold label until a human removes it. 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 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit 806914e
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6af5286a0542f510e9d2b8a1
😎 Deploy Preview https://deploy-preview-394--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

Copy link
Copy Markdown
Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Reviewed by reviewer — no findings.

Reviewer notes

Read the full source at lib/remarkRewriteLinks/index.ts and verified each new test against the branch it claims to cover. This looks correct to me.

  • ?view=raw → splitHref yields an empty path, hitting the if (!original) return href short-circuit (index.ts:85). Expected passthrough is right.
  • ../docs → CROSS_PLUGIN_RE matches with capture group 2 undefined, exercising cross![2] ?? '' (index.ts:97); result /docs/ matches the trailing-slash branch.
  • /docs/analysis/criteria.mdx → takes the .mdx arm of the strip-extension ternary in the site-absolute block (index.ts:110-112).
  • VFile built without path → exercises the file.path ?? '' fallback (index.ts:141); the cross-plugin rewrite doesn't depend on sourceFile, so the asserted output is correct.

Reproduced locally at head 806914e: 20/20 tests pass and c8 reports 100% branch coverage on index.ts, matching the PR body's claim. Test-only change, no production code touched, all required checks green. No findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] lib/remarkRewriteLinks/index.ts: 4 branches uncovered by unit tests

0 participants