jukebox
All repositories: gitoria
6.5 KB
// tests/jb15.mjs — JB15 (jukebox#15): the now-playing overlay must show ALL its controls and a usable part of the queue at every screen size, and the// last queued song must be reachable (scrolled into view). Before the fix a short screen (a tablet in landscape, a phone on its side) gave the queue// 100 px or less (the big cover took the room), so the section at the bottom was cut off after a row or less.// Own server on a generated database of 300 songs, headless Chrome (a gate; the proof of the change itself is done in his Chrome on lisbeth, see the report).// node tests/jb15.mjs env: JB15_PORT (default 8721), JB15_DIR (scratch), JB15_ROOT (checkout to test), HL_PORT_BASE (default 8540), JUKEBOX_COLD_MSimport { spawn, execFileSync } from 'node:child_process'import { rmSync, mkdirSync, writeFileSync } from 'node:fs'import { dirname, join } from 'node:path'import { fileURLToPath } from 'node:url'process.env.HL_CHROME = process.env.HL_CHROME || '/opt/google/chrome/chrome'process.env.HL_PORT_BASE = process.env.HL_PORT_BASE || '8540'const { launchBrowser, sleep } = await import('./cdp.mjs')const root = process.env.JB15_ROOT || join(dirname(fileURLToPath(import.meta.url)), '..')const dir = process.env.JB15_DIR || '/media/STORAGE/claude-scratch/atlas/JB15/gate'const port = Number(process.env.JB15_PORT || 8721)const BASE = `http://127.0.0.1:${port}`const COLD_MS = Number(process.env.JUKEBOX_COLD_MS || 150000)let pass = 0, fail = 0const check = (name, ok, detail = '') => { console.log((ok ? 'ok ' : 'FAIL ') + name + (ok ? '' : ' — ' + detail)); if (ok) pass++; else fail++ }mkdirSync(dir, { recursive: true })process.env.TMPDIR = dirlet server = null, browser = null, log = ''async function stop() {if (browser) { try { await browser.close() } catch {} browser = null }if (server) { try { server.kill('SIGTERM') } catch {} await sleep(500); server = null }}process.on('SIGINT', async () => { await stop(); process.exit(1) })const storage = join(dir, 'storage')const tone = join(dir, 'tone300.mp3')rmSync(storage, { recursive: true, force: true })execFileSync('ffmpeg', ['-v', 'error', '-y', '-f', 'lavfi', '-i', 'sine=frequency=440:duration=300', '-q:a', '9', tone])const cover = join(root, 'tests/fixtures/withcover/folder.jpg')execFileSync(join(root, 'bin/hybriel'), [join(root, 'tools/make-test-db.hl'), tone, cover, '300'], { env: { ...process.env, JUKEBOX_STORAGE: storage }, encoding: 'utf8', timeout: 600000 })server = spawn(join(root, 'bin/hybriel'), ['project.hl'], { cwd: root, env: { ...process.env, JUKEBOX_PORT: String(port), JUKEBOX_STORAGE: storage, JUKEBOX_AUTOSCAN: '0', JUKEBOX_WATCH: '0', HL_HOST: '127.0.0.1' }, stdio: ['ignore', 'pipe', 'pipe'] })console.log('server pid ' + server.pid)server.stdout.on('data', (d) => { log += d }); server.stderr.on('data', (d) => { log += d })const SIZES = [[390, 844], [844, 390], [800, 1280], [1280, 800], [1024, 768], [1280, 900], [1280, 600], [1024, 552]]try {for (const t0 = Date.now(); ; ) {try { if ((await fetch(BASE + '/api/stats')).ok) break } catch {}if (Date.now() - t0 > COLD_MS) { console.log(log); throw new Error('the server did not come up') }await sleep(500)}browser = await launchBrowser()console.log('chrome pid ' + browser.proc?.pid)const page = await browser.newPage()const ev = (e) => page.evaluate(e)await page.send('Emulation.setDeviceMetricsOverride', { width: 800, height: 1280, deviceScaleFactor: 1, mobile: false })await page.goto(BASE + '/')await page.waitForSelector('virtual-list .vl-row:not(.blank)')await sleep(1200)await page.click('virtual-list .vl-row[data-index="2"]')await page.waitFor(`(() => { const a = document.querySelector('media-player audio'); return a && a.currentSrc.indexOf('/stream/') > 0 })()`, { timeout: 20000, label: 'a song plays' })await ev(`document.querySelector('media-player audio').pause()`)for (const [w, h] of SIZES) {await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: 1, mobile: false })await sleep(400)if (await ev(`!document.querySelector('.jb-app').classList.contains('open')`)) { await page.click('.jb-bar media-player .mp-cover'); await sleep(500) }const m = await ev(`(() => {const vh = innerHeight, vw = innerWidthconst q = document.querySelector('.jb-bar media-player > div:not(.mp-cover)')const inside = (s) => { const e = document.querySelector(s); if (!e) return 'missing'; const b = e.getBoundingClientRect(); const cs = getComputedStyle(e); if (cs.display === 'none') return 'hidden'; return (b.top >= -1 && b.bottom <= vh + 1 && b.left >= -1 && b.right <= vw + 1) ? 'ok' : 'outside ' + Math.round(b.top) + '..' + Math.round(b.bottom) + ' of ' + vh }const controls = ['.jb-close', '.jb-bar mp-seek', '.jb-bar button.jb-prev', '.jb-bar .mp-back', '.jb-bar .mp-play', '.jb-bar .mp-forward', '.jb-bar button.jb-next', '.jb-bar .mp-times', '.jb-bar .mp-mute', '.jb-bar .mp-speed'].map((s) => [s, inside(s)])const items = [...q.querySelectorAll('ol.mp-queue li')].filter((li) => getComputedStyle(li).display !== 'none')q.scrollTop = q.scrollHeightconst last = items[items.length - 1].getBoundingClientRect(), qb = q.getBoundingClientRect()const bar = document.querySelector('.jb-bar')return { controls, qh: Math.round(qb.height), n: items.length, lastIn: last.bottom <= qb.bottom + 1 && last.bottom <= vh + 1 && last.top >= qb.top - 1, rem: parseFloat(getComputedStyle(document.documentElement).fontSize), barScroll: [bar.scrollHeight, bar.clientHeight] }})()`)const bad = m.controls.filter(([, r]) => r !== 'ok')check(`${w}x${h}: every control of the overlay is inside the screen`, bad.length === 0, JSON.stringify(bad))check(`${w}x${h}: the queue has room for at least 3 rows (${m.qh} px)`, m.qh >= 3 * 44, 'queue ' + m.qh + ' px')check(`${w}x${h}: the last queued song can be scrolled into view`, m.lastIn && m.n >= 20, JSON.stringify({ lastIn: m.lastIn, n: m.n }))check(`${w}x${h}: the overlay itself does not overflow`, m.barScroll[0] <= m.barScroll[1] + 1, JSON.stringify(m.barScroll))// the close button really closes it, and the screen under it is usable again}await page.click('.jb-close')await page.waitFor(`!document.querySelector('.jb-app').classList.contains('open')`, { label: 'closed' })check('the close button closes the overlay', true)} catch (e) {check('gate ran to the end', false, String(e && e.message || e))} finally {await stop()}console.log(`${pass} passed, ${fail} failed`)process.exit(fail ? 1 : 0)
Branches
Latest commits
- 1838d7e8Records: S1 startedmre
- a43fca3fRecords: mission 001 decided pointsmre
- 41773828Records: statusmre
- a82c0805Records: mission 001 brief (Style form)mre
- a4bce6d1Records: ticket push subscriptionmre
- 14abde3bjukebox: records: Atlas's records moved to worldapi-conductor/archivemre
- 0433e9a8jukebox: records: gitoria remote added and pushedmre
- 1722d707jukebox: records: repo creation handed to Gitoriamre
- b42e7dfbjukebox: conductor records (CONDUCTOR.md, STATUS.md), old STATUS archivedmre
- 1b0d0bc1jukebox: a startup error prints its message before exit 1 (hybriel#247)mre
- b19c478bjukebox JB18 (jukebox#17): onto Hybriel set-day31 (b287cd82, contains the SIGPIPE fix 6d2ca454): plugins/core and plugins/web re-vendored, bin/ from the set; a client that closes /stream while it is written no longer kills the server (90 aborted streams survived, the old bin died with exit 141 on the first)mre
- 73867a2ejukebox#2: Style blocks in the language's nested form (rules named after the View's own elements, pseudo-classes nested, merged duplicates); the same CSS rules, the pages look the samemre
- 06c548d6jukebox JB15: report, log linemre
- 980859cbjukebox JB15 (jukebox#15): the now-playing overlay on a short screen (tablet or phone on its side) gave the queue 12 to 100 px because the big cover took the room; the cover now shrinks with the screen height and goes away under 41rem, the queue keeps 3+ rows; gate tests/jb15.mjs at 8 sizesmre
- 9efc40ffjukebox#12 #14: Grok session 1793246574527-181160mre
- 7d58b36ejukebox JB13 (jukebox#13): Next and Previous ask for the songs after / before the current song's id in the current order, not for place + 1; gate tests/jb13.mjs checks Next with the queue down to one song after the order changedmre
- 51358794jukebox JB14 (jukebox#14): the Songs screen opens sorted the way it was left (kept on the server in storage/ui.json), the sort control shows the sort the rows really have (selected options, autocomplete off); gate tests/jb14.mjsmre
- cc68a063jukebox JB13 (jukebox#13): a tapped song plays the song that was tapped, found by its id in the list as it is now (not by its row number, which counted plays move); the queue goes on from its place there, the rows refresh on the tap; gate tests/jb13.mjs (songs by plays, favourites)mre
- 88d3d5c1jukebox JB12b (jukebox#12): the scroll handle is big (2.75rem x 4rem, accent colour, grip) and drawn on every device, no media query; native bar hidden; gate tests/touch.mjs checks the drawn width with and without touchmre
- b58e4495jukebox JB11 (jukebox#11): the next song starts in the ended event on the same audio element, so it also starts with the screen locked; gate tests/jb11.mjs (hidden tab, no frames)mre