feat: ordering from the menu tablet at a table (platform-v2 step 6.6, D-30)
- tablet_orders (0034) + services/tablet_orders.py: venue rules (menu_tablet.ordering) with
per-tablet overrides: kitchen or waiter confirms first, no open order open/refuse, limits
(items per order, of one dish, time between orders)
- /api/menu-tablet: quote, order, order/{id}, bill (see + ask), requests accept/decline, ordering
- terminal: Add to the order (POS ProductDialog), cart, note, send, live status, the bill
- waiter: TabletRequests on the table page, tablet_order message theme with Open the table
- manager: Settings -> Menu tablets
- tests: test_tablet_orders.py, menu-tablet unit, menu_tablet.mjs e2e (the done-when)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
// prices; search finds a product (also typed in Latin letters) and its price; a product opens big;
|
||||
// the view options from the device config change it live; a price change shows without a reload;
|
||||
// the guest's language; back to the start after a while without a touch; a tablet at a table calls
|
||||
// a waiter (5.7b).
|
||||
// a waiter (5.7b); guests at a table order (two of a dish with an extra) and it reaches the
|
||||
// table's order and the kitchen; a waiter confirms first when set so; the bill (6.6).
|
||||
// Starts its own backend (:8067) and the terminal (:5195).
|
||||
// node menu_tablet.mjs
|
||||
import path from 'node:path'
|
||||
@@ -14,7 +15,7 @@ import { supportLogin } from './lib/support.mjs'
|
||||
const backend = await startBackend({ port: 8067, siteId: 'test-site-1', env: { LICENSE_MODE: 'off' } })
|
||||
const term = await startTerminalVite({ port: 5195, backendUrl: backend.url })
|
||||
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||
const r = reporter('menu tablet: the menu, search, views, live prices, languages, idle reset (5.7a), call a waiter (5.7b)')
|
||||
const r = reporter('menu tablet: the menu, search, views, live prices, languages, idle reset (5.7a), call a waiter (5.7b), order and the bill (6.6)')
|
||||
const errors = []
|
||||
let failures = 0
|
||||
|
||||
@@ -102,6 +103,61 @@ try {
|
||||
&& (await tab.getByTestId('menu-call-sent').textContent()).includes(t5.label || String(t5.number)))
|
||||
await tab.screenshot({ path: path.join(OUT, 'menu-tablet-call.png') })
|
||||
|
||||
// 6.6: guests order from the tablet at the table (the done-when): two of a dish with an extra
|
||||
await api('POST', '/api/business-day/open', { token: boss, body: {} }).catch(() => {})
|
||||
await api('PUT', `/api/products/${souvlaki.id}`, { token: boss, body: { quick_options: [{ name: 'Extra pita', price: 0.5 }] } })
|
||||
await api('PUT', '/api/menu-tablet/ordering', { token: boss, body: { confirm: 'kitchen', no_order: 'open', max_items: 20, max_of_one: 10, min_seconds: 0 } })
|
||||
await api('PATCH', `/api/devices/${dev.id}`, { token: boss, body: { config: { table: t5.id, ordering: true } } }) // the device's whole config
|
||||
await tab.getByTestId('menu-search').fill('souvl')
|
||||
await tab.getByTestId('menu-results').locator(`[data-testid="menu-item"][data-id="${souvlaki.id}"]`).click()
|
||||
r.check('6.6: with "Guests can order" on, a dish has "Add to the order"', await shown(tab, 'menu-order-add', 15_000))
|
||||
await tab.getByTestId('menu-order-add').click()
|
||||
await shown(tab, 'product-dialog', 5000)
|
||||
await tab.getByTestId('product-dialog').locator('[data-quick]').first().click()
|
||||
await tab.getByTestId('dialog-add').click()
|
||||
await tab.getByTestId('menu-cart').click()
|
||||
await tab.getByTestId('menu-order-line').first().getByRole('button').nth(1).click() // one more
|
||||
const qty = await waitFor(async () => ((await tab.getByTestId('menu-order-qty').first().textContent()) === '2' ? true : null), 5000, 200)
|
||||
const cartTotal = await waitFor(async () => { const x = await tab.getByTestId('menu-order-total').textContent(); return x.includes((2 * (7.7 + 0.5)).toFixed(2)) ? x : null }, 8000, 200) // re-priced after the change
|
||||
r.check('6.6: the cart: two of it, priced by the server with the extra', !!qty && String(cartTotal).includes((2 * (7.7 + 0.5)).toFixed(2)), String(cartTotal))
|
||||
await tab.screenshot({ path: path.join(OUT, 'menu-tablet-cart.png') })
|
||||
await tab.getByTestId('menu-order-send').click()
|
||||
await tab.getByTestId('menu-order-confirm').click()
|
||||
r.check('6.6: sent: the tablet says it is in the kitchen', await tab.locator('[data-testid="menu-order-status"][data-status="sent"]').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false))
|
||||
const tableOrder = async () => (await api('GET', '/api/orders/', { token: boss })).find(o => o.table_id === t5.id)
|
||||
const placed = await tableOrder()
|
||||
const lines = (placed?.items || []).filter(i => i.product_id === souvlaki.id && i.status !== 'cancelled')
|
||||
r.check("6.6: the table's order has them, from the tablet", lines.length > 0 && lines.reduce((n, i) => n + i.quantity, 0) === 2 && lines.every(i => i.source === 'tablet'),
|
||||
JSON.stringify(lines.map(i => [i.quantity, i.source])))
|
||||
|
||||
// a waiter confirms first: it waits, then the waiter accepts and the tablet hears it
|
||||
await api('PATCH', `/api/devices/${dev.id}`, { token: boss, body: { config: { table: t5.id, ordering: true, order_confirm: 'waiter' } } })
|
||||
await sleep(500)
|
||||
await tab.getByTestId('menu-search').fill('souvl')
|
||||
await tab.getByTestId('menu-results').locator(`[data-testid="menu-item"][data-id="${souvlaki.id}"]`).click()
|
||||
await tab.getByTestId('menu-order-add').click()
|
||||
await tab.getByTestId('dialog-add').click()
|
||||
await tab.getByTestId('menu-cart').click()
|
||||
await tab.getByTestId('menu-order-send').click()
|
||||
await tab.getByTestId('menu-order-confirm').click()
|
||||
r.check('6.6: a waiter confirms first: the tablet says it waits', await tab.locator('[data-testid="menu-order-status"][data-status="waiting"]').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false))
|
||||
const waiting = await api('GET', `/api/menu-tablet/requests?table_id=${t5.id}`, { token: boss })
|
||||
r.check("6.6: …and it is on the table's list for the waiters", waiting.length === 1)
|
||||
if (waiting[0]) await api('POST', `/api/menu-tablet/requests/${waiting[0].id}/accept`, { token: boss, body: {} })
|
||||
r.check('6.6: accepted: the tablet shows it in the kitchen, live', await tab.locator('[data-testid="menu-order-status"][data-status="sent"]').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false))
|
||||
|
||||
// the bill: what the table ordered so far, and asking for it
|
||||
await tab.getByTestId('menu-bill-button').click()
|
||||
const due = 2 * (7.7 + 0.5) + 7.7 // two with the extra, then one without
|
||||
r.check("6.6: the bill lists the table's order and what is due", await shown(tab, 'menu-bill', 5000)
|
||||
&& await tab.getByTestId('menu-bill-line').count() >= 2 && (await tab.getByTestId('menu-bill-due').textContent()).includes(due.toFixed(2)),
|
||||
`${due} / ${await tab.getByTestId('menu-bill-due').textContent().catch(() => '')}`)
|
||||
await tab.screenshot({ path: path.join(OUT, 'menu-tablet-bill.png') })
|
||||
await tab.getByTestId('menu-bill-ask').click()
|
||||
r.check('6.6: asking for the bill says a waiter is bringing it', await shown(tab, 'menu-bill-asked', 5000))
|
||||
await tab.keyboard.press('Escape')
|
||||
await tab.getByTestId('menu-search').fill('')
|
||||
|
||||
// the guest's language, then back to the start after a while
|
||||
await tab.getByTestId('menu-lang-en').click()
|
||||
const enPlaceholder = await tab.getByTestId('menu-search').getAttribute('placeholder')
|
||||
|
||||
Reference in New Issue
Block a user