Refactor: Remove unused readJsonFile helper, improve server process handling in Playwright setup, and optimize superuser booking and draft count logic.
This commit is contained in:
@@ -285,6 +285,36 @@ async function openVehicleSelectionFromPrimaryProduct(page, productName = "Tank
|
||||
await expect(page.getByTestId("pos-mobile-vehicle-selection")).toBeVisible({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
async function dragAcrossPrimaryProduct(page, offsetY = 48) {
|
||||
const trigger = page.getByTestId("pos-mobile-primary-product-card");
|
||||
await expect(trigger).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
const box = await trigger.boundingBox();
|
||||
if (!box) {
|
||||
throw new Error("Primary product card bounding box is unavailable.");
|
||||
}
|
||||
|
||||
const clientX = Math.round(box.x + box.width / 2);
|
||||
const clientY = Math.round(box.y + Math.min(box.height - 24, 40));
|
||||
|
||||
await trigger.dispatchEvent("pointerdown", {
|
||||
pointerType: "touch",
|
||||
clientX,
|
||||
clientY,
|
||||
});
|
||||
await trigger.dispatchEvent("pointermove", {
|
||||
pointerType: "touch",
|
||||
clientX,
|
||||
clientY: clientY - offsetY,
|
||||
});
|
||||
await page.waitForTimeout(650);
|
||||
await page.locator("body").dispatchEvent("pointerup", {
|
||||
pointerType: "touch",
|
||||
clientX,
|
||||
clientY: clientY - offsetY,
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForBookingHydration(page, { primaryId, addonProductIds = [] } = {}) {
|
||||
await expect
|
||||
.poll(
|
||||
@@ -2125,6 +2155,49 @@ test.describe("POS mobile order flow", () => {
|
||||
.toBe(63);
|
||||
});
|
||||
|
||||
test("dragging on the primary product card does not open vehicle selection", async ({ page }) => {
|
||||
const orderId = 9403;
|
||||
const fixture = createMobilePosFixture({
|
||||
ordersById: {
|
||||
[orderId]: buildRegularOrder(orderId, {
|
||||
reference: "SCROLL-GUARD",
|
||||
reg_1: "AB12345",
|
||||
}),
|
||||
},
|
||||
orderItemsByOrderId: {
|
||||
[orderId]: [],
|
||||
},
|
||||
});
|
||||
|
||||
await setupMobilePosPage(page, fixture, {
|
||||
token: "mobile-step2-scroll-guard-token",
|
||||
seedState: {
|
||||
customerId: REGULAR_CUSTOMER_ID,
|
||||
reg: "AB12345",
|
||||
reference: "SCROLL-GUARD",
|
||||
includePrimaryItem: true,
|
||||
primaryItemId: 53,
|
||||
vehicleType: 53,
|
||||
lastOrderId: null,
|
||||
},
|
||||
route: {
|
||||
step: 2,
|
||||
orderId,
|
||||
customerId: REGULAR_CUSTOMER_ID,
|
||||
},
|
||||
});
|
||||
|
||||
await expect(page.getByTestId("pos-mobile-step-2")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("pos-mobile-vehicle-selection")).toHaveCount(0);
|
||||
|
||||
await dragAcrossPrimaryProduct(page);
|
||||
|
||||
await expect(page.getByTestId("pos-mobile-step-2")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("pos-mobile-vehicle-selection")).toHaveCount(0);
|
||||
|
||||
await openVehicleSelectionFromPrimaryProduct(page);
|
||||
});
|
||||
|
||||
test("copy previous wash restores the last order primary service, addons, and standalone additional items", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user