diff --git a/ui/cypress/e2e/orgs.test.ts b/ui/cypress/e2e/orgs.test.ts index f114132c047..3a682de448d 100644 --- a/ui/cypress/e2e/orgs.test.ts +++ b/ui/cypress/e2e/orgs.test.ts @@ -1,3 +1,4 @@ +const secondOrg = 'Second Org' describe('Orgs', () => { beforeEach(() => { cy.flush() @@ -19,14 +20,15 @@ describe('Orgs', () => { }) }) - describe('when user wants to rename an org', () => { + describe('updating and switching orgs', () => { beforeEach(() => { cy.signin().then(() => { + cy.createOrg(secondOrg) cy.visit('/') }) }) - it('should be able to rename the org', () => { + it('should be able to rename the org and switch to another org', () => { const extraText = '_my_renamed_org_in_e2e' cy.getByTestID('user-nav').click() cy.getByTestID('user-nav-item-about').click() @@ -40,6 +42,19 @@ describe('Orgs', () => { cy.get('.cf-tree-nav--team') .contains(extraText) .should('have.length', 1) + + // Switch Orgs + cy.getByTestID('user-nav').click() + cy.getByTestID('user-nav-item-switch-orgs').click() + cy.getByTestID('overlay--body').within(() => { + cy.contains(secondOrg).click() + }) + + cy.getByTestID('user-nav') + .click() + .contains(secondOrg) + cy.getByTestID('page').should('exist') + cy.getByTestID('page-header').should('exist') }) }) }) diff --git a/ui/cypress/support/commands.ts b/ui/cypress/support/commands.ts index ff50f8ba0ab..53596ab1fcf 100644 --- a/ui/cypress/support/commands.ts +++ b/ui/cypress/support/commands.ts @@ -114,12 +114,14 @@ export const createDashboardTemplate = ( }) } -export const createOrg = (): Cypress.Chainable => { +export const createOrg = ( + name = 'test org' +): Cypress.Chainable => { return cy.request({ method: 'POST', url: '/api/v2/orgs', body: { - name: 'test org', + name, }, }) } diff --git a/ui/src/pageLayout/components/OrgSwitcherItem.tsx b/ui/src/pageLayout/components/OrgSwitcherItem.tsx index c7595db3f4f..141b4fdf465 100644 --- a/ui/src/pageLayout/components/OrgSwitcherItem.tsx +++ b/ui/src/pageLayout/components/OrgSwitcherItem.tsx @@ -30,7 +30,7 @@ const OrgSwitcherItem: FC = ({ const handleClick = (): void => { onDismiss() - history.push(`orgs/${orgID}`) + history.push(`/orgs/${orgID}`) } const currentOrgIndicator = selected ? Current : null