Files
pleno-vue/tests/e2e/userBookWash.spec.ts
T

75 lines
3.0 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 goToBookingProductSelectionStepWithOptions(page, bookingTestData, {
selectInitialProduct: false,
});
const interiorCategoryTab = page.locator('[data-testid="pos-product-category-tab-2"]:visible').first();
if ((await interiorCategoryTab.count()) > 0) {
await interiorCategoryTab.click();
} else {
await page.locator('[data-testid="pos-product-category-select"]:visible').first().selectOption("2");
}
const interiorProductCard = page.locator('[data-testid="pos-product-card-63"]:visible').first();
await expect(interiorProductCard).toBeVisible();
await expect(interiorProductCard).toContainText("Indvendig vask Forvogn");
});
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.locator('[data-testid="pos-product-categories-loading"]:visible').first()).toBeVisible();
await expect(page.locator('[data-testid="pos-products-loading"]:visible').first()).toBeVisible();
await expect(page.locator('[data-testid="pos-product-categories-loading"]:visible')).toHaveCount(0, {
timeout: 10_000,
});
await expect(page.locator('[data-testid="pos-product-card-53"]:visible').first()).toBeVisible({ timeout: 10_000 });
await expect(page.locator('[data-testid="pos-products-loading"]:visible')).toHaveCount(0, { timeout: 10_000 });
await page.locator('[data-testid="pos-product-category-tab-2"]:visible').first().click();
await expect(page.locator('[data-testid="pos-products-loading"]:visible').first()).toBeVisible();
await expect(page.locator('[data-testid="pos-product-card-63"]:visible').first()).toBeVisible({ timeout: 10_000 });
await expect(page.locator('[data-testid="pos-products-loading"]:visible')).toHaveCount(0, { timeout: 10_000 });
});