Skip to content

Scheduling infrastructure for absolutely everyone.

update OOO e2e tests to remove flakiness (#18367)

Vijaye6ef4e19881f
diff --git a/apps/web/playwright/lib/testUtils.ts b/apps/web/playwright/lib/testUtils.ts
index 43005af7024..7cc89f19f31 100644
--- a/apps/web/playwright/lib/testUtils.ts
+++ b/apps/web/playwright/lib/testUtils.ts
@@ -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));
}
}
}
diff --git a/apps/web/playwright/out-of-office.e2e.ts b/apps/web/playwright/out-of-office.e2e.ts
index 8f93ae7577a..c251ccaef66 100644
--- a/apps/web/playwright/out-of-office.e2e.ts
+++ b/apps/web/playwright/out-of-office.e2e.ts
@@ -21,8 +21,12 @@ test.describe("Out of office", () => {
await user.apiLogin();
await page.goto("/settings/my-account/out-of-office");
+ await page.waitForLoadState("domcontentloaded");
+
+ const addOOOButton = page.getByTestId("add_entry_ooo");
+ const dateButton = page.locator('[data-testid="date-range"]');
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
- await page.getByTestId("add_entry_ooo").click();
await page.getByTestId("reason_select").click();
await page.getByTestId("select-option-4").click();
@@ -68,8 +72,12 @@ test.describe("Out of office", () => {
await user.apiLogin();
await page.goto(`/settings/my-account/out-of-office`);
+ await page.waitForLoadState("domcontentloaded");
+
+ const addOOOButton = page.getByTestId("add_entry_ooo");
+ const dateButton = page.locator('[data-testid="date-range"]');
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
- await page.getByTestId("add_entry_ooo").click();
await page.getByTestId("reason_select").click();
await page.getByTestId("select-option-4").click();
@@ -204,10 +212,13 @@ test.describe("Out of office", () => {
await user.apiLogin();
await page.goto("/settings/my-account/out-of-office");
+ await page.waitForLoadState("domcontentloaded");
- await page.getByTestId("add_entry_ooo").click();
+ const addOOOButton = page.getByTestId("add_entry_ooo");
+ const dateButton = page.locator('[data-testid="date-range"]');
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
- await page.locator('[data-testid="date-range"]').click();
+ await dateButton.click();
await selectToAndFromDates(page, "13", "22", true);
@@ -244,10 +255,13 @@ test.describe("Out of office", () => {
await user.apiLogin();
await page.goto("/settings/my-account/out-of-office");
+ await page.waitForLoadState("domcontentloaded");
- await page.getByTestId("add_entry_ooo").click();
+ const addOOOButton = page.getByTestId("add_entry_ooo");
+ const dateButton = page.locator('[data-testid="date-range"]');
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
- await page.locator('[data-testid="date-range"]').click();
+ await dateButton.click();
await selectToAndFromDates(page, "13", "22");
@@ -256,9 +270,8 @@ test.describe("Out of office", () => {
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();
// add another entry
- await page.getByTestId("add_entry_ooo").click();
-
- await page.locator('[data-testid="date-range"]').click();
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
+ await dateButton.click();
await selectToAndFromDates(page, "11", "24");
@@ -274,10 +287,13 @@ test.describe("Out of office", () => {
await user.apiLogin();
await page.goto("/settings/my-account/out-of-office");
+ await page.waitForLoadState("domcontentloaded");
- await page.getByTestId("add_entry_ooo").click();
+ const addOOOButton = page.getByTestId("add_entry_ooo");
+ const dateButton = page.locator('[data-testid="date-range"]');
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
- await page.locator('[data-testid="date-range"]').click();
+ await dateButton.click();
await selectToAndFromDates(page, "13", "22");
@@ -286,9 +302,8 @@ test.describe("Out of office", () => {
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();
// add another entry
- await page.getByTestId("add_entry_ooo").click();
-
- await page.locator('[data-testid="date-range"]').click();
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
+ await dateButton.click();
await selectToAndFromDates(page, "13", "22");
@@ -308,13 +323,13 @@ test.describe("Out of office", () => {
//Creates 2 OOO entries:
//First OOO is created on Next month 1st - 3rd
- await clickUntilDialogVisible(addOOOButton, dateButton);
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3");
await expect(page.locator(`data-testid=table-redirect-n-a`).nth(0)).toBeVisible();
//Second OOO is created on Next month 4th - 6th
- await clickUntilDialogVisible(addOOOButton, dateButton);
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "4", "6");
await expect(page.locator(`data-testid=table-redirect-n-a`).nth(1)).toBeVisible();
@@ -341,7 +356,7 @@ test.describe("Out of office", () => {
const dateButton = await page.locator('[data-testid="date-range"]');
//As owner,OOO is created on Next month 1st - 3rd, forwarding to 'member-1'
- await clickUntilDialogVisible(addOOOButton, dateButton);
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3", "member-1");
await expect(
@@ -352,7 +367,7 @@ test.describe("Out of office", () => {
await member1User?.apiLogin();
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
- await clickUntilDialogVisible(addOOOButton, dateButton);
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "4", "5", "owner");
await expect(page.locator(`data-testid=table-redirect-${owner.username ?? "n-a"}`).nth(0)).toBeVisible();
@@ -380,7 +395,7 @@ test.describe("Out of office", () => {
const dateButton = await page.locator('[data-testid="date-range"]');
//As owner,OOO is created on Next month 1st - 3rd, forwarding to 'member-1'
- await clickUntilDialogVisible(addOOOButton, dateButton);
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3", "member-1");
await expect(
@@ -391,7 +406,7 @@ test.describe("Out of office", () => {
await member1User?.apiLogin();
await page.goto("/settings/my-account/out-of-office");
await page.waitForLoadState();
- await clickUntilDialogVisible(addOOOButton, dateButton);
+ await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await selectDateAndCreateOOO(page, "2", "5", "owner", 400);
await expect(page.locator(`text=${t("booking_redirect_infinite_not_allowed")}`)).toBeTruthy();