Skip to content

test: add behavior tests for DocsSidebar collapse state and navigation - #148

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-docs-sidebar
Oct 1, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-docs-sidebar

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds src/__tests__/DocsSidebar.behavior.test.tsx — 18 behavior tests for src/components/docs/DocsSidebar.tsx, which previously had only the two smoke cases in DocsChrome.behavior.test.tsx.

Claims: src/components/docs/DocsSidebar.tsx → mount-time collapse effect (findActivePath, collapseAll), getFirstChildRoute(), renderMenuItem, renderActiveProjectTree, renderProjectLink, renderProject, scroll/resize offset effect. Test-only; no production files touched. Disjoint from #145 (EditPageLink.tsx) and #146 (lockfile).

What is pinned

  • Initial state: folder chain to the active page stays open while siblings collapse; theme.collapsed === false keeps a folder open; general sections (Community/Contributing/News) collapse unless the current path is inside one, in which case their nested active path opens too.
  • getFirstChildRoute(): skips Meta/Separator/# children, recurses into nested folders, and a folder with no navigable route renders a plain toggle button instead of a link.
  • Folder rows: label link expands a collapsed folder but does not collapse an open one; chevron toggles either way; index, _meta, #, Separator, Meta and blank-title items are not rendered.
  • Project rows: active-project header button collapses/expands the tree; the tree is omitted when the pageMap has no project items; non-active projects render as links whose chevron reveals the Overview sub-link and whose label click expands only when collapsed; every project is a link on /docs/introduction; omitted projectId renders Hive as an expanded link row.
  • Layout: scroll events are throttled through requestAnimationFrame (two scrolls → one frame) and the frame updates top/height from the navbar's bounding rect; no navbar → defaults untouched.
  • Chrome: mobile close button toggles menuOpen; footer collapse flips to lg:w-16.

changelog.d/added-docs-sidebar-tests.md follows the existing added-related-projects-tests.md pattern.

Validation (main@5fffc7e, Node 26.10)

  • npx vitest run --coverage: 757/757 pass (was 739); all files 78.10 → 79.68% statements, thresholds unchanged.
  • DocsSidebar.tsx: 76.97 → 91.16% statements, 85.71% functions. Remaining uncovered lines 468-516 are renderLegacyGroup, which is defined but never called (LEGACY_PROJECTS is empty) — noted on the issue as a cleanup, not a test gap.
  • npm run lint, npx tsc --noEmit, npx prettier --check on the new file: clean.

Related Issue

Closes #147


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

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

Covers src/components/docs/DocsSidebar.tsx: mount-time findActivePath/
collapseAll state (nested active page, theme.collapsed=false, general
sections, docs guide), getFirstChildRoute recursion and the no-route
toggle button, folder and project link-vs-chevron toggle semantics,
hidden index/_meta/#/Separator items, the requestAnimationFrame scroll
throttle, and mobile close / footer collapse wiring.

DocsSidebar.tsx statements 76.97% -> 91.16%; the only remaining
uncovered region is renderLegacyGroup, which is never called.

Closes #147

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <quality@hive.kubestellar.io>
@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. 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.

@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hivecommons-docs ready!

Name Link
🔨 Latest commit fedbb03
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6abdd46bf571fa0008114f07
😎 Deploy Preview https://deploy-preview-148--hivecommons-docs.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 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks correct to me. Test-only change; I ran it against the component rather than reading alone.

Verified at fedbb03:

  • npx vitest run src/__tests__/DocsSidebar.behavior.test.tsx → 18/18 pass; full suite → 757/757 (matches the body's count). No cross-test interference from the document.body.innerHTML / requestAnimationFrame spies — both are reset in afterEach (vi.restoreAllMocks(), body cleared).
  • Each assertion I traced maps to a real branch in src/components/docs/DocsSidebar.tsx: projectId || 'hive' fallback at :152, proj.id === projectId && !isDocsGuide at :460, toggleMenu on the close button at :532.
  • changelog.d/added-docs-sidebar-tests.md follows the added-<slug>.md fragment convention.

One low-severity note for the maintainer, not a blocker: two tests pin behaviour that is incidental rather than intended —

  • "renders Hive as an expanded link row when projectId is omitted": the only production caller is SidebarContainer.tsx:21, whose prop type (projectId: ProjectId, :17) makes the omitted case unreachable. The test freezes the mount-effect (:152) vs render (:460) disagreement that only shows up with an undefined projectId.
  • "closes the mobile menu from the close button": the button labelled "Close sidebar" calls toggleMenu (DocsSidebar.tsx:532, DocsProvider.tsx:36), so the test asserts it opens the drawer first. That's a pre-existing quirk, harmless in practice because the button sits inside the off-screen aside when closed — but anyone who later fixes it to setMenuOpen(false) will break this test and may read the failure as a regression.

If you'd rather not carry those two, dropping them loses nothing of value; the other 16 are solid. Fine to land as-is otherwise.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] DocsSidebar.tsx: mount-time collapse state, folder/project toggles and scroll throttle untested (77% stmts, 14/42 fns)

0 participants