Skip to content

fix: correct team switch logic - #821

Open
dennisvankekem wants to merge 2 commits into
mainfrom
APL-1868
Open

fix: correct team switch logic#821
dennisvankekem wants to merge 2 commits into
mainfrom
APL-1868

Conversation

@dennisvankekem

Copy link
Copy Markdown
Collaborator

Considerations

  • I have tested the changes in both light and dark mode.
  • I have considered the need for new unit tests.
  • I have tested the changes on a cluster.
  • I have included relevant documentation updates.
  • I have an approved Figma design or have reflected my changes in Figma
  • I have verified that the UI/UX is consistent in major browsers (e.g., Chrome, Firefox, Safari, Edge).
  • I have tested the changes for responsiveness in different screen resolutions.
  • I have tested expected error states and verified that the user is presented with informative error messages.
  • I have tested the feature with unusual or extreme inputs (e.g., very long strings, empty states, clicking a button multiple times quickly).

Copilot AI review requested due to automatic review settings July 28, 2026 09:07

Copilot AI 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.

Pull request overview

This PR corrects the team-switch navigation logic in the Header component so that switching teams reliably lands users on the appropriate team dashboard/section overview, and adds unit tests to validate the updated routing behavior.

Changes:

  • Replace string-replace based team switching with pathname segment parsing to preserve (or intentionally reset to) the correct section when changing teams.
  • Tighten the handleChangeTeam event typing by using MUI’s SelectChangeEvent.
  • Add a new Header.test.tsx suite covering common team-switching routes (dashboard, section overview, nested resource pages, and non-team routes).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/components/Header.tsx Updates getNextPathname logic to compute the correct next route when switching teams.
src/components/Header.test.tsx Adds unit tests validating team switching behavior across several route shapes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/Header.tsx
Comment thread src/components/Header.test.tsx
Comment thread src/components/Header.test.tsx
Copilot AI review requested due to automatic review settings July 29, 2026 13:00

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

src/components/Header.tsx:139

  • getNextPathname breaks for the /teams route (exact route exists) because segments becomes ['teams'] and the function falls through to return /teams/${nextTeamId}/${segments[2]}``, producing /teams/<id>/undefined. Handle the `/teams` case explicitly (and consider adding a regression test for it).
    const segments = pathname.split('/').filter(Boolean)

    // Not on a team route
    if (segments[0] !== 'teams') return `/teams/${nextTeamId}`

src/components/Header.test.tsx:79

  • useLocation is mocked without the required key field (and without a cast), which can cause TypeScript errors depending on the Location type from react-router. Include a key and cast to ReturnType<typeof useLocation> like the other mocked hooks.
  mockedUseLocation.mockReturnValue({
    pathname,
    search: '',
    hash: '',
    state: undefined,

src/components/Header.test.tsx:196

  • document.querySelector(...) can return null, and passing that into fireEvent.change is both a TypeScript error and a potential runtime failure if the selector ever changes. Assert non-null (or use Testing Library queries) before firing the event.
    const hiddenInput = document.querySelector('[data-cy="select-oboteam"] input')

    fireEvent.change(hiddenInput, {
      target: {
        value: 'alpha',

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.

3 participants