gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchplaying-row05c3578c|||PR Keep each playing row bound to the shell song on day76mreplaying-row/tests/jb16.mjs

4.9 KB

  1. // JB16: playing identity follows the shell across transport controls and page returns.
  2. import { spawn, execFileSync } from 'node:child_process'
  3. import { mkdirSync } from 'node:fs'
  4. import { join, resolve } from 'node:path'
  5. process.env.HL_PORT_BASE ||= '8625'
  6. process.env.HL_CHROME ||= '/opt/google/chrome/chrome'
  7. const root = resolve(process.env.JB16_ROOT || '.')
  8. const dir = resolve(process.env.JB16_DIR || '../jb16')
  9. mkdirSync(dir, {recursive:true}); process.env.TMPDIR=dir
  10. const {launchBrowser,sleep} = await import(root+'/tests/cdp.mjs')
  11. const port = process.env.JB16_PORT || '8820', base='http://127.0.0.1:'+port
  12. const tone=join(dir,'tone.mp3'), storage=join(dir,'storage')
  13. execFileSync('ffmpeg',['-v','error','-y','-f','lavfi','-i','sine=frequency=440:duration=60','-q:a','9',tone])
  14. execFileSync(root+'/bin/hybriel',[root+'/tools/make-test-db.hl',tone,root+'/tests/fixtures/withcover/folder.jpg','12'],{env:{...process.env,JUKEBOX_STORAGE:storage},timeout:600000})
  15. let browser,log='',pass=0,fail=0
  16. const server=spawn(root+'/bin/hybriel',['project.hl'],{cwd:root,env:{...process.env,JUKEBOX_PORT:port,JUKEBOX_STORAGE:storage,JUKEBOX_AUTOSCAN:'0',JUKEBOX_WATCH:'0'},stdio:['ignore','pipe','pipe']})
  17. console.log('server PID',server.pid);server.stdout.on('data',d=>log+=d);server.stderr.on('data',d=>log+=d)
  18. try {
  19. for(let t=Date.now();;){try{if((await fetch(base)).ok)break}catch{}if(Date.now()-t>180000)throw Error(log);await sleep(500)}
  20. browser=await launchBrowser();console.log('Chrome PID',browser.proc?.pid)
  21. const p=await browser.newPage(),ev=s=>p.evaluate(s)
  22. await p.goto(base);await p.waitForSelector('virtual-list .vl-row:not(.blank)');await sleep(800)
  23. const same=`(()=>{const a=document.querySelector('audio'),s=document.querySelector('virtual-list .vl-row.current');return !!a?.currentSrc && s?.dataset.id===a.currentSrc.split('/').pop()})()`
  24. const check=async name=>{let ok=true;try{await p.waitFor(same,{timeout:4000})}catch{ok=false}console.log(ok?'ok':'FAIL',name,await ev(`({src:document.querySelector('audio')?.currentSrc,selected:[...document.querySelectorAll('virtual-list .vl-row.current')].map(x=>x.dataset.id)})`));ok?pass++:fail++}
  25. const step=async(name,sel)=>{await ev(`document.querySelector('audio').currentTime=0`);await p.click(sel);await sleep(300);await check(name)}
  26. await p.click('virtual-list .vl-row:not(.blank)');await check('Songs tap')
  27. await step('Songs Next','.jb-next');await step('Songs second Next','.jb-next');await step('Songs Previous','.jb-prev')
  28. await ev(`document.querySelector('audio').currentTime=document.querySelector('audio').duration-.3`);await sleep(1100);await check('Songs natural end')
  29. await p.click('.mp-cover');await p.click('.mp-queue li:nth-child(2) button');await p.click('.jb-close');await check('Next up queue tap')
  30. await p.click('#shuffle');await sleep(800);await check('Songs Shuffle');await p.click('#jb-shuffle');await sleep(500)
  31. // Client navigation via real links preserves the shell; browser history returns the kept page.
  32. const nav=async path=>{const parts=path.split('/');const section=parts.length>2?'/'+parts[1]:path;await p.click(`application-header a[href="${section}"]`);await p.waitFor(`location.pathname===${JSON.stringify(section)}`);if(parts.length>2){await p.waitForSelector(`.vl-row[data-id="${parts[2]}"]`);await p.click(`.vl-row[data-id="${parts[2]}"]`);await p.waitFor(`location.pathname===${JSON.stringify(path)}`)}await sleep(600)}
  33. const albums=(await(await fetch(base+'/api/albums?limit=200')).json()).items
  34. await nav('/albums/'+albums.find(x=>x.name==='Twin Album').id);await p.waitForSelector('virtual-list .vl-row:not(.blank)');await p.click('virtual-list .vl-row:not(.blank)');await check('Album tap');await step('Album Next','.jb-next');await step('Album Previous','.jb-prev')
  35. await nav('/');await check('Songs return while playing')
  36. const artists=(await(await fetch(base+'/api/artists?limit=200')).json()).items
  37. await nav('/artists/'+artists.find(x=>x.name==='Dora Disc').id);await p.click('[data-tab="songs"]');await p.waitForSelector('virtual-list .vl-row:not(.blank)');await p.click('virtual-list .vl-row:not(.blank)');await check('Artist tap');await step('Artist Next','.jb-next');await step('Artist Previous','.jb-prev')
  38. await nav('/search');await p.type('#q','Disc');await sleep(1000);await p.waitForSelector('virtual-list .vl-row:not(.blank)');await p.click('virtual-list .vl-row:not(.blank)');await check('Search tap');await step('Search Next','.jb-next');await step('Search Previous','.jb-prev')
  39. await nav('/');await step('Songs after Search Next','.jb-next');await ev('history.back();1');await p.waitFor(`location.pathname==='/search'`);await sleep(600);await check('Back restores Search with current song');await ev('history.forward();1');await p.waitFor(`location.pathname==='/'`);await sleep(600);await check('Forward restores Songs with current song')
  40. }finally{if(browser)await browser.close();server.kill('SIGTERM');await sleep(500);console.log('stopped server',server.pid)}
  41. console.log(`${pass} passed, ${fail} failed`);process.exitCode=fail?1:0

