test: add behavior tests for DocsSidebar collapse state and navigation - #148
Conversation
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>
|
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 Hive will automatically remove the |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for hivecommons-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
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 thedocument.body.innerHTML/requestAnimationFramespies — both are reset inafterEach(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 && !isDocsGuideat:460,toggleMenuon the close button at:532. changelog.d/added-docs-sidebar-tests.mdfollows theadded-<slug>.mdfragment 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 undefinedprojectId. - "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-screenasidewhen closed — but anyone who later fixes it tosetMenuOpen(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
Test Improvement
Adds
src/__tests__/DocsSidebar.behavior.test.tsx— 18 behavior tests forsrc/components/docs/DocsSidebar.tsx, which previously had only the two smoke cases inDocsChrome.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
theme.collapsed === falsekeeps 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(): skipsMeta/Separator/#children, recurses into nested folders, and a folder with no navigable route renders a plain toggle button instead of a link.index,_meta,#,Separator,Metaand blank-title items are not rendered./docs/introduction; omittedprojectIdrenders Hive as an expanded link row.requestAnimationFrame(two scrolls → one frame) and the frame updatestop/heightfrom the navbar's bounding rect; no navbar → defaults untouched.menuOpen; footer collapse flips tolg:w-16.changelog.d/added-docs-sidebar-tests.mdfollows the existingadded-related-projects-tests.mdpattern.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 arerenderLegacyGroup, which is defined but never called (LEGACY_PROJECTSis empty) — noted on the issue as a cleanup, not a test gap.npm run lint,npx tsc --noEmit,npx prettier --checkon 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