feat(waiter): a table's earlier orders (platform-v2 step 4.7)

- GET /api/tables/{id}/history: the table's closed / cancelled orders, newest first,
  for the waiters of its zone (ordering.orders.open), never older than the history
  module's history_days (free tier 31, D-6), module.disabled when history is off;
  each order with times, total (cancelled items left out), people and items.
- Waiter: a History tab on the table (and "This table's earlier orders" on a free
  table); orders expand to their items; the last answer is kept on the phone and
  shown offline, marked as saved; the plan's day limit is shown.
- Tests: test_table_history.py (4), waiter e2e +2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 04:45:31 +02:00
co-authored by Claude Opus 5.5
parent f8d91e7fae
commit 9e1912bce0
7 changed files with 306 additions and 2 deletions
+14 -1
View File
@@ -15,7 +15,7 @@ const vite = await startViteNative({ port: 5181, backendUrl: backend.url })
const APP = 'http://localhost:5181'
const TOKEN_KEY = 'xenia:dev:token'
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('waiter: sign-in v2, lock, approvals (4.2), keys (4.3), server prices (4.4), languages (4.5)')
const r = reporter('waiter: sign-in v2, lock, approvals (4.2), keys (4.3), server prices (4.4), languages (4.5), table history (4.7)')
const errors = []
let failures = 0
@@ -244,6 +244,19 @@ try {
for (const o of [sent, synced]) if (o) await api('DELETE', `/api/orders/${o.id}`, { token: boss }).catch(() => {})
await a.goto(`${APP}/tables`)
// ── 4.7: a table's earlier orders (the order sent above was cancelled: it is history now) ──
await a.goto(`${APP}/tables/${t4.id}`)
await a.getByTestId('history-open').click({ timeout: 10_000 })
const histShown = await shown(a, 'history-order', 10_000)
const histText = await a.getByTestId('table-history').innerText().catch(() => '')
r.check('4.7: a free table shows its earlier orders (the cancelled one, with its total)', histShown && histText.includes(`#${sent?.id}`), histText.replace(/\s+/g, ' ').slice(0, 160))
await ctxA.setOffline(true)
await a.getByTestId('history-open').click()
await a.getByTestId('history-open').click()
r.check('4.7: offline the saved history shows, marked as saved', await shown(a, 'history-cached', 10_000) && await a.getByTestId('history-order').count() > 0)
await ctxA.setOffline(false)
await a.goto(`${APP}/tables`)
// ── 4.5: English first; the language switch in the user menu, saved to the person ──
const navText = () => a.locator('body').innerText()
await a.goto(`${APP}/tables`)