feat: tables and orders in the manager on v2 (platform-v2 step 6.9)
- manager: new pages/orders/ (Tables page cards + quick actions, order page with
lines, multi-select pay/discount/cancel/tab, staff + customer, price changes,
history, the menu + cart beside it); a free table opens a new order on first
Send; v1 TablesPage, OrderDetailPage, DesktopOrderingTab, ManagerOrderDrawer
and PaymentMethodModal removed
- ordering by line id like the phones: GET /api/orders/menu (the counter's
product shape, in-store prices); the product dialog, cart rules and quote hook
move to packages/ordering (@xenia/ordering), shared by counter, menu tablet,
manager
- close follows orders.close_with_unpaid (pay first, or write off after saying
so) on the order page and the overview's quick view; paying asks cash or card
- a confirmed booking can keep its table ahead (manager, phones, counter):
POST /api/connect/bookings/{id}/table, reservations create/PATCH; refused with
reservation.table_kept within 2 h of another booking
- tests: test_manager_ordering.py, online bookings +2, manager orders.test.mjs,
@xenia/ordering, e2e manager.mjs (take, change, pay-first close, RESERVED)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1007,6 +1007,55 @@ try {
|
||||
&& await page.locator('[data-testid="manager-floor"] [data-testid="floor-table"]').count() >= 2)
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-floor-live.png') })
|
||||
|
||||
// ── 6.9: an order taken, changed, paid and closed from the manager by the phones' rules ──
|
||||
const od = 'orders:'
|
||||
await api('POST', '/api/business-day/open', { token: boss, body: {} }).catch(() => {})
|
||||
await api('PUT', '/api/settings/orders.close_with_unpaid', { token: boss, body: { value: 'false' } })
|
||||
const omenu = await api('GET', '/api/orders/menu', { token: boss })
|
||||
const [pA, pB] = omenu.products.filter(p => p.available && !p.service && !p.prefs.length && p.price > 0)
|
||||
const busyIds = new Set((await api('GET', '/api/orders/', { token: boss })).map(o => o.table_id))
|
||||
const otable = (await api('GET', '/api/tables/', { token: boss })).find(x => x.is_active !== false && !busyIds.has(x.id))
|
||||
await page.goto(`${APP}/tables`)
|
||||
await page.locator(`[data-testid="table-card"][data-table="${otable.id}"] [data-testid="table-open"]`).click()
|
||||
await page.getByTestId('order-new').waitFor({ timeout: 10_000 }).catch(() => {})
|
||||
const product = id => page.locator(`[data-testid="order-product"][data-id="${id}"]`).first()
|
||||
await product(pA.id).click()
|
||||
await product(pA.id).click()
|
||||
r.check(`${od} a free table opens a new order; two taps make one line of 2`, (await page.getByTestId('cart-qty').first().textContent().catch(() => '')) === '2')
|
||||
await page.getByTestId('order-send').click()
|
||||
await page.waitForURL(/\/orders\/\d+$/, { timeout: 10_000 }).catch(() => {})
|
||||
const oid = Number(page.url().split('/').pop())
|
||||
let mo = oid ? await api('GET', `/api/orders/${oid}`, { token: boss }) : null
|
||||
r.check(`${od} "Send" opened the table's order, priced by the server`, mo?.table_id === otable.id && mo.items.length === 1
|
||||
&& mo.items[0].quantity === 2 && Math.abs(mo.items[0].unit_price - pA.price) < 0.001, JSON.stringify(mo?.items?.map(i => [i.product_id, i.quantity, i.unit_price])))
|
||||
await page.getByTestId('order-page').waitFor({ timeout: 8000 }).catch(() => {})
|
||||
await product(pB.id).click()
|
||||
await page.getByTestId('order-send').click()
|
||||
const lineB = page.locator(`[data-testid="order-line"][data-status="active"][data-name="${pB.name}"]`).first()
|
||||
await lineB.waitFor({ timeout: 8000 }).catch(() => {})
|
||||
await lineB.getByTestId('line-pick').check()
|
||||
await page.getByTestId('lines-cancel').click()
|
||||
await page.getByTestId('cancel-no-print').click()
|
||||
for (let i = 0; i < 20 && !mo?.items?.some(x => x.product_id === pB.id && x.status === 'cancelled'); i++) { await sleep(250); mo = await api('GET', `/api/orders/${oid}`, { token: boss }) }
|
||||
r.check(`${od} a line added, then cancelled (no ticket)`, mo.items.some(x => x.product_id === pB.id && x.status === 'cancelled'))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-order.png'), fullPage: true })
|
||||
await page.getByTestId('order-close').click()
|
||||
const payFirst = await page.getByTestId('pay-dialog').waitFor({ timeout: 5000 }).then(() => true).catch(() => false)
|
||||
r.check(`${od} "Close" with unpaid lines takes the payment first (close_with_unpaid off)`, payFirst
|
||||
&& (await page.getByTestId('pay-amount').textContent()).includes((pA.price * 2).toFixed(2)))
|
||||
await page.getByTestId('pay-cash').click()
|
||||
for (let i = 0; i < 20 && mo?.status !== 'closed'; i++) { await sleep(250); mo = await api('GET', `/api/orders/${oid}`, { token: boss }) }
|
||||
r.check(`${od} …paid in cash and closed`, mo.status === 'closed' && mo.items.filter(x => x.status === 'paid').every(x => x.payment_method === 'cash')
|
||||
&& await page.locator('[data-testid="order-page"][data-status="closed"]').waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
|
||||
// a booking given a table ahead shows RESERVED on it
|
||||
const soon = await page.evaluate(() => new Date(Date.now() + 3600_000).toISOString())
|
||||
const kept = await api('POST', '/api/reservations/', { token: boss, body: { guest_name: 'Kept E2E', party_size: 3, reserved_for: soon, table_id: otable.id } })
|
||||
await page.goto(`${APP}/tables`)
|
||||
r.check(`${od} a booking given the table shows RESERVED on its card`, !!kept?.id
|
||||
&& await page.locator(`[data-testid="table-card"][data-table="${otable.id}"] [data-testid="table-reserved"]`).waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-tables.png'), fullPage: true })
|
||||
await api('PATCH', `/api/reservations/${kept.id}/status`, { token: boss, body: { status: 'cancelled' } }).catch(() => {})
|
||||
|
||||
await api('PUT', '/api/platform/modules/connect_orders', { token: boss, body: { enabled: true } })
|
||||
await page.goto(`${APP}/online-orders`)
|
||||
await page.getByTestId('online-orders').waitFor({ timeout: 10_000 }).catch(() => {})
|
||||
|
||||
@@ -16,6 +16,7 @@ const suites = [
|
||||
['unit: packages/access (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/access'], CS],
|
||||
['unit: packages/signage (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/signage'], CS],
|
||||
['unit: packages/floorplan (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/floorplan'], CS],
|
||||
['unit: packages/ordering (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/ordering'], CS],
|
||||
['unit: manager_dashboard (node --test)', 'npm', ['test', '--silent', '-w', 'manager-dashboard'], CS],
|
||||
['lint: manager_dashboard (v2 code)', 'npm', ['run', 'lint', '--silent', '-w', 'manager-dashboard'], CS],
|
||||
['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS],
|
||||
|
||||
Reference in New Issue
Block a user