From e0158b2c7239998444d778e682e26328660c8f86 Mon Sep 17 00:00:00 2001 From: bonamin Date: Wed, 18 Nov 2026 10:04:20 +0200 Subject: [PATCH] test(cloud): the public menu carries each product's allergens (contract C-2, platform-v2 step 6.3) The snapshot is stored as the site sends it, so `allergens` {key: contains | may_contain} reaches GET /api/menu/{site} for the QR menu and the order app without a cloud change. Co-Authored-By: Claude Opus 5.5 --- cloud_backend/tests/test_checkout.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cloud_backend/tests/test_checkout.py b/cloud_backend/tests/test_checkout.py index b2e402c..b54f08f 100644 --- a/cloud_backend/tests/test_checkout.py +++ b/cloud_backend/tests/test_checkout.py @@ -126,3 +126,17 @@ def test_order_numbers_per_site_and_tracking_by_token(client, admin_h): assert tj["lines"] == [{"name": "Cola 1.5L", "quantity": 2, "unit_price": 2.5, "options": []}] and tj["order_type"] == "takeaway" assert client.get("/api/orders/status/ORD-0001").status_code == 404 # ambiguous now assert client.get("/api/orders/track/nope").status_code == 404 + + +def test_the_public_menu_carries_each_products_allergens(client, admin_h): + """Plan step 6.3 (contract C-2): the site sends `allergens` {key: contains | may_contain} per + product; the public menu passes them to the QR menu and the order app as they are.""" + site = _new_site(client, admin_h) + numeric = _heartbeat(client, site)["site_numeric_id"] + snap = {"categories": [{"id": 1, "name": "All", "products": [ + {"id": PIE, "name": "Pie", "base_price": 5.0, "digital_price": 5.0, "digital_available": True, + "sold_at": ["qr_table"], "prices": {"qr_table": 5.0}, "quick_options": [], + "allergens": {"gluten": "contains", "sesame": "may_contain"}}]}], "ordering": ORDERING, "timezone": "Europe/Athens"} + assert client.post("/api/menu/sync", headers=_h(site), json={"site_id": numeric, "snapshot_json": json.dumps(snap)}).status_code == 200 + menu = client.get(f"/api/menu/{site['site_id']}").json() + assert menu["categories"][0]["products"][0]["allergens"] == {"gluten": "contains", "sesame": "may_contain"}