update OOO e2e tests to remove flakiness (#18367)

This commit is contained in:
Vijay authored and GitHub committed 2024-12-24 13:49:49 +00:00
1 parent 3c2619a7a3
commit e6ef4e1988
2 files changed
+49 -23

No files matched your search

+14 -3
View File
@@ -542,16 +542,27 @@ 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 = 500
delay = 2000
) {
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 {
if (i === retries - 1) throw new Error("Dialog did not appear after multiple attempts.");
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));
}
}
}