Skip to content

Commit

Permalink
fix: switch org (#19039)
Browse files Browse the repository at this point in the history
* fix: switching orgs

* chore: test name
  • Loading branch information
121watts authored Jul 23, 2020
1 parent 8b106bc commit b9a3abd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
19 changes: 17 additions & 2 deletions ui/cypress/e2e/orgs.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const secondOrg = 'Second Org'
describe('Orgs', () => {
beforeEach(() => {
cy.flush()
Expand All @@ -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()
Expand All @@ -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')
})
})
})
6 changes: 4 additions & 2 deletions ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ export const createDashboardTemplate = (
})
}

export const createOrg = (): Cypress.Chainable<Cypress.Response> => {
export const createOrg = (
name = 'test org'
): Cypress.Chainable<Cypress.Response> => {
return cy.request({
method: 'POST',
url: '/api/v2/orgs',
body: {
name: 'test org',
name,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pageLayout/components/OrgSwitcherItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const OrgSwitcherItem: FC<Props> = ({

const handleClick = (): void => {
onDismiss()
history.push(`orgs/${orgID}`)
history.push(`/orgs/${orgID}`)
}

const currentOrgIndicator = selected ? <em>Current</em> : null
Expand Down

0 comments on commit b9a3abd

Please sign in to comment.