feat(signage): reviews typed in by hand and their widget; Add a widget at the top of the widgets, the list in layers (new widgets on top)

Reviews (name, stars, text, date, where) under Signage -> Message & settings, shown
one at a time by the reviews widget (a minimum of stars, seconds each); not pulled
from Google (owner's choice). The widgets section: one "Add a widget" menu at its
top instead of a button per kind; the cards are layers, the top one drawn over the
others, so a new widget goes on top; the arrows bring forward / send backward.
Plan 6R.19, F-113.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 14:21:17 +02:00
co-authored by Claude Opus 5.5
parent f26e51273c
commit 189bd2777b
14 changed files with 339 additions and 52 deletions
+17 -7
View File
@@ -43,6 +43,9 @@ async function upload(token, bytes, name, type) {
const res = await fetch(`${backend.url}/api/media`, { method: 'POST', headers: { authorization: `Bearer ${token}` }, body: form })
return res.json()
}
/** "Add a widget" at the top of the widgets section (owner 2026-11-22), then the kind. */
const addWidget = async kind => { await mgrPage.getByTestId('signage-widget-add').click(); await mgrPage.getByTestId(`signage-widget-add-${kind}`).click() }
let mgrPage = null
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)
@@ -205,6 +208,7 @@ try {
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()
mgrPage = mgr
mgr.on('pageerror', e => errors.push(e.message))
await mgr.goto(`${MANAGER}/login`)
await mgr.getByTestId('login-form').waitFor({ timeout: 60_000 })
@@ -291,7 +295,7 @@ try {
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 addWidget('clock')
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)
@@ -310,18 +314,20 @@ try {
// ── 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 addWidget('text')
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 listed = await mgr.getByTestId('signage-widget').evaluateAll(els => els.map(e => e.dataset.kind))
r.check('owner 2026-11-22: "Add a widget" puts the new one at the top of the list (drawn over the others)', listed[0] === 'text', JSON.stringify(listed))
await mgr.locator('[data-testid="signage-widget"][data-kind="text"]').getByTestId('signage-widget-down').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): a text widget, sent backward with its arrow (under the clock)', kinds.indexOf('text') > kinds.indexOf('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()
await addWidget('hstack')
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()
@@ -581,19 +587,23 @@ try {
const ident = await api('GET', '/api/identity', { token: boss })
await api('PUT', '/api/identity', { token: boss, body: { name: ident.name || 'Taverna', wifi: { ssid: 'Xenia Guests', password: 'kalimera', security: 'WPA' },
contact: { phone: '2310 123456', instagram: '@xenia' } } })
await api('PUT', '/api/signage/reviews', { token: boss, body: { reviews: [{ name: 'Maria', stars: 5, text: 'Best octopus on the island' }, { name: 'Bob', stars: 2, text: 'Meh' }] } })
await api('PUT', '/api/identity/hours', { token: boss, body: { days: [[{ from: '12:00', to: '23:00' }], [], [], [], [], [], []] } })
const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } })
await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [
{ kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' },
{ kind: 'countdown', position: 'top-center', countdown_to: '2099-01-01T00:00', text: 'Opening in' },
{ kind: 'hours', position: 'top-left' }, { kind: 'wifi', position: 'bottom-right' }, { kind: 'contact', position: 'bottom-left' },
{ kind: 'ticker', position: 'top-bar', text: 'Fresh fish today' }] } } })
{ kind: 'ticker', position: 'top-bar', text: 'Fresh fish today' },
{ kind: 'reviews', position: 'custom', box: { x: 30, y: 40, w: 40, h: 25 } }] } } })
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } })
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV',
await waitFor(async () => (await widgetsOn()) || null, 15_000, 300) === true)
r.check('6R.15: the Wi-Fi widget carries the code that joins the network', (await tv.getByTestId('signage-w-wifi').textContent()).includes('Xenia Guests')
&& await tv.getByTestId('signage-w-wifi').locator('svg').count() > 0)
r.check('6R.19: a review typed in by hand shows (the 2-star one is left out)', await tv.getByTestId('signage-w-reviews').getAttribute('data-count') === '1'
&& (await tv.getByTestId('signage-w-reviews').textContent()).includes('Best octopus'))
r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim()))
await tv.screenshot({ path: path.join(OUT, 'signage-new-widgets.png') })