Files
pleno-vue/tests/e2e/guest-book-wash-mobile.spec.ts
T

70 lines
2.3 KiB
TypeScript

import { expect, type Page, test } from "@playwright/test";
const guestDepartments = [
{
id: 1,
name: "Taastrup",
description: "Taastrup Truck Wash",
latitude: 55.651,
longitude: 12.302,
order_priority: 1,
},
{
id: 2,
name: "Køge",
description: "Køge Truck Wash",
latitude: 55.458,
longitude: 12.182,
order_priority: 2,
},
];
function json(body: unknown, status = 200) {
return {
status,
contentType: "application/json",
headers: {
"access-control-allow-origin": "*",
"access-control-allow-headers": "Content-Type, Authorization, *",
"access-control-allow-methods": "GET, POST, OPTIONS",
},
body: JSON.stringify(body),
};
}
async function mockGuestBookWashApi(page: Page) {
await page.route("**/guest/departments**", async (route) => {
await route.fulfill(json({ data: guestDepartments }));
});
await page.route("**/guest/validation/customer-number", async (route) => {
await route.fulfill(json({ data: { exists: true } }));
});
await page.route("**/auth/session**", async (route) => {
await route.fulfill(json({ message: "Unauthenticated" }, 401));
});
}
test.describe("Guest book wash mobile", () => {
test("keeps the booking controls visible after the full guest flow loads", async ({ page }, testInfo) => {
test.skip(!testInfo.project.name.includes("mobile"), "Mobile layout coverage runs on mobile projects only.");
await mockGuestBookWashApi(page);
await page.goto("/guest/book/wash", { waitUntil: "domcontentloaded" });
await expect(page.getByTestId("guest-dashboard-title")).toBeVisible();
await expect(page.getByTestId("guest-dashboard-title")).toContainText(/Book Vask|Book wash/i);
await expect(page.getByTestId("booking-mobile-next")).toBeVisible({ timeout: 15_000 });
await expect(page.getByTestId("booking-mobile-next")).toBeDisabled();
await expect(page.getByTestId("guest-booking-controls")).toHaveCount(0);
await expect(page.getByText("Du er i gæstetilstand.")).toBeVisible();
await expect(page.getByText("Vælg en vaskehal").first()).toBeVisible();
const hasHorizontalOverflow = await page.evaluate(
() => document.documentElement.scrollWidth > document.documentElement.clientWidth + 1
);
expect(hasHorizontalOverflow).toBe(false);
});
});