feat: staff apps show the menu in the reader's language (plan 6R.L)

The waiters' phones and the counter show categories, products and every
choice (quick options, extras and sub-choices, preferences, shared sets,
ingredients, groups) in the signed-in person's language, falling back to
the stored text. Display only: carts, lines, tickets and the kitchen keep
the venue's text (ids, sub-choices by stored name). In the venue's own
language nothing changes.

- @xenia/access: menuText / useMenuText (mt, mt.choice, mt.line, mt.matches)
- /api/pos/menu carries translations for products, categories and choices
- shared ProductDialog takes a text() prop (the counter passes useMenuText)
- search finds a product by its name in any language (counter, waiter)
- waiter: useMenuNames for sent lines; picker, drawer, cart, summary,
  table lines, quantity / price history, favourites setup
- counter: categories, cards, dialog, cart lines, table lines, payment rows
- tests: access menuText, ordering search, test_pos per-language,
  e2e waiter.mjs and terminal.mjs 6R.L blocks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 20:18:10 +02:00
co-authored by Claude Opus 5.5
parent f107deca8c
commit 0840247768
29 changed files with 518 additions and 123 deletions
+30
View File
@@ -377,6 +377,36 @@ try {
const posSession = await page.evaluate(async () => (await window.__xeniaClient.get('/api/pos/session')).data)
r.check('3.3a: the shift is the cashier\'s own, with the starting cash', posSession.shift?.starting_cash === 20, JSON.stringify(posSession.shift))
// ── 6R.L: the counter in the cashier's language (display only): the manager switches to Greek ──
{
const tr = await api('PUT', `/api/products/${burgerP.id}`, { token: boss, body: {
translations: { en: { name: 'E2E Burger' }, el: { name: 'Μπέργκερ E2E' } },
preference_sets: burgerP.preference_sets.map(ps => ({ ...ps, translations: { el: 'Ψήσιμο' },
choices: ps.choices.map(c => ({ ...c, translations: c.name === 'Well done' ? { el: 'Καλοψημένο' } : {} })) })),
} })
Object.assign(burgerP, tr) // the choices are recreated: new ids for the checks below
await page.evaluate(async () => window.__xeniaClient.patch('/api/auth/me', { language: 'el' }))
await page.reload()
await shown(page, 'pos-screen', 15_000)
await page.getByTestId('pos-search').fill('burg e2e')
const card = page.locator(`[data-testid="pos-product"][data-product="${burgerP.id}"]`)
const cardOk = await card.waitFor({ timeout: 5000 }).then(() => true).catch(() => false)
r.check('6R.L: a cashier in Greek sees the dish in Greek (found by its English name too)', cardOk && (await card.innerText()).includes('Μπέργκερ E2E'), cardOk ? await card.innerText() : 'not found')
await page.getByTestId('pos-search').fill('μπεργκ')
r.check('6R.L: …and by its Greek name', await card.waitFor({ timeout: 5000 }).then(() => true).catch(() => false))
if (cardOk) {
await card.getByTestId('product-info').click()
const dialogText = await page.getByTestId('product-dialog').innerText({ timeout: 5000 }).catch(() => '')
r.check('6R.L: the choices in Greek where they have it, as they are where not', dialogText.includes('Ψήσιμο') && dialogText.includes('Καλοψημένο')
&& dialogText.includes('Rare') && !dialogText.includes('Well done'), dialogText.replace(/\s+/g, ' ').slice(0, 200))
await page.keyboard.press('Escape')
}
await page.getByTestId('pos-search').fill('')
await page.evaluate(async () => window.__xeniaClient.patch('/api/auth/me', { language: '' }))
await page.reload()
await shown(page, 'pos-screen', 15_000)
}
await page.getByTestId('pos-search').fill('burg e2e')
const burgerCard = page.locator(`[data-testid="pos-product"][data-product="${burgerP.id}"]`)
r.check('3.3a: search finds the product by name (words in any order)', await burgerCard.waitFor({ timeout: 5000 }).then(() => true).catch(() => false)