-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(e2e): deal with the fact that the modal might already be closed (#…
…6153) * deal with the fact that the modal might already be closed * pull out the hide modal logic, use it in two places
- Loading branch information
Showing
4 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/compass-e2e-tests/helpers/commands/hide-visible-modal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { CompassBrowser } from '../compass-browser'; | ||
import * as Selectors from '../selectors'; | ||
|
||
import Debug from 'debug'; | ||
|
||
const debug = Debug('compass-e2e-tests'); | ||
|
||
export async function hideVisibleModal(browser: CompassBrowser): Promise<void> { | ||
// If there's some race condition where something else is closing the modal at | ||
// the same time we're trying to close the modal, then make it error out | ||
// quickly so it can be ignored and we move on. | ||
|
||
if (await browser.$(Selectors.LGModal).isDisplayed()) { | ||
// close any modals that might be in the way | ||
const waitOptions = { timeout: 2_000 }; | ||
try { | ||
await browser.clickVisible(Selectors.LGModalClose, waitOptions); | ||
await browser.$(Selectors.LGModal).waitForDisplayed({ reverse: true }); | ||
} catch (err) { | ||
// if the modal disappears by itself in the meantime, that's fine | ||
debug('ignoring', err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters