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
+3
View File
@@ -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)
+12 -1
View File
@@ -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
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)',