Skip to content

Commit

Permalink
Merge pull request #127 from funidata/fix-e2e-date
Browse files Browse the repository at this point in the history
Fix flawed logic in date navigation test
  • Loading branch information
joonashak authored Aug 7, 2024
2 parents f68afac + e4ac8aa commit 04b86c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions e2e/tests/controls.mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});

Expand All @@ -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}`);
Expand Down
10 changes: 7 additions & 3 deletions e2e/tests/controls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});

Expand All @@ -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}`);
Expand Down

0 comments on commit 04b86c6

Please sign in to comment.