70 lines
2.6 KiB
TypeScript
70 lines
2.6 KiB
TypeScript
import { expect, test, type Page } from "@playwright/test";
|
|
import { bookingTestData } from "./fixtures";
|
|
import {
|
|
completeBookingCreationFlow,
|
|
goToBookingProductSelectionStep,
|
|
goToBookingProductSelectionStepWithOptions,
|
|
} from "./support/bookingFlow";
|
|
import { mockApi, primeMockSession } from "./support/network.js";
|
|
|
|
async function prepareBookingPage(page: Page, pos: true | Record<string, unknown> = true) {
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
sessionData: {
|
|
display_name: "Booking User",
|
|
customer_number: 12345679,
|
|
permissions: ["user"],
|
|
},
|
|
pos,
|
|
});
|
|
|
|
await primeMockSession(page, { bootPath: "/user" });
|
|
}
|
|
|
|
test("[BOOKINGS][User][Creation] should create a new booking", async ({ page }) => {
|
|
await prepareBookingPage(page);
|
|
await completeBookingCreationFlow(page, bookingTestData);
|
|
});
|
|
|
|
test("[BOOKINGS][User][Creation] should show interior wash products on the interior category", async ({ page }) => {
|
|
await prepareBookingPage(page);
|
|
await goToBookingProductSelectionStep(page, bookingTestData);
|
|
|
|
const interiorCategoryTab = page.getByTestId("pos-product-category-tab-2");
|
|
if (await interiorCategoryTab.isVisible().catch(() => false)) {
|
|
await interiorCategoryTab.click();
|
|
} else {
|
|
await page.getByTestId("pos-product-category-select").selectOption("2");
|
|
}
|
|
|
|
await expect(page.getByTestId("pos-product-card-63")).toBeVisible();
|
|
await expect(page.getByText("Indvendig vask Forvogn")).toBeVisible();
|
|
});
|
|
|
|
test("[BOOKINGS][User][Creation] should show desktop loading states while categories and products resolve", async ({
|
|
page,
|
|
}, testInfo) => {
|
|
test.skip(!testInfo.project.name.toLowerCase().includes("desktop"), "Desktop only");
|
|
|
|
await prepareBookingPage(page, {
|
|
departmentCategoriesDelayMs: 700,
|
|
productsDelayMs: 900,
|
|
});
|
|
|
|
await goToBookingProductSelectionStepWithOptions(page, bookingTestData, {
|
|
selectInitialProduct: false,
|
|
});
|
|
|
|
await expect(page.getByTestId("pos-product-categories-loading")).toBeVisible();
|
|
await expect(page.getByTestId("pos-products-loading")).toBeVisible();
|
|
|
|
await expect(page.getByTestId("pos-product-categories-loading")).toHaveCount(0, { timeout: 10_000 });
|
|
await expect(page.getByTestId("pos-product-card-53")).toBeVisible({ timeout: 10_000 });
|
|
await expect(page.getByTestId("pos-products-loading")).toHaveCount(0, { timeout: 10_000 });
|
|
|
|
await page.getByTestId("pos-product-category-tab-2").click();
|
|
await expect(page.getByTestId("pos-products-loading")).toBeVisible();
|
|
await expect(page.getByTestId("pos-product-card-63")).toBeVisible({ timeout: 10_000 });
|
|
await expect(page.getByTestId("pos-products-loading")).toHaveCount(0, { timeout: 10_000 });
|
|
});
|