Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: "fix: update OOO e2e tests to remove flakiness" #18411

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.");
}
}
}
55 changes: 20 additions & 35 deletions apps/web/playwright/out-of-office.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ 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();
Expand Down Expand Up @@ -72,12 +68,8 @@ 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();
Expand Down Expand Up @@ -212,13 +204,10 @@ 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 dateButton.click();
await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22", true);

Expand Down Expand Up @@ -255,13 +244,10 @@ 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 dateButton.click();
await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22");

Expand All @@ -270,8 +256,9 @@ test.describe("Out of office", () => {
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();

// add another entry
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await page.getByTestId("add_entry_ooo").click();

await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "11", "24");

Expand All @@ -287,13 +274,10 @@ 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 dateButton.click();
await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22");

Expand All @@ -302,8 +286,9 @@ test.describe("Out of office", () => {
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();

// add another entry
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await dateButton.click();
await page.getByTestId("add_entry_ooo").click();

await page.locator('[data-testid="date-range"]').click();

await selectToAndFromDates(page, "13", "22");

Expand All @@ -323,13 +308,13 @@ test.describe("Out of office", () => {

//Creates 2 OOO entries:
//First OOO is created on Next month 1st - 3rd
await clickUntilDialogVisible(addOOOButton, dateButton, page, "outOfOfficeReasonList?batch=1");
await clickUntilDialogVisible(addOOOButton, dateButton);
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, page, "outOfOfficeReasonList?batch=1");
await clickUntilDialogVisible(addOOOButton, dateButton);
await dateButton.click();
await selectDateAndCreateOOO(page, "4", "6");
await expect(page.locator(`data-testid=table-redirect-n-a`).nth(1)).toBeVisible();
Expand All @@ -356,7 +341,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, page, "outOfOfficeReasonList?batch=1");
await clickUntilDialogVisible(addOOOButton, dateButton);
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3", "member-1");
await expect(
Expand All @@ -367,7 +352,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, page, "outOfOfficeReasonList?batch=1");
await clickUntilDialogVisible(addOOOButton, dateButton);
await dateButton.click();
await selectDateAndCreateOOO(page, "4", "5", "owner");
await expect(page.locator(`data-testid=table-redirect-${owner.username ?? "n-a"}`).nth(0)).toBeVisible();
Expand Down Expand Up @@ -395,7 +380,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, page, "outOfOfficeReasonList?batch=1");
await clickUntilDialogVisible(addOOOButton, dateButton);
await dateButton.click();
await selectDateAndCreateOOO(page, "1", "3", "member-1");
await expect(
Expand All @@ -406,7 +391,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, page, "outOfOfficeReasonList?batch=1");
await clickUntilDialogVisible(addOOOButton, dateButton);
await dateButton.click();
await selectDateAndCreateOOO(page, "2", "5", "owner", 400);
await expect(page.locator(`text=${t("booking_redirect_infinite_not_allowed")}`)).toBeTruthy();
Expand Down
Loading