gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchday39cfe95440|||PR day39 re-vendor: Hybriel 51e921d7 (bin 6b481aa7), ids kebab-case since hybriel#256: quoted state rule and tests use jb-shuffle / jb-repeatmreday39/tests/ui.mjs

25.2 KB

  1. // tests/ui.mjs — the jukebox's SCREEN GATE: its own server on a generated database of 13,450 songs (tools/make-test-db.hl, not the real library) and a real headless
  2. // Chrome (tests/cdp.mjs): real clicks, wheel scrolling and keys. Phone first (390 px), then 1280. Every song of the test database points at one 60 s tone (ffmpeg).
  3. // node tests/ui.mjs env: JUKEBOX_UI_PORT (server, default 8710), JUKEBOX_UI_CHROME (Chrome debug ports, HL_PORT_BASE+200..: default base 8500 → 8700-8709),
  4. // JUKEBOX_UI_DIR (scratch, default /media/STORAGE/claude-scratch/atlas/JB2/gate-ui), JUKEBOX_UI_SHOTS (screenshots dir), JUKEBOX_UI_URL (use a server that already runs: skips the start and the database)
  5. import { spawn, execFileSync } from 'node:child_process'
  6. import { rmSync, mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs'
  7. import { dirname, join } from 'node:path'
  8. import { fileURLToPath } from 'node:url'
  9. process.env.HL_CHROME = process.env.HL_CHROME || '/opt/google/chrome/chrome'
  10. process.env.HL_PORT_BASE = process.env.HL_PORT_BASE || '8500'
  11. const { launchBrowser } = await import('./cdp.mjs')
  12. const root = join(dirname(fileURLToPath(import.meta.url)), '..')
  13. const dir = process.env.JUKEBOX_UI_DIR || '/media/STORAGE/claude-scratch/atlas/JB2/gate-ui'
  14. const shots = process.env.JUKEBOX_UI_SHOTS || join(dir, 'shots')
  15. const port = Number(process.env.JUKEBOX_UI_PORT || 8710)
  16. const BASE = process.env.JUKEBOX_UI_URL || `http://127.0.0.1:${port}`
  17. const COLD_MS = Number(process.env.JUKEBOX_COLD_MS || 150000)
  18. let pass = 0, fail = 0
  19. const check = (name, ok, detail = '') => { console.log((ok ? 'ok ' : 'FAIL ') + name + (ok ? '' : ' — ' + detail)); if (ok) pass++; else fail++ }
  20. const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
  21. mkdirSync(shots, { recursive: true })
  22. let server = null, browser = null, log = ''
  23. async function stop() {
  24. if (browser) { try { await browser.close() } catch {} browser = null }
  25. if (server) { try { server.kill('SIGTERM') } catch {} await sleep(500); server = null }
  26. }
  27. process.on('SIGINT', async () => { await stop(); process.exit(1) })
  28. // ---- the test database and the server --------------------------------------------------------------------------------------
  29. const storage = join(dir, 'storage')
  30. const tone = join(dir, 'tone.mp3')
  31. if (!process.env.JUKEBOX_UI_URL) {
  32. rmSync(storage, { recursive: true, force: true })
  33. mkdirSync(dir, { recursive: true })
  34. execFileSync('ffmpeg', ['-v', 'error', '-y', '-f', 'lavfi', '-i', 'sine=frequency=440:duration=60', '-q:a', '9', tone])
  35. const cover = join(root, 'tests/fixtures/withcover/folder.jpg')
  36. const t0 = Date.now()
  37. const made = execFileSync(join(root, 'bin/hybriel'), [join(root, 'tools/make-test-db.hl'), tone, cover], { env: { ...process.env, JUKEBOX_STORAGE: storage }, encoding: 'utf8', timeout: 600000 })
  38. console.log(made.trim() + ' (' + (Date.now() - t0) + ' ms)')
  39. 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'] })
  40. server.stdout.on('data', (d) => { log += d }); server.stderr.on('data', (d) => { log += d })
  41. for (const t0 = Date.now(); ; ) {
  42. try { if ((await fetch(BASE + '/')).ok) break } catch {}
  43. if (Date.now() - t0 > COLD_MS) { console.log(log); throw new Error('the server did not come up') }
  44. await sleep(500)
  45. }
  46. }
  47. try {
  48. // ---- the JSON API and the audio route -------------------------------------------------------------------------------------
  49. const j = async (p) => (await fetch(BASE + p)).json()
  50. const stats = (await j('/api/stats')).library
  51. check('the test database has 13,459 files', stats.songs === 13459, JSON.stringify(stats))
  52. const byPlays = await j('/api/songs?sort=plays&limit=3')
  53. check('sort=plays: the most played first', byPlays.items.length === 3 && byPlays.items[0].playCount >= byPlays.items[1].playCount && byPlays.items[0].playCount === 12, JSON.stringify(byPlays.items.map((s) => s.playCount)))
  54. const some = (await j('/api/songs?sort=title&limit=1')).items[0]
  55. const full = readFileSync(tone)
  56. const get = (id, headers = {}, method = 'GET') => fetch(BASE + '/stream/' + id, { headers, method })
  57. let r = await get(some.id, { Range: 'bytes=0-99' })
  58. const b0 = Buffer.from(await r.arrayBuffer())
  59. check('stream: Range bytes=0-99 answers 206 with 100 bytes', r.status === 206 && b0.length === 100 && r.headers.get('content-range') === `bytes 0-99/${full.length}`, r.status + ' ' + r.headers.get('content-range'))
  60. check('stream: the bytes are the file\'s bytes', b0.equals(full.subarray(0, 100)))
  61. check('stream: content type audio/mpeg, Accept-Ranges bytes', r.headers.get('content-type') === 'audio/mpeg' && r.headers.get('accept-ranges') === 'bytes', r.headers.get('content-type'))
  62. r = await get(some.id, { Range: 'bytes=1000-1999' }); const b1 = Buffer.from(await r.arrayBuffer())
  63. check('stream: a range in the middle is the right slice', r.status === 206 && b1.equals(full.subarray(1000, 2000)))
  64. r = await get(some.id, { Range: 'bytes=-50' }); const b2 = Buffer.from(await r.arrayBuffer())
  65. check('stream: a suffix range gives the last 50 bytes', r.status === 206 && b2.equals(full.subarray(full.length - 50)))
  66. r = await get(some.id, { Range: `bytes=${full.length - 10}-` }); const b3 = Buffer.from(await r.arrayBuffer())
  67. check('stream: an open range runs to the end', r.status === 206 && b3.equals(full.subarray(full.length - 10)))
  68. r = await get(some.id, { Range: `bytes=${full.length + 5}-` })
  69. check('stream: a range past the end answers 416', r.status === 416, '' + r.status)
  70. r = await get(some.id, { Range: 'bytes=0-1,5-9' })
  71. check('stream: a list of ranges is not an error (answers 206 with the start)', r.status === 206)
  72. r = await get(some.id)
  73. check('stream: no Range header: the first chunk, 206', r.status === 206 && Buffer.from(await r.arrayBuffer()).length === Math.min(full.length, 1048576))
  74. r = await get('nosuchsong1'); check('stream: an unknown id is 404', r.status === 404, '' + r.status)
  75. r = await get('..%2F..%2Fetc%2Fpasswd'); check('stream: a path in the URL is 404, never read', r.status === 404, '' + r.status)
  76. r = await fetch(BASE + '/stream/' + some.id, { method: 'POST' }); check('stream: POST is refused', r.status === 405)
  77. r = await fetch(BASE + '/api/thumb/' + some.id); check('a thumbnail of an unknown cover is 404', r.status === 404)
  78. const withCover = (await j('/api/albums?limit=200')).items.find((a) => a.coverId)
  79. r = await fetch(BASE + '/api/thumb/' + withCover.coverId); const th = Buffer.from(await r.arrayBuffer())
  80. check('the thumbnail is a small jpeg', r.status === 200 && r.headers.get('content-type') === 'image/jpeg' && th.length < 20000 && th[0] === 0xff, r.status + ' ' + th.length)
  81. // ---- the screens, phone first --------------------------------------------------------------------------------------------
  82. browser = await launchBrowser()
  83. const page = await browser.newPage()
  84. const ev = (e) => page.evaluate(e)
  85. const shot = async (name) => { const s = await page.send('Page.captureScreenshot', { format: 'png' }); writeFileSync(join(shots, name + '.png'), Buffer.from(s.data, 'base64')) }
  86. const press = async (key, code, vk) => { await page.send('Input.dispatchKeyEvent', { type: 'rawKeyDown', key, code, windowsVirtualKeyCode: vk }); await page.send('Input.dispatchKeyEvent', { type: 'keyUp', key, code, windowsVirtualKeyCode: vk }) }
  87. const wheel = async (dy, x = 200, y = 400) => { await page.send('Input.dispatchMouseEvent', { type: 'mouseWheel', x, y, deltaX: 0, deltaY: dy }) }
  88. const rowsInDom = () => ev(`document.querySelectorAll('virtual-list .vl-row').length`)
  89. const firstTitle = () => ev(`(document.querySelector('virtual-list .vl-row:not(.blank) .vl-title')||{}).textContent`)
  90. const goto = async (path) => { await page.goto(BASE + path); await page.waitForSelector('jb-screen') }
  91. const clientNav = async (href) => { await page.click('.menu-toggle'); await page.waitFor(`document.querySelector('app-sidebar:popover-open')`); await page.click(`app-sidebar a[href="${href}"]`); await page.waitFor(`location.pathname === ${JSON.stringify(href)}`) }
  92. await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 2, mobile: true })
  93. let t0 = Date.now()
  94. await goto('/')
  95. await page.waitForSelector('virtual-list .vl-row')
  96. console.log('first paint of Songs at 390: ' + (Date.now() - t0) + ' ms')
  97. await sleep(800)
  98. check('Songs: the count says 13,458 songs (a song in two folders is shown once)', (await ev(`document.querySelector('#count').textContent`)) === '13,458 songs')
  99. const n0 = await rowsInDom()
  100. check('Songs: only the rows near the viewport are in the page (< 100)', n0 > 5 && n0 < 100, '' + n0)
  101. const geo = await ev(`(() => { const rows = [...document.querySelectorAll('virtual-list .vl-row')].map((r) => r.getBoundingClientRect()); const r0 = document.querySelector('.vl-row'); const th = r0.querySelector('.vl-thumb').getBoundingClientRect(), tx = r0.querySelector('.vl-text').getBoundingClientRect(); return { steps: rows.slice(1).map((r, i) => Math.round(r.top - rows[i].top)), thumbMid: th.top + th.height / 2, textMid: tx.top + tx.height / 2, rowMid: rows[0].top + rows[0].height / 2, h: rows[0].height, titleSub: (() => { const t = r0.querySelector('.vl-title').getBoundingClientRect(), s = r0.querySelector('.vl-sub').getBoundingClientRect(); return Math.round(s.top - t.bottom) })() } })()`)
  102. check('Songs: the rows are 56 px apart, no looser (dense list)', geo.steps.every((s) => s === 56) && geo.h === 56, JSON.stringify(geo.steps.slice(0, 5)))
  103. check('Songs: thumbnail, text and row share one centre line (±1 px)', Math.abs(geo.thumbMid - geo.rowMid) <= 1 && Math.abs(geo.textMid - geo.rowMid) <= 1, JSON.stringify(geo))
  104. check('Songs: the title and its second line touch (gap ≤ 2 px)', geo.titleSub <= 2, '' + geo.titleSub)
  105. await shot('songs-390')
  106. // scroll to the end with the real wheel
  107. t0 = Date.now()
  108. for (let i = 0; i < 40; i++) { await wheel(60000); await sleep(60) }
  109. await page.waitFor(`(() => { const s = document.querySelector('.vl-scroller'); return s.scrollTop + s.clientHeight >= s.scrollHeight - 2 })()`, { timeout: 20000 })
  110. await sleep(1200)
  111. const end = await ev(`(() => { const rows = [...document.querySelectorAll('virtual-list .vl-row')]; return { n: rows.length, blank: rows.filter((r) => r.classList.contains('blank')).length, last: rows[rows.length - 1].getAttribute('data-index'), text: rows[rows.length - 1].textContent } })()`)
  112. console.log('scrolled to the end in ' + (Date.now() - t0) + ' ms')
  113. check('Songs: scrolled to the end of 13,450 rows the page still holds < 100 rows', end.n < 100, JSON.stringify(end))
  114. check('Songs: the last row is number 13,458 and its text arrived (no blank rows)', end.last === '13457' && end.blank === 0 && end.text.length > 5, JSON.stringify(end))
  115. // sort with the keyboard on the select
  116. await goto('/')
  117. await page.waitForSelector('virtual-list .vl-row')
  118. // the screen now opens where it was left (jukebox#20): the end of the list. Back to the first row with the wheel, as a listener does: a sort change does not scroll a far-down list
  119. // back to the top by itself (emit vlTop() does not move it; the same on main, reported in reports/JB20)
  120. // OPEN BUG components#27 (virtual-list resetKey): this wheel-to-top is a workaround in the gate, the bug is NOT fixed; remove it when components#27 is fixed
  121. for (let i = 0; i < 40; i++) { await wheel(-60000); await sleep(60) }
  122. await page.waitFor(`document.querySelector('.vl-scroller').scrollTop === 0`, { timeout: 20000 })
  123. await sleep(900)
  124. const apiFirst = async (q) => (await j('/api/songs?limit=1&' + q)).items[0].title
  125. await page.focus('#sort'); await press('ArrowDown', 'ArrowDown', 40)
  126. await page.waitFor(`document.querySelector('#sort').value === 'title'`)
  127. await page.waitFor(`document.querySelector('virtual-list .vl-row .vl-title').textContent !== ''`)
  128. await sleep(500)
  129. check('Sort by title: the first row is the API\'s first title', (await firstTitle()) === (await apiFirst('sort=title')), (await firstTitle()) + ' / ' + (await apiFirst('sort=title')))
  130. await press('ArrowDown', 'ArrowDown', 40); await sleep(900)
  131. check('Sort by album: the first row is the API\'s first album song', (await firstTitle()) === (await apiFirst('sort=album')), await firstTitle())
  132. await press('ArrowDown', 'ArrowDown', 40); await sleep(900)
  133. const playsRow = await ev(`document.querySelector('virtual-list .vl-row .vl-aside').textContent`)
  134. check('Sort by most played: the first row shows 12×', playsRow === '12×', playsRow)
  135. // favourites
  136. await goto('/')
  137. await page.waitForSelector('virtual-list .vl-row')
  138. const fav5 = (await j('/api/songs?minPlays=5&limit=1')).total
  139. check('the API knows the favourites count', fav5 === stats.playedAtLeast5, fav5 + ' / ' + stats.playedAtLeast5)
  140. await page.click('#fav')
  141. await page.waitFor(`document.querySelector('#count').textContent === ${JSON.stringify(fav5.toLocaleString('en-US') + ' songs')}`, { timeout: 10000, label: 'favourites count' })
  142. check('Favourites: the count line shows the songs played at least 5 times', true)
  143. const line = await ev(`(() => { const mid = (e) => { const r = e.getBoundingClientRect(); return r.top + r.height / 2 }; const c = document.querySelector('jb-count'); return [mid(c.querySelector('output')), mid(c.querySelector('input')), mid(c.querySelectorAll('span')[1]), c.getBoundingClientRect().height] })()`)
  144. check('Favourites: the count, the minimum field and the words stand on one line (centres within 6 px)', Math.max(...line.slice(0, 3)) - Math.min(...line.slice(0, 3)) <= 6, JSON.stringify(line))
  145. check('Favourites: the minimum is 5 by default', (await ev(`document.querySelector('#favmin').value`)) === '5')
  146. await shot('favourites-390')
  147. const fav9 = (await j('/api/songs?minPlays=9&limit=1')).total
  148. await page.focus('#favmin'); await ev(`document.querySelector('#favmin').select()`)
  149. await page.send('Input.insertText', { text: '9' })
  150. await page.waitFor(`document.querySelector('#count').textContent === ${JSON.stringify(fav9.toLocaleString('en-US') + ' songs')}`, { timeout: 10000, label: 'favourites 9' })
  151. check('Favourites: N adjustable, 9 changes the count', fav9 < fav5)
  152. const minPlaysSeen = await ev(`(async () => { const s = document.querySelector('.vl-scroller'); s.scrollTop = 56 * 40; await new Promise((r) => setTimeout(r, 900)); return [...document.querySelectorAll('.vl-row:not(.blank)')].length })()`)
  153. check('Favourites: rows are loaded after a scroll in the filtered list', minPlaysSeen > 5, '' + minPlaysSeen)
  154. // search through the phone's menu
  155. await goto('/')
  156. await page.waitForSelector('virtual-list .vl-row')
  157. await clientNav('/search')
  158. await page.waitForSelector('#q')
  159. check('Search: the header toggle opened the menu and the page changed without a reload', true)
  160. t0 = Date.now()
  161. await page.type('#q', 'zebra fixture')
  162. await page.waitFor(`(() => { const h = [...document.querySelectorAll('jb-hits h2')].find((x) => x.textContent.startsWith('Songs')); return !!h && h.textContent === 'Songs · 1' })()`, { timeout: 15000, label: 'search result' })
  163. console.log('search response (last key to the result): ' + (Date.now() - t0) + ' ms in all')
  164. const found = await ev(`[...document.querySelectorAll('virtual-list .vl-row:not(.blank) .vl-title')].map((e) => e.textContent)`)
  165. check('Search: the known song is found while typing', found.includes('Zebra Fixture Anthem'), JSON.stringify(found))
  166. await page.type('#q', ' nonexistentword')
  167. await page.waitFor(`document.querySelector('#count').textContent === 'Nothing found.'`, { timeout: 15000, label: 'every word must match' })
  168. check('Search: every word must match (a word that is not there finds nothing)', true)
  169. await ev(`(() => { const q = document.querySelector('#q'); q.value = ''; q.dispatchEvent(new Event('input', { bubbles: true })) })()`)
  170. await page.type('#q', 'quentin fixture')
  171. await page.waitFor(`(() => { const h = [...document.querySelectorAll('jb-hits h2')].find((x) => x.textContent.startsWith('Songs')); return !!h && h.textContent === 'Songs · 1' })()`, { timeout: 15000 })
  172. const hits = await ev(`[...document.querySelectorAll('jb-hits button .jb-name')].map((e) => e.textContent)`)
  173. check('Search: the artist and the album are found too', hits.includes('Quentin Fixture') && hits.includes('Known Album'), JSON.stringify(hits))
  174. await shot('search-390')
  175. await ev(`(() => { const q = document.querySelector('#q'); q.value = ''; q.dispatchEvent(new Event('input', { bubbles: true })) })()`)
  176. await page.type('#q', 'xyzzy')
  177. await page.waitFor(`document.querySelector('#count').textContent === 'Nothing found.'`, { timeout: 15000 })
  178. check('Search: no match shows 0 songs', true)
  179. await ev(`(() => { const q = document.querySelector('#q'); q.value = ''; q.dispatchEvent(new Event('input', { bubbles: true })) })()`)
  180. await page.type('#q', 'zebra fixture')
  181. await page.waitFor(`(() => { const h = [...document.querySelectorAll('jb-hits h2')].find((x) => x.textContent.startsWith('Songs')); return !!h && h.textContent === 'Songs · 1' })()`, { timeout: 15000 })
  182. // play the found song: a tap on its row
  183. await page.click('virtual-list .vl-row:not(.blank)')
  184. await page.waitFor(`(() => { const a = document.querySelector('media-player audio'); return a && a.currentTime > 0.6 && !a.paused })()`, { timeout: 20000, label: 'currentTime advances' })
  185. const audio1 = await ev(`(() => { const a = document.querySelector('media-player audio'); return { src: a.src, t: a.currentTime, paused: a.paused } })()`)
  186. check('Play: the song plays (currentTime advances)', audio1.t > 0.6 && !audio1.paused && audio1.src.includes('/stream/'), JSON.stringify(audio1))
  187. const bar = await ev(`(() => { const b = document.querySelector('.jb-bar').getBoundingClientRect(); return { h: Math.round(b.height), bottom: Math.round(b.bottom), vh: innerHeight, w: Math.round(b.width) } })()`)
  188. check('Play: the player bar sits at the bottom of the phone screen and the progress bar is half a finger', bar.h <= 84 && bar.h >= 68 && bar.bottom === bar.vh, JSON.stringify(bar))
  189. const barGeo = await ev(`(() => { const r = (s) => document.querySelector(s).getBoundingClientRect(); const bar = r('.jb-bar'); const seek = r('.jb-bar mp-seek'); const track = r('.jb-bar mp-seek .mp-track'); const t = r('.jb-bar .mp-cover h2'); return { seekAbove: seek.bottom <= r('.jb-bar .mp-play').top + 2, seekTop: Math.round(seek.top - bar.top), seekH: Math.round(seek.height), trackH: Math.round(track.height), title: document.querySelector('.jb-bar .mp-cover h2').textContent, titleInside: t.top >= bar.top && t.bottom <= bar.bottom && t.width > 40, buttons: [...document.querySelectorAll('.jb-bar mp-buttons button')].filter((b) => b.getBoundingClientRect().width > 0).length } })()`)
  190. check('Play: the progress bar is on top, 22 px tall, the title is inside the bar, play / pause in the media player, previous and next beside it', barGeo.seekAbove && barGeo.seekTop <= 2 && barGeo.seekH >= 20 && barGeo.seekH <= 26 && barGeo.trackH >= 20 && barGeo.trackH <= 26 && barGeo.title === 'Zebra Fixture Anthem' && barGeo.titleInside && barGeo.buttons === 1, JSON.stringify(barGeo))
  191. await shot('player-390')
  192. // the song goes on while the screen changes
  193. await clientNav('/artists')
  194. await page.waitForSelector('virtual-list .vl-row:not(.blank)')
  195. await sleep(1500)
  196. const audio2 = await ev(`(() => { const a = document.querySelector('media-player audio'); return { src: a.src, t: a.currentTime, paused: a.paused } })()`)
  197. check('Play: it keeps playing when the screen changes to Artists', audio2.src === audio1.src && audio2.t > audio1.t && !audio2.paused, JSON.stringify([audio1, audio2]))
  198. const lastRow = await ev(`(() => { const r = document.querySelector('virtual-list .vl-row:not(.blank)').getBoundingClientRect(); const b = document.querySelector('.jb-bar').getBoundingClientRect(); const s = document.querySelector('.vl-scroller').getBoundingClientRect(); return { scrollerBottom: Math.round(s.bottom), barTop: Math.round(b.top) } })()`)
  199. check('Play: the list ends where the bar starts (nothing hidden under it)', lastRow.scrollerBottom <= lastRow.barTop + 1, JSON.stringify(lastRow))
  200. // artist -> albums and songs; album -> songs in track order, large cover
  201. await page.click('virtual-list .vl-row:not(.blank)')
  202. await page.waitFor(`location.pathname.startsWith('/artists/')`)
  203. await page.waitForSelector('#name')
  204. const artistName = await ev(`document.querySelector('#name').textContent`)
  205. check('Artist: a tap opens the artist (name on top)', artistName.length > 2, artistName)
  206. check('Artist: albums and songs tabs', (await ev(`document.querySelectorAll('jb-tabs button[data-tab]').length`)) === 2)
  207. await page.click('jb-tabs button[data-tab="songs"]')
  208. await page.waitFor(`document.querySelector('jb-tabs button[data-tab="songs"]').classList.contains('on')`)
  209. await sleep(700)
  210. check('Artist: the songs tab lists their songs', (await ev(`document.querySelectorAll('.vl-row:not(.blank)').length`)) > 0)
  211. await page.click('jb-tabs button[data-tab="albums"]')
  212. await page.waitFor(`document.querySelector('jb-tabs button[data-tab="albums"]').classList.contains('on') && !document.querySelector('.vl-row:not(.blank) .vl-aside').textContent.includes(':')`, { timeout: 15000, label: 'albums tab' })
  213. await sleep(500)
  214. await page.click('virtual-list .vl-row:not(.blank)')
  215. try { await page.waitFor(`location.pathname.startsWith('/albums/')`, { timeout: 5000 }) } catch (e) {
  216. console.log('DIAG after the tap on an album row: ' + await ev(`location.pathname + ' | ' + document.querySelector('jb-tabs button.on').textContent + ' | ' + [...document.querySelectorAll('.vl-row:not(.blank)')].slice(0, 2).map((r) => r.outerHTML.slice(0, 200)).join(' || ')`))
  217. throw e
  218. }
  219. await page.waitForSelector('jb-head img#cover, jb-head .jb-nocover')
  220. await sleep(900)
  221. const alb = await ev(`(() => { const c = document.querySelector('jb-head img#cover') || document.querySelector('jb-head .jb-nocover'); const r = c.getBoundingClientRect(); const titles = [...document.querySelectorAll('.vl-row:not(.blank) .vl-title')].map((e) => e.textContent); return { cover: Math.round(r.width), top: Math.round(r.top), titles, vw: innerWidth } })()`)
  222. check('Album: the cover is large on top (≥ 250 px wide at 390)', alb.cover >= 250, JSON.stringify(alb))
  223. const nums = alb.titles.map((t) => parseInt(t, 10))
  224. check('Album: the songs are in track order', nums.length > 3 && nums.every((n, i) => i === 0 || n > nums[i - 1]), JSON.stringify(alb.titles))
  225. await shot('album-390')
  226. await page.click('virtual-list .vl-row:not(.blank)')
  227. await page.waitFor(`document.querySelector('media-player audio').src.includes('/stream/') && document.querySelector('media-player audio').currentTime < 3`, { timeout: 20000 })
  228. await sleep(1500)
  229. check('Album: a tap plays that song', await ev(`!document.querySelector('media-player audio').paused && document.querySelector('media-player audio').currentTime > 0.5`))
  230. check('The page has no script errors', page.problems().filter((m) => m.level === 'error').length === 0, page.dumpConsole())
  231. // ---- desktop ---------------------------------------------------------------------------------------------------------------
  232. await page.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 800, deviceScaleFactor: 1, mobile: false })
  233. await goto('/')
  234. await page.waitForSelector('virtual-list .vl-row:not(.blank)')
  235. await sleep(800)
  236. check('Desktop: the menu stands in the header (Songs, Artists, Albums, Search)', (await ev(`[...document.querySelectorAll('application-header main-menu a')].map((a) => a.textContent).join(',')`)) === 'Songs,Artists,Albums,Search')
  237. check('Desktop: rows are in the page (< 100)', (await rowsInDom()) < 100 && (await rowsInDom()) > 5)
  238. await shot('songs-1280')
  239. await goto('/search'); await page.type('#q', 'zebra'); await page.waitFor(`(() => { const h = [...document.querySelectorAll('jb-hits h2')].find((x) => x.textContent.startsWith('Songs')); return !!h && h.textContent === 'Songs · 1' })()`, { timeout: 15000 })
  240. await shot('search-1280')
  241. await goto('/albums'); await page.waitForSelector('virtual-list .vl-row:not(.blank)'); await sleep(1500); await page.click('virtual-list .vl-row:not(.blank)')
  242. await page.waitFor(`location.pathname.startsWith('/albums/')`); await sleep(1200)
  243. await shot('album-1280')
  244. await page.click('virtual-list .vl-row:not(.blank)')
  245. await page.waitFor(`(() => { const a = document.querySelector('media-player audio'); return a && a.currentTime > 0.6 && !a.paused })()`, { timeout: 20000 })
  246. await sleep(500)
  247. const bar2 = await ev(`(() => { const bar = document.querySelector('.jb-bar').getBoundingClientRect(); const t = document.querySelector('.jb-bar .mp-cover h2').getBoundingClientRect(); return { title: document.querySelector('.jb-bar .mp-cover h2').textContent, inside: t.top >= bar.top && t.bottom <= bar.bottom && t.width > 40, times: document.querySelector('.jb-bar .mp-times').getBoundingClientRect().width > 20 } })()`)
  248. check('Desktop: a song without a cover still shows its title in the bar, and the times', bar2.title.length > 3 && bar2.inside && bar2.times, JSON.stringify(bar2))
  249. await shot('player-1280')
  250. check('Desktop: the player bar plays', true)
  251. await page.close()
  252. } catch (e) {
  253. fail++; console.log('FAIL the gate stopped: ' + (e && e.stack || e)); if (log) console.log(log.slice(-2000))
  254. } finally {
  255. await stop()
  256. }
  257. console.log(`\n${pass} passed, ${fail} failed`)
  258. process.exit(fail ? 1 : 0)

Branches

Latest commits

  • cfe95440|||PR day39 re-vendor: Hybriel 51e921d7 (bin 6b481aa7), ids kebab-case since hybriel#256: quoted state rule and tests use jb-shuffle / jb-repeatmre
  • f3614c9bRe-vendor to Hybriel day39 (51e921d7, bin 6b481aa7)mre
  • 9f5c6532Merge branch 'status-22-pr' into mainJukebox
  • 5838d6c7|||PR STATUS: #22 pending decision, PR-only rulemre
  • 29d2029cRecords: PR-only rule (Kunibert)mre
  • adacb0abRecords: neutral ticket rule, #22 decision recordedmre
  • b2d6f121Records: #308 hold liftedmre
  • 7ab67533Records: day39 on hold (hybriel#308)mre
  • 22f21739Records: note rebase before mergemre
  • f7368ea3Records: mission 011 day39, waits for lisbethmre
  • 9515d2cdRecords: jb20 livemre
  • 019f6601ui gate: comment names the open bug components#27 (workaround, not fixed)mre
  • 277a2722README: provenance linemre
  • 4169ca6aREADME: sync pinmre
  • a01f3aa8ui gate: back to the top before the sort checks (the screen reopens where it was left)mre
  • f7936c20Lists keep their scroll position across a reload (jukebox#20): per-list offsets in storage/ui.json, gate jb20mre
  • d67906devirtual-list and icons from components.hybriel e5b98ec (centerId, scrollTop, onScroll)mre
  • df7920ceRecords: R3 startedmre
  • 0549f038Mission 010: jb20 livemre
  • 273494e2STATUS rewrittenmre