feat(manager): the menu board editor and widgets (platform-v2 step 5.6b)

- Menu board: everything or chosen whole categories (sub-categories
  included, new products join) plus single products found by search; hide a
  product from the board (and show it again); the board's own order with
  arrows on what the server resolved (categories and products; boardOrder
  writes it); a badge per product; grouping, headings, photos, descriptions,
  whose prices (a sales point or none), sold out crossed out or hidden,
  columns, products per page (or as many as fit), seconds per page; colours,
  font, size, background.
- Widgets (text and menu slides): logo, venue name, date (long / short),
  clock (seconds), message of the day (or its own text), QR code (ordering /
  QR menu / a link + caption), weather (1-3 days, says it needs internet);
  where (corners, bars) and size.
- The preview stays in view while the settings scroll.
- @xenia/signage: the venue clock's Intl call names its time zone where the
  i18n guard reads it.
- tests: manager signage.test.mjs +1; e2e signage.mjs builds a menu board in
  the editor (categories, a single product, the order, a badge, hiding, a
  clock) and checks what was saved and resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 22:16:49 +02:00
co-authored by Claude Opus 5.5
parent 152388321e
commit 5f6b51fb8b
11 changed files with 509 additions and 20 deletions
+45 -2
View File
@@ -1,4 +1,4 @@
// Signage suite (plan steps 5.5a, 5.5b, 5.6a): a TV paired as a signage screen plays its playlist (picture,
// Signage suite (plan steps 5.5a, 5.5b, 5.6a, 5.6b): 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).
@@ -22,7 +22,7 @@ const managerVite = spawn('npx', ['vite', '--port', String(MPORT), '--strictPort
stdio: ['ignore', mlog, mlog], env: { ...process.env, XENIA_BACKEND: backend.url },
})
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b), the editor (5.6a)')
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b), the editor (5.6a, 5.6b)')
const errors = []
let failures = 0
@@ -234,6 +234,49 @@ try {
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: opening.id } })
const onTv = await waitFor(async () => ((await tv.getByTestId('signage-title').allTextContents().catch(() => [])).includes('Opening soon') ? true : null), 30_000, 300)
r.check('5.6a: …and the TV plays it', !!onTv)
// ── 5.6b: a menu board built in the editor ───────────────────────────────
const cats = await api('GET', '/api/products/categories', { token: boss })
const [catA, catB] = cats.filter(c => !c.parent_id)
const extra = products.find(x => x.category_id !== catA.id && x.category_id !== catB.id) || products[products.length - 1]
await mgr.getByTestId('signage-add-slide').click()
await mgr.getByTestId('signage-template-menuBoard').click()
await mgr.getByTestId('signage-menu-editor').waitFor({ timeout: 10_000 })
await mgr.getByTestId('signage-menu-select').selectOption('custom')
await mgr.locator(`[data-testid="signage-menu-category"][data-name="${catA.name}"]`).click()
await mgr.locator(`[data-testid="signage-menu-category"][data-name="${catB.name}"]`).click()
await mgr.getByTestId('signage-menu-search').fill(extra.name.slice(0, 4))
await mgr.getByTestId('signage-menu-found-item').filter({ hasText: extra.name }).first().click()
const groupsSeen = await waitFor(async () => {
const n = await mgr.getByTestId('signage-menu-group').count()
return n >= 2 ? n : null
}, 10_000, 300)
r.check('5.6b: chosen categories and a single product appear on the board (the server resolves the draft)', !!groupsSeen,
String(groupsSeen))
// the second category first; a badge on the first product shown; hide one
await mgr.getByTestId('signage-menu-group').nth(1).getByTestId('signage-group-up').click()
const firstRow = mgr.getByTestId('signage-menu-row').first()
await sleep(700)
const badgeId = Number(await firstRow.getAttribute('data-id'))
await firstRow.getByTestId('signage-menu-badge').selectOption('offer')
const hideRow = mgr.getByTestId('signage-menu-row').nth(1)
const hiddenId = Number(await hideRow.getAttribute('data-id'))
await hideRow.getByTestId('signage-item-hide').click()
await mgr.getByTestId('signage-widget-add-clock').click()
await sleep(900)
r.check('5.6b: the preview shows the board with its badge',
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-badge').count()) > 0, 8000, 300) === true)
await mgr.getByTestId('signage-slide-save').click()
await sleep(1000)
const op = (await api('GET', '/api/signage/playlists', { token: boss })).find(x => x.name === 'Opening')
const menuSlide = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu')
const mc = menuSlide?.content || {}
r.check('5.6b: saved: the categories, the single product, the hidden one, the board\'s own order, the badge, the clock',
mc.select === 'custom' && mc.category_ids?.includes(catA.id) && mc.category_ids?.includes(catB.id) && mc.product_ids?.includes(extra.id)
&& mc.exclude_ids?.includes(hiddenId) && mc.category_order?.[0] === catB.id && mc.badges?.[String(badgeId)] === 'offer'
&& (mc.widgets || []).some(w => w.kind === 'clock')
&& !menuSlide.menu.groups.flatMap(g => g.items).some(i => i.id === hiddenId) && menuSlide.menu.groups[0].category?.id === catB.id,
JSON.stringify({ select: mc.select, cats: mc.category_ids, prods: mc.product_ids, ex: mc.exclude_ids, order: mc.category_order, badges: mc.badges }))
await mgr.screenshot({ path: path.join(OUT, 'signage-menu-editor.png') })
await mgr.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)