Skip to content

Commit

Permalink
test(sidebar): group new nav tests
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Sep 10, 2024
1 parent b27f993 commit 8553647
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions static/app/components/sidebar/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ describe('Sidebar', function () {
await userEvent.click(screen.getByTestId('sidebar-dropdown'));
});

it('does not render collapse with navigation-sidebar-v2 flag', async function () {
renderSidebar({
organization: {...organization, features: ['navigation-sidebar-v2']},
});

// await for the page to be rendered
expect(await screen.findByText('Issues')).toBeInTheDocument();
// Check that the user name is no longer visible
expect(screen.queryByText(user.name)).not.toBeInTheDocument();
// Check that the organization name is no longer visible
expect(screen.queryByText(organization.name)).not.toBeInTheDocument();
expect(screen.queryByTestId('sidebar-collapse')).not.toBeInTheDocument();
});

it('has can logout', async function () {
renderSidebar({
organization: OrganizationFixture({access: ['member:read']}),
Expand Down Expand Up @@ -323,7 +309,7 @@ describe('Sidebar', function () {
expect(apiMocks.broadcasts).toHaveBeenCalled();
});

expect(screen.getByTitle('Primary Navigation')).toBeInTheDocument();
expect(screen.getByLabelText('Primary Navigation')).toBeInTheDocument();
});

it('in self-hosted-errors-only mode, only shows links to basic features', async function () {
Expand Down Expand Up @@ -434,4 +420,39 @@ describe('Sidebar', function () {
expect(await screen.findByTestId('floating-accordion')).toBeInTheDocument();
});
});

describe('Stacked navigation with navigation-sidebar-v2 flag', () => {
it('renders secondary subnav for issues', async function () {
renderSidebar({
organization: {...organization, features: ['navigation-sidebar-v2']},
});

expect(await screen.findByText('Issues')).toBeInTheDocument();
expect(await screen.findByLabelText('Secondary Navigation')).toBeInTheDocument();
});

it('does not render secondary subnav for projects', async function () {
renderSidebar({
organization: {...organization, features: ['navigation-sidebar-v2']},
});
mockUseLocation.mockReturnValue({...LocationFixture(), pathname: '/projects'});

expect(
await screen.findByLabelText('Secondary Navigation')
).not.toBeInTheDocument();
});

it('does not render collapse with navigation-sidebar-v2 flag', async function () {
renderSidebar({
organization: {...organization, features: ['navigation-sidebar-v2']},
});

expect(await screen.findByText('Issues')).toBeInTheDocument();
// Check that the user name is no longer visible
expect(screen.queryByText(user.name)).not.toBeInTheDocument();
// Check that the organization name is no longer visible
expect(screen.queryByText(organization.name)).not.toBeInTheDocument();
expect(screen.queryByTestId('sidebar-collapse')).not.toBeInTheDocument();
});
});
});

0 comments on commit 8553647

Please sign in to comment.