feat(signage): new widgets (shape, scrolling text, countdown, opening hours, Wi-Fi, contact details); the venue's opening hours on the server, edited on the Schedule page
Shapes: rectangle, circle, triangle, polygon, star or own corners, fill or gradient, border. Countdown: to a time every day or a date, from now / a span before / a set time, in venue time (the slide shows what is left right now). Opening hours, Wi-Fi (with a join-the-network code) and contact details read the venue's identity and opening hours (GET/PUT /api/identity/hours; Schedule -> Opening hours, shaded on its timeline); the editor warns with a link when they're missing. Plan 6R.15, F-112. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -277,3 +277,41 @@ test('a Wi-Fi QR code: escaped, open networks without a password, hidden ones (6
|
||||
assert.equal(wifiQr({ ssid: 'Open', password: 'x', security: 'nopass', hidden: true }), 'WIFI:T:nopass;S:Open;H:true;;')
|
||||
assert.equal(wifiQr({ password: 'x' }), '')
|
||||
})
|
||||
|
||||
test('a countdown: from a span before, waiting, running, done; a date; the text (6R.15)', async () => {
|
||||
const { countdownState, countdownText } = await import('../src/logic.js')
|
||||
const w = { countdown_to: '17:00', countdown_start: 'before', countdown_before: 120 }
|
||||
const at = (hhmm, date = '2026-11-22') => ({ date, minutes: Number(hhmm.slice(0, 2)) * 60 + Number(hhmm.slice(3)) })
|
||||
// the owner's case: ends at 5, starts 2 h before, the slide shows at 3:30 → 1:30:00 left
|
||||
assert.deepEqual(countdownState(w, at('15:30')), { state: 'running', left: 5400 })
|
||||
assert.equal(countdownText(5400), '1:30:00')
|
||||
assert.deepEqual(countdownState(w, at('14:00')), { state: 'waiting', left: 7200 })
|
||||
assert.equal(countdownState(w, at('17:00')).state, 'done')
|
||||
assert.equal(countdownState({ countdown_to: '17:00' }, at('09:00')).left, 8 * 3600)
|
||||
assert.equal(countdownState({ countdown_to: '17:00', countdown_start: 'at', countdown_at: '16:00' }, at('15:00')).state, 'waiting')
|
||||
const ny = countdownState({ countdown_to: '2026-12-31T23:59' }, at('23:59', '2026-12-30'), 30)
|
||||
assert.equal(ny.left, 86400 - 30)
|
||||
assert.equal(countdownText(ny.left), '23:59:30')
|
||||
assert.equal(countdownText(2 * 86400 + 61), '2d 00:01:01')
|
||||
assert.equal(countdownText(309), '05:09')
|
||||
assert.equal(countdownState({}, at('10:00')).state, 'none')
|
||||
})
|
||||
|
||||
test('opening hours in lines: same hours grouped, today marked; shapes as points (6R.15)', async () => {
|
||||
const { hoursRows, shapePoints } = await import('../src/logic.js')
|
||||
const lunch = [{ from: '12:00', to: '23:00' }]
|
||||
const hours = { days: [lunch, lunch, lunch, lunch, [{ from: '12:00', to: '01:00' }], [], lunch] }
|
||||
const rows = hoursRows(hours, { today: 1 })
|
||||
assert.deepEqual(rows.map(r => r.days), [[0, 1, 2, 3], [4], [5], [6]])
|
||||
assert.equal(rows[0].today, true)
|
||||
assert.deepEqual(rows[2].spans, [])
|
||||
assert.equal(hoursRows(hours, { group: false }).length, 7)
|
||||
assert.deepEqual(hoursRows(hours, { only: 5 }).map(r => r.days), [[5]])
|
||||
assert.deepEqual(hoursRows({ days: [] }), [])
|
||||
assert.equal(shapePoints({ shape: 'triangle' }), '50,0 100,100 0,100')
|
||||
assert.equal(shapePoints({ shape: 'star', shape_sides: 5 }).split(' ').length, 10)
|
||||
assert.equal(shapePoints({ shape: 'polygon', shape_sides: 6 }).split(' ').length, 6)
|
||||
assert.equal(shapePoints({ shape: 'custom', shape_points: '0,0 100,0 50,120' }), '0,0 100,0 50,100')
|
||||
assert.equal(shapePoints({ shape: 'custom', shape_points: '1,1' }), null)
|
||||
assert.equal(shapePoints({ shape: 'rectangle' }), null)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user