Skip to content

test: cover language-switcher branches in useNavDropdowns - #266

Merged
hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-nav-lang-switcher-branches
Oct 7, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
mainfrom
quality/test-nav-lang-switcher-branches

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

src/components/navbar/useNavDropdowns.ts had 14 uncovered lines, all in the language-switcher integration (.language-switcher-container hover handling and the MutationObserver that wires the portal-rendered [role="listbox"]). These paths drive real UI state (isDropdownOpen) and the switcher's open/close clicks, so a regression there would silently break hover-to-open on the navbar.

This PR adds 11 behaviour tests to src/__tests__/useNavDropdowns.test.tsx covering:

  • cancelling a pending nav-dropdown hide timer when the switcher is hovered (and verifying the cleared timer never fires)
  • hovering while the listbox is already visible (no extra click; hover state still tracked for the later leave)
  • leaving when the listbox never appeared (state cleared after the 300 ms delay, no click)
  • close-lang-switcher while hovered but no listbox visible (state cleared, no click), and when neither hovered nor visible (no-op)
  • MutationObserver wiring of the listbox's own mouseenter (cancels close) / mouseleave (schedules close), for both a directly-added listbox and one nested inside an added subtree
  • listbox removed while hovered → isDropdownOpen drops to false; removal of unrelated nodes is ignored
  • observer disconnected on unmount

Coverage (npx vitest run --coverage, coverage/lcov.info, HEAD 5d49f94)

useNavDropdowns.ts before after
lines 142/156 (91.0%) 156/156 (100%)
functions 27/29 (93.1%) 29/29 (100%)
branches 73.9% 59/69 (85.5%)

No production code changed. Test-only, so no changelog.d fragment per changelog.d/README.md. npm run lint, prettier --check, and tsc --noEmit pass on the test file.

Evidence note: this repository has only the vitest unit suite (no end-to-end suite is configured), so the gap above was covered by no automated test before this PR.


Filed by quality agent (ACMM L4/L6 — full mode)

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

Adds 11 behavior tests for the language-switcher integration in
useNavDropdowns: cancelling a pending nav-dropdown hide on switcher hover,
hovering while the listbox is already visible, leaving without a listbox,
close-lang-switcher without a visible listbox, listbox mouseenter/mouseleave
wiring via MutationObserver (direct and nested added nodes), listbox removal
while hovered, unrelated-node removal, and observer teardown on unmount.

useNavDropdowns.ts: 91.0% -> 100% lines, 93.1% -> 100% functions,
73.9% -> 85.5% branches.

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

Copy link
Copy Markdown

✅ Deploy Preview for hivecommons-docs ready!

Name Link
🔨 Latest commit 765b172
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6ac699a8cf5ff000080bc73a
😎 Deploy Preview https://deploy-preview-266--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 added quality Created by Hive for agent-filed issue provenance testing Created by Hive for agent-filed issue provenance labels Oct 7, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit f0b8c54 into main Oct 7, 2026
10 of 11 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the quality/test-nav-lang-switcher-branches branch October 7, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes quality Created by Hive for agent-filed issue provenance size/L testing Created by Hive for agent-filed issue provenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants