|
| 1 | +import {Organization} from '../../../src/types' |
| 2 | + |
| 3 | +const doSetup = (cy, numAccounts: number) => { |
| 4 | + cy.signin().then(() => { |
| 5 | + cy.get('@org').then(({id}: Organization) => { |
| 6 | + cy.setFeatureFlags({ |
| 7 | + uiUnificationFlag: true, |
| 8 | + multiAccount: true, |
| 9 | + }).then(() => { |
| 10 | + cy.quartzProvision({ |
| 11 | + accountType: 'free', |
| 12 | + numAccounts, |
| 13 | + }).then(() => { |
| 14 | + cy.visit(`/orgs/${id}/accounts/settings`) |
| 15 | + }) |
| 16 | + }) |
| 17 | + }) |
| 18 | + }) |
| 19 | +} |
| 20 | + |
| 21 | +describe('Account Page; user with 3 accounts', () => { |
| 22 | + beforeEach(() => doSetup(cy, 3)) |
| 23 | + |
| 24 | + it('can get to the page and get the accounts, and the switch button is showing', () => { |
| 25 | + cy.getByTestID('account-settings--header').should('be.visible') |
| 26 | + cy.getByTestID('user-account-switch-btn').should('be.visible') |
| 27 | + cy.getByTestID('account-active-name--block').contains('Influx') |
| 28 | + |
| 29 | + cy.getByTestID('user-account-switch-btn').click() |
| 30 | + |
| 31 | + cy.getByTestID('switch-account--dialog').within(() => { |
| 32 | + const prefix = 'accountSwitch-toggle-choice' |
| 33 | + |
| 34 | + cy.getByTestID(`${prefix}-0-ID`).should('be.visible') |
| 35 | + cy.getByTestID(`${prefix}-0-ID`).contains('Influx') |
| 36 | + cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked') |
| 37 | + |
| 38 | + cy.getByTestID(`${prefix}-1-ID`).should('be.visible') |
| 39 | + cy.getByTestID(`${prefix}-1-ID`).contains('Veganomicon (default)') |
| 40 | + |
| 41 | + cy.getByTestID(`${prefix}-2-ID`).should('be.visible') |
| 42 | + cy.getByTestID(`${prefix}-2-ID`).contains('Stradivarius') |
| 43 | + |
| 44 | + // at first; the switch button should be disabled: |
| 45 | + cy.getByTestID('actually-switch-account--btn').should('be.disabled') |
| 46 | + |
| 47 | + // now: select another option: |
| 48 | + cy.getByTestID(`${prefix}-2-ID`).click() |
| 49 | + |
| 50 | + // check that it is selected before checking the button enabled state: |
| 51 | + cy.getByTestID(`${prefix}-2-ID--input`).should('be.checked') |
| 52 | + |
| 53 | + // now; the button should be enabled: |
| 54 | + cy.getByTestID('actually-switch-account--btn').should('be.enabled') |
| 55 | + }) |
| 56 | + }) |
| 57 | +}) |
| 58 | + |
| 59 | +describe('Account Page; user with one account', () => { |
| 60 | + beforeEach(() => cy.flush().then(() => doSetup(cy, 1))) |
| 61 | + |
| 62 | + it('can get to the page and get the accounts, and the switch button is NOT showing', () => { |
| 63 | + cy.getByTestID('account-settings--header').should('be.visible') |
| 64 | + cy.getByTestID('user-account-switch-btn').should('not.exist') |
| 65 | + |
| 66 | + cy.getByTestID('account-active-name--block').contains('Veganomicon') |
| 67 | + }) |
| 68 | +}) |
0 commit comments