Skip to content

test(layout): add sidebar/topbar tests and remove misnamed middleware.tsx - #1376

Merged
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
dzekojohn4:feat/issue-1303-sidebar-topbar-tests
Aug 26, 2026
Merged

test(layout): add sidebar/topbar tests and remove misnamed middleware.tsx#1376
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
dzekojohn4:feat/issue-1303-sidebar-topbar-tests

Conversation

@dzekojohn4

@dzekojohn4 dzekojohn4 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

Closes #1303
Closes #1300
Closes #1301
Closes #1302

Adds unit tests for the Sidebar and Topbar layout components (12 tests total) and deletes the unused frontend/components/middleware.tsx file — a misnamed duplicate of the real Sidebar that confused file search results.

Why

sidebar.tsx and topbar.tsx implement the app's primary navigation chrome with no test coverage. The Sidebar component's active-route highlighting and logout flow are critical UX behaviors that should be verified. Separately, frontend/components/middleware.tsx exported a Sidebar component but was never imported anywhere — it is a stale duplicate of layout/sidebar.tsx. Its filename reads as Next.js route-protection middleware but contains none; the real middleware is frontend/middleware.ts at the project root. This caused confusion when searching for "middleware" in the codebase.

What was built

frontend/components/layout/sidebar.test.tsx:

Test What it covers
Navigation items All 11 nav items render with correct labels
Active highlighting aria-current="page" set on active route link
Logout Calls useAuthStore.logout() and router.push("/login")
Settings/Notifications Bottom links render correctly
Logo text "AssetsUp" brand text renders

frontend/components/layout/topbar.test.tsx:

Test What it covers
Page title Correct title based on pathname
User initials First+last initial rendered
User name/role Full name and role displayed
Dropdown toggle Opens/closes user menu
Logout Calls logout() and redirects to /login
Wallet button WalletButton component renders
Hamburger onMenuClick callback fires on click

Deleted files:

  • frontend/components/middleware.tsx — unused duplicate of layout/sidebar.tsx; not imported by any file in the project

Integration changes outside layout/

  • frontend/components/middleware.tsx — deleted. Not imported by any file; the real Sidebar is at layout/sidebar.tsx (imported by app/(dashboard)/layout.tsx), and the real Next.js middleware is frontend/middleware.ts.

Acceptance criteria coverage

  • Navigation highlighting and logout both have test coverage (sidebar.test.tsx — 5 tests covering aria-current, logout + redirect)
  • No file named middleware.tsx exists outside the real Next.js frontend/middleware.ts (deleted)

Test plan

  • npm test in frontend/ — 12/12 passing (all new tests for this feature)

Env vars / Notes

No new environment variables. Tests mock next/navigation, @/store/auth.store, @/components/wallet/wallet-button, and @/lib/theme-provider using jest.mock().

….tsx

- Add sidebar.test.tsx: navigation rendering, active-route highlighting,
  logout button, Settings/Notifications links, logo text (5 tests)
- Add topbar.test.tsx: page title, user initials/name/role, dropdown
  toggle, logout redirect, wallet button, hamburger menu click (7 tests)
- Delete frontend/components/middleware.tsx: unused duplicate Sidebar
  component; the real Sidebar lives in layout/sidebar.tsx and the real
  Next.js middleware is at frontend/middleware.ts

Closes DistinctCodes#1303
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@dzekojohn4 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@dzekojohn4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@yusuftomilola yusuftomilola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No merge conflicts with main. Sidebar/topbar tests plus removing the misnamed middleware.tsx is a good cleanup - approving.

@yusuftomilola
yusuftomilola merged commit 57f880c into DistinctCodes:main Aug 26, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants