From 54b695778a7dd4591dae9343bac8388ba81909b9 Mon Sep 17 00:00:00 2001 From: Kimi Kuru Date: Thu, 1 Aug 2024 13:03:03 +0300 Subject: [PATCH 1/2] Fix flawed logic in date navigation test --- e2e/tests/controls.spec.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e/tests/controls.spec.ts b/e2e/tests/controls.spec.ts index be41aaf5..79b1424c 100644 --- a/e2e/tests/controls.spec.ts +++ b/e2e/tests/controls.spec.ts @@ -9,15 +9,17 @@ test.describe("Browse week", () => { test("Should browse weeks forward", async ({ page, t }) => { const jump = 3; - for (let i = 0; i < jump; i++) + for (let i = 0; i < jump; i++) { await page.getByRole("button", { name: t("controls.aria.nextWeek") }).click(); + } await expect(page).toHaveURL(`/entries/week/${startingWeek + jump}`); }); test("Should browse weeks backward", async ({ page, t }) => { const jump = 3; - for (let i = 0; i < jump; i++) + for (let i = 0; i < jump; i++) { await page.getByRole("button", { name: t("controls.aria.prevWeek") }).click(); + } await expect(page).toHaveURL(`/entries/week/${startingWeek - jump}`); }); @@ -29,8 +31,10 @@ test.describe("Browse week", () => { await expect(page).toHaveURL(`/entries/week/${currentWeek}`); }); - test("Should go to specific week", async ({ page }) => { + test("Should go to specific week", async ({ page, dayjs }) => { const jump = 4; + const startingWeek = dayjs().week(); + await page.goto(`/entries/week/${startingWeek}`); await page.getByRole("combobox", { name: String(startingWeek) }).click(); await page.getByRole("option", { name: String(startingWeek + jump) }).click(); await expect(page).toHaveURL(`/entries/week/${startingWeek + jump}`); From e4ac8aacf894926eacfef206183f9a862f9e4090 Mon Sep 17 00:00:00 2001 From: Kimi Kuru Date: Thu, 1 Aug 2024 13:16:40 +0300 Subject: [PATCH 2/2] Fix date test mobile --- e2e/tests/controls.mobile.spec.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e/tests/controls.mobile.spec.ts b/e2e/tests/controls.mobile.spec.ts index 23d3af9a..aabfa63a 100644 --- a/e2e/tests/controls.mobile.spec.ts +++ b/e2e/tests/controls.mobile.spec.ts @@ -9,15 +9,17 @@ test.describe("Browse week mobile", () => { test("Should browse weeks forward", async ({ page, t }) => { const jump = 3; - for (let i = 0; i < jump; i++) + for (let i = 0; i < jump; i++) { await page.getByRole("button", { name: t("controls.aria.nextWeek") }).click(); + } await expect(page).toHaveURL(`/entries/week/${startingWeek + jump}`); }); test("Should browse weeks backward", async ({ page, t }) => { const jump = 3; - for (let i = 0; i < jump; i++) + for (let i = 0; i < jump; i++) { await page.getByRole("button", { name: t("controls.aria.prevWeek") }).click(); + } await expect(page).toHaveURL(`/entries/week/${startingWeek - jump}`); }); @@ -29,8 +31,10 @@ test.describe("Browse week mobile", () => { await expect(page).toHaveURL(`/entries/week/${currentWeek}`); }); - test("Should go to specific week", async ({ page }) => { + test("Should go to specific week", async ({ page, dayjs }) => { const jump = 4; + const startingWeek = dayjs().week(); + await page.goto(`/entries/week/${startingWeek}`); await page.getByRole("combobox", { name: String(startingWeek) }).click(); await page.getByRole("option", { name: String(startingWeek + jump) }).click(); await expect(page).toHaveURL(`/entries/week/${startingWeek + jump}`);