A slide is drawn at its playlist's shape, as large as fits the screen's picture, the bands in its own background (or stretched, the screen's choice). Playlists and library slides may have a shape of their own (aspect, Alembic 0045). Signage -> Screens -> Calibrate the picture: the TV outlines its area with arrows and its size, each edge moves pixel by pixel or a preset centres a shape; the TV follows live (signage.calibrate) and reports its window (POST /screen/viewport). Plan 6R.13, F-110. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
617 lines
49 KiB
JavaScript
617 lines
49 KiB
JavaScript
// Signage suite (plan steps 5.5a, 5.5b, 5.6a-c): 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, spawn } from 'node:child_process'
|
||
import { openSync } from 'node:fs'
|
||
import path from 'node:path'
|
||
import { chromium } from 'playwright'
|
||
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), the editor (5.6a-c)')
|
||
const errors = []
|
||
let failures = 0
|
||
|
||
async function api(method, url, { token, body } = {}) {
|
||
const res = await fetch(backend.url + url, {
|
||
method, headers: { 'content-type': 'application/json', ...(token ? { authorization: `Bearer ${token}` } : {}) },
|
||
body: body === undefined ? undefined : JSON.stringify(body),
|
||
})
|
||
const text = await res.text()
|
||
let data = null
|
||
try { data = JSON.parse(text) } catch { data = text }
|
||
if (!res.ok) throw new Error(`${method} ${url} → ${res.status} ${text.slice(0, 200)}`)
|
||
return data
|
||
}
|
||
async function upload(token, bytes, name, type) {
|
||
const form = new FormData()
|
||
form.append('file', new Blob([bytes], { type }), name)
|
||
const res = await fetch(`${backend.url}/api/media`, { method: 'POST', headers: { authorization: `Bearer ${token}` }, body: form })
|
||
return res.json()
|
||
}
|
||
const shown = (page, testId, timeout = 10_000) => page.getByTestId(testId).first().waitFor({ timeout }).then(() => true).catch(() => false)
|
||
const kindNow = page => page.getByTestId('signage-slide').getAttribute('data-kind', { timeout: 2000 }).catch(() => null)
|
||
|
||
/** The kinds the screen shows over `ms`, in order, without repeats next to each other. */
|
||
async function watch(page, ms) {
|
||
const seen = []
|
||
const end = Date.now() + ms
|
||
while (Date.now() < end) {
|
||
const k = await kindNow(page)
|
||
if (k && seen[seen.length - 1] !== k) seen.push(k)
|
||
await sleep(200)
|
||
}
|
||
return seen
|
||
}
|
||
|
||
try {
|
||
const boss = await supportLogin(backend.url)
|
||
await api('PUT', '/api/platform/modules/signage', { token: boss, body: { enabled: true } }).catch(() => {})
|
||
|
||
// a 2-second video recorded in the browser (WebM), a photo, a playlist of four slides
|
||
const rec = await browser.newPage()
|
||
const webm = Buffer.from(await rec.evaluate(async () => {
|
||
const c = document.createElement('canvas'); c.width = 320; c.height = 180
|
||
const g = c.getContext('2d')
|
||
const rec = new MediaRecorder(c.captureStream(25), { mimeType: 'video/webm' })
|
||
const parts = []
|
||
rec.ondataavailable = e => parts.push(e.data)
|
||
rec.start()
|
||
const t0 = performance.now()
|
||
await new Promise(done => {
|
||
const draw = () => {
|
||
const s = (performance.now() - t0) / 2000
|
||
g.fillStyle = `hsl(${Math.round(s * 360)},70%,50%)`; g.fillRect(0, 0, 320, 180)
|
||
if (s < 1) requestAnimationFrame(draw); else done()
|
||
}
|
||
draw()
|
||
})
|
||
rec.stop()
|
||
await new Promise(r => { rec.onstop = r })
|
||
const buf = await new Blob(parts, { type: 'video/webm' }).arrayBuffer()
|
||
return [...new Uint8Array(buf)]
|
||
}))
|
||
await rec.close()
|
||
const jpg = execFileSync(PYTHON, ['-c', "import io,sys;from PIL import Image;b=io.BytesIO();Image.new('RGB',(1920,1080),(200,40,40)).save(b,'JPEG');sys.stdout.buffer.write(b.getvalue())"])
|
||
const photo = await upload(boss, jpg, 'promo.jpg', 'image/jpeg')
|
||
const video = await upload(boss, webm, 'clip.webm', 'video/webm')
|
||
r.check('setup: a photo and a video in the library', photo.kind === 'image' && video.kind === 'video', `${photo.kind} ${video.kind} ${JSON.stringify(video).slice(0, 120)}`)
|
||
const pl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'Window', orientation: 'landscape' } })
|
||
const add = body => api('POST', `/api/signage/playlists/${pl.id}/slides`, { token: boss, body })
|
||
await add({ kind: 'image', duration_s: 3, content: { media_id: photo.id } })
|
||
await add({ kind: 'text', duration_s: 3, transition: 'slide', content: { title: 'Happy hour', body: '17:00 - 19:00', background: { kind: 'colour', colour: '#1e3a8a' } } })
|
||
await add({ kind: 'video', content: { media_id: video.id } })
|
||
await add({ kind: 'menu', duration_s: 3, content: { title: 'Our menu', select: 'all', page_size: 12 } })
|
||
|
||
// ── the TV ────────────────────────────────────────────────────────────────
|
||
const tv = await (await browser.newContext({ viewport: { width: 1280, height: 720 } })).newPage()
|
||
tv.on('pageerror', e => errors.push(e.message))
|
||
const fetched = []
|
||
tv.on('request', q => fetched.push(q.url()))
|
||
await tv.goto(term.url)
|
||
await shown(tv, 'pairing-code', 20_000)
|
||
const code = await tv.getByTestId('pairing-code').getAttribute('data-code')
|
||
const dev = await api('POST', '/api/devices', { token: boss, body: { code, app_key: 'signage', name: 'Window TV' } })
|
||
r.check('a TV paired as a signage screen opens the player (nothing to play yet)', await shown(tv, 'app-signage', 20_000) && await shown(tv, 'signage-empty', 5000))
|
||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
||
r.check('…its playlist starts at once (signage.changed)', await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300))
|
||
const order = await watch(tv, 16_000)
|
||
const seq = order.join(' ')
|
||
r.check('the slides play in order: picture → text → video (to its end) → menu board → picture…',
|
||
/image text video menu/.test(seq) || /text video menu image/.test(seq) || /video menu image text/.test(seq) || /menu image text video/.test(seq), seq)
|
||
const img = await waitFor(async () => (await kindNow(tv)) === 'image' ? tv.getByTestId('signage-image').evaluate(i => i.naturalWidth) : null, 20_000, 200)
|
||
r.check('the picture shows (from the copy kept on the TV)', img > 0 && (await tv.getByTestId('signage-image').getAttribute('src')).startsWith('blob:'), String(img))
|
||
await tv.screenshot({ path: path.join(OUT, 'signage-image.png') })
|
||
await waitFor(async () => (await kindNow(tv)) === 'text', 20_000, 150)
|
||
r.check('the text slide comes in with its transition (slide)', (await tv.getByTestId('signage-slide').getAttribute('class')).includes('sg-in-slide')
|
||
&& (await tv.getByTestId('signage-title').textContent()) === 'Happy hour')
|
||
await sleep(900)
|
||
await tv.screenshot({ path: path.join(OUT, 'signage-text.png') })
|
||
await waitFor(async () => (await kindNow(tv)) === 'menu', 20_000, 150)
|
||
r.check('the menu board lists the products with prices', await tv.getByTestId('signage-menu-item').count() > 0 && await tv.getByTestId('signage-menu-price').count() > 0)
|
||
await tv.screenshot({ path: path.join(OUT, 'signage-menu.png') })
|
||
|
||
// ── 5.4e: the server makes the video's version for screens; the TV switches to it by itself ──
|
||
const ready = await waitFor(async () => {
|
||
const m = await api('GET', `/api/media/${video.id}`, { token: boss })
|
||
return m.processing === 'done' || m.processing === 'failed' ? m : null
|
||
}, 90_000, 1000)
|
||
r.check('5.4e: the WebM video gets a still frame and a version every screen plays (H.264 MP4)', !!ready?.urls?.play && !!ready?.urls?.full,
|
||
JSON.stringify(ready && { processing: ready.processing, urls: Object.keys(ready.urls) }))
|
||
r.check('5.4e: …the TV is told and fetches that version without a reload',
|
||
!!(await waitFor(async () => (fetched.some(u => u.endsWith(`${video.sha256}/play`)) ? true : null), 20_000, 300)))
|
||
const poster = await waitFor(async () => ((await kindNow(tv)) === 'video' ? tv.getByTestId('signage-video').getAttribute('poster') : null), 30_000, 200)
|
||
r.check('5.4e: …and plays it with its still frame behind it while it loads', !!poster, String(poster))
|
||
|
||
// ── a TV mounted sideways ─────────────────────────────────────────────────
|
||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { rotation: 90 } })
|
||
r.check('turn the picture 90°: the frame turns', await waitFor(async () => (await tv.getByTestId('signage-frame').getAttribute('data-rotation')) === '90', 15_000, 300))
|
||
await tv.screenshot({ path: path.join(OUT, 'signage-rotated.png') })
|
||
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' } })
|
||
// (a landscape board keeps its shape on a portrait TV unless the screen stretches it: 6R.13)
|
||
await api('PUT', `/api/signage/screens/${dev2.id}`, { token: boss, body: { playlist_id: board.id, orientation: 'portrait', fit: 'stretch' } })
|
||
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)
|
||
|
||
// ── 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('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()
|
||
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)
|
||
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()
|
||
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)
|
||
// ── 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').click()
|
||
await mgr.getByRole('option', { name: 'Chosen categories and products' }).click()
|
||
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'))
|
||
// owner review 5: several badges, from the venue's list, in the shared dropdown
|
||
await firstRow.getByTestId('signage-menu-badge').click()
|
||
await mgr.getByRole('option', { name: 'Offer' }).click()
|
||
await mgr.getByRole('option', { name: 'Spicy' }).click()
|
||
await mgr.keyboard.press('Escape')
|
||
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 badges (two, with their icons)',
|
||
await waitFor(async () => (await mgr.getByTestId('signage-preview').locator('[data-testid="signage-badge"] svg').count()) >= 2, 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)]?.join() === 'offer,spicy'
|
||
&& (mc.widgets || []).some(w => w.kind === 'clock')
|
||
&& !menuSlide.menu.groups.flatMap(g => g.items).some(i => i.id === hiddenId && !i.hidden) && 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') })
|
||
// ── owner review 2 (2026-11-21): a hidden product stays in the list, greyed; widgets ordered, moved by the keys from their card; stacks ──
|
||
r.check('2026-11-21 (2): a product hidden from the board stays in the list of the editor, marked hidden',
|
||
await mgr.locator(`[data-testid="signage-menu-row"][data-id="${hiddenId}"]`).getAttribute('data-hidden') === 'true')
|
||
await mgr.getByTestId('signage-widget-add-text').click()
|
||
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-own-text').fill('Happy hour')
|
||
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-up').click()
|
||
const kinds = await mgr.getByTestId('signage-widget').evaluateAll(els => els.map(e => e.dataset.kind))
|
||
r.check('2026-11-21 (2): a text widget, moved up the list with its arrow', kinds.indexOf('text') < kinds.lastIndexOf('clock'), JSON.stringify(kinds))
|
||
r.check('2026-11-21 (2): …shown on the preview', await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-w-text').count()) > 0, 5000, 200) === true)
|
||
const textCard = mgr.locator('[data-testid="signage-widget"][data-kind="text"]')
|
||
await textCard.locator('span', { hasText: 'Text' }).first().click()
|
||
await mgr.keyboard.press('ArrowRight')
|
||
r.check('2026-11-21 (2): picked on its card, the arrow keys move the widget (Custom)',
|
||
await waitFor(async () => (await textCard.getByTestId('signage-widget-position').textContent()).includes('Custom'), 4000, 200) === true)
|
||
await mgr.getByTestId('signage-widget-add-hstack').click()
|
||
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
||
await stackCard.getByTestId('signage-stack-cell-editor').first().getByTestId('signage-stack-add').click()
|
||
await mgr.getByTestId('signage-stack-add-clock').click()
|
||
// the parts sized by dragging the line between them on the bar (owner review 3)
|
||
const bar = await stackCard.getByTestId('signage-stack-bar').first().boundingBox()
|
||
const ln = await stackCard.getByTestId('signage-stack-line').first().boundingBox()
|
||
await mgr.mouse.move(ln.x + ln.width / 2, ln.y + ln.height / 2)
|
||
await mgr.mouse.down()
|
||
await mgr.mouse.move(bar.x + bar.width * 0.25, ln.y + ln.height / 2, { steps: 6 })
|
||
await mgr.mouse.up()
|
||
r.check('2026-11-21 (2): a horizontal stack: a clock in its first part, 25 / 75, on the preview',
|
||
await waitFor(async () => {
|
||
const cells = mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell')
|
||
return (await cells.count()) === 2 && (await cells.first().getAttribute('data-share')) === '25'
|
||
&& (await cells.first().getByTestId('signage-w-clock').count()) === 1
|
||
}, 6000, 300) === true)
|
||
// "Add a widget" to the second part
|
||
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).getByTestId('signage-stack-add').click()
|
||
await mgr.getByTestId('signage-stack-add-date').click()
|
||
r.check('2026-11-21 (3): "Add a widget" puts a date in the second part',
|
||
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1).getByTestId('signage-w-date').count()) === 1, 6000, 300) === true)
|
||
// owner review 4: a second widget in the same part, then one removed
|
||
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).getByTestId('signage-stack-add').click()
|
||
await mgr.getByTestId('signage-stack-add-text').click()
|
||
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="text"]').getByTestId('signage-widget-own-text').fill('Two in one')
|
||
const part2 = () => mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1)
|
||
r.check('2026-11-21 (4): a part holds two widgets (a date and a text), one over the other',
|
||
await waitFor(async () => (await part2().getByTestId('signage-stack-place').count()) === 2 && (await part2().getByTestId('signage-w-text').count()) === 1
|
||
&& (await part2().getByTestId('signage-w-date').count()) === 1, 6000, 300) === true)
|
||
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="date"]').getByTestId('signage-stack-part-remove').click()
|
||
r.check('2026-11-21 (4): …and one of them removed',
|
||
await waitFor(async () => (await part2().getByTestId('signage-stack-place').count()) === 1 && (await part2().getByTestId('signage-w-date').count()) === 0, 6000, 300) === true)
|
||
// owner review 5: a widget in a part aligned to the bottom, in italics, in a colour of its own
|
||
const textInPart = stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="text"]')
|
||
await textInPart.getByTestId('signage-cell-vertical-bottom').click()
|
||
await textInPart.getByTestId('signage-widget-look-toggle').click()
|
||
await textInPart.getByTestId('signage-widget-italic').click()
|
||
await textInPart.getByTestId('signage-widget-colour-open').click()
|
||
await mgr.getByTestId('signage-widget-colour-preset').nth(7).click()
|
||
r.check('2026-11-21 (5): a widget in a part: at the bottom of its place, in italics, its own colour',
|
||
await waitFor(async () => {
|
||
const place = part2().getByTestId('signage-stack-place').first()
|
||
const css = await place.evaluate(el => ({ align: getComputedStyle(el).alignItems, italic: getComputedStyle(el.querySelector('[data-testid="signage-w-text"]')).fontStyle,
|
||
colour: getComputedStyle(el.querySelector('[data-widget]')).color }))
|
||
return ['flex-end', 'flow-end'].includes(css.align) && css.italic === 'italic' && css.colour === 'rgb(239, 68, 68)' ? true : null
|
||
}, 6000, 300) === true, JSON.stringify(await part2().getByTestId('signage-stack-place').first().evaluate(el => ({ align: getComputedStyle(el).alignItems,
|
||
italic: getComputedStyle(el.querySelector('[data-testid="signage-w-text"]')).fontStyle, colour: getComputedStyle(el.querySelector('[data-widget]')).color })).catch(e => String(e))))
|
||
// Delete removes the picked widget (picked on its card)
|
||
await stackCard.locator('span', { hasText: 'Horizontal stack' }).first().click()
|
||
await mgr.keyboard.press('Delete')
|
||
r.check('2026-11-21 (3): Delete removes the picked widget', await waitFor(async () => (await mgr.locator('[data-testid="signage-widget"][data-kind="stack"]').count()) === 0, 4000, 200) === true)
|
||
await textCard.getByTestId('signage-widget-remove').click()
|
||
// this board's own name for a product; the names aligned right
|
||
await mgr.getByTestId('signage-item-name').first().hover()
|
||
await mgr.getByTestId('signage-item-name-edit').first().click()
|
||
await mgr.getByTestId('signage-item-name-input').fill('Signature dish')
|
||
await mgr.getByTestId('signage-item-name-input').press('Enter')
|
||
await mgr.getByTestId('signage-look-item_style-align-right').click()
|
||
// owner review 4: each look field changes only itself; the colour panel stays inside the window
|
||
r.check('2026-11-21 (4): names align left or right only', (await mgr.getByTestId('signage-look-item_style-align-center').count()) === 0)
|
||
const setRange = (loc, v) => loc.evaluate((el, x) => {
|
||
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(el, String(x))
|
||
el.dispatchEvent(new Event('input', { bubbles: true }))
|
||
}, v)
|
||
const headSize = async () => mgr.getByTestId('signage-look-heading_style-size').inputValue()
|
||
const before = await headSize()
|
||
await setRange(mgr.getByTestId('signage-look-item_style-size'), 180)
|
||
const headColour = async () => (await mgr.getByTestId('signage-look-heading_style-colour-open').textContent()).trim()
|
||
const colourBefore = await headColour()
|
||
await mgr.getByTestId('signage-accent-open').click()
|
||
const panel = await mgr.getByTestId('signage-accent-panel').boundingBox()
|
||
const vw = await mgr.evaluate(() => innerWidth)
|
||
r.check('2026-11-21 (4): the colour panel opens inside the window (12 ready colours)',
|
||
panel && panel.x >= 0 && panel.x + panel.width <= vw && (await mgr.getByTestId('signage-accent-preset').count()) === 12, JSON.stringify(panel))
|
||
await mgr.getByTestId('signage-accent-preset').nth(10).click()
|
||
r.check('2026-11-21 (4): the names size and the badges colour leave the headings as they were',
|
||
(await headSize()) === before && (await headColour()) === colourBefore, `${before} → ${await headSize()}, ${colourBefore} → ${await headColour()}`)
|
||
await mgr.getByTestId('signage-look-dots-colour-open').click()
|
||
await setRange(mgr.getByTestId('signage-look-dots-colour-opacity'), 50)
|
||
r.check('2026-11-21 (4): a see-through colour (#rrggbbaa)', /^#[0-9a-f]{8}$/.test((await mgr.getByTestId('signage-look-dots-colour-open').textContent()).trim()))
|
||
await mgr.keyboard.press('Escape')
|
||
r.check('2026-11-21 (3): a product named for this board only shows on the preview, the catalogue name under it in the list',
|
||
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByText('Signature dish').count()) > 0
|
||
&& (await mgr.getByTestId('signage-menu-board').getByText(/Catalogue:/).count()) > 0, 6000, 300) === true)
|
||
// ── 2026-11-21: a widget moved and sized on the preview; the slide kept in the Slides library ──
|
||
await mgr.getByTestId('signage-preview-box').scrollIntoViewIfNeeded()
|
||
await sleep(300)
|
||
const handle = mgr.getByTestId('signage-canvas-widget').last()
|
||
const hb = await handle.boundingBox()
|
||
await mgr.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2)
|
||
await mgr.mouse.down()
|
||
await mgr.mouse.move(hb.x - 200, hb.y + 120, { steps: 6 })
|
||
await mgr.mouse.up()
|
||
const se = await mgr.getByTestId('signage-handle-se').boundingBox()
|
||
await mgr.mouse.move(se.x + 7, se.y + 7)
|
||
await mgr.mouse.down()
|
||
await mgr.mouse.move(se.x + 60, se.y + 30, { steps: 5 })
|
||
await mgr.mouse.up()
|
||
r.check('2026-11-21 (6): a clock placed by hand is exactly as big as what it shows (its outline is the clock)',
|
||
await waitFor(async () => {
|
||
const box = await mgr.getByTestId('signage-preview').locator('[data-tight]').last().boundingBox()
|
||
const sel = await mgr.getByTestId('signage-canvas-selected').boundingBox()
|
||
return box && sel && Math.abs(box.width - sel.width) < 3 && Math.abs(box.height - sel.height) < 3
|
||
}, 4000, 200) === true)
|
||
r.check('2026-11-21: a widget dragged on the preview reads "Custom" in its card',
|
||
(await mgr.locator('[data-testid="signage-widget"][data-selected="true"]').getByTestId('signage-widget-position').textContent()).includes('Custom'))
|
||
await mgr.getByTestId('signage-slide-save').click()
|
||
await sleep(900)
|
||
const moved = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu').content.widgets.find(w => w.position === 'custom')
|
||
r.check('2026-11-21: …saved with its own box', moved?.position === 'custom' && moved.size === 'custom' && moved.box?.w > 0 && moved.box?.h > 0, JSON.stringify(moved))
|
||
const mc3 = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu').content
|
||
r.check('2026-11-21 (3): saved with a name for this board and the names aligned right',
|
||
Object.values(mc3.names || {}).includes('Signature dish') && mc3.item_style?.align === 'right', JSON.stringify({ names: mc3.names, item: mc3.item_style }))
|
||
// owner review 5: leaving a slide with changes: "Save and leave"
|
||
await mgr.getByTestId('signage-menu-title').fill('Saved on the way out')
|
||
await mgr.locator('[data-testid="signage-slide-card"]:not([data-kind="menu"])').first().click()
|
||
await mgr.getByTestId('signage-discard-alt').click()
|
||
await sleep(1000)
|
||
r.check('2026-11-21 (5): "Save and leave" saves the slide before going to the next one',
|
||
(await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu').content.title === 'Saved on the way out')
|
||
await mgr.locator('[data-testid="signage-slide-card"][data-kind="menu"]').first().click()
|
||
await sleep(800)
|
||
await mgr.getByTestId('signage-keep-slide').click()
|
||
await mgr.getByTestId('signage-keep-name').fill('Board to keep')
|
||
await mgr.getByTestId('signage-keep-confirm').click()
|
||
await sleep(800)
|
||
const kept = (await api('GET', '/api/signage/library', { token: boss })).slides.find(x => x.name === 'Board to keep')
|
||
r.check('2026-11-21: a playlist\'s slide kept in the Slides library', kept?.kind === 'menu' && kept.content.widgets.some(w => w.position === 'custom'))
|
||
await mgr.getByTestId('signage-add-slide').click()
|
||
await mgr.locator('[data-testid="signage-add-saved"][data-name="Board to keep"]').click()
|
||
await sleep(900)
|
||
r.check('2026-11-21: …and added from "Your slides" to the playlist (a copy)',
|
||
(await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.filter(x => x.kind === 'menu').length === 2)
|
||
// removing a slide asks inside the page (not the browser)
|
||
await mgr.getByTestId('signage-slide-card').last().getByTestId('signage-slide-delete').click()
|
||
await mgr.getByTestId('signage-slide-delete-confirm-ok').click()
|
||
await sleep(900)
|
||
r.check('2026-11-21: a slide removed after the page\'s own question',
|
||
(await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.filter(x => x.kind === 'menu').length === 1)
|
||
// ── 5.6c: screens, schedules, the message of the day ─────────────────────
|
||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
||
await mgr.getByTestId('signage-tab-settings').click()
|
||
await mgr.getByTestId('signage-weather').waitFor({ timeout: 10_000 })
|
||
const savedMessage = (await api('GET', '/api/signage/message', { token: boss })).text || ''
|
||
await waitFor(async () => ((await mgr.getByTestId('signage-message').inputValue()) === savedMessage ? true : null), 10_000, 200) // loaded
|
||
await mgr.getByTestId('signage-message').fill('Kalimera from the manager')
|
||
await mgr.getByTestId('signage-message-save').click()
|
||
await sleep(700)
|
||
r.check('5.6c: the message of the day is saved from the manager', (await api('GET', '/api/signage/message', { token: boss })).text === 'Kalimera from the manager')
|
||
// owner review 5: the venue's badges: one added with its name, colours and icon
|
||
await mgr.getByTestId('signage-badge-add').click()
|
||
const newRow = mgr.getByTestId('signage-badge-row').last()
|
||
await newRow.getByTestId('signage-badge-name-en').fill('Gluten free')
|
||
await newRow.getByTestId('signage-badge-icon-open').click()
|
||
await mgr.getByTestId('signage-badge-icon-wheat-off').click()
|
||
await mgr.getByTestId('signage-badges-save').click()
|
||
await sleep(700)
|
||
const mine = (await api('GET', '/api/signage/badges', { token: boss })).badges.at(-1)
|
||
r.check('2026-11-21 (5): a badge of the venue saved with its name and icon', mine?.names?.en === 'Gluten free' && mine?.icon === 'wheat-off', JSON.stringify(mine))
|
||
r.check('2026-11-21 (5): the tab is "Message & settings"', (await mgr.getByTestId('signage-tab-settings').textContent()).includes('settings'))
|
||
r.check('5.6c: the weather section says what it needs (no town yet)', await shown(mgr, 'signage-weather', 5000)
|
||
&& (await mgr.getByTestId('signage-weather').textContent()).includes('internet'))
|
||
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 })
|
||
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 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 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-add-entry').click()
|
||
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()
|
||
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()
|
||
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 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: [] } })
|
||
// a library slide as the screen's default (2026-11-21)
|
||
await mgr.getByTestId('signage-tab-screens').click()
|
||
await card.waitFor({ timeout: 10_000 })
|
||
await choose(card, 'signage-screen-playlist', 'Board to keep')
|
||
r.check('2026-11-21: Screens: a library slide as the default plays alone on the TV',
|
||
!!(await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === `slide:${kept.id}`, 15_000, 300)))
|
||
// ── 6R.13: slides keep their shape on a 21:9 TV; stretch; a playlist of its own shape; calibrating ──
|
||
await choose(card, 'signage-screen-playlist', 'Window')
|
||
await waitFor(async () => (await tv.getByTestId('app-signage').getAttribute('data-playlist')) === String(pl.id), 15_000, 300)
|
||
await tv.setViewportSize({ width: 1260, height: 540 })
|
||
const boxNow = () => tv.getByTestId('signage-shape').getAttribute('data-box', { timeout: 3000 }).catch(() => null)
|
||
r.check('6R.13: a 16:9 slide on a 21:9 TV keeps its shape, centred, the bands in its own background',
|
||
await waitFor(async () => (await boxNow()) === '960x540', 10_000, 200) === true && await tv.getByTestId('signage-backdrop').count() > 0, String(await boxNow()))
|
||
await tv.screenshot({ path: path.join(OUT, 'signage-21x9-bands.png') })
|
||
await choose(card, 'signage-screen-fit', 'Stretch to fill')
|
||
r.check('6R.13: …or stretched over the whole picture (the screen\'s choice)', await waitFor(async () => (await boxNow()) === '1260x540', 10_000, 200) === true)
|
||
await choose(card, 'signage-screen-fit', 'Keep their shape (bands)')
|
||
await waitFor(async () => (await boxNow()) === '960x540', 10_000, 200)
|
||
// the playlist built for 21:9 (its own shape, picked in the editor) fills it
|
||
await mgr.getByTestId('signage-tab-playlists').click()
|
||
await mgr.locator('[data-testid="signage-playlist-item"][data-name="Window"]').click()
|
||
await mgr.getByTestId('signage-orientation-custom').click()
|
||
await mgr.getByTestId('signage-shape-panel').locator('[data-shape="21:9"]').click()
|
||
const wide = await waitFor(async () => ((await api('GET', `/api/signage/playlists/${pl.id}`, { token: boss })).aspect === '21:9' ? true : null), 8000, 300)
|
||
r.check('6R.13: a playlist given its own shape (21:9) in the editor', wide === true
|
||
&& (await mgr.getByTestId('signage-orientation').getAttribute('data-shape')) === '21:9')
|
||
r.check('6R.13: …the TV draws it over the whole 21:9 picture, no bands',
|
||
await waitFor(async () => (await boxNow()) === '1260x540', 10_000, 200) === true && await tv.getByTestId('signage-backdrop').count() === 0, String(await boxNow()))
|
||
await api('PUT', `/api/signage/playlists/${pl.id}`, { token: boss, body: { orientation: 'landscape' } })
|
||
// calibrating: the TV outlines its picture; a preset and a pixel move reach it at once
|
||
await mgr.getByTestId('signage-tab-screens').click()
|
||
await card.getByTestId('signage-screen-calibrate').click()
|
||
const outlined = await shown(tv, 'signage-calibrate', 10_000)
|
||
const outline = outlined ? await tv.getByTestId('signage-calibrate').getAttribute('data-size') : null
|
||
r.check('6R.13: Calibrate the picture: the TV outlines it with arrows and its size', outline === '1260x540', `${outlined} ${outline}`)
|
||
r.check('6R.13: …the dialog knows the TV\'s window (it reported 1260 × 540)',
|
||
await waitFor(async () => (await mgr.getByTestId('signage-calibrate-window').textContent()).includes('1260 × 540'), 8000, 300) === true)
|
||
await mgr.getByTestId('signage-calibrate-dialog').locator('[data-preset="16:9"]').click()
|
||
const areaNow = () => tv.getByTestId('signage-area').getAttribute('data-area')
|
||
r.check('6R.13: the 16:9 preset leaves the largest 16:9 box in the middle of the TV', await waitFor(async () => (await areaNow()) === '150,0,960,540', 8000, 200) === true, String(await areaNow()))
|
||
const plus = mgr.getByTestId('signage-calibrate-top').locator('xpath=..').locator('button').last()
|
||
await plus.click(); await plus.click()
|
||
r.check('6R.13: …the top edge moved in 2 px with + (the TV follows)', await waitFor(async () => (await areaNow()) === '150,2,960,538', 8000, 200) === true, String(await areaNow()))
|
||
await mgr.screenshot({ path: path.join(OUT, 'signage-calibrate.png') })
|
||
await tv.screenshot({ path: path.join(OUT, 'signage-calibrate-tv.png') })
|
||
await mgr.getByTestId('signage-calibrate-done').click()
|
||
r.check('6R.13: Done: the outline goes away, the calibrated picture stays',
|
||
await tv.getByTestId('signage-calibrate').waitFor({ state: 'detached', timeout: 10_000 }).then(() => true).catch(() => false) && (await areaNow()) === '150,2,960,538')
|
||
const saved = (await api('GET', '/api/signage/screens', { token: boss })).find(x => x.id === dev.id)
|
||
r.check('6R.13: the insets are the screen\'s settings', JSON.stringify(saved.area) === JSON.stringify({ left: 150, top: 2, right: 150, bottom: 0 }), JSON.stringify(saved.area))
|
||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { area_left: 0, area_top: 0, area_right: 0, area_bottom: 0 } })
|
||
await tv.setViewportSize({ width: 1280, height: 720 })
|
||
|
||
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)
|
||
r.check('server stopped: the TV keeps playing its slides', new Set(offlineOrder).size >= 3,
|
||
`${offlineOrder.join(' ')} pages=${await tv.getByTestId('signage-menu').getAttribute('data-pages', { timeout: 1000 }).catch(() => '?')}`)
|
||
r.check('…with a small mark, never the banner over the slides', await shown(tv, 'offline-mark', 15_000) && await tv.getByTestId('offline-banner').count() === 0)
|
||
const offImg = await waitFor(async () => (await kindNow(tv)) === 'image' ? tv.getByTestId('signage-image').evaluate(i => i.complete && i.naturalWidth) : null, 20_000, 200)
|
||
r.check('…and the picture still shows', offImg > 0, String(offImg))
|
||
|
||
// ── back: it catches up ──────────────────────────────────────────────────
|
||
backend = await startBackend({ port: 8065, siteId: 'test-site-1', dataDir, env: { LICENSE_MODE: 'off' } })
|
||
const boss2 = await supportLogin(backend.url)
|
||
await api('POST', `/api/signage/playlists/${pl.id}/slides`, { token: boss2, body: { kind: 'text', duration_s: 3, position: 0, content: { title: 'Back online' } } })
|
||
const caught = await waitFor(async () => {
|
||
const titles = await tv.getByTestId('signage-title').allTextContents().catch(() => [])
|
||
return titles.includes('Back online') ? true : null
|
||
}, 60_000, 300)
|
||
r.check('server back: the TV catches up (a slide added meanwhile shows)', !!caught)
|
||
r.check('…and the mark goes away', await tv.getByTestId('offline-mark').waitFor({ state: 'detached', timeout: 20_000 }).then(() => true).catch(() => false))
|
||
|
||
r.check('no page errors', errors.length === 0, errors.join(' | '))
|
||
failures += r.done()
|
||
} catch (e) {
|
||
console.error(e)
|
||
r.check('the suite ran to the end', false, String(e.message).split(/\r?\n/)[0]) // never "all passed" after a crash
|
||
failures += r.done()
|
||
} finally {
|
||
await browser.close()
|
||
term.stop()
|
||
killTree(managerVite)
|
||
await backend.stop()
|
||
}
|
||
process.exit(failures ? 1 : 0)
|