Skip to content

Commit

Permalink
Fix E2E flake caused by date pickers (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs authored Sep 5, 2023
1 parent 7d74919 commit fc0d4ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion server/e2e/showItems.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ const test = base.extend<{ showPage: Page }>({
await page.goto("/shows/create");
await page.getByLabel("Name").fill("Test Show");
await page.getByLabel("Start").click();
await page.getByText("27").click();
// The E2E suite doesn't care what date this is, as long as it's in the future.
// We specifically use a day between 8 and 21, because sometimes the date picker
// can show the last/first week of the previous/next month, and two buttons with
// the same text will break Playwright (Strict Mode).
// So we go to the next month and then pick the 15th.
await page.getByLabel("Go to next month").click();
await page.getByText("15").click();
await page.locator("input[type=time]").fill("19:30");
await page.keyboard.press("Escape");
await page.getByRole("button", { name: "Create" }).click();
Expand Down
4 changes: 3 additions & 1 deletion server/e2e/shows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ test("create show", async ({ page }) => {
await page.getByRole("button", { name: "New Show" }).click();
await page.getByLabel("Name").fill("Test Show");
await page.getByLabel("Start").click();
await page.getByText("27").click();
// see comment in showItems.spec.ts for an explanation
await page.getByLabel("Go to next month").click();
await page.getByText("15").click();
await page.keyboard.press("Escape");
await page.getByRole("button", { name: "Create" }).click();
await expect(page.getByRole("heading", { name: "Test Show" })).toBeVisible();
Expand Down

0 comments on commit fc0d4ad

Please sign in to comment.