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:
+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()
|
||||
|
||||
Reference in New Issue
Block a user