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:
2026-11-18 10:47:03 +02:00
co-authored by Claude Opus 5.5
parent 5048f82a4c
commit e395d99704
32 changed files with 459 additions and 38 deletions
+19 -3
View File
@@ -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)',