feat: online ordering settings (services, hours, preparation, slots) and the order app e2e (platform-v2 3S, S.4)
- connect_orders.ordering setting; GET/PUT /api/connect/fees/ordering (validated: services, hours per day incl. past midnight, preparation, slot minutes, days ahead, ASAP); pushed to the cloud with the menu (snapshot `ordering`). - Manager: the Online ordering page gains "Services and hours" (OrderingSettings.jsx; logic in feesLogic.js, unit-tested); nav label "Online ordering". - tests/e2e/order_app.mjs: a real cloud + the built order app in a phone-sized browser: takeaway and delivery placed, priced by the cloud (fee by area, minimum refused), the site moves the delivery to delivered and the page follows; a rejection with its reason; Greek. In run-all, with the order app's unit tests. - Tests: backend +1 (406), manager unit +1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -133,3 +133,21 @@ def test_changes_push_the_menu_soon():
|
||||
assert not menu_changed("GET", "/api/products/", 200)
|
||||
assert not menu_changed("POST", "/api/pricing/modifiers", 422)
|
||||
assert not menu_changed("POST", "/api/orders/1/items", 200)
|
||||
|
||||
|
||||
def test_online_ordering_settings(client, db, owner_h):
|
||||
"""S.4: the services, hours and timing the online ordering app follows (the cloud
|
||||
enforces them); off until the venue turns a service on."""
|
||||
from services.cloud_sync import menu_snapshot
|
||||
assert client.get("/api/connect/fees/ordering", headers=owner_h).json()["services"] == []
|
||||
body = {"services": ["delivery", "takeaway"], "hours": {"5": [["20:00", "02:00"]], "6": [["12:00", "16:00"], ["18:00", "23:00"]]},
|
||||
"prep_minutes": 30, "slot_minutes": 15, "days_ahead": 1, "asap": False}
|
||||
r = client.put("/api/connect/fees/ordering", headers=owner_h, json=body)
|
||||
assert r.status_code == 200, r.text
|
||||
assert r.json()["services"] == ["takeaway", "delivery"] # fixed order
|
||||
assert client.get("/api/connect/fees", headers=owner_h).json()["ordering"]["days_ahead"] == 1
|
||||
snap, _ = menu_snapshot(db)
|
||||
assert snap["ordering"]["hours"]["6"] == [["12:00", "16:00"], ["18:00", "23:00"]] and snap["ordering"]["asap"] is False
|
||||
for bad in ({"services": ["teleport"]}, {"hours": {"7": [["10:00", "11:00"]]}}, {"hours": {"1": [["10:00", "10:00"]]}},
|
||||
{"hours": {"1": [["25:00", "11:00"]]}}, {"slot_minutes": 1}, {"days_ahead": 30}, {"prep_minutes": -5}):
|
||||
assert client.put("/api/connect/fees/ordering", headers=owner_h, json=bad).status_code == 422, bad
|
||||
|
||||
Reference in New Issue
Block a user