puppetter: Add a waitForNavigation call before asserting the url.

Since we are doing a assert call checking a url without no page.waitForSelector
or similar calls, we add this to avoid flakes where the assert is called
when we are in process of navigation to the page. Also, we use Promise.all
here, and call page.waitForNavigation first, to avoid race conditions where
form is submitted quickly and navigation occurs and then we are stuck waiting
for a navigation. There were no flakes in the CI related to this issue, but
I expect someone with a slow hardware would probably stumble upto this in future.
This commit is contained in:
Priyank Patel
2020-05-27 00:28:17 +00:00
committed by Tim Abbott
parent 60c92b69c5
commit 60fa848aea

View File

@@ -12,7 +12,10 @@ async function realm_creation_tests(page) {
// submit the email for realm creation. // submit the email for realm creation.
await page.waitForSelector('#email'); await page.waitForSelector('#email');
await page.type('#email', email); await page.type('#email', email);
await page.$eval('#send_confirm', form => form.submit()); await Promise.all([
page.waitForNavigation(),
page.$eval('#send_confirm', form => form.submit()),
]);
// Make sure onfirmation email is sent. // Make sure onfirmation email is sent.
assert(page.url().includes('/accounts/new/send_confirm/' + email)); assert(page.url().includes('/accounts/new/send_confirm/' + email));