feat(menu): the menu in English and Greek (platform-v2 step 6.4, D-29)
- products.translations / categories.translations (Alembic 0033, core/menu_languages.py: el + en,
name / description / quick options by their base name; catalog.translation). Empty = the text
as typed; no machine translation (owner).
- In the manager's product editor ("In English" / "In Greek", quick extras), the category dialog,
and a menu board's Language (signage MenuContent.language).
- Customer screens only: cloud snapshot names / descriptions per language (C-2), the menu tablet's
EL / EN switch the names (localize), signage boards; tickets, KDS, counter, phones keep the base.
- Catalogue bundles carry translations; @xenia/access menuLanguages.js (a backend test compares).
- e2e: manager (the other language saved), menu tablet (EN / EL names), QR table (English on
the menu, the base name on the kitchen's order, Greek page as typed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r
|
||||
| `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` |
|
||||
| `packages/api/` | Shared HTTP client (`createApiClient`: session/device headers, `err.xenia` codes, the manager-approval retry) and the live WebSocket client with cursor replay (`createLiveClient`, used by the waiter's `useWebSocket`) (CS-18) |
|
||||
| `packages/signage/` | `@xenia/signage` (5.6a): signage slides as the TVs draw them (`SlideView`, `TextSlide`, `MenuSlide`, `Widgets`) and the player's pure logic (schedule pick, slide windows, menu pages; tests in `tests/`), shared by the terminal's player and the manager's previews. Sizes are container units (`cqmin`): a slide needs a parent with `container-type: size` (`frameStyle()`; the manager's `SlidePreview` lays it out at 1920 × 1080 and scales it down, so previews match a TV). Both apps' Tailwind `content` include it |
|
||||
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (CS-18); the fixed lists every app shares with the backend: sales points (`salesPoints.js` = `core/sales_points.py`) and the 14 EU allergens (`allergens.js` = `core/allergens.py`, 6.3; tests compare them), and `<Allergens>` (a product's allergens, the same in every app). Plain-JS subpaths `@xenia/access/salesPoints`, `/allergens` for Node tests |
|
||||
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (CS-18); the fixed lists every app shares with the backend: sales points (`salesPoints.js` = `core/sales_points.py`) the 14 EU allergens (`allergens.js` = `core/allergens.py`, 6.3) and the menu's languages (`menuLanguages.js` = `core/menu_languages.py`, 6.4: el + en; a product's own name is its base text, translations in `products.translations` / `categories.translations` are for customer screens only; tests compare the lists), and `<Allergens>` (a product's allergens, the same in every app). Plain-JS subpaths `@xenia/access/salesPoints`, `/allergens` for Node tests |
|
||||
| `packages/i18n/` | Translations (`locales/<lang>/<ns>.json`), language resolution, venue-time / money / number formatting, the comma-or-dot number parser, and the guard `scripts/check-i18n.mjs` (CS-17). Sample: `/i18n-sample` (dev) |
|
||||
| `.dockerignore` | The frontend images build with **`client-services/` as context** (`-f waiter_pwa/Dockerfile .`), so this file decides what Docker sees. The backend still builds from `local_backend/`. |
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ CODES: dict[str, tuple[int, str]] = {
|
||||
"catalog.unknown_category": (422, "There is no category {category_id}."),
|
||||
"catalog.primary_not_listed": (422, "The main category ({category_id}) must be one of the product's categories."),
|
||||
"catalog.allergen": (422, "Unknown allergen or level: {allergen}."),
|
||||
"catalog.translation": (422, "The menu can't be translated like that: {what}."),
|
||||
# converted from HTTPException (plan step 6.1)
|
||||
"auth.password_current_required": (400, "Enter your current password to set a new one."),
|
||||
"auth.no_password": (400, "This account has no password yet."),
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
"""The menu in other languages (plan step 6.4, owner decisions 2026-11-18, D-29).
|
||||
|
||||
The menu's languages are English and Greek (fixed for now). A product's own name and
|
||||
description are its base text, in whatever language the venue typed them (usually the venue's
|
||||
language). Translations add the other language:
|
||||
|
||||
products.translations {"en": {"name": "…", "description": "…", "quick": {"<quick option's name>": "…"}}}
|
||||
categories.translations {"en": {"name": "…"}}
|
||||
|
||||
Quick options are kept by their base name (they are recreated on every product save, so ids
|
||||
change). A missing translation shows the base text, whatever its language — never Latin letters,
|
||||
never a machine translation (owner). Who sees translations: the customer-facing screens (QR menu,
|
||||
order app, menu tablet, signage menu boards). Tickets, the kitchen display, the counter and the
|
||||
waiters' phones keep the base text (the staff's).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
MENU_LANGUAGES: tuple[str, ...] = ("el", "en")
|
||||
PRODUCT_FIELDS = ("name", "description")
|
||||
|
||||
|
||||
def _load(value):
|
||||
if value in (None, "", {}):
|
||||
return {}
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
value = json.loads(value)
|
||||
except ValueError:
|
||||
return {}
|
||||
return value if isinstance(value, dict) else {}
|
||||
|
||||
|
||||
def _bad(what):
|
||||
from core.errors import XeniaError
|
||||
return XeniaError("catalog.translation", what=what)
|
||||
|
||||
|
||||
def normalize_product(value) -> dict:
|
||||
"""API input → the stored shape; empty texts dropped; unknown languages or fields refused."""
|
||||
data = _load(value)
|
||||
out = {}
|
||||
for lang, fields in data.items():
|
||||
if lang not in MENU_LANGUAGES or not isinstance(fields, dict):
|
||||
raise _bad(lang)
|
||||
clean = {}
|
||||
for k, v in fields.items():
|
||||
if k in PRODUCT_FIELDS:
|
||||
if v is not None and not isinstance(v, str):
|
||||
raise _bad(f"{lang}.{k}")
|
||||
if (v or "").strip():
|
||||
clean[k] = v.strip()
|
||||
elif k == "quick":
|
||||
if not isinstance(v, dict):
|
||||
raise _bad(f"{lang}.quick")
|
||||
quick = {str(base): str(text).strip() for base, text in v.items() if str(text or "").strip()}
|
||||
if quick:
|
||||
clean["quick"] = quick
|
||||
else:
|
||||
raise _bad(f"{lang}.{k}")
|
||||
if clean:
|
||||
out[lang] = clean
|
||||
return out
|
||||
|
||||
|
||||
def normalize_category(value) -> dict:
|
||||
data = _load(value)
|
||||
out = {}
|
||||
for lang, fields in data.items():
|
||||
if lang not in MENU_LANGUAGES or not isinstance(fields, dict) or set(fields) - {"name"}:
|
||||
raise _bad(lang)
|
||||
if (fields.get("name") or "").strip():
|
||||
out[lang] = {"name": fields["name"].strip()}
|
||||
return out
|
||||
|
||||
|
||||
def dump(data: dict) -> str | None:
|
||||
return json.dumps(data, ensure_ascii=False) if data else None
|
||||
|
||||
|
||||
def of(row) -> dict:
|
||||
"""A product's or category's stored translations, read safely."""
|
||||
return _load(getattr(row, "translations", None))
|
||||
|
||||
|
||||
def texts(base: str | None, translations: dict, field: str) -> dict:
|
||||
"""{language: text} for every menu language: the translation, else the base text."""
|
||||
return {lang: (translations.get(lang) or {}).get(field) or base for lang in MENU_LANGUAGES}
|
||||
|
||||
|
||||
def quick_texts(base: str, translations: dict) -> dict:
|
||||
return {lang: ((translations.get(lang) or {}).get("quick") or {}).get(base) or base for lang in MENU_LANGUAGES}
|
||||
|
||||
|
||||
def product_texts(product, customer: bool = True) -> dict:
|
||||
"""{"names": {lang: …}, "descriptions": {lang: …}} for a customer-facing screen. `customer`:
|
||||
the customer apps' own name / description (digital_*) are the base when set."""
|
||||
tr = of(product)
|
||||
name = (product.digital_name if customer else None) or product.name
|
||||
desc = (product.digital_description if customer else None) or product.description
|
||||
return {"names": texts(name, tr, "name"), "descriptions": texts(desc or None, tr, "description")}
|
||||
@@ -0,0 +1,26 @@
|
||||
"""The menu in other languages (plan step 6.4, core/menu_languages.py): a product's and a
|
||||
category's translations as JSON {language: {field: text}}; null = none.
|
||||
|
||||
Revision ID: 0033_menu_translations
|
||||
Revises: 0032_product_allergens
|
||||
Create Date: 2026-11-18 15:00:00
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = '0033_menu_translations'
|
||||
down_revision = '0032_product_allergens'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
for table in ('products', 'categories'):
|
||||
with op.batch_alter_table(table, schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('translations', sa.Text(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
for table in ('products', 'categories'):
|
||||
with op.batch_alter_table(table, schema=None) as batch_op:
|
||||
batch_op.drop_column('translations')
|
||||
@@ -22,6 +22,8 @@ class Category(Base):
|
||||
# Its picture in the media library (plan step 5.2); the library refuses to delete it while set
|
||||
media_id = Column(Integer, ForeignKey("media.id", ondelete="SET NULL"), nullable=True, index=True)
|
||||
media = relationship("Media", lazy="joined")
|
||||
# The menu in other languages (plan step 6.4, core/menu_languages.py): {"en": {"name": "…"}}
|
||||
translations = Column(Text, nullable=True)
|
||||
|
||||
@property
|
||||
def image(self):
|
||||
@@ -88,6 +90,9 @@ class Product(Base):
|
||||
tags = Column(Text, nullable=True)
|
||||
# The EU allergens it has (plan step 6.3, core/allergens.py): JSON {key: "contains" | "may_contain"}
|
||||
allergens = Column(Text, nullable=True)
|
||||
# The menu in other languages (plan step 6.4, core/menu_languages.py):
|
||||
# {"en": {"name": "…", "description": "…", "quick": {"<quick option>": "…"}}}
|
||||
translations = Column(Text, nullable=True)
|
||||
|
||||
# Fiscal printer (ΦΗΜ) fields
|
||||
fiscal_name = Column(String, nullable=True) # short name for receipt (falls back to name)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from core.timeutil import venue_date, utcnow
|
||||
import json
|
||||
from core import allergens, sales_points
|
||||
from core import allergens, menu_languages, sales_points
|
||||
from datetime import datetime, timezone
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi.responses import JSONResponse
|
||||
@@ -61,6 +61,7 @@ def _serialize_product(p: Product) -> dict:
|
||||
"lifecycle_status": p.lifecycle_status, "sort_order": p.sort_order,
|
||||
"sold_at": sales_points.sold_at(p),
|
||||
"allergens": allergens.of(p),
|
||||
"translations": menu_languages.of(p),
|
||||
"quick_options": quick_options, "options": options,
|
||||
"ingredients": ingredients, "preference_sets": preference_sets,
|
||||
}
|
||||
@@ -77,6 +78,7 @@ def _serialize_category(cat: Category) -> dict:
|
||||
"name": cat.name, "color": cat.color, "sort_order": cat.sort_order,
|
||||
"parent_name": cat.parent.name if cat.parent else None,
|
||||
"general_sort_order": cat.general_sort_order, "auto_expanded": cat.auto_expanded,
|
||||
"translations": menu_languages.of(cat),
|
||||
"products": products,
|
||||
}
|
||||
|
||||
@@ -165,6 +167,8 @@ def import_catalog(payload: dict, db: Session = Depends(get_db), user: User = De
|
||||
existing.sort_order = cat_data.get("sort_order", 0)
|
||||
existing.general_sort_order = cat_data.get("general_sort_order", 0)
|
||||
existing.auto_expanded = cat_data.get("auto_expanded", False)
|
||||
if "translations" in cat_data: # 6.4; older bundles: unchanged
|
||||
existing.translations = menu_languages.dump(menu_languages.normalize_category(cat_data["translations"]))
|
||||
db.flush()
|
||||
return existing
|
||||
else:
|
||||
@@ -175,6 +179,7 @@ def import_catalog(payload: dict, db: Session = Depends(get_db), user: User = De
|
||||
parent_id=parent_id,
|
||||
general_sort_order=cat_data.get("general_sort_order", 0),
|
||||
auto_expanded=cat_data.get("auto_expanded", False),
|
||||
translations=menu_languages.dump(menu_languages.normalize_category(cat_data.get("translations"))),
|
||||
)
|
||||
db.add(cat)
|
||||
db.flush()
|
||||
@@ -191,6 +196,8 @@ def import_catalog(payload: dict, db: Session = Depends(get_db), user: User = De
|
||||
existing.sold_at = sales_points.dump(prod_data["sold_at"])
|
||||
if "allergens" in prod_data: # 6.3; older bundles: unchanged
|
||||
existing.allergens = allergens.dump(prod_data["allergens"])
|
||||
if "translations" in prod_data: # 6.4
|
||||
existing.translations = menu_languages.dump(menu_languages.normalize_product(prod_data["translations"]))
|
||||
db.flush()
|
||||
product = existing
|
||||
else:
|
||||
@@ -202,6 +209,7 @@ def import_catalog(payload: dict, db: Session = Depends(get_db), user: User = De
|
||||
sort_order=prod_data.get("sort_order", 0),
|
||||
sold_at=sales_points.dump(prod_data.get("sold_at", sales_points.ALL)),
|
||||
allergens=allergens.dump(prod_data.get("allergens")),
|
||||
translations=menu_languages.dump(menu_languages.normalize_product(prod_data.get("translations"))),
|
||||
)
|
||||
db.add(product)
|
||||
db.flush()
|
||||
|
||||
@@ -26,7 +26,7 @@ import time
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from core import allergens, sales_points
|
||||
from core import allergens, menu_languages, sales_points
|
||||
from core.access.deps import require_device
|
||||
from core.errors import XeniaError
|
||||
from database import get_db
|
||||
@@ -112,7 +112,8 @@ def menu(db: Session = Depends(get_db), dev=Depends(require_device("menu_tablet"
|
||||
ids = in_cat.get(c.id, [])
|
||||
has_sub = any(in_cat.get(x.id) for x in by_parent.get(c.id, []))
|
||||
if ids or has_sub:
|
||||
out_cats.append({"id": c.id, "name": c.name, "parent_id": c.parent_id, "depth": depth, "products": ids})
|
||||
out_cats.append({"id": c.id, "name": c.name, "names": menu_languages.texts(c.name, menu_languages.of(c), "name"),
|
||||
"parent_id": c.parent_id, "depth": depth, "products": ids})
|
||||
used.update(ids)
|
||||
shown = [by_id[i] for i in by_id if i in used]
|
||||
prices = dict(zip([p.id for p in shown], unit_prices(db, shown, point))) if point and shown else {}
|
||||
@@ -124,7 +125,7 @@ def menu(db: Session = Depends(get_db), dev=Depends(require_device("menu_tablet"
|
||||
"config": cfg,
|
||||
"categories": out_cats,
|
||||
"products": {str(p.id): {"id": p.id, "name": p.name, "description": p.description or None, "tags": _tags(p),
|
||||
"allergens": allergens.of(p),
|
||||
"allergens": allergens.of(p), **menu_languages.product_texts(p, customer=False),
|
||||
"price": round(prices[p.id], 2) if p.id in prices else None, "available": bool(p.is_available),
|
||||
"image": media_store.image_of(p.media)} for p in shown},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from core import allergens, sales_points
|
||||
from core import allergens, menu_languages, sales_points
|
||||
from database import get_db
|
||||
from models.product import Product, Category, ProductCategory, ProductOption, ProductQuickOption, ProductIngredient, ProductPreferenceSet, ProductPreferenceChoice, ProductModifierGroup
|
||||
from models.prep_zone import PrepZone
|
||||
@@ -192,6 +192,7 @@ def create_category(body: CategoryCreate, db: Session = Depends(get_db), user: U
|
||||
parent_id=body.parent_id,
|
||||
general_sort_order=body.general_sort_order,
|
||||
media_id=_picture(db, body.media_id),
|
||||
translations=menu_languages.dump(menu_languages.normalize_category(body.translations)),
|
||||
)
|
||||
db.add(cat)
|
||||
db.commit()
|
||||
@@ -267,8 +268,10 @@ def update_category(category_id: int, body: CategoryUpdate, db: Session = Depend
|
||||
cat = db.query(Category).filter(Category.id == category_id).first()
|
||||
if not cat:
|
||||
raise XeniaError("catalog.category_not_found")
|
||||
for field, value in body.model_dump(exclude_none=True, exclude={"media_id"}).items():
|
||||
for field, value in body.model_dump(exclude_none=True, exclude={"media_id", "translations"}).items():
|
||||
setattr(cat, field, value)
|
||||
if body.translations is not None:
|
||||
cat.translations = menu_languages.dump(menu_languages.normalize_category(body.translations))
|
||||
if "media_id" in body.model_fields_set:
|
||||
cat.media_id = _picture(db, body.media_id)
|
||||
db.commit()
|
||||
@@ -369,13 +372,14 @@ def reorder_products(items: List[ProductReorderItem], db: Session = Depends(get_
|
||||
@router.post("/", response_model=ProductOut, status_code=status.HTTP_201_CREATED)
|
||||
def create_product(body: ProductCreate, db: Session = Depends(get_db), user: User = Depends(require_menu_manager)):
|
||||
data = body.model_dump(exclude={"quick_options", "options", "ingredients", "preference_sets", "cost_breakdown", "prep_zone_ids", "tags",
|
||||
"category_id", "primary_category_id", "category_ids", "allergens"})
|
||||
"category_id", "primary_category_id", "category_ids", "allergens", "translations"})
|
||||
if data.get("sort_order") == 0:
|
||||
data["sort_order"] = db.query(Product).count()
|
||||
if body.cost_breakdown is not None:
|
||||
data["cost_breakdown"] = json.dumps([item.model_dump() for item in body.cost_breakdown])
|
||||
data["tags"] = json.dumps(body.tags) if body.tags is not None else None
|
||||
data["allergens"] = allergens.dump(body.allergens)
|
||||
data["translations"] = menu_languages.dump(menu_languages.normalize_product(body.translations))
|
||||
data["sold_at"] = sales_points.dump(body.sold_at)
|
||||
data["media_id"] = _picture(db, body.media_id)
|
||||
product = Product(**data)
|
||||
@@ -433,7 +437,7 @@ def update_product(product_id: int, body: ProductUpdate, db: Session = Depends(g
|
||||
scalar_fields = body.model_dump(
|
||||
exclude_none=True,
|
||||
exclude={"quick_options", "options", "ingredients", "preference_sets", "cost_breakdown", "prep_zone_ids", "tags", "modifier_groups",
|
||||
"category_id", "primary_category_id", "category_ids", "media_id", "allergens"},
|
||||
"category_id", "primary_category_id", "category_ids", "media_id", "allergens", "translations"},
|
||||
)
|
||||
if "media_id" in body.model_fields_set:
|
||||
product.media_id = _picture(db, body.media_id)
|
||||
@@ -457,6 +461,8 @@ def update_product(product_id: int, body: ProductUpdate, db: Session = Depends(g
|
||||
product.tags = None
|
||||
if body.allergens is not None:
|
||||
product.allergens = allergens.dump(body.allergens)
|
||||
if body.translations is not None:
|
||||
product.translations = menu_languages.dump(menu_languages.normalize_product(body.translations))
|
||||
if body.quick_options is not None:
|
||||
_replace_quick_options(db, product, body.quick_options)
|
||||
# Modifier groups must be recreated before items so we have the ID map
|
||||
|
||||
@@ -140,6 +140,7 @@ class MenuContent(_Strict):
|
||||
show_descriptions: bool = False
|
||||
badges: Dict[str, Badge] = Field(default_factory=dict) # product id → badge
|
||||
sold_out: Literal["strike", "hide"] = "strike"
|
||||
language: Optional[Literal["el", "en"]] = None # 6.4: the menu's language on this board; None = as typed
|
||||
# how it's laid out (the player pages through what doesn't fit, 5.5b)
|
||||
columns: int = Field(default=2, ge=1, le=3)
|
||||
page_size: Optional[int] = Field(default=None, ge=3, le=60) # items per page; None = as many as fit
|
||||
|
||||
@@ -4,6 +4,7 @@ from typing import Optional, List, Any, Literal, Dict
|
||||
|
||||
from core.sales_points import ALL as _SALES_POINTS, sold_at as _sold_at
|
||||
from core.allergens import of as _allergens_of
|
||||
from core.menu_languages import of as _menu_tr_of, _load as _menu_tr
|
||||
|
||||
SalesPoint = Literal["in_store", "in_store_takeaway", "qr_table", "online_takeaway", "online_delivery", "online_preorder"]
|
||||
|
||||
@@ -16,6 +17,7 @@ class CategoryCreate(BaseModel):
|
||||
general_sort_order: int = 0
|
||||
auto_expanded: bool = False
|
||||
media_id: Optional[int] = None # its picture in the media library (5.2)
|
||||
translations: Dict[str, Dict[str, str]] = {} # 6.4: {"en": {"name": "…"}}
|
||||
|
||||
|
||||
class CategoryUpdate(BaseModel):
|
||||
@@ -26,6 +28,7 @@ class CategoryUpdate(BaseModel):
|
||||
general_sort_order: Optional[int] = None
|
||||
auto_expanded: Optional[bool] = None
|
||||
media_id: Optional[int] = None # null clears it (sent explicitly)
|
||||
translations: Optional[Dict[str, Dict[str, str]]] = None # None = unchanged
|
||||
|
||||
|
||||
class CategoryOut(BaseModel):
|
||||
@@ -38,9 +41,15 @@ class CategoryOut(BaseModel):
|
||||
auto_expanded: bool = False
|
||||
media_id: Optional[int] = None
|
||||
image: Optional[dict] = None # {id, name, thumb, card, full} (services/media.image_of)
|
||||
translations: Dict[str, Dict[str, str]] = {}
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
@field_validator("translations", mode="before")
|
||||
@classmethod
|
||||
def _tr(cls, v):
|
||||
return _menu_tr(v)
|
||||
|
||||
|
||||
class CategoryReparentRequest(BaseModel):
|
||||
parent_id: Optional[int] = None
|
||||
@@ -349,6 +358,8 @@ class ProductBase(BaseModel):
|
||||
tags: Optional[List[str]] = None
|
||||
# The EU allergens (plan step 6.3): {key: "contains" | "may_contain"}, core/allergens.py
|
||||
allergens: Dict[str, str] = {}
|
||||
# The menu in other languages (6.4, core/menu_languages.py)
|
||||
translations: Dict[str, Dict[str, Any]] = {}
|
||||
# Service item flag
|
||||
is_service_item: bool = False
|
||||
# Fiscal printer (ΦΗΜ)
|
||||
@@ -397,6 +408,7 @@ class ProductUpdate(BaseModel):
|
||||
# Tags
|
||||
tags: Optional[List[str]] = None
|
||||
allergens: Optional[Dict[str, str]] = None # None = unchanged, {} = none
|
||||
translations: Optional[Dict[str, Dict[str, Any]]] = None # None = unchanged, {} = none
|
||||
# Service item flag
|
||||
is_service_item: Optional[bool] = None
|
||||
# Fiscal printer (ΦΗΜ)
|
||||
@@ -468,6 +480,7 @@ class ProductOut(ProductBase):
|
||||
'quick_add_enabled': getattr(data, 'quick_add_enabled', True),
|
||||
'tags': json.loads(data.tags) if isinstance(getattr(data, 'tags', None), str) else (getattr(data, 'tags', None) or []),
|
||||
'allergens': _allergens_of(data),
|
||||
'translations': _menu_tr_of(data),
|
||||
'is_service_item': bool(getattr(data, 'is_service_item', False)),
|
||||
'fiscal_name': getattr(data, 'fiscal_name', None),
|
||||
'fiscal_vat_group_id': getattr(data, 'fiscal_vat_group_id', None),
|
||||
|
||||
@@ -11,7 +11,7 @@ Lock behaviour (unchanged):
|
||||
- cloud sets locked=true → lock_pending while a workday is open, locked once it closes
|
||||
- expiry past grace / site deactivated → likewise never mid-service
|
||||
"""
|
||||
from core import allergens, sales_points
|
||||
from core import allergens, menu_languages, sales_points
|
||||
from core.access.queries import holders_filter
|
||||
from core.timeutil import utcnow
|
||||
import asyncio
|
||||
@@ -288,11 +288,14 @@ def menu_snapshot(db) -> tuple[dict, list]:
|
||||
"digital_available": bool(p.digital_available),
|
||||
"digital_image_url": p.digital_image_url,
|
||||
"image_url": p.image_url,
|
||||
"quick_options": [{"id": o.id, "name": o.name, "price": o.price} for o in p.quick_options],
|
||||
"quick_options": [{"id": o.id, "name": o.name, "price": o.price,
|
||||
"names": menu_languages.quick_texts(o.name, menu_languages.of(p))} for o in p.quick_options],
|
||||
"allergens": allergens.of(p), # 6.3: {key: "contains" | "may_contain"}
|
||||
**menu_languages.product_texts(p), # 6.4: names / descriptions {language: text}
|
||||
})
|
||||
if product_list:
|
||||
payload_categories.append({"id": cat.id, "name": cat.name, "sort_order": cat.sort_order,
|
||||
"names": menu_languages.texts(cat.name, menu_languages.of(cat), "name"),
|
||||
"products": product_list})
|
||||
# delivery areas and fee rules (S.3): the cloud applies them at checkout with the same
|
||||
# engine (services/fees.py); the venue's time zone says what "22:00" and "Saturday" mean
|
||||
|
||||
@@ -15,7 +15,7 @@ counter's: listed ids first in that order, the rest after them in the catalogue'
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from core import sales_points
|
||||
from core import menu_languages, sales_points
|
||||
|
||||
|
||||
def _descendants(cats_by_parent: dict, roots: list[int]) -> set[int]:
|
||||
@@ -78,10 +78,15 @@ def resolve(db, content: dict, now=None) -> dict:
|
||||
prices = dict(zip([p.id for p in products], unit_prices(db, products, point, now=now))) if point and products else {}
|
||||
badges = {int(k): v for k, v in (content.get("badges") or {}).items() if str(k).isdigit()}
|
||||
|
||||
lang = content.get("language") # 6.4: the board's language; None = the base texts
|
||||
|
||||
def text(row, base, field):
|
||||
return menu_languages.texts(base, menu_languages.of(row), field).get(lang, base) if lang else base
|
||||
|
||||
def item(p):
|
||||
image = media_store.image_of(p.media) if content.get("show_photos") else None
|
||||
return {"id": p.id, "name": p.digital_name or p.name,
|
||||
"description": (p.digital_description or p.description or None) if content.get("show_descriptions") else None,
|
||||
return {"id": p.id, "name": text(p, p.digital_name or p.name, "name"),
|
||||
"description": text(p, p.digital_description or p.description or None, "description") if content.get("show_descriptions") else None,
|
||||
"price": round(prices[p.id], 2) if p.id in prices else None,
|
||||
"available": bool(p.is_available), "image": image["card"] if image else None,
|
||||
"badge": badges.get(p.id)}
|
||||
@@ -90,7 +95,7 @@ def resolve(db, content: dict, now=None) -> dict:
|
||||
groups: dict = {}
|
||||
for p in products:
|
||||
groups.setdefault(p.primary_category_id, []).append(p)
|
||||
out = [{"category": {"id": cid, "name": by_id[cid].name} if cid in by_id else None,
|
||||
out = [{"category": {"id": cid, "name": text(by_id[cid], by_id[cid].name, "name")} if cid in by_id else None,
|
||||
"items": [item(p) for p in sorted(ps, key=prod_key)]}
|
||||
for cid, ps in sorted(groups.items(), key=lambda kv: cat_key(kv[0]))]
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
"""The menu in English and Greek (plan step 6.4, owner 2026-11-18): translations of product names,
|
||||
descriptions, quick options and category names; a missing one shows the base text. Customer
|
||||
screens use them (cloud menu, menu tablet, signage boards); tickets and staff screens don't."""
|
||||
from tests.test_live import err, owner_h, pair # noqa: F401 (fixtures)
|
||||
from tests.test_menu_tablet import menu, tablet # noqa: F401 (fixtures)
|
||||
|
||||
EN = {"en": {"name": "Pork souvlaki", "description": "On a skewer", "quick": {"Pita": "Pitta bread"}}}
|
||||
|
||||
|
||||
def test_translations_are_stored_cleaned_and_validated(client, owner_h, menu):
|
||||
pid = menu["souvlaki"].id
|
||||
r = client.put(f"/api/products/{pid}", headers=owner_h, json={"translations": {"en": {"name": " Pork souvlaki ", "description": ""}}})
|
||||
assert r.status_code == 200, r.text
|
||||
assert r.json()["translations"] == {"en": {"name": "Pork souvlaki"}} # trimmed, empty dropped
|
||||
assert client.put(f"/api/products/{pid}", headers=owner_h, json={"base_price": 4}).json()["translations"]["en"]["name"] == "Pork souvlaki"
|
||||
for bad in ({"fr": {"name": "x"}}, {"en": {"colour": "x"}}, {"en": {"quick": ["x"]}}):
|
||||
r = client.put(f"/api/products/{pid}", headers=owner_h, json={"translations": bad})
|
||||
assert r.status_code == 422 and err(r) == "catalog.translation", bad
|
||||
cat = menu["cats"]["grill"]
|
||||
r = client.put(f"/api/products/categories/{cat}", headers=owner_h, json={"translations": {"en": {"name": "From the grill"}}})
|
||||
assert r.status_code == 200 and r.json()["translations"] == {"en": {"name": "From the grill"}}
|
||||
assert client.put(f"/api/products/categories/{cat}", headers=owner_h, json={"translations": {"en": {"title": "x"}}}).status_code == 422
|
||||
|
||||
|
||||
def test_the_tablet_switches_names_and_falls_back_to_the_base(client, owner_h, menu, tablet):
|
||||
client.put(f"/api/products/{menu['souvlaki'].id}", headers=owner_h, json={"translations": EN})
|
||||
client.put(f"/api/products/categories/{menu['cats']['grill']}", headers=owner_h, json={"translations": {"en": {"name": "Grill (en)"}}})
|
||||
data = client.get("/api/menu-tablet/menu", headers=tablet["h"]).json()
|
||||
souv = data["products"][str(menu["souvlaki"].id)]
|
||||
assert souv["names"] == {"el": "Souvlaki", "en": "Pork souvlaki"} and souv["name"] == "Souvlaki"
|
||||
assert souv["descriptions"]["en"] == "On a skewer"
|
||||
steak = data["products"][str(menu["steak"].id)]
|
||||
assert steak["names"] == {"el": "Steak", "en": "Steak"} # not translated: the base name
|
||||
grill = next(c for c in data["categories"] if c["id"] == menu["cats"]["grill"])
|
||||
assert grill["names"] == {"el": "Grill", "en": "Grill (en)"}
|
||||
|
||||
|
||||
def test_the_cloud_menu_carries_names_per_language(client, db, owner_h, menu):
|
||||
from models.product import ProductQuickOption
|
||||
db.add(ProductQuickOption(product_id=menu["souvlaki"].id, name="Pita", price=0.5))
|
||||
db.commit()
|
||||
client.put(f"/api/products/{menu['souvlaki'].id}", headers=owner_h, json={"translations": EN})
|
||||
from services.cloud_sync import menu_snapshot
|
||||
snap, _ = menu_snapshot(db)
|
||||
grill = next(c for c in snap["categories"] if c["id"] == menu["cats"]["grill"])
|
||||
souv = next(p for p in grill["products"] if p["id"] == menu["souvlaki"].id)
|
||||
assert souv["names"] == {"el": "Souvlaki", "en": "Pork souvlaki"} and souv["name"] == "Souvlaki"
|
||||
assert souv["quick_options"][0]["names"] == {"el": "Pita", "en": "Pitta bread"}
|
||||
assert grill["names"] == {"el": "Grill", "en": "Grill"}
|
||||
|
||||
|
||||
def test_a_board_in_english_and_tickets_stay_in_the_base(client, db, owner_h, menu):
|
||||
client.put(f"/api/products/{menu['souvlaki'].id}", headers=owner_h, json={"translations": EN})
|
||||
from services.signage_menu import resolve
|
||||
names = lambda lang: [i["name"] for g in resolve(db, {"select": "all", "language": lang})["groups"] for i in g["items"]] # noqa: E731
|
||||
assert "Pork souvlaki" in names("en") and "Souvlaki" not in names("en")
|
||||
assert "Souvlaki" in names(None) and "Souvlaki" in names("el")
|
||||
# what the staff see (phones, counter): the base name
|
||||
assert next(p for p in client.get("/api/products/", headers=owner_h).json() if p["id"] == menu["souvlaki"].id)["name"] == "Souvlaki"
|
||||
|
||||
|
||||
def test_catalogue_bundle_keeps_translations(client, db, owner_h, menu):
|
||||
client.put(f"/api/products/{menu['beer'].id}", headers=owner_h, json={"translations": {"en": {"name": "Lager"}}})
|
||||
client.put(f"/api/products/categories/{menu['cats']['drinks']}", headers=owner_h, json={"translations": {"en": {"name": "Drinks (en)"}}})
|
||||
bundle = client.get("/api/data-transfer/export/catalog", headers=owner_h).json()
|
||||
client.put(f"/api/products/{menu['beer'].id}", headers=owner_h, json={"translations": {}})
|
||||
client.put(f"/api/products/categories/{menu['cats']['drinks']}", headers=owner_h, json={"translations": {}})
|
||||
assert client.post("/api/data-transfer/import/catalog", headers=owner_h, json=bundle).status_code < 300
|
||||
db.expire_all()
|
||||
from core.menu_languages import of
|
||||
from models.product import Category, Product
|
||||
assert of(db.get(Product, menu["beer"].id)) == {"en": {"name": "Lager"}}
|
||||
assert of(db.get(Category, menu["cats"]["drinks"])) == {"en": {"name": "Drinks (en)"}}
|
||||
|
||||
|
||||
|
||||
def test_the_frontend_list_matches_the_backend():
|
||||
"""packages/access/src/menuLanguages.js keeps the same languages."""
|
||||
import re
|
||||
from pathlib import Path
|
||||
from core.menu_languages import MENU_LANGUAGES
|
||||
js = (Path(__file__).resolve().parents[2] / "packages" / "access" / "src" / "menuLanguages.js").read_text(encoding="utf-8")
|
||||
listed = re.search(r"export const MENU_LANGUAGES = \[([^\]]*)\]", js).group(1)
|
||||
assert [x.strip().strip("'") for x in listed.split(",") if x.strip()] == list(MENU_LANGUAGES)
|
||||
@@ -2,6 +2,7 @@
|
||||
// (top level or under another category).
|
||||
import { useState } from 'react'
|
||||
import { Check } from 'lucide-react'
|
||||
import { translatedLanguages, useAccess } from '@xenia/access'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Field, Input, Select, cx } from '@xenia/ui'
|
||||
import MediaField from '../media/MediaField'
|
||||
@@ -13,16 +14,25 @@ export default function CategoryDialog({ category, parentName, saving, onSave, o
|
||||
const [name, setName] = useState(category.name ?? '')
|
||||
const [color, setColor] = useState(category.color ?? CATEGORY_COLOURS[0])
|
||||
const [image, setImage] = useState(category.image ?? null)
|
||||
const { venue } = useAccess()
|
||||
const others = translatedLanguages(venue?.language)
|
||||
const [tr, setTr] = useState(() => Object.fromEntries(others.map(l => [l, category.translations?.[l]?.name ?? ''])))
|
||||
const sub = !!category.parent_id
|
||||
const title = t(`products.category.${category.id ? 'edit' : 'new'}${sub ? 'Sub' : ''}`)
|
||||
return (
|
||||
<Dialog open size="sm" onClose={onClose} title={title} description={sub && parentName ? t('products.category.under', { name: parentName }) : undefined}
|
||||
footer={<>
|
||||
<Button variant="secondary" onClick={onClose}>{t('products.cancel')}</Button>
|
||||
<Button disabled={!name.trim()} loading={saving} onClick={() => onSave({ name: name.trim(), color, media_id: image?.id ?? null })} data-testid="category-save">{t('products.save')}</Button>
|
||||
<Button disabled={!name.trim()} loading={saving} onClick={() => onSave({ name: name.trim(), color, media_id: image?.id ?? null,
|
||||
translations: Object.fromEntries(Object.entries(tr).filter(([, v]) => v.trim()).map(([l, v]) => [l, { name: v.trim() }])) })} data-testid="category-save">{t('products.save')}</Button>
|
||||
</>}>
|
||||
<div className="grid gap-4">
|
||||
<Field label={t('products.category.name')}><Input value={name} onChange={e => setName(e.target.value)} autoFocus data-testid="category-name" /></Field>
|
||||
{others.map(l => (
|
||||
<Field key={l} label={t('products.editor.inLanguage', { language: t(`products.editor.lang.${l}`) })} hint={t('products.editor.trNameHint')}>
|
||||
<Input value={tr[l] ?? ''} onChange={e => setTr(s => ({ ...s, [l]: e.target.value }))} placeholder={name} data-testid={`category-name-${l}`} />
|
||||
</Field>
|
||||
))}
|
||||
<MediaField value={image} onChange={setImage} nameAfter={name} nameAfterLabel={t('media.nameAfterCategory')} label={t('media.photo')} testid="category-photo" />
|
||||
<div className="grid gap-2">
|
||||
<span className="text-label font-semibold text-ink">{t('products.category.colour')}</span>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// shared sub-set shown for every choice except those marked to hide it
|
||||
import { useRef, useState } from 'react'
|
||||
import { Heart, Plus, Trash2 } from 'lucide-react'
|
||||
import { translatedLanguages, useAccess } from '@xenia/access'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, EmptyState, IconButton, Input, Select, cx } from '@xenia/ui'
|
||||
import { favourites, moveChoice, moveFavourite, moveItem, removeChoice, removeGroup, setSub, toggleFavourite } from './formLogic'
|
||||
@@ -96,8 +97,10 @@ function Favourites({ form, setForm }) {
|
||||
|
||||
function QuickList({ form, setForm }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const { venue } = useAccess()
|
||||
const others = translatedLanguages(venue?.language)
|
||||
const set = (i, k, v) => setForm(f => ({ ...f, quick_options: f.quick_options.map((q, j) => (j === i ? { ...q, [k]: v } : q)) }))
|
||||
const add = () => setForm(f => ({ ...f, quick_options: [...f.quick_options, { name: '', price: 0, allow_multiple: false, is_favorite: false, favorite_sort_order: 0, is_compact: false }] }))
|
||||
const add = () => setForm(f => ({ ...f, quick_options: [...f.quick_options, { name: '', price: 0, allow_multiple: false, is_favorite: false, favorite_sort_order: 0, is_compact: false, tr: {} }] }))
|
||||
return (
|
||||
<div>
|
||||
<Intro text={t('products.editor.quickHint')}><Button size="sm" variant="secondary" icon={<Plus size={14} />} onClick={add}>{t('products.editor.addQuick')}</Button></Intro>
|
||||
@@ -109,6 +112,10 @@ function QuickList({ form, setForm }) {
|
||||
onUp={() => setForm(f => ({ ...f, quick_options: moveItem(f.quick_options, i, -1) }))} onDown={() => setForm(f => ({ ...f, quick_options: moveItem(f.quick_options, i, 1) }))} />
|
||||
<FavouriteToggle on={q.is_favorite} onClick={() => setForm(f => toggleFavourite(f, 'quick', i))} />
|
||||
<Input className="flex-1 min-w-36" value={q.name} onChange={e => set(i, 'name', e.target.value)} placeholder={t('products.editor.quickPlaceholder')} />
|
||||
{others.map(l => (
|
||||
<Input key={l} className="flex-1 min-w-32" value={q.tr?.[l] ?? ''} onChange={e => set(i, 'tr', { ...(q.tr ?? {}), [l]: e.target.value })}
|
||||
placeholder={t('products.editor.inLanguageShort', { language: t(`products.editor.lang.${l}`) })} aria-label={t('products.editor.inLanguageShort', { language: t(`products.editor.lang.${l}`) })} />
|
||||
))}
|
||||
<PriceInput className="w-32" value={q.price} onChange={v => set(i, 'price', v)} label={t('products.editor.extraCost')} />
|
||||
<Check checked={q.allow_multiple} onChange={v => set(i, 'allow_multiple', v)}>{t('products.editor.multiple')}</Check>
|
||||
<Check checked={q.is_compact} onChange={v => set(i, 'is_compact', v)}>{t('products.editor.compact')}</Check>
|
||||
|
||||
@@ -4,18 +4,20 @@
|
||||
import { useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Plus, Trash2, X } from 'lucide-react'
|
||||
import { SALES_POINTS } from '@xenia/access'
|
||||
import { SALES_POINTS, translatedLanguages, useAccess } from '@xenia/access'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Field, IconButton, InfoTip, Input, Select, Switch, Textarea, cx } from '@xenia/ui'
|
||||
import MediaField from '../../media/MediaField'
|
||||
import { costOf } from '../productsLogic'
|
||||
import { AllergensField, CategoriesField } from './Fields'
|
||||
import { UNITS, WEIGHED, cleanTag } from './formLogic'
|
||||
import { UNITS, WEIGHED, cleanTag, setTranslation } from './formLogic'
|
||||
import { Check, PriceInput } from './parts'
|
||||
|
||||
export function InfoTab({ form, set, setForm, categories, prepZones }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const { venue } = useAccess()
|
||||
const service = form.is_service_item
|
||||
const others = translatedLanguages(venue?.language)
|
||||
return (
|
||||
<div className="grid gap-4">
|
||||
<Switch checked={service} onChange={v => set('is_service_item', v)} label={t('products.editor.serviceItem')}
|
||||
@@ -29,6 +31,20 @@ export function InfoTab({ form, set, setForm, categories, prepZones }) {
|
||||
<Textarea rows={3} value={form.description} onChange={e => set('description', e.target.value)} />
|
||||
</Field>
|
||||
)}
|
||||
{!service && others.map(l => (
|
||||
<section key={l} className="grid gap-3 rounded-card border border-line bg-surface p-3" data-testid={`translation-${l}`}>
|
||||
<span className="flex items-center gap-1 text-label font-semibold text-ink">
|
||||
{t('products.editor.inLanguage', { language: t(`products.editor.lang.${l}`) })}
|
||||
<InfoTip>{t('products.editor.translationTip')}</InfoTip>
|
||||
</span>
|
||||
<Field label={t('products.editor.trName')} hint={t('products.editor.trNameHint')}>
|
||||
<Input value={form.translations?.[l]?.name ?? ''} onChange={e => setForm(f => setTranslation(f, l, 'name', e.target.value))} placeholder={form.name} data-testid={`translation-${l}-name`} />
|
||||
</Field>
|
||||
<Field label={t('products.editor.trDescription')}>
|
||||
<Textarea rows={2} value={form.translations?.[l]?.description ?? ''} onChange={e => setForm(f => setTranslation(f, l, 'description', e.target.value))} placeholder={form.description} />
|
||||
</Field>
|
||||
</section>
|
||||
))}
|
||||
{!service && <Tags tags={form.tags} onChange={v => set('tags', v)} />}
|
||||
{!service && (
|
||||
<Field label={t('products.editor.unit')} hint={WEIGHED.has(form.unit_type) ? t('products.editor.unitWeighed') : undefined}>
|
||||
|
||||
@@ -26,9 +26,12 @@ export function buildForm(p) {
|
||||
lifecycle_status: p.lifecycle_status ?? 'active',
|
||||
prep_zone_ids: [...(p.prep_zone_ids ?? [])],
|
||||
allergens: { ...(p.allergens ?? {}) },
|
||||
// the menu in other languages (6.4): {lang: {name, description}}; quick options' own on each row (`tr`)
|
||||
translations: Object.fromEntries(Object.entries(p.translations ?? {}).map(([l, v]) => [l, { name: v.name ?? '', description: v.description ?? '' }])),
|
||||
quick_options: (p.quick_options ?? []).map(q => ({
|
||||
name: q.name, price: q.price ?? 0, allow_multiple: !!q.allow_multiple, is_favorite: !!q.is_favorite,
|
||||
favorite_sort_order: q.favorite_sort_order ?? 0, is_compact: !!q.is_compact,
|
||||
tr: Object.fromEntries(Object.entries(p.translations ?? {}).map(([l, v]) => [l, v.quick?.[q.name] ?? ''])),
|
||||
})),
|
||||
options: (p.options ?? []).map(o => ({
|
||||
name: o.name, extra_cost: o.extra_cost ?? 0, allow_multiple: !!o.allow_multiple, multi_select: !!o.multi_select,
|
||||
@@ -84,6 +87,7 @@ export function buildBody(f) {
|
||||
lifecycle_status: f.lifecycle_status,
|
||||
prep_zone_ids: f.prep_zone_ids,
|
||||
allergens: f.allergens,
|
||||
translations: translationsBody(f),
|
||||
quick_options: f.quick_options.map((q, i) => ({
|
||||
name: q.name, price: num(q.price), allow_multiple: q.allow_multiple, sort_order: i,
|
||||
is_favorite: q.is_favorite, favorite_sort_order: q.favorite_sort_order, is_compact: q.is_compact,
|
||||
@@ -128,6 +132,22 @@ export function buildBody(f) {
|
||||
}
|
||||
}
|
||||
|
||||
/** The translations for the API: per language its name, description and the quick options' names (by their base name). */
|
||||
export function translationsBody(f) {
|
||||
const langs = new Set([...Object.keys(f.translations ?? {}), ...f.quick_options.flatMap(q => Object.keys(q.tr ?? {}))])
|
||||
const out = {}
|
||||
for (const l of langs) {
|
||||
const t = f.translations?.[l] ?? {}
|
||||
const quick = Object.fromEntries(f.quick_options.filter(q => q.name.trim() && (q.tr?.[l] ?? '').trim()).map(q => [q.name, q.tr[l].trim()]))
|
||||
const v = { ...(t.name?.trim() ? { name: t.name.trim() } : {}), ...(t.description?.trim() ? { description: t.description.trim() } : {}), ...(Object.keys(quick).length ? { quick } : {}) }
|
||||
if (Object.keys(v).length) out[l] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** A translated field of the product. */
|
||||
export const setTranslation = (f, lang, field, value) => ({ ...f, translations: { ...f.translations, [lang]: { ...(f.translations?.[lang] ?? {}), [field]: value } } })
|
||||
|
||||
/** Can it be saved: a name, and a price unless it's a service item. */
|
||||
export const canSave = f => !!f.name.trim() && (f.is_service_item || (f.base_price !== '' && f.base_price != null))
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// the draft (PlaylistEditor asks for it as you change things).
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { ArrowDown, ArrowUp, EyeOff, X } from 'lucide-react'
|
||||
import { SALES_POINTS } from '@xenia/access'
|
||||
import { MENU_LANGUAGES, SALES_POINTS } from '@xenia/access'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Field, IconButton, Input, Select, Switch } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
@@ -155,6 +155,10 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
||||
<Select value={c.sales_point ?? ''} onChange={e => setC({ sales_point: e.target.value || null })} data-testid="signage-menu-prices"
|
||||
options={[{ value: '', label: t('signage.menu.noPrices') }, ...SALES_POINTS.map(sp => ({ value: sp, label: t(`common:salesPoints.${sp}.name`) }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.menu.language')} hint={t('signage.menu.languageHint')}>
|
||||
<Select value={c.language ?? ''} onChange={e => setC({ language: e.target.value || null })} data-testid="signage-menu-language"
|
||||
options={[{ value: '', label: t('signage.menu.asTyped') }, ...MENU_LANGUAGES.map(l => ({ value: l, label: t(`products.editor.lang.${l}`) }))]} />
|
||||
</Field>
|
||||
<Field label={t('signage.menu.soldOut')}>
|
||||
<Select value={c.sold_out || 'strike'} onChange={e => setC({ sold_out: e.target.value })}
|
||||
options={[{ value: 'strike', label: t('signage.menu.strike') }, { value: 'hide', label: t('signage.menu.hideSoldOut') }]} />
|
||||
|
||||
@@ -109,3 +109,13 @@ test('the editor: favourites across lists, choices, groups', () => {
|
||||
assert.equal(body.ingredients[0].group_id, 0) // the group's index in modifier_groups
|
||||
assert.equal(buildBody(removeGroup(f, 7)).ingredients[0].group_id, null)
|
||||
})
|
||||
|
||||
test('the editor keeps the menu in other languages (6.4)', () => {
|
||||
const f = buildForm({ name: 'Σουβλάκι', base_price: 3, quick_options: [{ name: 'Πίτα' }, { name: 'Σάλτσα' }],
|
||||
translations: { en: { name: 'Skewer', quick: { 'Πίτα': 'Pitta' } } } })
|
||||
assert.equal(f.translations.en.name, 'Skewer')
|
||||
assert.equal(f.quick_options[0].tr.en, 'Pitta')
|
||||
const renamed = { ...f, quick_options: [{ ...f.quick_options[0], name: 'Πίτα αραβική' }, f.quick_options[1]] }
|
||||
assert.deepEqual(buildBody(renamed).translations, { en: { name: 'Skewer', quick: { 'Πίτα αραβική': 'Pitta' } } }) // kept by the new base name
|
||||
assert.deepEqual(buildBody({ ...f, translations: { en: { name: ' ', description: '' } }, quick_options: [] }).translations, {})
|
||||
})
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"exports": {
|
||||
".": "./src/index.js",
|
||||
"./salesPoints": "./src/salesPoints.js",
|
||||
"./allergens": "./src/allergens.js"
|
||||
"./allergens": "./src/allergens.js",
|
||||
"./menuLanguages": "./src/menuLanguages.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@xenia/api": "^0.0.0",
|
||||
|
||||
@@ -20,3 +20,4 @@ export { OverrideHost } from './OverrideHost.jsx'
|
||||
export { SALES_POINTS, IN_PERSON, DIGITAL, normalizeSalesPoints } from './salesPoints.js'
|
||||
export { ALLERGENS, ALLERGEN_LEVELS, allergenList, nextAllergenLevel, setAllergen } from './allergens.js'
|
||||
export { Allergens } from './Allergens.jsx'
|
||||
export { MENU_LANGUAGES, translatedLanguages, inLanguage } from './menuLanguages.js'
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// The menu's languages (plan step 6.4, owner 2026-11-18): English and Greek, the same list as the
|
||||
// backend's core/menu_languages.py. A product's own name is its base text; a translation adds
|
||||
// the other language; a missing translation shows the base text.
|
||||
export const MENU_LANGUAGES = ['el', 'en']
|
||||
|
||||
/** The languages a venue translates its menu into: every menu language but its own. */
|
||||
export const translatedLanguages = venueLanguage => MENU_LANGUAGES.filter(l => l !== venueLanguage)
|
||||
|
||||
/** A product's or category's text in a language: `names` / `descriptions` {lang: text} as the
|
||||
* backend resolves them for customer screens, else the base text. */
|
||||
export const inLanguage = (texts, lang, base) => (texts && texts[lang]) || base
|
||||
@@ -116,7 +116,8 @@
|
||||
"too_deep": "Οι κατηγορίες έχουν το πολύ δύο επίπεδα.",
|
||||
"own_parent": "Μια κατηγορία δεν μπορεί να είναι γονέας του εαυτού της.",
|
||||
"group_not_found": "Η ομάδα επιλογών δεν βρέθηκε.",
|
||||
"allergen": "Άγνωστο αλλεργιογόνο ή επίπεδο: {{allergen}}."
|
||||
"allergen": "Άγνωστο αλλεργιογόνο ή επίπεδο: {{allergen}}.",
|
||||
"translation": "Μη αποδεκτή μετάφραση μενού: {{what}}."
|
||||
},
|
||||
"system": {
|
||||
"log_not_found": "Δεν υπάρχει αρχείο καταγραφής για {{date}}."
|
||||
|
||||
@@ -1045,7 +1045,10 @@
|
||||
"perPage": "Προϊόντα ανά σελίδα",
|
||||
"perPageHint": "Κενό: όσα χωράνε στην τηλεόραση. Ένα μεγάλο μενού γυρίζει σελίδες.",
|
||||
"auto": "Όσα χωράνε",
|
||||
"pageSeconds": "Δευτερόλεπτα ανά σελίδα"
|
||||
"pageSeconds": "Δευτερόλεπτα ανά σελίδα",
|
||||
"language": "Γλώσσα",
|
||||
"languageHint": "Τα ονόματα των προϊόντων σε αυτή την οθόνη. Χωρίς μετάφραση: όπως γράφτηκαν.",
|
||||
"asTyped": "Όπως γράφτηκαν"
|
||||
},
|
||||
"badges": {
|
||||
"new": "Νέο",
|
||||
@@ -1801,7 +1804,17 @@
|
||||
"sharedHint": "Εμφανίζεται για όλες εκτός όσων το κρύβουν.",
|
||||
"addShared": "Κοινό υπο-σύνολο",
|
||||
"sharedName": "Όνομα κοινού υπο-συνόλου",
|
||||
"sharedPlaceholder": "π.χ. Είδος ζάχαρης"
|
||||
"sharedPlaceholder": "π.χ. Είδος ζάχαρης",
|
||||
"inLanguage": "Στα {{language}}",
|
||||
"inLanguageShort": "Στα {{language}}",
|
||||
"lang": {
|
||||
"el": "Ελληνικά",
|
||||
"en": "Αγγλικά"
|
||||
},
|
||||
"translationTip": "Τι βλέπουν οι πελάτες σε αυτή τη γλώσσα: QR μενού, online παραγγελίες, tablet μενού και οθόνες. Τα δελτία, οι οθόνες κουζίνας, το ταμείο και τα κινητά των σερβιτόρων κρατούν το όνομα όπως γράφτηκε. Αν μείνει κενό, οι πελάτες βλέπουν το όνομα όπως γράφτηκε.",
|
||||
"trName": "Όνομα",
|
||||
"trNameHint": "Κενό: το όνομα όπως γράφτηκε.",
|
||||
"trDescription": "Περιγραφή"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@
|
||||
"too_deep": "Categories go at most two levels deep.",
|
||||
"own_parent": "A category can't be its own parent.",
|
||||
"group_not_found": "Option group not found.",
|
||||
"allergen": "Unknown allergen or level: {{allergen}}."
|
||||
"allergen": "Unknown allergen or level: {{allergen}}.",
|
||||
"translation": "The menu can't be translated like that: {{what}}."
|
||||
},
|
||||
"system": {
|
||||
"log_not_found": "There is no log file for {{date}}."
|
||||
|
||||
@@ -1045,7 +1045,10 @@
|
||||
"perPage": "Products per page",
|
||||
"perPageHint": "Empty: as many as fit the TV. A long menu turns its pages.",
|
||||
"auto": "As many as fit",
|
||||
"pageSeconds": "Seconds per page"
|
||||
"pageSeconds": "Seconds per page",
|
||||
"language": "Language",
|
||||
"languageHint": "The products' names on this board. Not translated: as typed.",
|
||||
"asTyped": "As typed"
|
||||
},
|
||||
"badges": {
|
||||
"new": "New",
|
||||
@@ -1801,7 +1804,17 @@
|
||||
"sharedHint": "Offered with every choice except those that hide it.",
|
||||
"addShared": "Shared sub-set",
|
||||
"sharedName": "Name of the shared sub-set",
|
||||
"sharedPlaceholder": "e.g. Kind of sugar"
|
||||
"sharedPlaceholder": "e.g. Kind of sugar",
|
||||
"inLanguage": "In {{language}}",
|
||||
"inLanguageShort": "In {{language}}",
|
||||
"lang": {
|
||||
"el": "Greek",
|
||||
"en": "English"
|
||||
},
|
||||
"translationTip": "What guests see in this language: the QR menu, online ordering, the menu tablets and the screens. Tickets, the kitchen screens, the counter and the waiters' phones keep the name as typed above. Left empty, guests see the name as typed.",
|
||||
"trName": "Name",
|
||||
"trNameHint": "Empty: the name as typed.",
|
||||
"trDescription": "Description"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { applyTheme, Dialog, getStoredTheme, Input } from '@xenia/ui'
|
||||
import { Allergens } from '@xenia/access'
|
||||
import client from '../../api/client'
|
||||
import { useLiveEvent, useLiveEvents } from '../../device/context'
|
||||
import { idle, languagesOf, search, sections } from './logic'
|
||||
import { idle, languagesOf, localize, search, sections } from './logic'
|
||||
|
||||
const quiet = { xenia: { noOverride: true } }
|
||||
const CACHE_KEY = 'xenia:menu-tablet:menu'
|
||||
@@ -75,8 +75,9 @@ export default function MenuTabletApp() {
|
||||
return () => { window.removeEventListener('pointerdown', touch); window.removeEventListener('keydown', touch); clearInterval(id) }
|
||||
}, [cfg.idle_seconds, reset])
|
||||
|
||||
const groups = useMemo(() => sections(data, cfg.group !== false, language), [data, cfg.group, language])
|
||||
const found = useMemo(() => search(data, q, language), [data, q, language])
|
||||
const shown = useMemo(() => localize(data, language), [data, language]) // product names in the tablet's language (6.4)
|
||||
const groups = useMemo(() => sections(shown, cfg.group !== false, language), [shown, cfg.group, language])
|
||||
const found = useMemo(() => search(shown, q, language), [shown, q, language])
|
||||
const goTo = id => scroller.current?.querySelector(`[data-section="${id}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
|
||||
if (!data) return <main className="fixed inset-0 bg-canvas" data-testid="app-menu_tablet" />
|
||||
|
||||
@@ -6,12 +6,27 @@ export function fold(text) {
|
||||
return String(text ?? '').normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().trim()
|
||||
}
|
||||
|
||||
/** Does a product match a search? By its name in Greek or in Latin letters ("souvlaki"), or a tag. */
|
||||
/** Does a product match a search? By its name (shown or as typed, plan step 6.4) in Greek or in
|
||||
* Latin letters ("souvlaki"), or a tag. */
|
||||
export function matches(product, query) {
|
||||
const q = fold(query)
|
||||
if (!q) return true
|
||||
const name = fold(product.name)
|
||||
return name.includes(q) || fold(latin(product.name)).includes(q) || (product.tags || []).some(t => fold(t).includes(q))
|
||||
const names = [product.name, product.base_name].filter(Boolean)
|
||||
return names.some(n => fold(n).includes(q) || fold(latin(n)).includes(q)) || (product.tags || []).some(t => fold(t).includes(q))
|
||||
}
|
||||
|
||||
/**
|
||||
* The menu in the tablet's language (plan step 6.4): each product's and category's `names` /
|
||||
* `descriptions` for that language (the backend falls back to the text as typed); `base_name`
|
||||
* keeps the name as typed for the search.
|
||||
*/
|
||||
export function localize(data, language) {
|
||||
if (!data) return data
|
||||
const products = Object.fromEntries(Object.entries(data.products || {}).map(([id, p]) => [id, {
|
||||
...p, base_name: p.name, name: p.names?.[language] || p.name, description: p.descriptions?.[language] ?? p.description,
|
||||
}]))
|
||||
const categories = (data.categories || []).map(c => ({ ...c, name: c.names?.[language] || c.name }))
|
||||
return { ...data, products, categories }
|
||||
}
|
||||
|
||||
/** Every product once, A to Z (the ungrouped list and the search's results). */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// The menu tablet's logic (plan step 5.7a).
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { allProducts, fold, idle, languagesOf, matches, search, sections } from '../src/apps/menu-tablet/logic.js'
|
||||
import { allProducts, fold, idle, languagesOf, localize, matches, search, sections } from '../src/apps/menu-tablet/logic.js'
|
||||
|
||||
const data = {
|
||||
categories: [{ id: 1, name: 'Grill', depth: 0, products: [2, 1] }, { id: 3, name: 'Pita', depth: 1, products: [1] }, { id: 4, name: 'Empty', depth: 0, products: [9] }],
|
||||
@@ -34,3 +34,15 @@ test('back to the start after a while; the languages a guest can pick', () => {
|
||||
assert.deepEqual(languagesOf({ languages: 'en' }), ['en'])
|
||||
assert.deepEqual(languagesOf(undefined), ['el', 'en'])
|
||||
})
|
||||
|
||||
test('the menu in the language of the tablet (6.4): names switch, the base name still finds it', () => {
|
||||
const data = { products: { 1: { id: 1, name: 'Σουβλάκι', names: { el: 'Σουβλάκι', en: 'Pork skewer' }, description: 'Χοιρινό', descriptions: { el: 'Χοιρινό', en: 'Pork' } }, 2: { id: 2, name: 'Μπύρα' } },
|
||||
categories: [{ id: 5, name: 'Ψητά', names: { el: 'Ψητά', en: 'Grill' }, products: [1, 2] }] }
|
||||
const en = localize(data, 'en')
|
||||
assert.equal(en.products[1].name, 'Pork skewer')
|
||||
assert.equal(en.products[1].description, 'Pork')
|
||||
assert.equal(en.products[2].name, 'Μπύρα') // not translated: as typed
|
||||
assert.equal(en.categories[0].name, 'Grill')
|
||||
assert.ok(matches(en.products[1], 'souvl') && matches(en.products[1], 'pork'))
|
||||
assert.equal(localize(data, 'el').products[1].name, 'Σουβλάκι')
|
||||
})
|
||||
|
||||
@@ -874,6 +874,7 @@ try {
|
||||
await page.getByTestId('allergen-gluten').click()
|
||||
await page.getByTestId('allergen-milk').click()
|
||||
await page.getByTestId('allergen-milk').click()
|
||||
await page.getByTestId('translation-el-name').fill('E2E name in Greek') // 6.4: the test venue speaks English, so the other menu language is Greek
|
||||
r.check(`${pr} the editor lists both categories, the first one main; gluten "contains", milk "may contain"`,
|
||||
await page.locator(`[data-testid="product-category"][data-id="${catA.id}"][data-main="true"]`).count() === 1
|
||||
&& await page.locator(`[data-testid="product-category"][data-id="${catB.id}"][data-main="false"]`).count() === 1
|
||||
@@ -884,6 +885,8 @@ try {
|
||||
const savedP = (await api('GET', '/api/products/?all=true', { token: boss })).find(p => p.id === prodP.id)
|
||||
r.check(`${pr} saved: listed in both, the main one kept, its allergens`, JSON.stringify(savedP.category_ids) === JSON.stringify([catA.id, catB.id])
|
||||
&& savedP.primary_category_id === catA.id && JSON.stringify(savedP.allergens) === JSON.stringify({ gluten: 'contains', milk: 'may_contain' }), JSON.stringify([savedP.category_ids, savedP.allergens]))
|
||||
r.check(`${pr} 6.4: its name for the other menu language is saved; the name itself is unchanged`, savedP.translations?.el?.name === 'E2E name in Greek' && savedP.name === prodP.name,
|
||||
JSON.stringify(savedP.translations))
|
||||
await page.getByTestId(`category-${catB.id}`).click()
|
||||
const inB = page.locator(`[data-testid="product-group"][data-category="${catB.id}"] [data-testid="product-row"][data-id="${prodP.id}"]`)
|
||||
r.check(`${pr} it shows in the second category too, marked "also in" the first`, await inB.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
|
||||
@@ -36,7 +36,8 @@ try {
|
||||
await api('PUT', '/api/platform/modules/menu_tablet', { token: boss, body: { enabled: true } }).catch(() => {})
|
||||
const products = (await api('GET', '/api/products/?sold_at=in_store', { token: boss })).filter(p => !p.is_service_item && p.lifecycle_status === 'active')
|
||||
const souvlaki = products.find(p => /Σουβλάκι/.test(p.name)) || products[0]
|
||||
await api('PUT', `/api/products/${souvlaki.id}`, { token: boss, body: { allergens: { gluten: 'contains', mustard: 'may_contain' } } })
|
||||
await api('PUT', `/api/products/${souvlaki.id}`, { token: boss, body: { allergens: { gluten: 'contains', mustard: 'may_contain' },
|
||||
translations: { en: { name: 'Pork skewer (en)' } } } })
|
||||
|
||||
const tab = await (await browser.newContext({ viewport: { width: 1180, height: 820 }, hasTouch: true })).newPage()
|
||||
tab.on('pageerror', e => errors.push(e.message))
|
||||
@@ -59,6 +60,16 @@ try {
|
||||
r.check('6.3: …with its allergens', await tab.getByTestId('menu-details').locator('[data-allergen="gluten"][data-level="contains"]').count() === 1
|
||||
&& await tab.getByTestId('menu-details').locator('[data-allergen="mustard"][data-level="may_contain"]').count() === 1)
|
||||
await tab.keyboard.press('Escape')
|
||||
// 6.4: the language buttons switch the products' names too
|
||||
await tab.getByTestId('menu-search').fill('')
|
||||
const item = () => tab.locator(`[data-testid="menu-item"][data-id="${souvlaki.id}"]`).first()
|
||||
const wasEnglish = await tab.getByTestId('menu-lang-en').getAttribute('aria-pressed') === 'true'
|
||||
await tab.getByTestId('menu-lang-en').click()
|
||||
const inEnglish = await tab.waitForFunction(id => document.querySelector(`[data-testid="menu-item"][data-id="${id}"]`)?.textContent.includes('Pork skewer (en)'), souvlaki.id, { timeout: 5000 }).then(() => true).catch(() => false)
|
||||
await tab.getByTestId('menu-lang-el').click()
|
||||
await sleep(300)
|
||||
r.check('6.4: EN shows the English name, EL the name as typed', inEnglish && (await item().textContent()).includes(souvlaki.name))
|
||||
if (wasEnglish) await tab.getByTestId('menu-lang-en').click() // as it was (prices below are read in its format)
|
||||
await tab.getByTestId('menu-search').fill('zzzz')
|
||||
r.check('nothing found: says so', await shown(tab, 'menu-no-results', 5000))
|
||||
await tab.getByTestId('menu-search').fill('')
|
||||
|
||||
+19
-3
@@ -79,16 +79,22 @@ try {
|
||||
const code5 = qr.tables.find(t => t.id === t5.id)
|
||||
r.check('table 5 has its own code, pointing at the QR menu app', !!code5 && code5.url.startsWith(`http://localhost:${APP_PORT}/menu/${site.site_id}?t=`), code5?.url)
|
||||
const token5 = new URL(code5.url).searchParams.get('t')
|
||||
// 6.4: a dish translated to English (the venue types its menu in Greek)
|
||||
const firstDish = (await api('GET', '/api/products/')).find(p => !p.is_service_item && p.is_available && p.sold_at.includes('qr_table'))
|
||||
await api('PUT', `/api/products/${firstDish.id}`, { body: { translations: { en: { name: 'E2E dish in English' } } } })
|
||||
// the code reaches the cloud with the menu (pushed within seconds of the change)
|
||||
let seen = null
|
||||
for (let i = 0; i < 60 && !seen?.table; i++) {
|
||||
const translated = m => m?.categories?.some(c => c.products.some(p => p.id === firstDish.id && p.names?.en === 'E2E dish in English'))
|
||||
for (let i = 0; i < 60 && !(seen?.table && translated(seen)); i++) {
|
||||
seen = await cloud('GET', `/api/menu/${site.site_id}?t=${encodeURIComponent(token5)}`).catch(() => null)
|
||||
if (!seen?.table) await sleep(500)
|
||||
if (!(seen?.table && translated(seen))) await sleep(500)
|
||||
}
|
||||
r.check('6.4: the cloud menu carries the dish\'s name per language', translated(seen))
|
||||
r.check('the cloud knows table 5 by its code (the hash came with the menu), and ordering is on', seen?.table?.id === t5.id && seen.table_ordering === true,
|
||||
JSON.stringify(seen?.table))
|
||||
const dishes = seen.categories.flatMap(c => c.products).filter(p => p.digital_available !== false && (!p.sold_at || p.sold_at.includes('qr_table')))
|
||||
const [d1, d2] = dishes
|
||||
const d1 = dishes.find(p => p.id === firstDish.id)
|
||||
const d2 = dishes.find(p => p.id !== firstDish.id)
|
||||
|
||||
// ── the menu app, built for this cloud ────────────────────────────────────
|
||||
const build = spawn('npx', ['vite', 'build'], { cwd: APP_DIR, shell: process.platform === 'win32', env: { ...process.env, VITE_CLOUD_URL: CLOUD_URL }, stdio: 'ignore' })
|
||||
@@ -111,6 +117,7 @@ try {
|
||||
await page.goto(code5.url)
|
||||
r.check('scanning table 5: the menu says "Table 5" and lets them order', await page.getByTestId('table-banner').waitFor({ timeout: 15_000 }).then(() => true).catch(() => false)
|
||||
&& (await page.getByTestId('table-banner').textContent()).includes(seen.table.label))
|
||||
r.check('6.4: in English the menu shows the dish\'s English name', (await page.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`).textContent()).includes('E2E dish in English'))
|
||||
await page.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`).getByTestId('menu-add').click()
|
||||
await page.locator(`[data-testid="menu-product"][data-product="${d2.id}"]`).getByTestId('menu-add').click()
|
||||
await page.getByTestId('cart-button').click()
|
||||
@@ -129,6 +136,15 @@ try {
|
||||
const names = (order?.items ?? []).map(i => i.product_id)
|
||||
r.check('the two dishes are on table 5\'s order', !!order && names.includes(d1.id) && names.includes(d2.id), JSON.stringify(order?.items?.map(i => [i.product_name, i.unit_price])))
|
||||
r.check('…at the QR menu\'s prices', order?.items?.find(i => i.product_id === d1.id)?.unit_price === d1.prices.qr_table)
|
||||
r.check('6.4: the kitchen gets the name as typed (not the English one)', order?.items?.find(i => i.product_id === d1.id)?.product_name === firstDish.name,
|
||||
order?.items?.find(i => i.product_id === d1.id)?.product_name)
|
||||
const greek = await browser.newPage({ viewport: { width: 390, height: 844 } })
|
||||
await greek.addInitScript(() => localStorage.setItem('ot_lang', 'gr'))
|
||||
await greek.goto(code5.url)
|
||||
const gCard = greek.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`)
|
||||
r.check('6.4: in Greek the menu shows the name as typed', await gCard.waitFor({ timeout: 15_000 }).then(() => true).catch(() => false)
|
||||
&& (await gCard.textContent()).includes(firstDish.digital_name || firstDish.name) && !(await gCard.textContent()).includes('E2E dish in English'))
|
||||
await greek.close()
|
||||
r.check('…and in the kitchen (KDS)', (await api('GET', '/api/kds/orders')).orders.some(o => o.id === order?.id))
|
||||
for (let i = 0; i < 20 && !events.slice(before).some(e => e.type === 'order_updated' && e.data?.table_id === t5.id); i++) await sleep(200)
|
||||
r.check('…announced live to the waiters\' phones and the counter (order_updated for table 5)',
|
||||
|
||||
Reference in New Issue
Block a user