diff --git a/cypress/e2e/Users.js b/cypress/e2e/Users.js index 0fbd500f0..0b5ac3b60 100644 --- a/cypress/e2e/Users.js +++ b/cypress/e2e/Users.js @@ -72,8 +72,7 @@ describe('Users tests', () => { }) it("only the mocked user's programmes are visible", () => { - cy.get('[data-cy=nav-bar-button-studyProgramme]').click() - cy.get('[data-cy=nav-bar-button-class]').click() + cy.visit('/populations') cy.contains('label', 'Study programme') .siblings() .within(() => { diff --git a/services/frontend/src/components/material/NavigationBar/NavigationButton.tsx b/services/frontend/src/components/material/NavigationBar/NavigationButton.tsx index 7aaa67ef2..df1dad04b 100644 --- a/services/frontend/src/components/material/NavigationBar/NavigationButton.tsx +++ b/services/frontend/src/components/material/NavigationBar/NavigationButton.tsx @@ -14,7 +14,7 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => { const location = useLocation() const [anchorEl, setAnchorEl] = useState(null) - const { key, label, items } = item + const { label, items } = item const showItem = (subItemKey: string) => { if (['class', 'completedCoursesSearch', 'overview'].includes(subItemKey)) { @@ -64,7 +64,6 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => { <> setAnchorEl(event.currentTarget)} sx={{ display: 'flex' }} variant="button" @@ -77,10 +76,9 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => { showItem(subItem.key) && ( setAnchorEl(null)} - selected={location.pathname.includes(subItem.path)} + selected={location.pathname?.includes(subItem.path)} to={subItem.path} > {subItem.label} @@ -93,7 +91,7 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => { } return ( - + {label} ) diff --git a/services/frontend/src/components/material/NavigationBar/index.tsx b/services/frontend/src/components/material/NavigationBar/index.tsx index 8454245a7..b379f29d4 100644 --- a/services/frontend/src/components/material/NavigationBar/index.tsx +++ b/services/frontend/src/components/material/NavigationBar/index.tsx @@ -89,15 +89,16 @@ export const NavigationBar = () => { }} > - {!isLoading && ( + {!isLoading && location && ( {Object.entries(visibleNavigationItems).map(([key, item]) => ( } sx={{ '&:hover': { color: 'inherit' } }} - to={item.path} + to={item.path ?? ''} /> ))}