feat: call a waiter from a menu tablet at a table (platform-v2 step 5.7b)
- backend: menu tablet device config `table` (ref, validated against active
tables) and `call_waiter`; GET /api/menu-tablet/menu gives the table and
whether it can call; POST /api/menu-tablet/call sends a `table_call` staff
message ("Table 5: the guests call a waiter.", venue language) to the table's
waiters (its open order's, else the zone's), at most once a minute per tablet
(menu_tablet.call_too_soon with the seconds left; menu_tablet.no_table).
- terminal: "Call a waiter" only on a tablet at a table; "A waiter is on the
way to table 5", then a countdown before it can call again; a failed call
says to ask at the counter.
- waiter: the call shows with its own look and "Open the table".
- manager: tables as the choices of a device setting.
- tests: backend +2 (535 → 533 passed total), e2e menu_tablet.mjs +3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Menu tablet suite (plan step 5.7a): a tablet paired as a menu tablet shows the venue's menu with
|
||||
// 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.
|
||||
// the guest's language; back to the start after a while without a touch; a tablet at a table calls
|
||||
// a waiter (5.7b).
|
||||
// Starts its own backend (:8067) and the terminal (:5195).
|
||||
// node menu_tablet.mjs
|
||||
import path from 'node:path'
|
||||
@@ -13,7 +14,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)')
|
||||
const r = reporter('menu tablet: the menu, search, views, live prices, languages, idle reset (5.7a), call a waiter (5.7b)')
|
||||
const errors = []
|
||||
let failures = 0
|
||||
|
||||
@@ -75,6 +76,18 @@ try {
|
||||
const live = await waitFor(async () => ((await tab.locator(`[data-testid="menu-item"][data-id="${souvlaki.id}"]`).textContent().catch(() => '')).includes('7.70') ? true : null), 15_000, 300)
|
||||
r.check('a price change shows on the tablet without a reload', !!live)
|
||||
|
||||
// 5.7b: a tablet at a table calls a waiter; one without a table has no button
|
||||
r.check('5.7b: a tablet not at a table has no "Call a waiter" button', await tab.getByTestId('menu-call-button').count() === 0)
|
||||
const tables = await api('GET', '/api/tables/', { token: boss })
|
||||
const t5 = tables.find(x => x.is_active !== false) || tables[0]
|
||||
await api('PATCH', `/api/devices/${dev.id}`, { token: boss, body: { config: { table: t5.id } } })
|
||||
r.check('5.7b: set at a table, it gets the button', await shown(tab, 'menu-call-button', 15_000))
|
||||
await tab.getByTestId('menu-call-button').click()
|
||||
r.check('5.7b: calling says a waiter is on the way, and waits before it can call again',
|
||||
await shown(tab, 'menu-call-sent', 5000) && await tab.getByTestId('menu-call-button').isDisabled()
|
||||
&& (await tab.getByTestId('menu-call-sent').textContent()).includes(t5.label || String(t5.number)))
|
||||
await tab.screenshot({ path: path.join(OUT, 'menu-tablet-call.png') })
|
||||
|
||||
// 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