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"}