File tree Expand file tree Collapse file tree 4 files changed +27
-10
lines changed
packages/compass-e2e-tests/helpers/commands Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,7 @@ async function resetForDisconnect(
4848 closeToasts ?: boolean ;
4949 } = { }
5050) {
51- if ( await browser . $ ( Selectors . LGModal ) . isDisplayed ( ) ) {
52- // close any modals that might be in the way
53- await browser . clickVisible ( Selectors . LGModalClose ) ;
54- await browser . $ ( Selectors . LGModal ) . waitForDisplayed ( { reverse : true } ) ;
55- }
51+ await browser . hideVisibleModal ( ) ;
5652
5753 // Collapse all the connections so that they will all hopefully fit on screen
5854 // and therefore be rendered.
Original file line number Diff line number Diff line change 1+ import type { CompassBrowser } from '../compass-browser' ;
2+ import * as Selectors from '../selectors' ;
3+
4+ import Debug from 'debug' ;
5+
6+ const debug = Debug ( 'compass-e2e-tests' ) ;
7+
8+ export async function hideVisibleModal ( browser : CompassBrowser ) : Promise < void > {
9+ // If there's some race condition where something else is closing the modal at
10+ // the same time we're trying to close the modal, then make it error out
11+ // quickly so it can be ignored and we move on.
12+
13+ if ( await browser . $ ( Selectors . LGModal ) . isDisplayed ( ) ) {
14+ // close any modals that might be in the way
15+ const waitOptions = { timeout : 2_000 } ;
16+ try {
17+ await browser . clickVisible ( Selectors . LGModalClose , waitOptions ) ;
18+ await browser . $ ( Selectors . LGModal ) . waitForDisplayed ( { reverse : true } ) ;
19+ } catch ( err ) {
20+ // if the modal disappears by itself in the meantime, that's fine
21+ debug ( 'ignoring' , err ) ;
22+ }
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -59,5 +59,6 @@ export * from './create-index';
5959export * from './drop-index' ;
6060export * from './hide-index' ;
6161export * from './unhide-index' ;
62+ export * from './hide-visible-modal' ;
6263export * from './hide-visible-toasts' ;
6364export * from './sidebar-collection' ;
Original file line number Diff line number Diff line change @@ -3,11 +3,7 @@ import type { CompassBrowser } from '../compass-browser';
33import * as Selectors from '../selectors' ;
44
55async function resetForRemove ( browser : CompassBrowser ) {
6- if ( await browser . $ ( Selectors . LGModal ) . isDisplayed ( ) ) {
7- // close any modals that might be in the way
8- await browser . clickVisible ( Selectors . LGModalClose ) ;
9- await browser . $ ( Selectors . LGModal ) . waitForDisplayed ( { reverse : true } ) ;
10- }
6+ await browser . hideVisibleModal ( ) ;
117
128 // Collapse all the connections so that they will all hopefully fit on screen
139 // and therefore be rendered.
You can’t perform that action at this time.
0 commit comments