From 4e77176494d22c85b69a14beb8b840aea9140e64 Mon Sep 17 00:00:00 2001 From: AKSHAT BHARDWAJ Date: Fri, 14 Aug 2026 23:02:51 +0530 Subject: [PATCH] fix(navbar): point home button to root route The Navbar Home button (the FCC logo link) was hard-coded to /classes, which is a teacher-only route. As a result, admins, students, and unauthenticated users were redirected to the error page when they clicked the site logo. This change makes the Home button point to /, the application's actual home page (pages/index.js), regardless of role or auth state, and brings it in line with the other "Menu" links in the codebase. Fixes #558 --- .../__snapshots__/error.test.jsx.snap | 2 +- .../__snapshots__/navbar.test.jsx.snap | 2 +- __tests__/components/navbar.test.jsx | 42 +++++++++++++++++++ components/navbar.js | 2 +- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/__tests__/components/__snapshots__/error.test.jsx.snap b/__tests__/components/__snapshots__/error.test.jsx.snap index e804bff57..ff4eb1b04 100644 --- a/__tests__/components/__snapshots__/error.test.jsx.snap +++ b/__tests__/components/__snapshots__/error.test.jsx.snap @@ -13,7 +13,7 @@ exports[`ErrorComponet displays error cause and error message properly 1`] = ` /> { @@ -15,3 +17,43 @@ describe('Navbar rendering correctly', () => { expect(tree).toMatchSnapshot(); }); }); + +describe('Navbar Home button', () => { + const findHomeLink = () => screen.getByRole('link', { name: /freecodecamp logo/i }); + + it('points to the application home page when logged in as a teacher', () => { + render( + + + + ); + expect(findHomeLink()).toHaveAttribute('href', '/'); + }); + + it('points to the application home page when logged in as an admin', () => { + render( + + + + ); + expect(findHomeLink()).toHaveAttribute('href', '/'); + }); + + it('points to the application home page when logged in as another role', () => { + render( + + + + ); + expect(findHomeLink()).toHaveAttribute('href', '/'); + }); + + it('points to the application home page when not logged in', () => { + render( + + + + ); + expect(findHomeLink()).toHaveAttribute('href', '/'); + }); +}); diff --git a/components/navbar.js b/components/navbar.js index fc24c5080..1f4c3664b 100644 --- a/components/navbar.js +++ b/components/navbar.js @@ -8,7 +8,7 @@ export default function Navbar({ children, hideAuthButton = false }) {
- +