@@ -8,11 +8,12 @@ export const setupProfile = (): Promise<any> => {
88 method : 'PUT' ,
99 url : 'api/v2/quartz/accounts/resetAllAccountOrgs' ,
1010 } )
11+ cy . visit ( '/' )
1112 cy . getByTestID ( 'home-page--header' ) . should ( 'be.visible' )
1213 cy . setFeatureFlags ( userProfileFeatureFlags ) . then ( ( ) => {
1314 // cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override.
1415 // The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route).
15- cy . wait ( 300 ) . then ( ( ) => {
16+ cy . wait ( 1200 ) . then ( ( ) => {
1617 cy . visit ( '/me/profile' )
1718 } )
1819 } )
@@ -96,6 +97,12 @@ describe('User profile page', () => {
9697 } )
9798
9899 it ( "displays the user's name and email" , ( ) => {
100+ cy . fixture ( 'multiOrgAccounts1.json' ) . then ( quartzAccounts => {
101+ cy . intercept ( 'GET' , '/api/v2/quartz/accounts' , quartzAccounts ) . as (
102+ 'getAccounts'
103+ )
104+ } )
105+
99106 cy . getByTestID ( 'user-profile--page' )
100107 . contains ( 'User Profile' )
101108 . should ( 'be.visible' )
@@ -133,17 +140,22 @@ describe('User profile page', () => {
133140
134141 describe ( 'multi-org users' , ( ) => {
135142 it ( 'allows the user to change their default account' , ( ) => {
136- cy . intercept ( {
137- path : '/api/v2/quartz/accounts/default' ,
138- method : 'PUT' ,
143+ cy . fixture ( 'multiOrgAccounts1.json' ) . then ( quartzAccounts => {
144+ cy . intercept ( 'GET' , '/api/v2/quartz/accounts' , quartzAccounts ) . as (
145+ 'getAccounts'
146+ )
147+ } )
148+
149+ cy . intercept ( 'PUT' , '/api/v2/quartz/accounts/default' , {
150+ statusCode : 204 ,
151+ data : '' ,
139152 } ) . as ( 'putQuartzDefaultAccount' )
140153
141154 cy . getByTestID ( 'user-profile--save-button' ) . should (
142155 'have.attr' ,
143156 'disabled'
144157 )
145158
146- // Confirm that the user can change default accounts solely by clicking in the dropdown.
147159 cy . getByTestID ( 'user-profile--change-account-header' )
148160 . contains ( 'Default Account' )
149161 . should ( 'be.visible' )
@@ -157,6 +169,15 @@ describe('User profile page', () => {
157169 . contains ( 'Influx' )
158170 . click ( )
159171
172+ cy . fixture ( 'multiOrgAccounts1.json' ) . then ( quartzAccounts => {
173+ quartzAccounts [ 0 ] . isDefault = true
174+ quartzAccounts [ 1 ] . isDefault = false
175+
176+ cy . intercept ( 'GET' , '/api/v2/quartz/accounts' , quartzAccounts ) . as (
177+ 'getAccounts'
178+ )
179+ } )
180+
160181 cy . getByTestID ( 'user-profile--save-button' )
161182 . should ( 'be.visible' )
162183 . click ( )
@@ -194,6 +215,13 @@ describe('User profile page', () => {
194215 . contains ( 'Veganomicon' )
195216 . click ( )
196217
218+ // Reset to default fixture, where Veganomicon is default.
219+ cy . fixture ( 'multiOrgAccounts1.json' ) . then ( quartzAccounts => {
220+ cy . intercept ( 'GET' , '/api/v2/quartz/accounts' , quartzAccounts ) . as (
221+ 'getAccounts'
222+ )
223+ } )
224+
197225 cy . getByTestID ( 'user-profile--save-button' )
198226 . should ( 'be.visible' )
199227 . click ( )
@@ -222,9 +250,9 @@ describe('User profile page', () => {
222250 } )
223251
224252 it ( 'allows the user to change their default org' , ( ) => {
225- cy . intercept ( {
226- path : '/api/v2/quartz/accounts/**/orgs/default' ,
227- method : 'PUT ' ,
253+ cy . intercept ( 'PUT' , '/api/v2/quartz/accounts/**/orgs/default' , {
254+ statusCode : 204 ,
255+ data : '' ,
228256 } ) . as ( 'putQuartzDefaultOrg' )
229257
230258 cy . getByTestID ( 'user-profile--current-account-header' )
@@ -309,14 +337,14 @@ describe('User profile page', () => {
309337 } )
310338
311339 it ( 'allows the user to change both their default account and org' , ( ) => {
312- cy . intercept ( {
313- path : '/api/v2/quartz/accounts/default' ,
314- method : 'PUT ' ,
340+ cy . intercept ( 'PUT' , '/api/v2/quartz/accounts/default' , {
341+ statusCode : 204 ,
342+ data : '' ,
315343 } ) . as ( 'putQuartzDefaultAccount' )
316344
317- cy . intercept ( {
318- path : '/api/v2/quartz/accounts/**/orgs/default' ,
319- method : 'PUT ' ,
345+ cy . intercept ( 'PUT' , '/api/v2/quartz/accounts/**/orgs/default' , {
346+ statusCode : 204 ,
347+ data : '' ,
320348 } ) . as ( 'putQuartzDefaultOrg' )
321349
322350 cy . getByTestID ( 'user-profile--change-account-dropdown' ) . type ( 'Inf' )
@@ -335,6 +363,15 @@ describe('User profile page', () => {
335363 . contains ( 'Test Org 1' )
336364 . click ( )
337365
366+ cy . fixture ( 'multiOrgAccounts1.json' ) . then ( quartzAccounts => {
367+ quartzAccounts [ 0 ] . isDefault = true
368+ quartzAccounts [ 1 ] . isDefault = false
369+
370+ cy . intercept ( 'GET' , '/api/v2/quartz/accounts' , quartzAccounts ) . as (
371+ 'getAccounts'
372+ )
373+ } )
374+
338375 cy . getByTestID ( 'user-profile--save-button' ) . click ( )
339376
340377 cy . wait ( [ '@putQuartzDefaultOrg' , '@putQuartzDefaultAccount' ] ) . then ( ( ) => {
0 commit comments