Branches

Latest commits

  • 05c3578c|||PR Keep each playing row bound to the shell song on day76mre
  • eaa7e6d6Vendor Hybriel day76 for live parent member readsmre
  • 0923398bMerge branch 'records-1124d' into mainJukebox
  • 78f0cc86|||PR records 2026-11-24: inbox-thread rule, "Not playing" confirmed and closedmre
  • c1b153c4Merge branch 'records-1124c' into mainJukebox
  • d7b5e780|||PR Records 2026-11-24 (2): live day72, PR #19 merge, #10 newsmre
  • 43b564dbMerge branch 'records-1124b' into mainJukebox
  • fa86b08c|||PR Records 2026-11-24: LOG, STATUS, missions 020-023mre
  • 0a2ae3daMerge remote-tracking branch 'origin/records-1123' into records-1124mre
  • 9a48cfcaMerge branch 'vendor-theme' into mainJukebox
  • 170d3735Merge branch 'code-order-2' into mainJukebox
  • 3f1918a7|||PR Re-sync layouts theme 4099e64 with Segoe UI firstmre
  • 2e7f6a43Vendor virtual-list 489afcf from components.hybrielmre
  • 0ba85799Merge branch 'reset-classes' into mainJukebox
  • 502eeed5jukebox#20: vendor virtual-list initial resetKey baseline fixmre
  • 6d5ce287|||PR jukebox#9 Centralize songs table reads and writes in db.hlmre
  • dcca21abjukebox#8 Move copies and queue logic into their topicsmre
  • 3b76651cjukebox#20: update virtual-list README pin and resetKey optionsmre
  • bc09e1e8|||PR jukebox#20: reset virtual lists through resetKey (partial validation)mre
  • a3796dc5Records: live step waits for idlemre