feat(terminal): signage menu boards that page by themselves, and the widgets (platform-v2 step 5.5b)

- Menu board: the board's own order, grouped with headings or one list,
  photos, descriptions, badges (translated), sold out crossed out with a
  label, prices in the venue's money format, dotted leaders, a page dot row.
  Pages: rows that fit from the frame's shape (portrait fits more), text size,
  photos / descriptions, the title and widget bars (`page_size` overrides);
  they go round every `page_seconds` while the slide lasts.
- Widgets on text and menu slides: logo, name, date, clock, message of the
  day, QR code, weather (hidden without a forecast) in corners and bars, three
  sizes.
- logic.js: menuPages, rowsPerColumn, frameHeightVmin, boardPages, menuMs,
  pageAt, weatherIcon (+4 tests).
- e2e signage.mjs: a long board pages by itself, widgets in place, weather
  hidden with no place, the chosen product first with its badge, a price change
  and sold out show within seconds, a portrait TV needs fewer pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 20:00:14 +02:00
co-authored by Claude Opus 5.5
parent e612e2436c
commit e90c2f4f8f
8 changed files with 375 additions and 40 deletions
+57 -2
View File
@@ -1,4 +1,4 @@
// Signage suite (plan step 5.5a): a TV paired as a signage screen plays its playlist (picture,
// Signage suite (plan steps 5.5a, 5.5b): a TV paired as a signage screen plays its playlist (picture,
// text, video to its end, menu board) in order with transitions, turns for a TV mounted sideways,
// keeps playing with the server stopped (a quiet mark, no banner), and catches up when it is back.
// Starts its own backend (:8065) and the terminal (:5193).
@@ -14,7 +14,7 @@ let backend = await startBackend({ port: 8065, siteId: 'test-site-1', env: { LIC
const dataDir = backend.dataDir
const term = await startTerminalVite({ port: 5193, backendUrl: backend.url })
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('signage: the player on a TV (5.5a)')
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b)')
const errors = []
let failures = 0
@@ -122,6 +122,61 @@ try {
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { rotation: 0 } })
await waitFor(async () => (await tv.getByTestId('signage-frame').getAttribute('data-rotation')) === '0', 15_000, 300)
// ── 5.5b: a menu board that pages by itself, live prices, sold out, widgets ──
await api('PUT', '/api/signage/message', { token: boss, body: { text: 'Fresh fish today' } })
const products = (await api('GET', '/api/products/?sold_at=in_store', { token: boss })).filter(p => !p.is_service_item && p.lifecycle_status === 'active')
const star = products[0]
const board = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'Menu board', orientation: 'landscape' } })
await api('POST', `/api/signage/playlists/${board.id}/slides`, { token: boss, body: { kind: 'menu', duration_s: 60, content: {
title: 'Our menu', select: 'all', show_descriptions: true, page_seconds: 4, product_order: [star.id], group_by_category: false, columns: 1,
badges: { [String(star.id)]: 'chef' }, background: { kind: 'colour', colour: '#14213d' }, accent_colour: '#fca311',
widgets: [{ kind: 'name', position: 'top-left' }, { kind: 'clock', position: 'top-right' }, { kind: 'message', position: 'bottom-bar' },
{ kind: 'date', position: 'bottom-bar' }, { kind: 'weather', position: 'top-center' }] } } })
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: board.id } })
await waitFor(async () => (await kindNow(tv)) === 'menu' && (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(board.id), 20_000, 300)
const pagesWide = Number(await tv.getByTestId('signage-menu').getAttribute('data-pages'))
const firstPage = await tv.getByTestId('signage-menu').getAttribute('data-page')
const flipped = await waitFor(async () => (await tv.getByTestId('signage-menu').getAttribute('data-page')) !== firstPage, 12_000, 300)
r.check(`5.5b: a long menu pages by itself (${pagesWide} pages on a wide TV)`, pagesWide > 1 && !!flipped, `${pagesWide} pages`)
r.check('5.5b: widgets in their places: the message of the day and the date in the bottom bar, the clock, the name',
(await tv.getByTestId('signage-bottom-bar').textContent()).includes('Fresh fish today') && await tv.getByTestId('signage-w-clock').count() === 1
&& await tv.getByTestId('signage-w-date').count() === 1)
r.check('5.5b: no weather place set → the weather widget is hidden', await tv.getByTestId('signage-w-weather').count() === 0)
await waitFor(async () => (await tv.getByTestId('signage-menu').getAttribute('data-page')) === '0', 20_000, 200)
r.check('5.5b: the chosen product first, with its badge', await tv.getByTestId('signage-menu-item').first().getAttribute('data-id') === String(star.id)
&& (await tv.getByTestId('signage-menu-item').first().textContent()).includes("Chef's pick"))
await tv.screenshot({ path: path.join(OUT, 'signage-menu-board.png') })
// a price change and a product going sold out show without a reload
await api('PUT', `/api/products/${star.id}`, { token: boss, body: { base_price: 9.9 } })
const priced = await waitFor(async () => {
await waitFor(async () => (await tv.getByTestId('signage-menu').getAttribute('data-page')) === '0', 20_000, 200)
const t = await tv.locator(`[data-testid="signage-menu-item"][data-id="${star.id}"]`).textContent().catch(() => '')
return t.includes('9.90') ? t : null
}, 30_000, 500)
r.check('5.5b: a price change shows on the board within seconds', !!priced, priced || '')
await api('PUT', `/api/products/${star.id}`, { token: boss, body: { is_available: false } })
const out = await waitFor(async () => {
await waitFor(async () => (await tv.getByTestId('signage-menu').getAttribute('data-page')) === '0', 20_000, 200)
return (await tv.locator(`[data-testid="signage-menu-item"][data-id="${star.id}"]`).getAttribute('data-available').catch(() => null)) === 'false' ? true : null
}, 30_000, 500)
r.check('5.5b: …and a product going sold out is crossed out', !!out && await tv.getByTestId('signage-sold-out').count() > 0)
await api('PUT', `/api/products/${star.id}`, { token: boss, body: { is_available: true } })
// the same board on a portrait TV fits more on each page
const tall = await (await browser.newContext({ viewport: { width: 720, height: 1280 } })).newPage()
tall.on('pageerror', e => errors.push(e.message))
await tall.goto(term.url)
await shown(tall, 'pairing-code', 20_000)
const code2 = await tall.getByTestId('pairing-code').getAttribute('data-code')
const dev2 = await api('POST', '/api/devices', { token: boss, body: { code: code2, app_key: 'signage', name: 'Tall TV' } })
await api('PUT', `/api/signage/screens/${dev2.id}`, { token: boss, body: { playlist_id: board.id, orientation: 'portrait' } })
await waitFor(async () => (await tall.getByTestId('signage-slide').getAttribute('data-kind').catch(() => null)) === 'menu', 20_000, 300)
const pagesTall = Number(await tall.getByTestId('signage-menu').getAttribute('data-pages'))
r.check('5.5b: on a portrait TV the same board needs fewer pages', pagesTall < pagesWide, `${pagesTall} < ${pagesWide}`)
await tall.screenshot({ path: path.join(OUT, 'signage-menu-portrait.png') })
await tall.context().close()
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300)
// ── the server stops: the TV keeps playing ────────────────────────────────
await backend.stop()
const offlineOrder = await watch(tv, 14_000)