Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switch org #19039

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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