feat(connect): table bookings from the online ordering app; food fired to the kitchen before arrival
Plan phase 3S, step S.6. - Pull: "reservation" / "preorder" orders become Reservations waiting for an answer (status "requested"; services/online_reservations.py), with the food ordered ahead kept on the booking (items_json at the cloud's prices, the site's price check) — no order yet. Migration 0020 (reservations: online_order_cloud_id, online_ref, items_json, total, online_price_diff, fire_at, order_id, response_note). - Confirm → the food's fire time = booking time − fire minutes (setting); the fire worker (connect_orders, every 20 s) turns the food into an order at that time (needs an open business day; waits otherwise): kitchen tickets, KDS (reference and time). Early arrival fires at once. Seating moves the order to the table (refused if the table has an open order). Decline / cancel / no-show with a reason. Every step mirrored to the cloud. - Found: the KDS filter dropped every online order without an online status (SQL NULL in NOT(a AND b)) — made NULL-safe. - Counter: Online → Bookings (requests first, then upcoming), BookingPanel (confirm, decline with reasons, food and when it goes to the kitchen, seat at a free table, cancel, no-show); the Online badge and chime count booking requests. - Manager: Online ordering → Table bookings settings (on, food ahead, hours, slot, notice, days ahead, party size, fire minutes); the dashboard's reservations card confirms / declines online requests; the reservations router delegates online bookings' status steps. - Tests: tests/test_online_bookings.py (8), unit tests (terminal, manager), e2e: order app (book with food → the venue confirms), terminal (request → confirm → the two dishes reach the KDS at the fire time, not before → seated), manager (booking settings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -572,6 +572,19 @@ try {
|
||||
if (feeProduct?.name !== 'Delivery') await sleep(100)
|
||||
}
|
||||
r.check('fees: the fee line\'s name and VAT group are saved', feeProduct?.name === 'Delivery' && feeProduct?.vat_group_id === 2, JSON.stringify(feeProduct))
|
||||
// S.6: table bookings online, with food ordered ahead
|
||||
await page.getByTestId('booking-enabled').click()
|
||||
await page.getByTestId('booking-food').click()
|
||||
await page.getByTestId('booking-party').fill('8')
|
||||
await page.getByTestId('booking-fire').fill('25')
|
||||
await page.getByTestId('ordering-save').click()
|
||||
let bookingCfg = null
|
||||
for (let i = 0; i < 30 && !bookingCfg?.enabled; i++) {
|
||||
bookingCfg = (await api('GET', '/api/connect/fees/ordering', { token: boss })).reservations
|
||||
if (!bookingCfg?.enabled) await sleep(100)
|
||||
}
|
||||
r.check('ordering: table bookings on, with food, 8 people at most, the kitchen 25 min before', bookingCfg?.enabled && bookingCfg.with_food && bookingCfg.party_max === 8
|
||||
&& bookingCfg.fire_minutes === 25, JSON.stringify(bookingCfg))
|
||||
r.check('fees: …and it never shows in the products list', !(await api('GET', '/api/products/?all=true', { token: boss })).some(p => p.id === feeProduct?.id))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-fees.png'), fullPage: true })
|
||||
|
||||
|
||||
+37
-3
@@ -20,7 +20,7 @@ const CLOUD_PORT = 8113
|
||||
const APP_PORT = 5211
|
||||
const CLOUD_URL = `http://127.0.0.1:${CLOUD_PORT}`
|
||||
const APP_DIR = path.join(REPO, 'cloud-service', 'connect_frontend', 'order-app')
|
||||
const r = reporter('order app: takeaway + delivery, priced by the cloud, tracked')
|
||||
const r = reporter('order app: takeaway + delivery + table booking, priced by the cloud, tracked')
|
||||
const procs = []
|
||||
|
||||
function start(cmd, args, opts, logName) {
|
||||
@@ -68,7 +68,7 @@ try {
|
||||
] },
|
||||
{ id: 2, name: 'Food', products: [
|
||||
{ id: 12, name: 'Souvlaki', digital_description: 'Pork, pita, tzatziki', base_price: 4, digital_price: 4, digital_available: true,
|
||||
sold_at: ['online_takeaway', 'online_delivery'], prices: { online_takeaway: 4, online_delivery: 4.2 }, quick_options: [] },
|
||||
sold_at: ['online_takeaway', 'online_delivery', 'online_preorder'], prices: { online_takeaway: 4, online_delivery: 4.2, online_preorder: 3.8 }, quick_options: [] },
|
||||
{ id: 13, name: 'Soup of the day', base_price: 6, digital_available: false, sold_at: ['online_delivery'], prices: { online_delivery: 6 }, quick_options: [] },
|
||||
] },
|
||||
],
|
||||
@@ -80,7 +80,9 @@ try {
|
||||
{ id: 3, name: 'Hills', area_ids: [2], action: 'add', value: 1, sales_points: ['online_delivery'] },
|
||||
],
|
||||
},
|
||||
ordering: { services: ['takeaway', 'delivery'], hours: {}, prep_minutes: 20, slot_minutes: 15, days_ahead: 0, asap: true },
|
||||
ordering: { services: ['takeaway', 'delivery'], hours: {}, prep_minutes: 20, slot_minutes: 15, days_ahead: 0, asap: true,
|
||||
// S.6: table bookings, with food ordered ahead
|
||||
reservations: { enabled: true, with_food: true, hours: {}, slot_minutes: 30, days_ahead: 7, notice_minutes: 0, party_max: 6, fire_minutes: 20 } },
|
||||
}
|
||||
await call('POST', '/api/menu/sync', { headers: siteH, body: { site_id: numeric, snapshot_json: JSON.stringify(snapshot) } })
|
||||
|
||||
@@ -171,6 +173,38 @@ try {
|
||||
r.check('a rejected order says so, with the reason', await page.waitForFunction(() => document.querySelector('[data-testid="track"]')?.dataset.status === 'rejected', null, { timeout: 15_000 })
|
||||
.then(() => true).catch(() => false) && await page.getByText('Closing early').count() === 1)
|
||||
|
||||
// ── S.6: book a table, with food ready on arrival ────────────────────────
|
||||
await page.goto(`http://localhost:${APP_PORT}/order/${site.site_id}`)
|
||||
await page.getByTestId('service-book').click()
|
||||
r.check('booking: the days the venue takes bookings (today + 7)', await page.getByTestId('booking').waitFor({ timeout: 5000 }).then(() => true).catch(() => false)
|
||||
&& await page.getByTestId('book-day').count() === 8)
|
||||
await page.getByTestId('book-day').nth(1).click() // tomorrow
|
||||
await page.getByTestId('book-time').filter({ hasText: '20:00' }).click({ timeout: 8000 })
|
||||
for (let i = 0; i < 2; i++) await page.getByTestId('booking').getByRole('button', { name: '+' }).click()
|
||||
r.check('booking: 4 people, tomorrow 20:00 picked; no food yet = no menu', await page.getByTestId('party').textContent() === '4' && await product(12).count() === 0)
|
||||
await page.getByTestId('book-food').check()
|
||||
r.check('booking: with food → the menu at the pre-order prices (souvlaki €3.80; the cola is not pre-orderable)',
|
||||
(await product(12).getByTestId('price').textContent()).includes('3.80') && await product(11).count() === 0)
|
||||
await product(12).getByTestId('add').click()
|
||||
await product(12).getByRole('button', { name: '+' }).click()
|
||||
await page.screenshot({ path: path.join(OUT, 'order-app-booking.png'), fullPage: true })
|
||||
await page.getByTestId('book-continue').click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="totals"]')?.dataset.total === '7.6', null, { timeout: 8000 }).catch(() => {})
|
||||
r.check('booking: the summary (table for 4, tomorrow) and the food priced by the cloud (€7.60)',
|
||||
(await page.getByTestId('booking-summary').textContent()).includes('Table for 4') && await page.getByTestId('totals').getAttribute('data-total') === '7.6')
|
||||
await page.getByTestId('place-order').click()
|
||||
await page.getByTestId('track').waitFor({ timeout: 10_000 }).catch(() => {})
|
||||
r.check('booking: requested → its page (booking ORD-0003, table for 4, waiting for the venue)',
|
||||
(await page.getByTestId('track-ref').textContent().catch(() => '')).includes('Booking ORD-0003')
|
||||
&& (await page.getByTestId('track').textContent()).includes('Table for 4') && await page.getByTestId('track').getAttribute('data-status') === 'pending_acceptance')
|
||||
const booked = (await call('GET', `/api/orders/pending/${numeric}`, { headers: siteH })).find(o => o.public_ref === 'ORD-0003')
|
||||
r.check('booking: the site receives a pre-order for 4 at the pre-order prices', booked?.order_type === 'preorder' && booked.party_size === 4
|
||||
&& booked.total === 7.6 && booked.sales_point === 'online_preorder' && !!booked.requested_for, JSON.stringify(booked))
|
||||
await call('PATCH', `/api/orders/${booked.id}/status`, { headers: siteH, body: { status: 'accepted' } })
|
||||
r.check('booking: the venue confirms → the page says so', await page.waitForFunction(() => document.querySelector('[data-testid="track"]')?.dataset.status === 'accepted', null, { timeout: 15_000 })
|
||||
.then(() => true).catch(() => false) && (await page.getByTestId('track').textContent()).includes('Confirmed'))
|
||||
await page.screenshot({ path: path.join(OUT, 'order-app-booking-track.png'), fullPage: true })
|
||||
|
||||
// ── Greek ────────────────────────────────────────────────────────────────
|
||||
await page.goto(`http://localhost:${APP_PORT}/order/${site.site_id}`)
|
||||
await page.getByRole('button', { name: 'EL' }).click()
|
||||
|
||||
+38
-1
@@ -39,7 +39,7 @@ const cloudServer = http.createServer((req, res) => {
|
||||
})
|
||||
await new Promise(res => cloudServer.listen(0, '127.0.0.1', res))
|
||||
const backend = await startBackend({ port: 8059, siteId: 'test-site-1', cloudUrl: `http://127.0.0.1:${cloudServer.address().port}`,
|
||||
env: { LICENSE_MODE: 'off', CONNECT_SYNC_INTERVAL_SECONDS: '1' } })
|
||||
env: { LICENSE_MODE: 'off', CONNECT_SYNC_INTERVAL_SECONDS: '1', XENIA_FIRE_CHECK_SECONDS: '2' } })
|
||||
const term = await startTerminalVite({ port: 5187, backendUrl: backend.url })
|
||||
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||
const r = reporter('terminal: pairing, sign-in, app states (paired screens)')
|
||||
@@ -607,6 +607,43 @@ try {
|
||||
r.check('3.3d: …and it leaves the New list', await page.waitForFunction(() => !document.querySelector('[data-testid="online-order"]'), null, { timeout: 5000 })
|
||||
.then(() => true).catch(() => false))
|
||||
|
||||
// ── S.6: a table booking with two dishes: confirmed, the dishes reach the KDS at the fire time ──
|
||||
const ordering = await api('GET', '/api/connect/fees/ordering', { token: boss })
|
||||
await api('PUT', '/api/connect/fees/ordering', { token: boss, body: { ...ordering,
|
||||
reservations: { ...ordering.reservations, enabled: true, with_food: true, fire_minutes: 1 } } })
|
||||
const arriving = new Date(Date.now() + 90_000) // the kitchen gets it a minute before: in ~30 s
|
||||
cloud.queue.push(cloudOrder(43, 'preorder', 'Eleni Booking', 0, { party_size: 4, requested_for: arriving.toISOString(), sales_point: 'online_preorder',
|
||||
customer_address: null }))
|
||||
await page.getByTestId('online-list-bookings').click()
|
||||
const bookingCard = page.locator('[data-testid="booking"][data-status="requested"]').first()
|
||||
r.check('S.6: a booking request reaches the counter (Online → Bookings), waiting for an answer',
|
||||
await bookingCard.waitFor({ timeout: 15_000 }).then(() => true).catch(() => false) && (await bookingCard.textContent()).includes('Eleni Booking'))
|
||||
await bookingCard.click()
|
||||
r.check('S.6: …it shows the party and the two dishes ordered ahead', await shown(page, 'booking-panel', 5000)
|
||||
&& (await page.getByTestId('booking-guest').textContent()).includes('4 people') && (await page.getByTestId('booking-food').textContent()).includes(`2× ${simple.name}`))
|
||||
await page.screenshot({ path: path.join(OUT, 'terminal-pos-booking.png') })
|
||||
await page.getByTestId('booking-confirm').click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="booking-panel"]')?.dataset.status === 'pending', null, { timeout: 8000 }).catch(() => {})
|
||||
for (let i = 0; i < 30 && !cloud.statuses.some(x => x.id === 43); i++) await sleep(100)
|
||||
r.check('S.6: Confirm → confirmed, and the customer is told', await page.getByTestId('booking-panel').getAttribute('data-status') === 'pending'
|
||||
&& cloud.statuses.some(x => x.id === 43 && x.status === 'accepted'), JSON.stringify(cloud.statuses.filter(x => x.id === 43)))
|
||||
const bookingOnKds = async () => (await api('GET', '/api/kds/orders', { token: boss })).orders.find(o => o.online_ref === 'ORD-0043')
|
||||
r.check('S.6: …the kitchen does not get the dishes at once', !(await bookingOnKds())
|
||||
&& (await page.getByTestId('booking-food').textContent()).includes('kitchen'))
|
||||
let fired = null
|
||||
for (let i = 0; i < 90 && !fired; i++) { fired = await bookingOnKds(); if (!fired) await sleep(1000) }
|
||||
const firedAt = Date.now()
|
||||
r.check('S.6: …at the fire time (a minute before arrival) the two dishes are on the KDS, with the time',
|
||||
!!fired && fired.items.reduce((s, i) => s + i.quantity, 0) === 2 && !!fired.requested_for && firedAt < arriving.getTime() - 50_000,
|
||||
JSON.stringify(fired?.items?.map(i => [i.product_name, i.quantity])))
|
||||
const freeTable = (await api('GET', '/api/pos/tables', { token: boss })).tables.find(x => !x.order)
|
||||
await page.getByTestId('booking-table').selectOption(String(freeTable.id))
|
||||
await page.getByTestId('booking-arrive').click()
|
||||
for (let i = 0; i < 30 && !cloud.statuses.some(x => x.id === 43 && x.status === 'delivered'); i++) await sleep(100)
|
||||
const seated = await api('GET', `/api/orders/${fired?.id}`, { token: boss }).catch(() => null)
|
||||
r.check('S.6: the guests arrive and are seated → their order moves to the table; the customer\'s page says welcome',
|
||||
seated?.table_id === freeTable.id && cloud.statuses.some(x => x.id === 43 && x.status === 'delivered'))
|
||||
|
||||
// ── 3.3e: refunds ───────────────────────────────────────────────────────
|
||||
// fiscal receipts on, with today's text-file bridge: it can't take credit notes yet, so the
|
||||
// cashier is told to issue it on the machine (owner decision 2026-11-15)
|
||||
|
||||
Reference in New Issue
Block a user