From 7b017cc218c01e7950266b7a32b686894eb3279b Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Mon, 10 Mar 2025 15:43:21 -0400 Subject: [PATCH] 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) --- playwright-tests/pages/BasePage.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index e538ee34..d2d03356 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -116,12 +116,22 @@ export class BasePage { } 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 () => { const currentUrl = this.page.url(); - expect(currentUrl).toContain(issPageValue); - }).toPass({ - intervals: [1_000], - timeout: 15_000 - }); + expect(currentUrl).not.toEqual(startingUrl); + }).toPass({ timeout: 180_000 }); } } \ No newline at end of file