Files
pleno-vue/tests/e2e/quarantine/component-harness/date-period-selector.smoke.spec.js
T

60 lines
2.5 KiB
JavaScript

import { expect, test } from "@playwright/test";
import { isCompactProject } from "./support/projects.js";
import { mockApi, seedAuthenticatedState } from "./support/network.js";
async function openHarness(page) {
await page.goto("/__e2e/date-period-selector", { waitUntil: "domcontentloaded" });
await expect(page.getByTestId("date-period-selector-harness-page")).toBeVisible();
}
test.describe("date period selector harness", () => {
test.beforeEach(async ({ page }) => {
await seedAuthenticatedState(page, "date-period-selector-harness-token");
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
});
});
test("@smoke other month opens the month selector", async ({ page }, testInfo) => {
const isCompact = isCompactProject(testInfo);
await page.clock.setFixedTime(new Date("2026-05-04T10:00:00.000Z"));
await openHarness(page);
if (isCompact) {
const anytimeOption = page
.getByTestId("date-period-shortcuts")
.locator("option")
.filter({ hasText: /anytime|når som helst/i });
await expect(anytimeOption).toHaveCount(1);
} else {
await expect(page.getByTestId("date-period-shortcut-anytime")).toContainText(/anytime|når som helst/i);
}
await page.getByTestId("date-period-other-dropdown-trigger").click();
const otherMonthOption = page.getByTestId("date-period-other-other_month");
await expect(otherMonthOption).toBeVisible();
await expect(otherMonthOption).toContainText(/other month|anden måned|annen måned|annan månad|anderer monat/i);
const optionBox = await otherMonthOption.boundingBox();
expect(optionBox?.width).toBeGreaterThan(120);
expect(optionBox?.height).toBeGreaterThanOrEqual(16);
await otherMonthOption.click();
const otherMonthModal = page.getByTestId("date-period-other-month-modal");
const otherMonthPicker = page.getByTestId("date-period-other-month-picker");
await expect(otherMonthModal).toBeVisible();
await expect(otherMonthPicker).toBeVisible();
await expect(otherMonthPicker.locator(".datepicker-table")).toBeVisible();
const previousBox = await otherMonthPicker.locator(".pagination-previous").boundingBox();
const yearBox = await otherMonthPicker.locator(".pagination-list").boundingBox();
const nextBox = await otherMonthPicker.locator(".pagination-next").boundingBox();
expect(previousBox?.x).toBeLessThan(yearBox?.x ?? 0);
expect(yearBox?.x).toBeLessThan(nextBox?.x ?? 0);
});
});