Skip to content

Commit

Permalink
trying to fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
anikdhabal committed Dec 29, 2024
1 parent e9344ba commit 09387e3
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions apps/web/playwright/lib/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,27 +542,16 @@ export async function expectPageToBeNotFound({ page, url }: { page: Page; url: s
export async function clickUntilDialogVisible(
dialogOpenButton: Locator,
visibleLocatorOnDialog: Locator,
page: Page,
matchUrl: string,
retries = 3,
delay = 2000
delay = 500
) {
for (let i = 0; i < retries; i++) {
await dialogOpenButton.click();
try {
const responsePromise = page.waitForResponse(
(response) => response.url().includes(matchUrl) && response.status() === 200
);
await dialogOpenButton.click();
await responsePromise;
await visibleLocatorOnDialog.waitFor({ state: "visible", timeout: delay });
return;
} catch {
console.warn(`clickUntilDialogVisible: Attempt ${i + 1} failed to open dialog`);
if (i === retries - 1) {
console.log("clickUntilDialogVisible: Dialog did not appear after multiple attempts.");
return;
}
await new Promise((resolve) => setTimeout(resolve, delay));
if (i === retries - 1) throw new Error("Dialog did not appear after multiple attempts.");
}
}
}

0 comments on commit 09387e3

Please sign in to comment.