Skip to content

test: cover docusaurus.config.ts markdown preprocessor - #404

Open
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-docusaurus-config-preprocessor
Open

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-docusaurus-config-preprocessor

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds lib/docusaurusConfigPreprocessor.test.mts, exercising both branches
of the inline markdown.preprocessor function in docusaurus.config.ts
(root README.md import that strips .md from site-absolute
/docs|analyses/... links, and the pass-through case for every other
imported file).

docusaurus.config.ts imports its ./lib/* helpers without file
extensions, which only Docusaurus's own webpack bundler resolves — importing
it directly under node --experimental-strip-types --test previously
failed with ERR_MODULE_NOT_FOUND. lib/testHelpers/resolveExtensionlessTs.mjs
is a small test-only Node module-resolution hook (node:module's
registerHooks) that falls back to <specifier>.ts / <specifier>/index.ts,
so the test can import the real docusaurus.config.ts and call its real
preprocessor — no change to any production import statement, and no
extraction of the regex into a new lib/ module.

Because docusaurus.config.ts also has several unrelated, env-dependent
branches (isProd/DEPLOY_PRIME_URL ternaries) this test doesn't target,
package.json's test:coverage now excludes docusaurus.config.ts and
lib/testHelpers/** from the --check-coverage thresholds added in #403,
so the existing 97%+ branch/line/function/statement gate keeps passing
(verified locally: npm run test:coverage still reports 100% across all
four metrics for every included file).

Related Issue

Fixes #398

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

Adds lib/docusaurusConfigPreprocessor.test.mts, exercising both
branches of the inline markdown.preprocessor function (root README.md
import vs. pass-through) directly against the real
docusaurus.config.ts.

docusaurus.config.ts imports its ./lib/* helpers without file
extensions, which only Docusaurus's own webpack bundler resolves —
node --experimental-strip-types --test fails with ERR_MODULE_NOT_FOUND
on a direct import. lib/testHelpers/resolveExtensionlessTs.mjs is a
test-only Node module-resolution hook (registerHooks) that falls back
to <specifier>.ts / <specifier>/index.ts, so the test can import the
real config file without any change to its production imports.

Because docusaurus.config.ts also contains several unrelated,
env-dependent branches (isProd/DEPLOY_PRIME_URL ternaries) that this
test does not and should not target, package.json's test:coverage
excludes docusaurus.config.ts and lib/testHelpers/** from the
--check-coverage thresholds added in #403, so the existing 97%+
branch/line/function/statement gate keeps passing.

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

Copy link
Copy Markdown
Contributor 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 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit d9b8476
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6af68e082e62e22213607d42
😎 Deploy Preview https://deploy-preview-404--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
Contributor Author
d9b8476

ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blocked

Hive flagged this PR (author @hivecommons-hive[bot], head d9b8476f977d) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation — a maintainer should confirm the change is intended before it merges.

  • sensitive_path — changes 1 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • package.json

Hive did not add the sentinel-alert label because this author is trusted. The finding remains recorded for audit and the dashboard Security tab; set sentinel.trusted_authors_block: true to require the blocking label for trusted authors too.

@hivecommons-hive

Copy link
Copy Markdown
Contributor 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 tree at head d9b8476 and ran the suite locally — this looks correct to me.

Verified:

  • The test assertions match the real preprocessor in docusaurus.config.ts:44-50: path.resolve(filePath) === importedReadmePath gates the rewrite, and the regex (\]\(|\]:\s*)(\/(?:docs|analyses)\/[^\s)#?]+)\.md(?=$|[\s)#?]) turns /docs/foo.md) into /docs/foo/) and preserves the #section fragment — exactly what lib/docusaurusConfigPreprocessor.test.mts:19-30 asserts. The pass-through case (line 32-40) exercises the ternary's false branch.
  • lib/testHelpers/resolveExtensionlessTs.mjs is genuinely test-only: no production import changes, and both fallback branches are needed (./lib/getBuildContext → .ts file, ./lib/remarkRewriteLinks → directory with index.ts, confirmed in the tree).
  • Ran npm ci && npm run test:coverage at head: 51/51 pass, coverage gate from chore: enforce coverage thresholds in c8 regression gate #403 still green (100% across all four metrics for included files), confirming the --exclude additions in package.json work as the body claims.

Two notes, neither a defect:

  1. The PR deliberately diverges from issue [quality] docusaurus.config.ts markdown preprocessor has zero test coverage #398's recommendation (extract the regex into lib/) in favor of a resolution hook, trading an enforced-coverage extraction for zero production change. Since the test still exercises the real inline function, I think this satisfies the issue's intent; the extraction remains available to a future refactor.
  2. registerHooks from node:module requires Node ≥ 22.15 / 23.5 — the suite passed for me on Node 26, but worth knowing if anyone runs the tests on an older 22.x.

No findings. A maintainer can take this at face value.

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] docusaurus.config.ts markdown preprocessor has zero test coverage

0 participants