Refactor e2e test fixtures and formatting for consistency:

- Removed unnecessary string quotes from numeric keys in `cvrSearchResponses` across `mobilePos.js` and related test files.
- Reformatted multiline function chaining and object initialization for improved readability.
- Enhanced fixture setup logic to ensure consistent mock data handling across test scenarios.
This commit is contained in:
Jeppe Bundgaard
2026-04-15 09:23:25 +02:00
parent 6b91097f98
commit 95a8f114bc
3 changed files with 39 additions and 12 deletions
+30 -5
View File
@@ -1504,15 +1504,30 @@ test.describe("Admin POS Orders - desktop step 1 customer and vehicle ownership"
await referenceInput.fill("MANUAL-REF-001");
await page.locator("#reg_1").fill("MANUAL1");
await expect(page.locator(".pos-selected-customer__title").filter({ hasText: /\(TEST\) Pleno/ }).first()).toBeVisible();
await expect(
page
.locator(".pos-selected-customer__title")
.filter({ hasText: /\(TEST\) Pleno/ })
.first()
).toBeVisible();
await expect(referenceInput).toHaveValue("MANUAL-REF-001");
await page.locator("#reg_1").fill("");
await expect(page.locator(".pos-selected-customer__title").filter({ hasText: /\(TEST\) Pleno/ }).first()).toBeVisible();
await expect(
page
.locator(".pos-selected-customer__title")
.filter({ hasText: /\(TEST\) Pleno/ })
.first()
).toBeVisible();
await expect(referenceInput).toHaveValue("MANUAL-REF-001");
await page.locator("#reg_1").fill("MANUAL2");
await expect(page.locator(".pos-selected-customer__title").filter({ hasText: /\(TEST\) Pleno/ }).first()).toBeVisible();
await expect(
page
.locator(".pos-selected-customer__title")
.filter({ hasText: /\(TEST\) Pleno/ })
.first()
).toBeVisible();
await expect(referenceInput).toHaveValue("MANUAL-REF-001");
});
@@ -1543,7 +1558,12 @@ test.describe("Admin POS Orders - desktop step 1 customer and vehicle ownership"
await activeConflictModal.getByTestId("pos-desktop-customer-conflict-keep").click();
await expect(activeConflictModal).toHaveCount(0);
await expect(page.locator(".pos-selected-customer__title").filter({ hasText: /\(TEST\) Pleno/ }).first()).toBeVisible();
await expect(
page
.locator(".pos-selected-customer__title")
.filter({ hasText: /\(TEST\) Pleno/ })
.first()
).toBeVisible();
await expect(page.locator("#reference")).toHaveValue("KEEP-REF");
await expect(page.locator("#reg_1")).toHaveValue("CONFLICT1");
@@ -1576,7 +1596,12 @@ test.describe("Admin POS Orders - desktop step 1 customer and vehicle ownership"
await activeConflictModal.getByTestId("pos-desktop-customer-conflict-use-vehicle").click();
await expect(activeConflictModal).toHaveCount(0);
await expect(page.locator(".pos-selected-customer__title").filter({ hasText: /\(TEST\) Conflict Fleet/ }).first()).toBeVisible();
await expect(
page
.locator(".pos-selected-customer__title")
.filter({ hasText: /\(TEST\) Conflict Fleet/ })
.first()
).toBeVisible();
await expect(page.locator("#reference")).toHaveValue("CONFLICT-VEHICLE-REF");
await expect(page.locator("#reg_1")).toHaveValue("CONFLICT1");
+4 -4
View File
@@ -417,7 +417,7 @@ test.describe("POS mobile order flow", () => {
}) => {
const fixture = createMobilePosFixture({
cvrSearchResponses: {
"41004355": {
41004355: {
data: {
vat: 41004355,
status: "Normal",
@@ -429,7 +429,7 @@ test.describe("POS mobile order flow", () => {
email: "mikkel@truckwash.dk",
},
},
"43423010": {
43423010: {
data: {
vat: 43423010,
status: "Normal",
@@ -491,7 +491,7 @@ test.describe("POS mobile order flow", () => {
test("add-customer popup ignores stale delayed CVR responses after a newer lookup resolves", async ({ page }) => {
const fixture = createMobilePosFixture({
cvrSearchResponses: {
"41004355": {
41004355: {
delayMs: 700,
data: {
vat: 41004355,
@@ -504,7 +504,7 @@ test.describe("POS mobile order flow", () => {
email: "mikkel@truckwash.dk",
},
},
"43423010": {
43423010: {
data: {
vat: 43423010,
status: "Normal",
+5 -3
View File
@@ -449,7 +449,7 @@ function buildDefaultFixture() {
],
});
const defaultCvrSearchResponses = {
"41004355": {
41004355: {
data: {
vat: 41004355,
status: "Normal",
@@ -461,7 +461,7 @@ function buildDefaultFixture() {
email: "mikkel@truckwash.dk",
},
},
"43423010": {
43423010: {
data: {
vat: 43423010,
status: "Normal",
@@ -691,7 +691,9 @@ function normalizeFixture(fixture) {
fixture.paymentIntentsByOrderId = mergeObjectMaps({}, fixture.paymentIntentsByOrderId);
fixture.bookingsById = mergeObjectMaps({}, fixture.bookingsById);
fixture.cvrSearchResponses = mergeObjectMaps({}, fixture.cvrSearchResponses);
fixture.customerRegistrationResponse = clone(fixture.customerRegistrationResponse || { status: 200, data: { success: true } });
fixture.customerRegistrationResponse = clone(
fixture.customerRegistrationResponse || { status: 200, data: { success: true } }
);
fixture.deletedOrderIds = Array.isArray(fixture.deletedOrderIds) ? fixture.deletedOrderIds : [];
fixture.markCompletedOrderIds = Array.isArray(fixture.markCompletedOrderIds) ? fixture.markCompletedOrderIds : [];