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
+2 -2
View File
@@ -614,10 +614,10 @@ try {
await page.getByTestId('display-save').click()
let idleCfg = null
for (let i = 0; i < 30 && idleCfg?.style !== 'qr'; i++) {
idleCfg = (await api('GET', '/api/display/settings', { token: boss })).idle
idleCfg = (await api('GET', '/api/display/looks', { token: boss })).find(l => l.is_default)?.config
if (idleCfg?.style !== 'qr') await sleep(100)
}
r.check('settings: customer display → a QR code to the online ordering, with a caption', idleCfg?.style === 'qr'
r.check('settings: customer display → the default look: a QR code to the online ordering, with a caption', idleCfg?.style === 'qr'
&& idleCfg.qr_target === 'ordering' && idleCfg.qr_caption === 'Order online', JSON.stringify(idleCfg))
await page.screenshot({ path: path.join(OUT, 'manager-display-settings.png'), fullPage: true })
+26
View File
@@ -156,6 +156,32 @@ try {
(await page.getByTestId('media-used-by').innerText().catch(() => '')).includes(p1.name) && await page.getByTestId('media-delete').isDisabled())
await page.keyboard.press('Escape')
// ── 5.3: the customer display's looks pick their pictures from the library ──
await api('PUT', '/api/platform/modules/customer_display', { token: boss, body: { enabled: true } }).catch(() => {})
await page.goto(`${MANAGER}/settings`)
await page.getByText('Customer display', { exact: true }).click()
await page.getByTestId('display-look-new').click({ timeout: 15_000 })
await page.getByTestId('display-look-new-name').fill('Promo')
await page.getByTestId('display-look-create').click()
await page.locator('[data-testid="display-look"][data-name="Promo"][aria-selected="true"]').waitFor({ timeout: 10_000 })
await page.getByTestId('display-style-slideshow').click()
await page.getByTestId('display-slides-add').click()
const picker = page.getByTestId('media-picker')
for (const i of [0, 1, 2]) await picker.getByTestId('media-item').nth(i).click()
await page.getByTestId('media-picker-add').click()
r.check('5.3: a new look "Promo": three pictures picked at once from the library, in order',
await page.getByTestId('display-slide-item').count() === 3)
await page.getByTestId('display-save').click()
await sleep(1000)
const looks = await api('GET', '/api/display/looks', { token: boss })
const promo = looks.find(l => l.name === 'Promo')
r.check('5.3: saved: the look is a slideshow of three library pictures; the default look is unchanged',
promo?.config.style === 'slideshow' && promo.config.slides.length === 3 && promo.preview.slide_urls.length === 3
&& looks.find(l => l.is_default)?.name === 'Main', JSON.stringify(looks.map(l => [l.name, l.config.style, l.config.slides])))
await page.screenshot({ path: path.join(OUT, 'media-display-looks.png'), fullPage: true })
const usedSlide = await api('DELETE', `/api/media/${promo.config.slides[0]}`, { token: boss }).then(() => 'deleted', e => e.message)
r.check('5.3: a picture in a look cannot be deleted from the library', usedSlide.includes('409'), usedSlide)
// ── The waiter's phone: photos fetched ahead, shown offline ─────────────────
const phone = await browser.newContext({ viewport: { width: 393, height: 852 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true })
const w = await phone.newPage()
+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' } })