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:
@@ -596,6 +596,68 @@ try {
|
||||
await a.getByRole('button', { name: /Dark theme/ }).click()
|
||||
await a.reload()
|
||||
|
||||
// ── 6R.L: the phone shows the menu in the waiter's language (display only); the line, and so
|
||||
// the ticket, keeps the venue's text. The venue is English here; Maria switches to Greek. ──
|
||||
{
|
||||
const cat = await api('POST', '/api/products/categories', { token: boss, body: {
|
||||
name: 'EN-6RL Cat', sort_order: 99, translations: { en: { name: 'EN-6RL Cat' }, el: { name: 'ΕΛ-6RL Κατηγορία' } } } })
|
||||
const dish = await api('POST', '/api/products/', { token: boss, body: {
|
||||
name: 'EN-6RL Dish', base_price: 4, primary_category_id: cat.id, quick_add_enabled: false,
|
||||
translations: { en: { name: 'EN-6RL Dish' }, el: { name: 'ΕΛ-6RL Πιάτο' } },
|
||||
quick_options: [{ name: 'EN-6RL extra', price: 0.5, translations: { en: 'EN-6RL extra', el: 'ΕΛ-6RL έξτρα' } },
|
||||
{ name: 'EN-6RL only', translations: { en: 'EN-6RL only' } }], // no Greek: shown as it is
|
||||
ingredients: [{ name: 'EN-6RL onion', translations: { en: 'EN-6RL onion', el: 'ΕΛ-6RL κρεμμύδι' } }] } })
|
||||
const tl = (await api('GET', '/api/tables/', { token: boss })).find(t => !t.open_order_id && !t.current_order_id)
|
||||
await a.goto(`${APP}/tables`)
|
||||
await a.getByRole('button', { name: 'demo_maria' }).first().click({ timeout: 10_000 })
|
||||
await a.getByTestId('menu-language-el').click()
|
||||
await waitFor(async () => (await navText()).includes('Τραπέζια'), 8000, 300)
|
||||
await a.goto(`${APP}/tables/${tl.id}/add?new=1`)
|
||||
await a.getByRole('button', { name: 'ΕΛ-6RL Κατηγορία', exact: true }).first().click({ timeout: 15_000 }).catch(() => {})
|
||||
const card = a.locator('[data-testid="product-card"][data-name="EN-6RL Dish"]').first()
|
||||
const cardShown = await card.waitFor({ timeout: 10_000 }).then(() => true).catch(() => false)
|
||||
const cardText = cardShown ? await card.innerText() : ''
|
||||
r.check('6R.L: a phone in Greek at an English venue: the category and the dish in Greek', cardShown && cardText.includes('ΕΛ-6RL Πιάτο') && !cardText.includes('EN-6RL'), cardText.replace(/\s+/g, ' '))
|
||||
if (cardShown) {
|
||||
await card.click()
|
||||
await a.getByTestId('drawer-tab-quick').click({ timeout: 5000 }).catch(() => {})
|
||||
const drawerText = await waitFor(async () => { const x = await a.locator('body').innerText(); return x.includes('ΕΛ-6RL έξτρα') && x }, 5000, 300) || ''
|
||||
r.check('6R.L: the choices in Greek, one without a Greek name as it is', drawerText.includes('ΕΛ-6RL έξτρα') && drawerText.includes('EN-6RL only') && !drawerText.includes('EN-6RL extra'),
|
||||
drawerText.replace(/\s+/g, ' ').slice(0, 300))
|
||||
await a.getByText('ΕΛ-6RL έξτρα', { exact: true }).first().click()
|
||||
await a.getByTestId('drawer-tab-ingredients').click({ timeout: 5000 }).catch(() => {})
|
||||
await a.getByText('ΕΛ-6RL κρεμμύδι', { exact: true }).first().click({ timeout: 5000 }).catch(() => {})
|
||||
await a.screenshot({ path: path.join(OUT, 'waiter-6rl-drawer.png') })
|
||||
await a.getByTestId('drawer-add').click()
|
||||
await a.getByTestId('cart-open').click()
|
||||
await a.getByRole('button', { name: /^(SEND|SUMMARY|ΑΠΟΣΤΟΛΗ|ΣΥΝΟΨΗ)/ }).last().click()
|
||||
if (await shown(a, 'summary-total', 3000)) await a.getByRole('button', { name: /SEND|ΑΠΟΣΤΟΛΗ/ }).last().click()
|
||||
}
|
||||
const sentL = await waitFor(async () => {
|
||||
const st = await api('GET', `/api/tables/${tl.id}/status`, { token: boss })
|
||||
if (!st.active_order_id) return null
|
||||
const o = await api('GET', `/api/orders/${st.active_order_id}`, { token: boss })
|
||||
return o.items.length ? o : null
|
||||
}, 10_000, 500)
|
||||
const line = sentL?.items?.[0]
|
||||
const opts = line ? JSON.parse(line.selected_options || '[]').map(o => o.name) : []
|
||||
const removedL = line ? JSON.parse(line.removed_ingredients || '[]') : []
|
||||
r.check('6R.L: the sent line keeps the venue\'s text (what the ticket prints), not the phone\'s',
|
||||
line?.product_name === 'EN-6RL Dish' && opts.includes('EN-6RL extra') && removedL.includes('EN-6RL onion'),
|
||||
JSON.stringify([line?.product_name, opts, removedL]))
|
||||
await a.goto(`${APP}/tables/${tl.id}`)
|
||||
const tableText = await waitFor(async () => { const x = await a.locator('body').innerText(); return x.includes('ΕΛ-6RL Πιάτο') && x }, 10_000, 500) || ''
|
||||
r.check('6R.L: the table\'s sent line shows in Greek on this phone', tableText.includes('ΕΛ-6RL Πιάτο') && !tableText.includes('EN-6RL Dish'), tableText.replace(/\s+/g, ' ').slice(0, 300))
|
||||
await a.screenshot({ path: path.join(OUT, 'waiter-6rl-table.png') })
|
||||
await a.goto(`${APP}/tables`)
|
||||
await a.getByRole('button', { name: 'demo_maria' }).first().click({ timeout: 10_000 })
|
||||
await a.getByTestId('menu-language-en').click()
|
||||
await waitFor(async () => (await navText()).includes('Tables'), 8000, 300)
|
||||
if (sentL) await api('DELETE', `/api/orders/${sentL.id}`, { token: boss }).catch(() => {})
|
||||
await api('DELETE', `/api/products/${dish.id}`, { token: boss }).catch(() => {})
|
||||
await api('DELETE', `/api/products/categories/${cat.id}`, { token: boss }).catch(() => {})
|
||||
}
|
||||
|
||||
// ── 6F.7: "ask" (the default): the second phone asks; Continue signs the first one out and it
|
||||
// says why; an order queued offline on the first phone goes out after it signs in again ──
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user