feat(waiter): table bookings on the phone; shared ReasonPicker (platform-v2 step 4.8c)

- Waiter: Bookings (side drawer, for whoever has connect_orders.manage or
  reservations.manage, with the online-orders app on): requests made online are
  confirmed or declined with a reason the guest sees; confirmed ones are seated at a free
  table (its seats shown, a warning mark when the party is bigger) or cancelled / marked
  as a no-show; the food ordered ahead and its kitchen time; live updates.
- Backend: the bookings routes take reservations.manage too (require_any).
- @xenia/ui ReasonPicker + reasonText (gallery, unit test), first piece moved from the
  terminal (4.6 → 4.8): the counter's online reject and booking decline dialogs use it;
  the waiter loads @xenia/ui styles.css (the .x-* components; tokens as before).
- Tests: waiter e2e +2 (request listed with the key, confirmed and seated from the phone);
  terminal.mjs and qr_table.mjs green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 10:10:14 +02:00
co-authored by Claude Opus 5.5
parent 1e8271e370
commit f57894dcb7
16 changed files with 387 additions and 37 deletions
+22
View File
@@ -322,6 +322,28 @@ try {
r.check('4.8: more guests than seats is allowed, with a hint (not a limit)', await a.getByTestId('seats-hint').getAttribute('data-over') === 'true')
await a.goto(`${APP}/tables`)
// bookings on the phone: a request made online is confirmed and the guests seated (the counter's flow)
const sqlite = sql => execFileSync(PYTHON, ['-c', `import sqlite3; c = sqlite3.connect(r"${path.join(backend.dataDir, 'pos.db')}"); r = c.execute(${JSON.stringify(sql)}).fetchall(); c.commit(); print(r)`], { encoding: 'utf8' }).trim()
sqlite("insert into reservations (guest_name, party_size, phone, reserved_for, status, source, online_ref, created_at, updated_at) values ('E2E Guest', 2, '6900000000', datetime('now', '+2 hours'), 'requested', 'online', 'ORD-E2E', datetime('now'), datetime('now'))")
const waiterRole = await api('GET', '/api/waiters/roles/waiter/permissions', { token: boss })
await api('PUT', '/api/waiters/roles/waiter/permissions', { token: boss, body: { keys: [...waiterRole.keys, 'connect_orders.manage'] } })
await a.goto(`${APP}/tables`)
await a.reload()
await a.locator('button').filter({ has: a.locator('svg') }).first().click().catch(() => {})
const drawerHasBookings = await a.getByRole('button', { name: 'Bookings' }).isVisible({ timeout: 5000 }).catch(() => false)
await a.goto(`${APP}/bookings`)
const card = () => a.locator('[data-testid="booking-card"]').filter({ hasText: 'E2E Guest' })
await card().first().waitFor({ timeout: 10_000 }).catch(() => {})
r.check('4.8: with the online-orders key the phone lists the booking request (drawer: Bookings)', drawerHasBookings && await card().getAttribute('data-status') === 'requested')
await card().getByTestId('booking-confirm').click()
await waitFor(async () => await card().getAttribute('data-status') === 'pending', 10_000, 300)
await card().getByTestId('booking-table').selectOption({ index: 1 })
await card().getByTestId('booking-arrive').click()
const seated = await waitFor(async () => /arrived', \d+/.test(sqlite("select status, table_id from reservations where online_ref = 'ORD-E2E'")) && 1, 10_000, 500)
r.check('4.8: …confirmed and seated at a table from the phone', !!seated, sqlite("select status, table_id from reservations where online_ref = 'ORD-E2E'"))
await api('PUT', '/api/waiters/roles/waiter/permissions', { token: boss, body: { keys: waiterRole.default_keys } })
await a.goto(`${APP}/tables`)
// ── 4.6: the look on the shared tokens: the venue's colour and light / dark reach the phone ──
const accentOf = () => a.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--x-accent-rgb').trim())
r.check('4.6: the venue colour (default amber) is on the phone', await a.evaluate(() => document.documentElement.dataset.venueTheme) === 'amber')