Skip to content

test: cover isProd-dependent url/editUrl branches in docusaurus.config.ts - #413

Merged
nate-double-u merged 5 commits into
mainfrom
quality/test-config-build-context
Nov 16, 2026
Merged

nate-double-u merged 5 commits into
mainfrom
quality/test-config-build-context

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds lib/docusaurusConfigBuildContext.test.mts plus a test-only harness
lib/testHelpers/printConfigBuildUrls.mjs (same extensionless-import
pattern as lib/testHelpers/resolveExtensionlessTs.mjs) that imports
docusaurus.config.ts in a fresh child process per env combination —
necessary because getBuildContext() runs once at module load time.

Covers the three isProd-dependent fields in docusaurus.config.ts that
had zero unit assertions: the top-level url, the docs preset's
editUrl, and the analyses plugin's editUrl. This file is excluded
from the test:coverage c8 gate, and the only existing test for it
(lib/docusaurusConfigPreprocessor.test.mts) only exercises
markdown.preprocessor — it never touches these fields.

This is disjoint from #408 (fixes the TS2339 typecheck regression in
docusaurusConfigPreprocessor.test.mts), #410 (adds a reference-link
test case to that same file), #411 (tightens test:coverage thresholds),
and #412 (covers resolveExtensionlessTs.mjs's own resolution branches):
none of those add any assertion on config.url/config.*.editUrl, and
this PR doesn't touch any file those PRs touch.

Verified: npx prettier --check and npx tsc --noEmit both pass (the
only tsc error is the pre-existing, unrelated TS2339 regression already
fixed by #408). Manually inverted the isProd check in
docusaurus.config.ts (reverted before commit) and confirmed the new
localhost-fallback test fails with the wrong URL, so the assertions
actually detect regressions. No production code changed.

Related Issue

Refs #407 (needs-human: no — this finding was auto-folded into #407's
component tracker by the hive's dedup logic since it also touches the
docusaurus.config.ts test cluster, but it is a distinct, disjoint
sub-finding about three previously-unasserted isProd branches, not the
typecheck regression #407/#408 already fix. Leaving #407 open since it
still tracks that unrelated typecheck fix.)


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

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

…g.ts

docusaurus.config.ts is excluded from the c8 coverage gate, and the
existing lib/docusaurusConfigPreprocessor.test.mts only exercises the
markdown.preprocessor function. Its three isProd-dependent fields
(top-level url, docs preset editUrl, analyses plugin editUrl) had no
unit assertion at all.

Adds a test-only harness (lib/testHelpers/printConfigBuildUrls.mjs,
following the resolveExtensionlessTs.mjs pattern already used to import
docusaurus.config.ts directly in tests) that spawns a fresh process per
env combination, since getBuildContext() is evaluated once at module
load time. Verified the new test actually detects a regression: a
manual mutation inverting the isProd check (reverted before commit)
made the localhost-fallback test fail with the wrong URL.

No production code changed.

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 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

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

hivecommons-hive Bot commented Nov 14, 2026 •

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

Verified locally — looks correct to me. (I cannot approve; a maintainer's signature is needed.)

What I checked against the tree at 5edea67:

  • The three assertions match docusaurus.config.ts exactly: url ternary (docusaurus.config.ts:30-32), docs preset editUrl (line 72), analyses plugin editUrl (line 93), with isProd derived from BUILD_ENV === 'production' in lib/getBuildContext.ts:14-15. The accessor paths in lib/testHelpers/printConfigBuildUrls.mjs:14-16 (presets[0][1].docs.editUrl, plugins[0][1].editUrl) match the config's actual shape.
  • Ran the suite: all 3 tests pass. The localhost-fallback case correctly passes DEPLOY_PRIME_URL: '' so an inherited env value can't leak in.
  • Ran npm run test:coverage on this branch against current main (post-test: tighten coverage gate thresholds to match actual 100% coverage #411 100% thresholds): the gate still passes at 100% across the board, so the child-process coverage merge from spawnSync doesn't regress the tightened gate.
  • The harness lives under lib/testHelpers/ (c8-excluded) and reuses the existing resolveExtensionlessTs.mjs hook — consistent with the pattern test: cover resolveExtensionlessTs.mjs resolution hook branches #412 just covered.

No findings. No production code touched; disjoint from #408/#410/#411/#412 as the body claims.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified in the URL-configuration regression tests or their test-only harness.

No open issues 🎉

What changed in this PR

Adds regression tests for the production-dependent URL settings in docusaurus.config.ts, complementing the existing markdown preprocessor tests without changing production code.

Changes:

  • Tests production URLs and edit links, deploy-preview URLs without edit links, and the localhost fallback.
  • Adds a test-only harness that loads the configuration in a fresh child process for each environment combination.
File Description
lib/​testHelpers/​printConfigBuildUrls.mjs Loads the configuration and prints its site and edit URLs as JSON.
lib/​docusaurusConfigBuildContext.test.mts Asserts URL behavior for production, deploy-preview, and development environments.

Review effort: Balanced

@nate-double-u
nate-double-u merged commit 92c2b9f into main Nov 16, 2026
9 checks passed
@nate-double-u
nate-double-u deleted the quality/test-config-build-context branch November 16, 2026 23:20
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.

2 participants