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>
48 lines
3.0 KiB
JavaScript
48 lines
3.0 KiB
JavaScript
// The signage editor's helpers (plan step 5.6a).
|
|
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { fitsOrientation, mediaEntry, misfits, moved, slideBody, slideFromTemplate, TEMPLATES, totalSeconds, windowParts } from '../src/pages/signage/signageLogic.js'
|
|
|
|
test('templates fill their texts in the manager\'s language and copy their content', () => {
|
|
const tpl = TEMPLATES.find(x => x.key === 'happyHour')
|
|
const a = slideFromTemplate(tpl, k => `T(${k})`)
|
|
assert.equal(a.kind, 'text')
|
|
assert.equal(a.content.title, 'T(signage.templates.happyHour.title)')
|
|
assert.equal(a.time_from, '17:00')
|
|
a.content.background.colour = '#000000'
|
|
assert.notEqual(tpl.content.background.colour, '#000000') // a copy, never the template itself
|
|
assert.ok(TEMPLATES.every(x => ['image', 'video', 'text', 'menu'].includes(x.kind)))
|
|
})
|
|
|
|
test('does a picture fit the playlist\'s shape', () => {
|
|
assert.equal(fitsOrientation({ width: 1920, height: 1080 }, 'landscape'), true)
|
|
assert.equal(fitsOrientation({ width: 1080, height: 1920 }, 'landscape'), false)
|
|
assert.equal(fitsOrientation({ width: 1080, height: 1920 }, 'portrait'), true)
|
|
assert.equal(fitsOrientation({ width: 800, height: 800 }, 'portrait'), true)
|
|
assert.equal(fitsOrientation({}, 'portrait'), null)
|
|
const media = { 1: { width: 1080, height: 1920 }, 2: { width: 1920, height: 1080 } }
|
|
const slides = [{ id: 10, content: { media_id: 1 } }, { id: 11, content: { media_id: 2 } },
|
|
{ id: 12, content: { background: { kind: 'media', media_id: 1 } } }, { id: 13, content: { background: { kind: 'colour', media_id: 1 } } }]
|
|
assert.deepEqual(misfits(slides, media, 'landscape'), { 10: [1], 12: [1] })
|
|
})
|
|
|
|
test('the timeline: when a slide shows, the round\'s time, moving', () => {
|
|
assert.deepEqual(windowParts({}), [])
|
|
assert.deepEqual(windowParts({ days: [0, 1, 2, 3, 4, 5, 6] }), [])
|
|
assert.deepEqual(windowParts({ days: [5, 6], time_from: '12:00' }).map(p => p.key), ['days', 'hours'])
|
|
assert.equal(windowParts({ date_to: '2026-12-31' })[0].params.from, '…')
|
|
const media = { 7: { duration_ms: 12_400 } }
|
|
assert.equal(totalSeconds([{ enabled: true, duration_s: 8 }, { enabled: false, duration_s: 50 },
|
|
{ enabled: true, kind: 'video', video_to_end: true, content: { media_id: 7 } }], media), 20)
|
|
assert.deepEqual(moved([1, 2, 3, 4], 3, 0), [4, 1, 2, 3])
|
|
assert.deepEqual(moved([1, 2, 3], 0, 9), [1, 2, 3])
|
|
})
|
|
|
|
test('what is sent back, and library items as the slides need them', () => {
|
|
const b = slideBody({ id: 1, kind: 'text', name: '', duration_s: 9, enabled: 1, days: undefined, content: { title: 'x' }, menu: {} })
|
|
assert.deepEqual(b, { name: null, duration_s: 9, transition: null, video_to_end: false, enabled: true, days: [], time_from: null, time_to: null,
|
|
date_from: null, date_to: null, content: { title: 'x' } })
|
|
assert.deepEqual(mediaEntry({ id: 3, kind: 'video', name: 'v', width: 1, height: 2, duration_ms: 5, urls: { original: '/o' } }).url, '/o')
|
|
assert.equal(mediaEntry({ id: 3, kind: 'image', urls: { full: '/f', original: '/o', thumb: '/t' } }).url, '/f')
|
|
})
|