feat(signage,scenes): schedule lines with screens and smart days, screens' defaults, horizontal timeline, scenes

- Scenes (Alembic 0043, models/scene.py, /api/scenes, core.scenes.manage): named
  modes on or off (optionally until a time); price rules / deals get the
  condition "a scene is on"; signage lines can play only during a scene;
  turning one on tells every screen and pushes the online menu.
- Signage schedules are lines (signage_schedule_items): playlist, screens
  ([] = every screen), priority, days, smart days (1st / last day, first / last
  week, Greek public holidays or not: core/calendar_days.py, mirrored in
  @xenia/signage), hours, dates, scene. No line → the screen's default
  playlist. 0043 turns the old named schedules into lines for their screens.
- Screens: default playlist, TV shape, turn; what plays now and why.
- Manager: tabs Screens · Playlists · Schedules · Slides (placeholder) ·
  Message and weather; schedule lines with playlist / screens / priority /
  delete on one line; the playlist editor's horizontal timeline of fixed
  cards, the slide's basics beside its preview (one height), then its content;
  Management → Scenes; the scene condition in pricing.
- Tests: backend (lines, smart days, scenes, prices), player logic, e2e.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 19:22:47 +02:00
co-authored by Claude Opus 5.5
parent abab158b7c
commit 60e6a16217
44 changed files with 1429 additions and 533 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ const PAGES = [
'dashboard', 'tables', 'tables?view=qr', 'online-orders', 'online-orders?tab=settings', 'crm/contacts', 'crm/customers',
'financials/expenses', 'financials/tabs', 'management/media', 'management/signage', 'management/staff', 'management/sessions',
'management/approvals', 'management/schedule', 'management/prep-zones', 'management/pricing', 'management/pricing?tab=channels',
'management/products', 'management/tables', 'management/tables?tab=floor', 'inventory/throwaways', 'notes',
'management/products', 'management/tables', 'management/tables?tab=floor', 'management/scenes', 'management/signage?tab=playlists', 'management/signage?tab=schedules', 'inventory/throwaways', 'notes',
'reports/today', 'reports/store', 'devices', 'license', 'apps', 'settings?tab=operation',
]
const SHOTS = ['dashboard', 'tables', 'tables?view=qr', 'online-orders?tab=settings', 'crm/contacts', 'crm/customers', 'financials/expenses',
+36 -21
View File
@@ -212,6 +212,10 @@ try {
await mgr.getByRole('button', { name: 'Sign in', exact: true }).click()
await mgr.waitForURL(u => u.pathname !== '/login', { timeout: 20_000 })
await mgr.goto(`${MANAGER}/management/signage`)
r.check('2026-11-21: Signage opens on Screens; the tabs: screens, playlists, schedules, slides, message and weather',
await shown(mgr, 'signage-tab-screens', 20_000) && await mgr.getByTestId('signage-tab-screens').getAttribute('aria-selected') === 'true'
&& JSON.stringify(await mgr.locator('[data-testid^="signage-tab-"]').evaluateAll(els => els.map(e => e.dataset.testid.slice(12)))) === JSON.stringify(['screens', 'playlists', 'schedules', 'slides', 'settings']))
await mgr.getByTestId('signage-tab-playlists').click()
r.check('5.6a: Management → Signage lists the playlists', await shown(mgr, 'signage-playlist-item', 20_000)
&& await mgr.getByTestId('signage-playlist-item').count() >= 2)
await mgr.getByTestId('signage-new-playlist').click()
@@ -237,6 +241,12 @@ try {
await mgr.getByTestId('signage-slide-save').click()
await sleep(800)
r.check('5.6a: …and the timeline card shows the warning', await mgr.getByTestId('signage-card-misfit').count() === 1)
const tl = await mgr.getByTestId('signage-slide-card').evaluateAll(els => els.map(e => e.getBoundingClientRect()))
r.check('2026-11-21: the timeline runs sideways, cards of one size', tl.length === 2 && Math.abs(tl[0].top - tl[1].top) < 1 && tl[1].left > tl[0].left && Math.abs(tl[0].width - tl[1].width) < 1)
const top = await mgr.getByTestId('signage-slide-basics').boundingBox()
const box = await mgr.getByTestId('signage-preview-box').boundingBox()
r.check('2026-11-21: the slide\'s basics and its preview side by side, one height', Math.abs(top.y - box.y) < 2 && Math.abs(top.height - box.height) < 2 && box.x > top.x,
JSON.stringify([top, box]))
await mgr.screenshot({ path: path.join(OUT, 'signage-editor.png'), fullPage: true })
// the picture first: the arrow on its card
await mgr.getByTestId('signage-slide-card').nth(1).getByTestId('signage-up').click()
@@ -306,38 +316,43 @@ try {
await mgr.getByTestId('signage-tab-screens').click()
const card = mgr.locator('[data-testid="signage-screen"][data-name="Window TV"]')
await card.waitFor({ timeout: 10_000 })
await card.getByTestId('signage-screen-playlist').selectOption({ label: 'Opening' })
const choose = async (where, testid, label) => { await where.getByTestId(testid).click(); await mgr.getByRole('option', { name: label }).first().click() }
await choose(card, 'signage-screen-playlist', 'Opening')
const opId = (await api('GET', '/api/signage/playlists', { token: boss })).find(x => x.name === 'Opening').id
r.check('5.6c: Screens: choosing the playlist switches the TV', !!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(opId), 15_000, 300)))
await card.getByTestId('signage-screen-rotation').selectOption('180')
r.check('5.6c: Screens: choosing the default playlist switches the TV', !!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(opId), 15_000, 300)))
await choose(card, 'signage-screen-rotation', 'Upside down')
r.check('5.6c: …and turning its picture', !!(await waitFor(async () => (await tv.getByTestId('signage-frame').getAttribute('data-rotation')) === '180', 15_000, 300)))
await card.getByTestId('signage-screen-rotation').selectOption('0')
// a schedule: "Opening" around now, "Window" the rest of the time
await choose(card, 'signage-screen-rotation', 'No')
await choose(card, 'signage-screen-playlist', 'Window')
await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300)
// a schedule line: "Opening" around now on this TV; it wins over the TV's default ("Window")
const nowAthens = new Intl.DateTimeFormat('en-GB', { timeZone: 'Europe/Athens', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(new Date())
const [hh] = nowAthens.split(':').map(Number)
const from = `${String(Math.max(0, hh - 1)).padStart(2, '0')}:00`
const to = `${String(Math.min(23, hh + 1)).padStart(2, '0')}:59`
await mgr.getByTestId('signage-tab-schedules').click()
await mgr.getByTestId('signage-new-schedule').click()
await mgr.getByTestId('signage-schedule-editor').waitFor({ timeout: 10_000 })
await mgr.getByTestId('signage-schedule-name').fill('Opening hours')
await mgr.getByTestId('signage-add-entry').click()
await mgr.getByTestId('signage-entry-playlist').selectOption({ label: 'Opening' })
await mgr.getByTestId('signage-entry-from').fill(from)
await mgr.getByTestId('signage-entry-to').fill(to)
await mgr.getByTestId('signage-schedule-fallback').selectOption({ label: 'Window' })
const line = mgr.getByTestId('signage-schedule-entry').last()
await choose(line, 'signage-entry-playlist', 'Opening')
await choose(line, 'signage-entry-screens', 'Window TV')
await mgr.keyboard.press('Escape')
await line.getByTestId('signage-entry-from').fill(from)
await line.getByTestId('signage-entry-to').fill(to)
const row = await Promise.all(['signage-entry-playlist', 'signage-entry-screens', 'signage-entry-priority'].map(id => line.getByTestId(id).boundingBox()))
r.check('2026-11-21: a line\'s playlist, screens and priority: one height, one line', row.every(b => Math.abs(b.y - row[0].y) < 1 && Math.abs(b.height - row[0].height) < 1), JSON.stringify(row))
await mgr.getByTestId('signage-schedule-save').click()
await sleep(900)
const sch = (await api('GET', '/api/signage/schedules', { token: boss })).find(x => x.name === 'Opening hours')
r.check('5.6c: a schedule built in the manager: "Opening" now, "Window" the rest of the time',
sch?.entries?.[0]?.time_from === from && sch.playing_now?.name === 'Opening' && sch.fallback_playlist_id === pl.id, JSON.stringify(sch))
let lines = []
for (let i = 0; i < 20 && !lines.length; i++) { await sleep(300); lines = await api('GET', '/api/signage/schedules', { token: boss }) }
r.check('5.6c: a schedule line built in the manager: "Opening" now on Window TV',
lines[0]?.time_from === from && lines[0].playlist_id === opId && JSON.stringify(lines[0].screen_ids) === JSON.stringify([dev.id])
&& lines[0].playing_on.some(x => x.name === 'Window TV'), JSON.stringify(lines))
r.check('5.6c: the TV plays what its line picks now (over its default)', !!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(opId), 15_000, 300)))
await mgr.getByTestId('signage-tab-screens').click()
await card.getByTestId('signage-screen-playlist').selectOption({ label: 'Window' })
await sleep(500)
await card.getByTestId('signage-screen-schedule').selectOption({ label: 'Opening hours' })
r.check('5.6c: the TV on the schedule plays what it picks now', !!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(opId), 15_000, 300)))
r.check('5.6c: Screens says it plays by a schedule', (await card.getByTestId('signage-screen-now').textContent()).includes('by a schedule'))
await mgr.screenshot({ path: path.join(OUT, 'signage-screens.png'), fullPage: true })
await card.getByTestId('signage-screen-schedule').selectOption('')
await mgr.getByTestId('signage-tab-schedules').click()
await mgr.screenshot({ path: path.join(OUT, 'signage-schedules.png'), fullPage: true })
await api('PUT', '/api/signage/schedules', { token: boss, body: { lines: [] } })
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)