feat(terminal): the customer display, with an idle screen each venue designs
Plan step 3.4. Owner (2026-11-16): the idle screen is configurable per venue. - routers/customer_display.py (module customer_display, /api/display): the counter POS pushes its state (POST /api/display/state: idle | cart | paid with lines, total, paid, change); only the displays linked to that POS get `display.state`; the last state is kept in memory for a display that reconnects (GET /api/display/state). pos_counter's device scope includes customer_display.state. - The idle screen: setting customer_display.idle (name, logo, logo + name, blank, one image, slideshow, QR code to the online ordering / QR menu / any link; a line of text; dark or light); images uploaded to /app/data/display_media (JPG/PNG/WebP/GIF ≤ 5 MB, random names, served publicly on the LAN); a change sends `display.settings` to every display. New key customer_display.manage (owners, store managers; migration 0022). - Terminal: CustomerDisplayApp (cart with a large total, "Thank you" with the change for 12 s, the venue's idle screen, its theme), logic.js (unit-tested); the POS pushes from the sale cart and the payment dialog (tables, online orders too) via useDisplay(). qrcode.react added to the terminal (already in the workspace). - Manager: Settings → Customer display (style cards, venue name, text, look, slide seconds, QR target/link/caption, image upload/pick/order/delete). - Tests: tests/test_customer_display.py (3), terminal display.test.mjs (3); e2e terminal (linked vs unlinked display, < 1 s, paid, QR and slideshow idle screens), manager (the settings tab). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -590,6 +590,22 @@ try {
|
||||
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 })
|
||||
|
||||
// 3.4: the customer display's idle screen, the venue's choice
|
||||
await api('PUT', '/api/platform/modules/customer_display', { token: boss, body: { enabled: true } }).catch(() => {})
|
||||
await page.goto(`${APP}/settings`)
|
||||
await page.getByText('Customer display', { exact: true }).click()
|
||||
await page.getByTestId('display-style-qr').click()
|
||||
await page.getByTestId('display-qr-caption').fill('Order online')
|
||||
await page.getByTestId('display-save').click()
|
||||
let idleCfg = null
|
||||
for (let i = 0; i < 30 && idleCfg?.style !== 'qr'; i++) {
|
||||
idleCfg = (await api('GET', '/api/display/settings', { token: boss })).idle
|
||||
if (idleCfg?.style !== 'qr') await sleep(100)
|
||||
}
|
||||
r.check('settings: customer display → a QR code to the online ordering, with a caption', idleCfg?.style === 'qr'
|
||||
&& idleCfg.qr_target === 'ordering' && idleCfg.qr_caption === 'Order online', JSON.stringify(idleCfg))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-display-settings.png'), fullPage: true })
|
||||
|
||||
await page.goto(`${APP}/settings`)
|
||||
await page.getByText('Sign-in & security', { exact: true }).click()
|
||||
const waiterMode = page.getByTestId('setting-auth.waiter_login_mode')
|
||||
|
||||
@@ -684,6 +684,56 @@ try {
|
||||
{ order: saleOrder, name: simple.name }, { timeout: 8000 }).then(() => true).catch(() => false))
|
||||
await api('PUT', '/api/settings/fiscal.enabled', { token: boss, body: { value: 'false' } })
|
||||
await page.getByTestId('mode-sale').click()
|
||||
|
||||
// ── 3.4: the customer display ────────────────────────────────────────────
|
||||
// two displays: one linked to this counter, one not (another counter's); the venue's idle screen
|
||||
await api('PUT', '/api/platform/modules/customer_display', { token: boss, body: { enabled: true } }).catch(() => {})
|
||||
await api('PUT', '/api/settings/venue.name', { token: boss, body: { value: 'Taverna E2E' } })
|
||||
// its own address for the pairing rate limit (one per screen in a real venue)
|
||||
const myDisplay = await screen(await (await browser.newContext({ viewport: { width: 1024, height: 600 }, extraHTTPHeaders: { 'x-real-ip': '10.9.0.41' } })).newPage())
|
||||
await pairFromManager(myDisplay, boss, { app_key: 'customer_display', name: 'Display at the counter', linked_device_id: kitchen.id })
|
||||
// its own address for the pairing rate limit (one per screen in a real venue)
|
||||
const otherDisplay = await screen(await (await browser.newContext({ viewport: { width: 1024, height: 600 }, extraHTTPHeaders: { 'x-real-ip': '10.9.0.42' } })).newPage())
|
||||
await pairFromManager(otherDisplay, boss, { app_key: 'customer_display', name: 'Display elsewhere' })
|
||||
r.check('3.4: a display linked to the counter shows the idle screen: the venue name (the default)',
|
||||
await shown(myDisplay, 'display-idle', 15_000) && (await myDisplay.getByTestId('display-name').textContent()) === 'Taverna E2E')
|
||||
await simpleCard.locator('button').first().click()
|
||||
await simpleCard.locator('button').first().click()
|
||||
const started = Date.now()
|
||||
const seen = await myDisplay.waitForFunction(() => document.querySelector('[data-testid="app-customer_display"]')?.dataset.view === 'cart', null, { timeout: 5000 })
|
||||
.then(() => Date.now() - started).catch(() => null)
|
||||
const shownTotal = await myDisplay.getByTestId('display-total').textContent().catch(() => '')
|
||||
r.check('3.4: a sale shows on its own display within a second (the lines and the total)', seen != null && seen < 1500
|
||||
&& shownTotal.includes((2 * simple.price).toFixed(2)) && await myDisplay.getByTestId('display-line').count() === 1, `${seen} ms, ${shownTotal}`)
|
||||
r.check('3.4: …and not on another counter\'s display', await otherDisplay.getByTestId('app-customer_display').getAttribute('data-view') === 'idle')
|
||||
await myDisplay.screenshot({ path: path.join(OUT, 'terminal-display-cart.png') })
|
||||
await page.getByTestId('charge').click()
|
||||
await page.getByTestId('payment-dialog').waitFor({ timeout: 5000 })
|
||||
await page.getByTestId('cash-given').fill('50').catch(() => {})
|
||||
await page.getByTestId('pay-confirm').click()
|
||||
r.check('3.4: paid → "Thank you" with the change', await shown(myDisplay, 'display-paid', 5000)
|
||||
&& (await myDisplay.getByTestId('display-paid').textContent()).includes('Thank you'))
|
||||
await myDisplay.screenshot({ path: path.join(OUT, 'terminal-display-paid.png') })
|
||||
// the venue's choice: a QR code to its online ordering, then a slideshow of its photos
|
||||
await api('PUT', '/api/display/settings', { token: boss, body: { style: 'qr', qr_target: 'ordering', qr_caption: 'Order online', theme: 'light' } })
|
||||
r.check('3.4: the idle screen follows the venue\'s settings at once (a QR code to its ordering, light)',
|
||||
await myDisplay.waitForFunction(() => document.querySelector('[data-testid="display-qr"]'), null, { timeout: 20_000 }).then(() => true).catch(() => false)
|
||||
&& (await myDisplay.getByTestId('display-qr').getAttribute('data-link')).includes('/order/') && await myDisplay.evaluate(() => document.documentElement.dataset.theme) === 'light')
|
||||
await myDisplay.screenshot({ path: path.join(OUT, 'terminal-display-qr.png') })
|
||||
const png = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', 'base64')
|
||||
const uploadImg = async () => {
|
||||
const form = new FormData()
|
||||
form.append('file', new Blob([png], { type: 'image/png' }), 'promo.png')
|
||||
const res = await fetch(`${backend.url}/api/display/media`, { method: 'POST', headers: { authorization: `Bearer ${boss}` }, body: form })
|
||||
return res.json()
|
||||
}
|
||||
const [a, b] = [await uploadImg(), await uploadImg()]
|
||||
await api('PUT', '/api/display/settings', { token: boss, body: { style: 'slideshow', slides: [a.name, b.name], slide_seconds: 3, message: 'Today: 2 for 1' } })
|
||||
r.check('3.4: …or a slideshow of its photos, with its line of text',
|
||||
await myDisplay.waitForFunction(() => document.querySelectorAll('[data-testid="display-slide"]').length === 2, null, { timeout: 20_000 }).then(() => true).catch(() => false)
|
||||
&& (await myDisplay.getByTestId('display-message').textContent()) === 'Today: 2 for 1')
|
||||
await myDisplay.context().close()
|
||||
await otherDisplay.context().close()
|
||||
drawerServer.close()
|
||||
await page.getByRole('button', { name: 'Sign out' }).click()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user