Overhaul validation logic
Now, rather than retrying until we get a correct URL or a timeout, we check once, then, if the URL is wrong, we wait for a URL change and check again. (Unless, the current page is a bailout, in which case we know that the page isn't going to change)
This commit is contained in:
parent
a974e53bc8
commit
7b017cc218
1 changed files with 15 additions and 5 deletions
|
|
@ -116,12 +116,22 @@ export class BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateURL(issPageValue: string) {
|
async validateURL(issPageValue: string) {
|
||||||
|
let pass = false;
|
||||||
|
let currentUrl = this.page.url();
|
||||||
|
pass = currentUrl.includes(issPageValue);
|
||||||
|
const isBailout = currentUrl.includes('bailout-page');
|
||||||
|
if(!pass && !isBailout) {
|
||||||
|
await this.waitForURLToChange(currentUrl);
|
||||||
|
currentUrl = this.page.url();
|
||||||
|
pass = currentUrl.includes(issPageValue);
|
||||||
|
}
|
||||||
|
expect(pass).toBeTruthy();
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitForURLToChange(startingUrl: string) {
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
const currentUrl = this.page.url();
|
const currentUrl = this.page.url();
|
||||||
expect(currentUrl).toContain(issPageValue);
|
expect(currentUrl).not.toEqual(startingUrl);
|
||||||
}).toPass({
|
}).toPass({ timeout: 180_000 });
|
||||||
intervals: [1_000],
|
|
||||||
timeout: 15_000
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue