- Introduced `.prettierrc.json` to enforce consistent code formatting across the project. - Updated unit and e2e test files to address formatting issues, improve readability, and ensure alignment with the new Prettier configuration.
71 lines
2.5 KiB
JavaScript
71 lines
2.5 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
import { createPosFixture, mockApi, seedAuthenticatedState } from "./support/network.js";
|
|
|
|
const POS_PERMISSIONS = [
|
|
"admin",
|
|
"department_access_12",
|
|
"delete_order",
|
|
"edit_order_items",
|
|
"get_user",
|
|
"list_customer_attributes",
|
|
"get_custom_prices_other",
|
|
];
|
|
|
|
async function primeOperatorSession(page, token = "pos-customer-rules-token") {
|
|
await seedAuthenticatedState(page, token);
|
|
const sessionRequest = page.waitForResponse((response) => {
|
|
return response.request().method() === "GET" && response.url().includes("/auth/session");
|
|
});
|
|
await page.goto("/login");
|
|
await sessionRequest;
|
|
}
|
|
|
|
test("rules tab reloads customer attributes when the panel becomes visible", async ({ page }, testInfo) => {
|
|
test.skip(!testInfo.project.name.includes("desktop"), "Desktop only");
|
|
|
|
const fixture = createPosFixture({
|
|
customerAttributesByNumber: {
|
|
12345679: [
|
|
{ id: 1, customer_number: 12345679, attribute: "invoiceAllOrdersIndividually" },
|
|
{ id: 2, customer_number: 12345679, attribute: "invoiceWithStripe" },
|
|
],
|
|
},
|
|
});
|
|
const customer = fixture.customersByNumber[12345679];
|
|
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: POS_PERMISSIONS,
|
|
edgeGateways: false,
|
|
pos: fixture,
|
|
});
|
|
await primeOperatorSession(page);
|
|
|
|
await page.goto("/admin/12/modules/pos?step=1");
|
|
await expect(page.getByTestId("pos-step-1")).toBeVisible();
|
|
|
|
await page.locator("#reg_1").fill("AB12345");
|
|
await page.locator("#pos_select_customer_input").fill(String(customer.customerNumber));
|
|
await expect(page.locator(".customer-drop-down-select").first()).toBeVisible();
|
|
await page.locator(".customer-drop-down-select").first().click();
|
|
await expect(page.locator(".field.has-addons input[disabled]").last()).toHaveValue(customer.name);
|
|
|
|
await expect(page.locator(".pos-selected-customer__title").filter({ hasText: customer.name }).first()).toBeVisible();
|
|
|
|
const rulesTab = page.locator('[data-testid="pos-customer-tab-rules"]:visible').first();
|
|
await expect(rulesTab).toBeVisible();
|
|
|
|
const customerAttributesResponse = page.waitForResponse((response) => {
|
|
return (
|
|
response.request().method() === "GET" &&
|
|
response.url().includes(`/customer/attributes?customer_number=${customer.customerNumber}`)
|
|
);
|
|
});
|
|
|
|
await rulesTab.click();
|
|
await customerAttributesResponse;
|
|
|
|
await expect(page.locator("#invoiceAllOrdersIndividually:visible")).toBeChecked();
|
|
await expect(page.locator("#invoiceWithStripe:visible")).toBeChecked();
|
|
});
|