feat(manager): the overview, online orders and the day summary on v2 (platform-v2 step 6.2)
- DashboardPage (2.8k lines) → src/pages/overview/: OverviewPage + cards (shifts, tables, pending prints, notes, bookings, messages) and dialogs (order at a glance, shift review / end with the cash handover, day summary with cash count and checks); arithmetic in overviewLogic.js (tests/overview.test.mjs). Data via useLiveQuery: orders and tables live, day and shifts every 15 s. Bookings typed in venue time; decline reason in a dialog. - OnlineOrdersPage → src/pages/online/ on react-query + live events; unused API helpers dropped. - WorkdaySummaryModal → overview/DaySummaryDialog + DaySummaryTabs. - Every text in manager.json (en + el, 342 keys); tokens only; v2.json adds overview, hooks. - Backend: business day open/close answer only with codes (license.locked, license.expired, business_day.orders_open); XeniaError's v1 `detail` removed. - @xenia/i18n: formatDateTime with Intl options threw "unknown date style" (fixed, tested). - e2e manager.mjs: open the day, a shift (start, stats, end short), a live table, a booking, day stats, Greek, close the day (forced), online orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -774,6 +774,98 @@ try {
|
||||
(await chefRow.textContent().catch(() => '')).includes('Kitchen pass · Kitchen display'))
|
||||
await o.screenshot({ path: path.join(OUT, 'manager-owner-flow.png'), fullPage: true })
|
||||
|
||||
// ── 6.2: the overview (open the day, a shift, a table, close the day), online orders ──
|
||||
const ov = 'overview:'
|
||||
if (await api('GET', '/api/business-day/current', { token: boss })) { // earlier steps' orders may have opened one
|
||||
await api('POST', '/api/business-day/close', { token: boss, body: { force: true } })
|
||||
}
|
||||
await page.goto(`${APP}/dashboard`)
|
||||
await page.getByTestId('overview').waitFor({ timeout: 15_000 })
|
||||
const dayState = () => page.getByTestId('day-state').getAttribute('data-open')
|
||||
r.check(`${ov} the landing page shows the day closed, the figures, the tables and the cards`, await dayState() === 'false'
|
||||
&& await page.getByTestId('kpis').count() === 1 && await page.getByTestId('table-chip').count() > 0 && await page.getByTestId('shifts-card').count() === 1)
|
||||
await page.getByTestId('day-open').click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="day-state"]')?.dataset.open === 'true', null, { timeout: 8000 }).catch(() => {})
|
||||
r.check(`${ov} "Open the day" opens it`, await dayState() === 'true' && !!(await api('GET', '/api/business-day/current', { token: boss })))
|
||||
const ovWaiter = (await api('GET', '/api/waiters/', { token: boss })).find(w => w.username === 'demo_maria')
|
||||
await page.getByTestId('shift-start').click()
|
||||
await page.getByTestId('shift-start-waiter').selectOption(String(ovWaiter.id))
|
||||
await page.getByRole('dialog').getByLabel('Starting cash').fill('20,5')
|
||||
await page.getByTestId('shift-start-confirm').click()
|
||||
const ovRow = page.getByTestId('shift-row').filter({ hasText: ovWaiter.full_name })
|
||||
r.check(`${ov} a shift started for a waiter with €20.50 (typed with a comma)`, await ovRow.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
&& (await api('GET', '/api/shifts/?active_only=true', { token: boss })).shifts.some(s => s.waiter_id === ovWaiter.id && s.starting_cash === 20.5))
|
||||
const freeTable = (await api('GET', '/api/tables/', { token: boss })).find(t => !t.open_order_id && !t.current_order_id)
|
||||
const ovOrder = await api('POST', '/api/orders/', { token: await loginApi('demo_maria', { pin: '3302', client: 'waiter' }), body: { table_id: freeTable.id } })
|
||||
const chip = page.locator(`[data-testid="table-chip"][data-state="open"]`).filter({ hasText: freeTable.label || `T${freeTable.number}` }).first()
|
||||
r.check(`${ov} a table a waiter opens turns "open" by itself (live)`, await chip.waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
|
||||
await chip.click()
|
||||
r.check(`${ov} the table opens its order at a glance`, await page.getByTestId('order-dialog').waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
&& (await page.getByRole('dialog').textContent()).includes(`#${ovOrder.id}`))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-overview-order.png') })
|
||||
await page.keyboard.press('Escape')
|
||||
await ovRow.getByTestId('shift-stats').click()
|
||||
await page.getByTestId('shift-dialog').waitFor({ timeout: 8000 }).catch(() => {})
|
||||
r.check(`${ov} shift stats: €20.50 expected in the drawer`, (await page.getByTestId('shift-expected').textContent().catch(() => '')).includes('20.50'))
|
||||
await page.keyboard.press('Escape')
|
||||
await ovRow.getByTestId('shift-end').click()
|
||||
await page.getByTestId('shift-next').click()
|
||||
await page.getByTestId('shift-counted').fill('18')
|
||||
r.check(`${ov} ending it: €18 handed over shows "short"`, await page.getByTestId('shift-check').getAttribute('data-state').catch(() => '') === 'short')
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-overview-shift.png') })
|
||||
await page.getByTestId('shift-end-confirm').click()
|
||||
await ovRow.waitFor({ state: 'detached', timeout: 8000 }).catch(() => {})
|
||||
r.check(`${ov} …and the shift ends with the count kept`, await ovRow.count() === 0
|
||||
&& !(await api('GET', '/api/shifts/?active_only=true', { token: boss })).shifts.some(s => s.waiter_id === ovWaiter.id))
|
||||
if (await page.getByTestId('booking-new').count()) {
|
||||
await page.getByTestId('booking-new').click()
|
||||
await page.getByTestId('booking-name').fill('Eleni E2E')
|
||||
await page.getByRole('button', { name: '+1 h' }).click()
|
||||
await page.getByTestId('booking-save').click()
|
||||
const bookingRow = page.getByTestId('booking-row').filter({ hasText: 'Eleni E2E' })
|
||||
const want = await page.evaluate(() => Date.now() + 3600_000)
|
||||
const listed = await bookingRow.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
const saved = (await api('GET', '/api/reservations/?tab=upcoming', { token: boss })).find(b => b.guest_name === 'Eleni E2E')
|
||||
r.check(`${ov} a booking "in 1 hour" is saved at that moment (venue time) and listed`, listed
|
||||
&& !!saved && Math.abs(new Date(/[zZ]|[+-]\d\d:?\d\d$/.test(saved.reserved_for) ? saved.reserved_for : `${saved.reserved_for}Z`).getTime() - want) < 3 * 60_000, saved?.reserved_for)
|
||||
}
|
||||
await page.getByTestId('day-stats').click()
|
||||
await page.getByTestId('day-money').waitFor({ timeout: 8000 }).catch(() => {})
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-overview-day.png') })
|
||||
r.check(`${ov} day stats: the money tab, then staff`, await page.getByTestId('day-net').count() === 1
|
||||
&& await page.getByTestId('day-tab-staff').click().then(() => page.getByTestId('day-staff').waitFor({ timeout: 5000 })).then(() => true).catch(() => false))
|
||||
await page.keyboard.press('Escape')
|
||||
// both languages
|
||||
await page.getByTestId('user-menu').click()
|
||||
await page.getByRole('menuitemradio', { name: 'Ελληνικά' }).click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="tables-card"]')?.innerText.includes('Τραπέζια τώρα'), null, { timeout: 5000 }).catch(() => {})
|
||||
r.check(`${ov} in Greek`, (await page.getByTestId('day-state').textContent()).includes('Ημέρα ανοιχτή') && (await page.getByTestId('tables-card').textContent()).includes('Τραπέζια τώρα'))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-overview-el.png'), fullPage: true })
|
||||
await page.getByTestId('user-menu').click()
|
||||
await page.getByRole('menuitemradio', { name: 'English' }).click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="tables-card"]')?.innerText.includes('Tables now'), null, { timeout: 5000 }).catch(() => {})
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-overview.png'), fullPage: true })
|
||||
// close the day: the table is still open → the checks say so and the close is forced
|
||||
await page.getByTestId('day-close').click()
|
||||
await page.getByTestId('day-to-cash').click()
|
||||
await page.getByTestId('day-counted').fill('0')
|
||||
await page.getByTestId('day-to-checks').click()
|
||||
r.check(`${ov} closing: the checks show the open table`, await page.getByTestId('check-tables').getAttribute('data-ok').catch(() => '') === 'false')
|
||||
await page.getByTestId('day-close-confirm').click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="day-state"]')?.dataset.open === 'false', null, { timeout: 8000 }).catch(() => {})
|
||||
r.check(`${ov} …"Close the day" closes it and the open order with it`, await dayState() === 'false'
|
||||
&& !(await api('GET', '/api/business-day/current', { token: boss }))
|
||||
&& (await api('GET', `/api/orders/${ovOrder.id}`, { token: boss })).status === 'closed')
|
||||
|
||||
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(() => {})
|
||||
const noNew = await page.getByText('No new online orders.').waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
await page.getByTestId('online-tab-history').click()
|
||||
const past = await page.getByTestId('online-order').first().waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
r.check(`${ov} online orders: nothing new; the history lists the earlier online orders`, noNew && past
|
||||
&& await page.locator('[data-testid="online-order"]:not([data-status="delivered"]):not([data-status="rejected"])').count() === 0)
|
||||
|
||||
r.check('live: the manager connection carries no token in its address (4.0)', managerWs.some(u => u.includes('/api/ws/')) && managerWs.filter(u => u.includes('/api/')).every(u => !/token=/.test(u)), managerWs.filter(u => u.includes('/api/')).join(' ')) // (Vite's own dev socket has its token)
|
||||
r.check('no page errors', errors.length === 0, errors.slice(0, 3).join(' | '))
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user