Skip to content

test(layout): pin the "New" badge on a sidebar submenu's parent - #1674

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:test/sidebar-submenu-badge
Oct 28, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:test/sidebar-submenu-badge

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Follow-up from #1603: a test pins the "New" badge on a sidebar submenu's parent.

No test covered the badge on a submenu parent (the expandable item's button in sidebar.tsx); reverting it left every test passing.

  • A render test of the expanded sidebar finds "New" inside a submenu parent's button and inside a plain item.
  • The sidebar's heavy parts (brand switcher, profile, theme toggle, tracked-prompt count) are stubbed. The sidebar opens collapsed, so the test expands it through its store.
  • Review fix (127c499): the test mocks @/config/dashboard with its own menu, a plain item and a submenu parent, both badged. It doesn't depend on which product items are marked "New" today.

Checked both ways:

  • removing the badges from the real menu leaves the test passing;
  • removing the parent's badge from sidebar.tsx fails it.

Test only, no behaviour change.

Related issue

Follow-up from #1603's review.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

cd web && npx vitest run src/components/layout/sidebar.test.tsx

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Full checks were run in one tree with this batch's ten follow-up branches merged, and again after the review fixes:

  • server format, lint and npm test: 246 files, 3,343 tests passed;
  • web format, lint (0 errors; 7 warnings already on main), typecheck and build: all pass;
  • web vitest: 447 files, 4,352 tests passed (after the review fixes).

A pre-push review was run on all ten branches.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 28, 2026 05:41
Follow-up from ansvisor#1603. No test covered the badge on a submenu parent
(sidebar.tsx, the expandable item's button): reverting it left every test
passing. A render test of the expanded sidebar now finds "New" inside the
Content button (data-submenu="/dashboard/content"), and a plain item's
(Action Center) too. Removing the parent's badge fails it.

The sidebar's heavy parts (brand switcher, profile, theme toggle, the
tracked-prompt count) are stubbed; it opens collapsed, so the test
expands it through its store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-up. The test read the real dashboardNav, so it leaned on
Action Center and Content being marked "New" today: dropping either badge
from the product would fail it for no fault of the sidebar. It now mocks
@/config/dashboard with a plain item and a submenu parent, both badged.
Removing the badge from the real menu leaves it passing; removing the
parent's badge from sidebar.tsx still fails it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk 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.

Looks good.

What I checked:

  • Own change. Two commits (121880c, 127c499) on 3f6a4d4, test only. It merges cleanly on main (b591947) and with #1670, #1671 and #1675.
  • The mocks. @/config/dashboard is replaced by a menu of its own, and the sidebar only imports dashboardNav from it. The other mocked modules are the ones the sidebar reaches that need a session, a store or the network. So the test pins how a badge is drawn, not which items are marked new today.
  • Tests.
    • sidebar.test.tsx passes at the head, and so do the other four files in components/layout (18 tests).
    • With the badge taken out of the submenu parent's button in sidebar.tsx, the test fails.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants