Format customer rule tests

This commit is contained in:
Jeppe B
2026-07-16 12:11:06 +02:00
parent 77a0c4e018
commit 20c383d22d
2 changed files with 18 additions and 8 deletions
+4 -1
View File
@@ -489,7 +489,10 @@ test("desktop remains fail-closed when an active product rule has a malformed re
await page.getByTestId("pos-product-card-53").first().click();
await expect(page.getByTestId("pos-add-to-cart-53").first()).toBeDisabled();
await page.getByTestId("pos-add-to-cart-53").first().evaluate((button) => button.click());
await page
.getByTestId("pos-add-to-cart-53")
.first()
.evaluate((button) => button.click());
expect(orderItemPosts).toEqual([]);
});
+14 -7
View File
@@ -71,14 +71,21 @@ describe("customer product rules", () => {
});
it("validates the structured exact-product contract for every active product-impact rule", () => {
expect(hasValidCustomerProductRestrictionContract([
attribute("restrictSpotFree", [23], [{ id: 7, name: "Rinses", product_ids: [23] }]),
{ attribute: "requiresReferenceNumber", product_restriction: null },
])).toBe(true);
expect(
hasValidCustomerProductRestrictionContract([
attribute("restrictSpotFree", [23], [{ id: 7, name: "Rinses", product_ids: [23] }]),
{ attribute: "requiresReferenceNumber", product_restriction: null },
])
).toBe(true);
expect(hasValidCustomerProductRestrictionContract([{ attribute: "restrictSpotFree" }])).toBe(false);
expect(hasValidCustomerProductRestrictionContract([
{ attribute: "restrictSpotFree", product_restriction: { version: 1, collections: [], disabled_product_ids: null } },
])).toBe(false);
expect(
hasValidCustomerProductRestrictionContract([
{
attribute: "restrictSpotFree",
product_restriction: { version: 1, collections: [], disabled_product_ids: null },
},
])
).toBe(false);
});
it("normalizes top-level and nested restriction response variants", () => {