test(e2e): display looks (two displays, two slideshows; looks UI with library pictures); docs

- terminal.mjs: the looks API drives the idle screen; a second look on the
  other display: two displays show two different slideshows from the library.
- manager.mjs: the default look's QR design through Settings.
- media.mjs: a new look with three pictures picked at once, a picture in a look
  can't be deleted.
- pack README: the customer display row; CS-19 (screen designs are records a
  device picks with a ref field).
- run-all --no-android: all passed except terminal's "server unreachable →
  banner" (8 s wait, under load); terminal.mjs alone right after: all passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 17:50:52 +02:00
co-authored by Claude Opus 5.5
parent 6d84e43330
commit 51b764fe7e
4 changed files with 54 additions and 15 deletions
+24 -11
View File
@@ -15,8 +15,9 @@
import http from 'node:http'
import net from 'node:net'
import path from 'node:path'
import { execFileSync } from 'node:child_process'
import { chromium } from 'playwright'
import { BROWSER_CHANNEL, OUT, reporter, sleep } from './lib/env.mjs'
import { BROWSER_CHANNEL, OUT, PYTHON, reporter, sleep, waitFor } from './lib/env.mjs'
import { startBackend, startTerminalVite } from './lib/proc.mjs'
import { supportLogin } from './lib/support.mjs'
@@ -715,24 +716,36 @@ try {
r.check('3.4: paid → "Thank you" with the change', await shown(myDisplay, 'display-paid', 5000)
&& (await myDisplay.getByTestId('display-paid').textContent()).includes('Thank you'))
await myDisplay.screenshot({ path: path.join(OUT, 'terminal-display-paid.png') })
// the venue's choice: a QR code to its online ordering, then a slideshow of its photos
await api('PUT', '/api/display/settings', { token: boss, body: { style: 'qr', qr_target: 'ordering', qr_caption: 'Order online', theme: 'light' } })
r.check('3.4: the idle screen follows the venue\'s settings at once (a QR code to its ordering, light)',
// the venue's choice: a QR code to its online ordering, then a slideshow of its photos (a look; 5.3)
const main = (await api('GET', '/api/display/looks', { token: boss })).find(l => l.is_default)
await api('PUT', `/api/display/looks/${main.id}`, { token: boss, body: { config: { style: 'qr', qr_target: 'ordering', qr_caption: 'Order online', theme: 'light' } } })
r.check('3.4: the idle screen follows the look at once (a QR code to the venue ordering, light)',
await myDisplay.waitForFunction(() => document.querySelector('[data-testid="display-qr"]'), null, { timeout: 20_000 }).then(() => true).catch(() => false)
&& (await myDisplay.getByTestId('display-qr').getAttribute('data-link')).includes('/order/') && await myDisplay.evaluate(() => document.documentElement.dataset.theme) === 'light')
await myDisplay.screenshot({ path: path.join(OUT, 'terminal-display-qr.png') })
const png = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', 'base64')
const uploadImg = async () => {
const uploadImg = async (rgb) => {
const jpg = execFileSync(PYTHON, ['-c', `import io,sys;from PIL import Image;b=io.BytesIO();Image.new('RGB',(1280,720),(${rgb})).save(b,'JPEG');sys.stdout.buffer.write(b.getvalue())`])
const form = new FormData()
form.append('file', new Blob([png], { type: 'image/png' }), 'promo.png')
const res = await fetch(`${backend.url}/api/display/media`, { method: 'POST', headers: { authorization: `Bearer ${boss}` }, body: form })
form.append('file', new Blob([jpg], { type: 'image/jpeg' }), 'promo.jpg')
const res = await fetch(`${backend.url}/api/media`, { method: 'POST', headers: { authorization: `Bearer ${boss}` }, body: form })
return res.json()
}
const [a, b] = [await uploadImg(), await uploadImg()]
await api('PUT', '/api/display/settings', { token: boss, body: { style: 'slideshow', slides: [a.name, b.name], slide_seconds: 3, message: 'Today: 2 for 1' } })
r.check('3.4: …or a slideshow of its photos, with its line of text',
const [a, b, c] = [await uploadImg('200,40,40'), await uploadImg('40,200,40'), await uploadImg('40,40,200')]
await api('PUT', `/api/display/looks/${main.id}`, { token: boss, body: { config: { style: 'slideshow', slides: [a.id, b.id], slide_seconds: 3, message: 'Today: 2 for 1' } } })
r.check('3.4: …or a slideshow of its photos (from the media library), with its line of text',
await myDisplay.waitForFunction(() => document.querySelectorAll('[data-testid="display-slide"]').length === 2, null, { timeout: 20_000 }).then(() => true).catch(() => false)
&& (await myDisplay.getByTestId('display-message').textContent()) === 'Today: 2 for 1')
// 5.3: the other display gets its own look, another slideshow
const promo = await api('POST', '/api/display/looks', { token: boss, body: { name: 'Promo', config: { style: 'slideshow', slides: [c.id], slide_seconds: 5 } } })
const otherId = (await api('GET', '/api/display/displays', { token: boss })).find(d => d.name === 'Display elsewhere').id
await api('PUT', `/api/display/displays/${otherId}/look`, { token: boss, body: { look_id: promo.id } })
const slidesOf = page => page.evaluate(() => [...document.querySelectorAll('[data-testid="display-slide"]')].map(e => e.getAttribute('src') || e.style.backgroundImage || ''))
const otherSlides = await waitFor(async () => { const s = await slidesOf(otherDisplay); return s.length === 1 ? s : null }, 20_000, 300)
const mySlides = await slidesOf(myDisplay)
r.check('5.3: two displays, two slideshows from the library (each display its own look)',
!!otherSlides && otherSlides[0].includes(c.sha256) && mySlides.length === 2 && mySlides.every(u => !u.includes(c.sha256)),
JSON.stringify({ mine: mySlides.map(u => u.slice(-40)), other: otherSlides?.map(u => u.slice(-40)) }))
await otherDisplay.screenshot({ path: path.join(OUT, 'terminal-display-promo.png') })
// ── 3.5: caller ID at the counter ────────────────────────────────────────
await api('PUT', '/api/platform/modules/caller_id', { token: boss, body: { enabled: true } }).catch(() => {})
await api('POST', '/api/customers/', { token: boss, body: { name: 'Kostas Regular', phone: '+30 697 555 1234', notes: 'Always extra tzatziki' } })