Update validateURL to account for more scenarios

In some scenarios, the URL will not have already changed by the time
this check is being made, so if the check fails, we wait and recheck
a few times
This commit is contained in:
Alex Humphries 2025-03-07 09:37:19 -05:00
parent cf4c4d8585
commit 16ce5ad0e4

View file

@ -116,7 +116,21 @@ export class BasePage {
}
async validateURL(url: string) {
const currentUrl = this.page.url();
expect(currentUrl).toEqual(url);
let failCount = 0;
/*
We can't assume that the URL has already changed when we get here, but the point of this
is to help speed up tests, so we want to move on as soon as we can if this passes, but
without waiting too long if it fails
*/
while(failCount < 10) {
await this.page.waitForTimeout(1000);
const currentUrl = this.page.url();
if(currentUrl == url)
break;
else {
failCount++;
}
}
expect(failCount).not.toEqual(10);
}
}