feat(manager): the signage editor: playlists, the timeline, slides with a live preview, templates (platform-v2 step 5.6a)
Management → Signage: playlists (name, landscape / portrait, default transition, duplicate, delete with the screens it plays on); the timeline (drag or arrows to reorder, duplicate, remove, on / off, time and when it shows at a glance, a round's total time); a slide's settings (name, seconds or a video to its end, transition, days / hours / dates, the picture or video, fit, text, alignment, font, colour, size, background colour or photo with darkening; a menu board's title, columns and colours) with a live preview drawn by @xenia/signage at 1920 × 1080 and scaled down; new slides empty or from templates (promotion, announcement, happy hour 17-19, welcome, menu board, video); a warning on the slide and its card when a picture or video doesn't fit the playlist's shape. Unit tests (4), e2e signage.mjs builds a playlist in the manager and the TV plays it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+67
-5
@@ -1,20 +1,28 @@
|
||||
// Signage suite (plan steps 5.5a, 5.5b): a TV paired as a signage screen plays its playlist (picture,
|
||||
// Signage suite (plan steps 5.5a, 5.5b, 5.6a): 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).
|
||||
// node signage.mjs
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { execFileSync, spawn } from 'node:child_process'
|
||||
import { openSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { chromium } from 'playwright'
|
||||
import { BROWSER_CHANNEL, OUT, PYTHON, reporter, sleep, waitFor } from './lib/env.mjs'
|
||||
import { startBackend, startTerminalVite } from './lib/proc.mjs'
|
||||
import { BROWSER_CHANNEL, CS, OUT, PYTHON, reporter, sleep, waitFor } from './lib/env.mjs'
|
||||
import { killTree, startBackend, startTerminalVite, waitHttp } from './lib/proc.mjs'
|
||||
import { supportLogin } from './lib/support.mjs'
|
||||
|
||||
let backend = await startBackend({ port: 8065, siteId: 'test-site-1', env: { LICENSE_MODE: 'off' } })
|
||||
const dataDir = backend.dataDir
|
||||
const term = await startTerminalVite({ port: 5193, backendUrl: backend.url })
|
||||
const MPORT = 5194
|
||||
const MANAGER = `http://localhost:${MPORT}`
|
||||
const mlog = openSync(path.join(OUT, `vite-${MPORT}.log`), 'w')
|
||||
const managerVite = spawn('npx', ['vite', '--port', String(MPORT), '--strictPort'], {
|
||||
cwd: path.join(CS, 'manager_dashboard'), shell: process.platform === 'win32', detached: process.platform !== 'win32',
|
||||
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)')
|
||||
const r = reporter('signage: the player on a TV (5.5a), menu boards and widgets (5.5b), the editor (5.6a)')
|
||||
const errors = []
|
||||
let failures = 0
|
||||
|
||||
@@ -177,6 +185,59 @@ try {
|
||||
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)
|
||||
|
||||
// ── 5.6a: the editor in the manager ──────────────────────────────────────
|
||||
await waitHttp(`${MANAGER}/`)
|
||||
const tallJpg = execFileSync(PYTHON, ['-c', "import io,sys;from PIL import Image;b=io.BytesIO();Image.new('RGB',(1080,1920),(30,140,90)).save(b,'JPEG');sys.stdout.buffer.write(b.getvalue())"])
|
||||
const tallPhoto = await upload(boss, tallJpg, 'tall poster.jpg', 'image/jpeg')
|
||||
const mgr = await (await browser.newContext({ viewport: { width: 1440, height: 900 } })).newPage()
|
||||
mgr.on('pageerror', e => errors.push(e.message))
|
||||
await mgr.goto(`${MANAGER}/login`)
|
||||
await mgr.getByTestId('login-form').waitFor({ timeout: 60_000 })
|
||||
if (!(await mgr.getByTestId('login-account').count())) await mgr.getByLabel('Username').fill('manager')
|
||||
await mgr.getByLabel('Password').fill('password')
|
||||
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('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()
|
||||
await mgr.getByTestId('signage-new-name').fill('Opening')
|
||||
await mgr.getByTestId('signage-create-playlist').click()
|
||||
await waitFor(async () => (await mgr.getByTestId('signage-playlist-name').inputValue().catch(() => '')) === 'Opening', 15_000, 200)
|
||||
await mgr.getByRole('dialog').waitFor({ state: 'detached', timeout: 5000 }).catch(() => {})
|
||||
await mgr.getByTestId('signage-add-slide').click()
|
||||
r.check('5.6a: "Add a slide" offers empty slides and ready-made ones with a preview',
|
||||
await mgr.getByTestId('signage-template-preview').count() >= 5)
|
||||
await mgr.getByTestId('signage-template-announcement').click()
|
||||
await mgr.getByTestId('signage-slide-editor').waitFor({ timeout: 10_000 })
|
||||
await mgr.getByTestId('signage-text-title').fill('Opening soon')
|
||||
r.check('5.6a: the preview follows the editor as you type (as the TV draws it)',
|
||||
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-title').textContent().catch(() => '')) === 'Opening soon', 5000, 200))
|
||||
await mgr.getByTestId('signage-slide-save').click()
|
||||
await sleep(800)
|
||||
await mgr.getByTestId('signage-add-slide').click()
|
||||
await mgr.getByTestId('signage-template-promo').click()
|
||||
await mgr.getByTestId('signage-picture-pick').click({ timeout: 10_000 })
|
||||
await mgr.getByTestId('media-picker').locator(`[data-testid="media-item"][data-id="${tallPhoto.id}"]`).click()
|
||||
r.check('5.6a: a tall picture on a landscape playlist is flagged', await shown(mgr, 'signage-picture-misfit', 5000))
|
||||
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)
|
||||
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()
|
||||
await sleep(800)
|
||||
const opening = (await api('GET', '/api/signage/playlists', { token: boss })).find(p => p.name === 'Opening')
|
||||
const full = await api('GET', `/api/signage/playlists/${opening.id}`, { token: boss })
|
||||
r.check('5.6a: built in the manager: the picture, then the text "Opening soon"', full.slides.map(x => x.kind).join(',') === 'image,text'
|
||||
&& full.slides[1].content.title === 'Opening soon' && full.slides[0].content.media_id === tallPhoto.id, JSON.stringify(full.slides.map(x => [x.kind, x.content.title])))
|
||||
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)
|
||||
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)
|
||||
|
||||
// ── the server stops: the TV keeps playing ────────────────────────────────
|
||||
await backend.stop()
|
||||
const offlineOrder = await watch(tv, 14_000)
|
||||
@@ -204,6 +265,7 @@ try {
|
||||
} finally {
|
||||
await browser.close()
|
||||
term.stop()
|
||||
killTree(managerVite)
|
||||
await backend.stop()
|
||||
}
|
||||
process.exit(failures ? 1 : 0)
|
||||
|
||||
Reference in New Issue
Block a user