-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FI-1434 feat: add action
waitForStartOfPageLoad
- Loading branch information
Showing
5 changed files
with
41 additions
and
3 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {getPlaywrightPage} from '../../useContext'; | ||
import {assertValueIsDefined} from '../../utils/asserts'; | ||
import {getFullPackConfig} from '../../utils/config'; | ||
|
||
type Options = Readonly<{ | ||
timeout?: number; | ||
}>; | ||
|
||
/** | ||
* Waits for start of page load (when change the url or reload page). | ||
*/ | ||
export const waitForStartOfPageLoad = async (options?: Options): Promise<URL> => { | ||
const page = getPlaywrightPage(); | ||
const timeout = options?.timeout ?? getFullPackConfig().pageRequestTimeout; | ||
|
||
let urlObject: URL | undefined; | ||
|
||
await page.waitForURL( | ||
(url) => { | ||
urlObject = url; | ||
|
||
return true; | ||
}, | ||
{timeout}, | ||
); | ||
|
||
assertValueIsDefined(urlObject, 'urlObject is defined', {timeout}); | ||
|
||
return urlObject; | ||
}; |