Skip to content

Commit c72867a

Browse files
authored
fix: move userAccount tests into a single root describe and flush during setup (#3980)
1 parent b2d113a commit c72867a

File tree

1 file changed

+118
-108
lines changed

1 file changed

+118
-108
lines changed
Lines changed: 118 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,171 @@
11
import {Organization} from '../../../src/types'
22

33
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,
4+
cy.flush().then(() => {
5+
cy.signin().then(() => {
6+
cy.get('@org').then(({id}: Organization) => {
7+
cy.setFeatureFlags({
8+
uiUnificationFlag: true,
9+
multiAccount: true,
1310
}).then(() => {
14-
cy.visit(`/orgs/${id}/accounts/settings`)
11+
cy.quartzProvision({
12+
accountType: 'free',
13+
numAccounts,
14+
}).then(() => {
15+
cy.visit(`/orgs/${id}/accounts/settings`)
16+
})
1517
})
1618
})
1719
})
1820
})
1921
}
2022

21-
describe('Account Page; user with 4 accounts', () => {
22-
beforeEach(() => doSetup(cy, 4))
23+
describe('Account Page tests', () => {
24+
describe('User with 4 accounts', () => {
25+
beforeEach(() => doSetup(cy, 4))
2326

24-
it('can change the default account, and then see that it changed on the switch dialog; also checks that the switch button is enabled and disabled correctly', () => {
25-
cy.getByTestID('account-settings--header').should('be.visible')
26-
cy.getByTestID('user-account-switch-btn').should('be.visible')
27-
cy.getByTestID('input--active-account-name').should('have.value', 'Influx')
27+
it('can change the default account, and then see that it changed on the switch dialog; also checks that the switch button is enabled and disabled correctly', () => {
28+
cy.getByTestID('account-settings--header').should('be.visible')
29+
cy.getByTestID('user-account-switch-btn').should('be.visible')
30+
cy.getByTestID('input--active-account-name').should(
31+
'have.value',
32+
'Influx'
33+
)
2834

29-
cy.getByTestID('user-account-switch-btn').click()
35+
cy.getByTestID('user-account-switch-btn').click()
3036

31-
const prefix = 'accountSwitch-toggle-choice'
37+
const prefix = 'accountSwitch-toggle-choice'
3238

33-
cy.getByTestID('switch-account--dialog').within(() => {
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')
39+
cy.getByTestID('switch-account--dialog').within(() => {
40+
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
41+
cy.getByTestID(`${prefix}-0-ID`).contains('Influx')
42+
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
3743

38-
cy.getByTestID(`${prefix}-1-ID`).should('be.visible')
39-
cy.getByTestID(`${prefix}-1-ID`).contains('Veganomicon (default)')
44+
cy.getByTestID(`${prefix}-1-ID`).should('be.visible')
45+
cy.getByTestID(`${prefix}-1-ID`).contains('Veganomicon (default)')
4046

41-
cy.getByTestID(`${prefix}-2-ID`).should('be.visible')
42-
cy.getByTestID(`${prefix}-2-ID`).contains('Stradivarius')
47+
cy.getByTestID(`${prefix}-2-ID`).should('be.visible')
48+
cy.getByTestID(`${prefix}-2-ID`).contains('Stradivarius')
4349

44-
cy.getByTestID(`${prefix}-3-ID`).should('be.visible')
45-
cy.getByTestID(`${prefix}-3-ID`).contains('Yamaha')
50+
cy.getByTestID(`${prefix}-3-ID`).should('be.visible')
51+
cy.getByTestID(`${prefix}-3-ID`).contains('Yamaha')
4652

47-
// at first; the switch button should be disabled:
48-
cy.getByTestID('actually-switch-account--btn').should('be.disabled')
53+
// at first; the switch button should be disabled:
54+
cy.getByTestID('actually-switch-account--btn').should('be.disabled')
4955

50-
// the set default button should be *enabled*
51-
cy.getByTestID('switch-default-account--btn').should('be.enabled')
56+
// the set default button should be *enabled*
57+
cy.getByTestID('switch-default-account--btn').should('be.enabled')
5258

53-
// now: select another option:
54-
cy.getByTestID(`${prefix}-1-ID`).click()
59+
// now: select another option:
60+
cy.getByTestID(`${prefix}-1-ID`).click()
5561

56-
// check that it is selected before checking the button enabled state:
57-
cy.getByTestID(`${prefix}-1-ID--input`).should('be.checked')
62+
// check that it is selected before checking the button enabled state:
63+
cy.getByTestID(`${prefix}-1-ID--input`).should('be.checked')
5864

59-
// now; the button should be enabled:
60-
cy.getByTestID('actually-switch-account--btn').should('be.enabled')
65+
// now; the button should be enabled:
66+
cy.getByTestID('actually-switch-account--btn').should('be.enabled')
6167

62-
// and the default button should be *disabled* b/c just chose the default acct:
63-
cy.getByTestID('switch-default-account--btn').should('be.disabled')
68+
// and the default button should be *disabled* b/c just chose the default acct:
69+
cy.getByTestID('switch-default-account--btn').should('be.disabled')
6470

65-
// ok; now pick the third option:
66-
cy.getByTestID(`${prefix}-2-ID`).click()
71+
// ok; now pick the third option:
72+
cy.getByTestID(`${prefix}-2-ID`).click()
6773

68-
// check that it is selected before going to the next step:
69-
cy.getByTestID(`${prefix}-2-ID--input`).should('be.checked')
70-
cy.getByTestID('switch-default-account--btn').should('be.enabled')
74+
// check that it is selected before going to the next step:
75+
cy.getByTestID(`${prefix}-2-ID--input`).should('be.checked')
76+
cy.getByTestID('switch-default-account--btn').should('be.enabled')
7177

72-
cy.getByTestID('switch-default-account--btn').click()
73-
})
74-
// test that the notification is up:
75-
cy.getByTestID('notification-success').should('be.visible')
78+
cy.getByTestID('switch-default-account--btn').click()
79+
})
80+
// test that the notification is up:
81+
cy.getByTestID('notification-success').should('be.visible')
7682

77-
// now; bring up the dialog again, the default one should be changed:
78-
cy.getByTestID('user-account-switch-btn').click()
83+
// now; bring up the dialog again, the default one should be changed:
84+
cy.getByTestID('user-account-switch-btn').click()
7985

80-
cy.getByTestID('switch-account--dialog').within(() => {
81-
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
82-
cy.getByTestID(`${prefix}-0-ID`).contains('Influx')
83-
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
86+
cy.getByTestID('switch-account--dialog').within(() => {
87+
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
88+
cy.getByTestID(`${prefix}-0-ID`).contains('Influx')
89+
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
8490

85-
cy.getByTestID(`${prefix}-1-ID`).should('be.visible')
86-
cy.getByTestID(`${prefix}-1-ID`).contains('Veganomicon')
91+
cy.getByTestID(`${prefix}-1-ID`).should('be.visible')
92+
cy.getByTestID(`${prefix}-1-ID`).contains('Veganomicon')
8793

88-
cy.getByTestID(`${prefix}-2-ID`).should('be.visible')
89-
cy.getByTestID(`${prefix}-2-ID`).contains('Stradivarius (default)')
94+
cy.getByTestID(`${prefix}-2-ID`).should('be.visible')
95+
cy.getByTestID(`${prefix}-2-ID`).contains('Stradivarius (default)')
96+
})
9097
})
9198
})
92-
})
9399

94-
describe('Account Page; user with one account', () => {
95-
beforeEach(() => cy.flush().then(() => doSetup(cy, 1)))
100+
describe('User with one account', () => {
101+
beforeEach(() => doSetup(cy, 1))
96102

97-
it('can get to the page and get the accounts, and the switch button is NOT showing', () => {
98-
cy.getByTestID('account-settings--header').should('be.visible')
99-
cy.getByTestID('user-account-switch-btn').should('not.exist')
103+
it('can get to the page and get the accounts, and the switch button is NOT showing', () => {
104+
cy.getByTestID('account-settings--header').should('be.visible')
105+
cy.getByTestID('user-account-switch-btn').should('not.exist')
100106

101-
cy.getByTestID('input--active-account-name').should(
102-
'have.value',
103-
'Veganomicon'
104-
)
107+
cy.getByTestID('input--active-account-name').should(
108+
'have.value',
109+
'Veganomicon'
110+
)
111+
})
105112
})
106-
})
107113

108-
describe('Account Page; user with two accounts', () => {
109-
beforeEach(() => cy.flush().then(() => doSetup(cy, 2)))
114+
describe('User with two accounts', () => {
115+
beforeEach(() => doSetup(cy, 2))
110116

111-
it('can get to the account page and rename the active account', () => {
112-
cy.getByTestID('account-settings--header').should('be.visible')
117+
it('can get to the account page and rename the active account', () => {
118+
cy.getByTestID('account-settings--header').should('be.visible')
113119

114-
cy.getByTestID('input--active-account-name').should('have.value', 'Influx')
120+
cy.getByTestID('input--active-account-name').should(
121+
'have.value',
122+
'Influx'
123+
)
115124

116-
cy.getByTestID('input--active-account-name').clear()
117-
cy.getByTestID('input--active-account-name').should('have.value', '')
125+
cy.getByTestID('input--active-account-name').clear()
126+
cy.getByTestID('input--active-account-name').should('have.value', '')
118127

119-
// what can I say? i am a fan
120-
const newName = 'Bruno-no-no-no'
121-
cy.getByTestID('input--active-account-name').type(newName)
122-
cy.getByTestID('rename-account--button').click()
128+
// what can I say? i am a fan
129+
const newName = 'Bruno-no-no-no'
130+
cy.getByTestID('input--active-account-name').type(newName)
131+
cy.getByTestID('rename-account--button').click()
123132

124-
// test that the notification is up:
125-
cy.getByTestID('notification-success').should('be.visible')
133+
// test that the notification is up:
134+
cy.getByTestID('notification-success').should('be.visible')
126135

127-
// now; bring up the dialog, the active name should be changed:
128-
cy.getByTestID('user-account-switch-btn').click()
136+
// now; bring up the dialog, the active name should be changed:
137+
cy.getByTestID('user-account-switch-btn').click()
129138

130-
const prefix = 'accountSwitch-toggle-choice'
139+
const prefix = 'accountSwitch-toggle-choice'
131140

132-
cy.getByTestID('switch-account--dialog').within(() => {
133-
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
134-
cy.getByTestID(`${prefix}-0-ID`).contains(newName)
135-
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
136-
cy.getByTestID('multi-account-switch-cancel').click()
137-
})
141+
cy.getByTestID('switch-account--dialog').within(() => {
142+
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
143+
cy.getByTestID(`${prefix}-0-ID`).contains(newName)
144+
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
145+
cy.getByTestID('multi-account-switch-cancel').click()
146+
})
138147

139-
// circle-ci and e2e tests got unstable, so best to put all the toys back
140-
// (reset the name)
141-
cy.getByTestID('account-settings--header').should('be.visible')
148+
// circle-ci and e2e tests got unstable, so best to put all the toys back
149+
// (reset the name)
150+
cy.getByTestID('account-settings--header').should('be.visible')
142151

143-
cy.getByTestID('input--active-account-name')
144-
.clear()
145-
.type('Influx')
146-
cy.getByTestID('rename-account--button').click()
152+
cy.getByTestID('input--active-account-name')
153+
.clear()
154+
.type('Influx')
155+
cy.getByTestID('rename-account--button').click()
147156

148-
// test that the notification is up:
149-
cy.getByTestID('notification-success').should('be.visible')
157+
// test that the notification is up:
158+
cy.getByTestID('notification-success').should('be.visible')
150159

151-
// now; bring up the dialog again, the active name should be changed:
152-
cy.getByTestID('user-account-switch-btn').click()
160+
// now; bring up the dialog again, the active name should be changed:
161+
cy.getByTestID('user-account-switch-btn').click()
153162

154-
cy.getByTestID('switch-account--dialog').within(() => {
155-
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
156-
cy.getByTestID(`${prefix}-0-ID`).contains('Influx')
157-
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
158-
cy.getByTestID('multi-account-switch-cancel').click()
163+
cy.getByTestID('switch-account--dialog').within(() => {
164+
cy.getByTestID(`${prefix}-0-ID`).should('be.visible')
165+
cy.getByTestID(`${prefix}-0-ID`).contains('Influx')
166+
cy.getByTestID(`${prefix}-0-ID--input`).should('be.checked')
167+
cy.getByTestID('multi-account-switch-cancel').click()
168+
})
159169
})
160170
})
161171
})

0 commit comments

Comments
 (0)