Skip to content

test: cover the docusaurus.config.js and sidebars.js navigation contract (tests/site-config.test.mjs) - #275

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-site-config
Open

kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-site-config

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/site-config.test.mjs (15 tests), the first test to import docusaurus.config.js and sidebars.js. Before this, neither file appeared in the coverage report at all — not at 0%, but never loaded by any test process.

The site's navigation and branding contract lives entirely in those two files and was verified only by a full docusaurus build, which fails late and prints a wall of build errors rather than a named assertion.

What is asserted

  • Navbar routes resolve. Every internal to: maps to a real doc route, the blog, or a static file. Route derivation mirrors the docs plugin under routeBasePath: '/' — an explicit frontmatter slug wins, otherwise the path relative to docs/ with index collapsing onto its directory.
  • Heading fragments exist. /community/end-user-community#projects-born-at-end-user-organizations is checked against the headings actually present in that doc.
  • Sidebar wiring is two-way. Every docSidebar navbar item names a sidebar defined in sidebars.js, and every sidebar is reachable from the navbar. A rename on either side currently fails silently.
  • Autogenerated sidebars point at populated directories under docs/.
  • Branding assets exist on diskfavicon, navbar.logo.src/srcDark, themeConfig.image, both headTags link hrefs, and theme.customCss.
  • onBrokenLinks stays 'throw'. The config carries the comment "Preserve broken-link enforcement; do not weaken." Nothing enforced it until now.
  • No two docs claim the same route.
  • SITE_URL/BASE_URL overrides flow into url, baseUrl and the JSON-LD logo URL, including the trailing-slash strip. This path only runs for GitHub Pages previews, so it is exercised least often exactly where a mistake is hardest to spot.

Implementation note

docusaurus.config.js is ESM but calls require.resolve() for its plugin list, which Docusaurus supplies through its own loader. The test installs a createRequire shim before importing. That is the one non-obvious part of the file.

Verification

  • 15/15 pass; full suite 70/70 (was 55/55). No existing test, helper or fixture is modified.
  • docusaurus.config.js and sidebars.js go from absent-from-report to 100% lines; all-files line coverage rises 73.51% → 90.26%.
  • Mutation-checked. Six independent mutations of docusaurus.config.js each fail at least one new test: bogus navbar route, onBrokenLinks weakened to 'warn', unknown sidebarId, missing logo asset, dead heading fragment, and removing the trailing-slash strip. The config was restored clean afterwards (git diff empty).
  • npx prettier --check clean.

Deliberately out of scope

The editUrl values pointing at castrojo/endusers are being corrected in #245. Asserting the post-fix value here would make this test red on main, so editUrl is not asserted.

Disjointness

Touches exactly one new file, tests/site-config.test.mjs, and no production code. No other open PR touches docusaurus.config.js, sidebars.js, or site navigation. It does not modify tests/helpers.mjs (claimed by #231) and adds no JSX import path (claimed by #229), so it does not overlap the component-test or fixture-sandbox work.

Related Issue

Closes #274 — merging this lands the only deliverable that issue describes, so nothing is left for it to track.


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

— hive: agent=quality backend=copilot model=claude-opus-5

No test imported docusaurus.config.js or sidebars.js, so neither file
appeared in the coverage report at all. The site's navbar routes, sidebar
wiring, asset references and preview-URL construction were verified only
by a full docusaurus build.

tests/site-config.test.mjs imports the real config (via a createRequire
shim, since the ESM config calls require.resolve for its plugin list) and
asserts that every internal navbar link resolves to a doc, the blog or a
static file; that heading fragments exist in their target doc; that every
docSidebar item names a sidebar and every sidebar is reachable; that
autogenerated sidebars point at populated docs directories; that branding
assets exist on disk; that onBrokenLinks stays 'throw'; that no two docs
claim the same route; and that SITE_URL/BASE_URL overrides flow correctly
into the JSON-LD logo URL.

Both files now report 100% lines and all-files line coverage rises from
73.51% to 90.26%.

Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
@kubestellar-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. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

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

Labels

agent/quality Approved by a Hive merger/owner for auto-merge on green CI hive/hosted-available-lke648397-260827-5n31 Approved by a Hive merger/owner for auto-merge on green CI hold quality Approved by a Hive merger/owner for auto-merge on green CI testing Approved by a Hive merger/owner for auto-merge on green CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] docusaurus.config.js and sidebars.js navigation contract has zero unit coverage

0 participants