diff --git a/packages/app/cypress/e2e/sidebar_navigation.cy.ts b/packages/app/cypress/e2e/sidebar_navigation.cy.ts index d4b336202107..2cfc8c6d4b36 100644 --- a/packages/app/cypress/e2e/sidebar_navigation.cy.ts +++ b/packages/app/cypress/e2e/sidebar_navigation.cy.ts @@ -1,5 +1,3 @@ -import type { Interception } from '@packages/net-stubbing/lib/external-types' - describe('Sidebar Navigation', () => { context('as e2e testing type', () => { beforeEach(() => { @@ -75,10 +73,6 @@ describe('Sidebar Navigation', () => { cy.percySnapshot() cy.get('[data-cy="sidebar-header"]').trigger('mouseout') - cy.get('[data-cy="switch-testing-type"]').realHover() - cy.contains('#tooltip-target > div', 'E2E Testing') - cy.get('[data-cy="switch-testing-type"]').trigger('mouseout') - cy.get('[data-e2e-href="/runs"]').realHover() cy.contains('#tooltip-target > div', 'Runs') cy.get('[data-e2e-href="/runs"]').trigger('mouseout') @@ -107,26 +101,42 @@ describe('Sidebar Navigation', () => { cy.findAllByText('todos').eq(1).should('be.visible') }) - it('displays the project name (expanded state)', () => { + it('displays the project name and opens a modal to switch testing type', () => { cy.findByLabelText('Sidebar').closest('[aria-expanded]').should('have.attr', 'aria-expanded', 'true') - cy.findAllByText('todos').eq(1).should('be.visible') - }) - - it('has menu item labeled by current active testing type that opens a modal to switch testing type (expanded state)', () => { - cy.findByLabelText('Sidebar').closest('[aria-expanded]').should('have.attr', 'aria-expanded', 'true') + cy.get('[data-cy="sidebar-header"]').within(() => { + cy.get('[data-cy="testing-type-e2e"]').should('be.visible') + cy.findByText('todos').should('be.visible') + }).click() - cy.findByText('E2E Testing').should('be.visible') - cy.get('[data-cy="switch-testing-type"]').click() cy.findByText('Choose a testing type').should('be.visible') + + cy.get('[data-cy-testingtype=e2e]').within(() => { + cy.contains('Configured') + }) + cy.intercept('mutation-SwitchTestingType_ReconfigureProject').as('SwitchTestingType') - cy.get('[data-cy-testingtype="component"]').click() - cy.wait('@SwitchTestingType').then((interception: Interception) => { - expect(interception.request.url).to.include('graphql/mutation-SwitchTestingType_ReconfigureProject') + cy.withCtx((ctx) => { + ctx.actions.project.reconfigureProject = sinon.stub() + }) + + cy.get('[data-cy-testingtype="component"]').within(() => { + cy.contains('Not Configured') + }).click() + + cy.wait('@SwitchTestingType').then((interception) => { + expect(interception.request.body.variables.testingType).eq('component') }) cy.get('[aria-label="Close"]').click() cy.findByText('Choose a testing type').should('not.exist') + + cy.findByLabelText('toggle navigation', { + selector: 'button', + }).click() + + cy.get('[data-cy="sidebar-header"]').click() + cy.findByText('Choose a testing type').should('be.visible') }) it('has unlabeled menu item that shows the keyboard shortcuts modal (expanded state)', () => { @@ -175,20 +185,6 @@ describe('Sidebar Navigation', () => { cy.get('[data-cy="app-header-bar"]').findByText('Settings').should('be.visible') cy.get('.router-link-active').findByText('Settings').should('be.visible') }) - - it('shows if testing type is configured when clicking switch testing type', () => { - cy.openProject('pristine-with-e2e-testing') - - cy.findByText('E2E Testing').should('be.visible') - cy.get('[data-cy="switch-testing-type"]').click() - cy.get('[data-cy-testingtype=e2e]').within(() => { - cy.contains('Configured') - }) - - cy.get('[data-cy-testingtype=component]').within(() => { - cy.contains('Not Configured') - }) - }) }) context('as component testing type', () => { @@ -198,15 +194,23 @@ describe('Sidebar Navigation', () => { cy.startAppServer('component') cy.visitApp() - cy.findByText('Component Testing').should('be.visible') - cy.get('[data-cy="switch-testing-type"]').click() - cy.get('[data-cy-testingtype=e2e]').within(() => { - cy.contains('Not Configured') - }) - + cy.get('[data-cy="sidebar-header"]').within(() => cy.get('[data-cy="testing-type-component"]')).click() cy.get('[data-cy-testingtype=component]').within(() => { cy.contains('Configured') }) + + cy.intercept('mutation-SwitchTestingType_ReconfigureProject').as('SwitchTestingType') + cy.withCtx((ctx) => { + ctx.actions.project.reconfigureProject = sinon.stub() + }) + + cy.get('[data-cy-testingtype="e2e"]').within(() => { + cy.contains('Not Configured') + }).click() + + cy.wait('@SwitchTestingType').then((interception) => { + expect(interception.request.body.variables.testingType).eq('e2e') + }) }) }) }) diff --git a/packages/app/src/navigation/SidebarNavigation.cy.tsx b/packages/app/src/navigation/SidebarNavigation.cy.tsx index 2c24e3f9e25e..17978dae1ec9 100644 --- a/packages/app/src/navigation/SidebarNavigation.cy.tsx +++ b/packages/app/src/navigation/SidebarNavigation.cy.tsx @@ -41,10 +41,6 @@ describe('SidebarNavigation', () => { cy.contains('#tooltip-target > div', 'test-project').should('be.visible') cy.get('[data-cy="sidebar-header"]').trigger('mouseout') - cy.get('[data-cy="switch-testing-type"]').realHover() - cy.contains('#tooltip-target > div', 'E2E Testing').should('be.visible') - cy.get('[data-cy="switch-testing-type"]').trigger('mouseout') - cy.get('[data-e2e-href="/runs"]').realHover() cy.contains('#tooltip-target > div', 'Runs').should('be.visible') cy.get('[data-e2e-href="/runs"]').trigger('mouseout') @@ -52,6 +48,6 @@ describe('SidebarNavigation', () => { it('opens a modal to switch testing type', { viewportWidth: 1280 }, () => { mountComponent() - cy.get('[data-cy="switch-testing-type"]').click() + cy.get('[data-cy="sidebar-header"]').click() }) }) diff --git a/packages/app/src/navigation/SidebarNavigation.vue b/packages/app/src/navigation/SidebarNavigation.vue index 3a4747febc81..7fd304613ebf 100644 --- a/packages/app/src/navigation/SidebarNavigation.vue +++ b/packages/app/src/navigation/SidebarNavigation.vue @@ -20,45 +20,14 @@
- {{ currentProject?.branch }} -
-- {{ currentProject?.branch }} -
-