components
All repositories: gitoria
4.7 KB
// node tests/virtual-list-reset.mjs — real wheel/click regression at 390 and 1280.// VL_BASELINE=1 adds only an inert resetKey declaration to the old component.// VL_PROOF=1 HL_CDP_URL=... VL_EXTERNAL=1 uses an already-started server and four sizes.import { spawn } from 'node:child_process';import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';import { resolve } from 'node:path';import { launchBrowser, sleep } from './cdp.mjs';const app = resolve(import.meta.dirname, '..');const shots = process.env.COMPONENTS_SHOTS || app + '/.scratch/reset-shots';mkdirSync(shots, {recursive:true});let server, browser, beforePages, log='', passed=0, failed=0;const pageList = async () => (await (await fetch(process.env.HL_CDP_URL + '/json/list')).json()).filter(p => p.type === 'page');const check=(name,ok,detail)=>{ console.log((ok?'ok ':'FAIL ')+name+' '+JSON.stringify(detail)); ok?passed++:failed++; };// The old component has no resetKey input. For the red proof only, add an inert// declaration so the same demo compiles; no reset behaviour is supplied.const component = app + '/components/virtual-list/virtual-list.hl';const oldComponent = readFileSync(component, 'utf8');if (process.env.VL_BASELINE === '1') writeFileSync(component, oldComponent.replace('Number scrollTop = null', "Number scrollTop = null\nString resetKey = ''"));try {const port=process.env.COMPONENTS_GATE_PORT || '8812';if (!process.env.VL_EXTERNAL) {server=spawn(app+'/bin/hybriel',['project.hl'],{cwd:app,env:{...process.env,COMPONENTS_PORT:port,COMPONENTS_WATCH:'0',COMPONENTS_SESSIONS:app+'/.scratch/reset-sessions/'},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 base='http://127.0.0.1:'+port;for(const start=Date.now();;){try{if((await fetch(base+'/')).ok)break;}catch{} if(server?.exitCode != null || Date.now()-start>150000)throw Error(log);await sleep(300);}if (process.env.HL_CDP_URL) { beforePages = await pageList(); writeFileSync(shots+'/pages-before.json',JSON.stringify(beforePages,null,2)); }writeFileSync(shots+'/served.html',await (await fetch(base+'/virtual-list')).text());browser=await launchBrowser({debugPortRange: (process.env.COMPONENTS_GATE_CHROME || '8813-8819').split('-').map(Number)});console.log('Chrome PID '+(browser.proc?.pid || 'attached'));const page=await browser.newPage();for(const [width,height] of (process.env.VL_PROOF ? [[390,844],[800,1280],[1280,800],[1280,900]] : [[390,844],[1280,900]])){await page.send('Emulation.setDeviceMetricsOverride',{width,height,deviceScaleFactor:1,mobile:width===390});await page.goto(base+'/virtual-list');await page.waitForSelector('.vl-row');await sleep(1000);const ev=s=>page.evaluate(s);const state=()=>ev(`({top:document.querySelector('.vl-scroller').scrollTop,blank:document.querySelectorAll('.vl-row.blank').length,first:document.querySelector('.vl-row')?.dataset.index,title:document.querySelector('.vl-title')?.textContent})`);const down=async()=>{const b=await page.box('.vl-scroller');await page.send('Input.dispatchMouseEvent',{type:'mouseWheel',x:b.x,y:b.y,deltaX:0,deltaY:336000});await sleep(700);check(width+' far down', (await state()).top>300000,await state());};await down();await page.click('#sort-reset');await sleep(1000);let s=await state();check(width+' sort resets to top with descending rows',s.top===0 && s.blank===0 && s.first==='0' && s.title==='Song number 13448',s);writeFileSync(shots+'/sort-'+width+'-'+height+'.png',Buffer.from((await page.send('Page.captureScreenshot',{format:'png'})).data,'base64'));await down();await page.click('#offset-reset');await sleep(1000);s=await state();check(width+' reset applies supplied offset and loads window',s.top===11200 && s.blank===0 && Number(s.first)>=180,s);writeFileSync(shots+'/offset-'+width+'-'+height+'.png',Buffer.from((await page.send('Page.captureScreenshot',{format:'png'})).data,'base64'));await down();const before=(await state()).top;await page.click('#same-reset');await sleep(300);check(width+' same key preserves position',(await state()).top===before,await state());check(width+' console clean',page.problems().length===0,page.dumpConsole());}}catch(e){failed++;console.log('FAIL '+e.stack+' '+log.slice(-2000));}finally{if (process.env.VL_BASELINE === '1') writeFileSync(component,oldComponent);if(browser)await browser.close();if(beforePages){const after = await pageList();writeFileSync(shots+'/pages-after.json',JSON.stringify(after,null,2));check('own tab closed and original page list preserved',JSON.stringify(after.map(p=>p.id).sort())===JSON.stringify(beforePages.map(p=>p.id).sort()),after.map(p=>({id:p.id,url:p.url})));}if(server){server.kill('SIGTERM');await sleep(500);}}console.log(passed+' passed, '+failed+' failed');process.exitCode=failed?1:0;
Branches
- b27b
- mainmain branch
- vl27-resetkey
Latest commits
- a06fc778Reset virtual-list window when the host changes resetKeyAtlas
- 3aab598cRe-vendor complete Hybriel day73 set for virtual-list resetAtlas
- 337ca075MD1 gate check measures frames in the page, not milliseconds from outside, and takes the middle load (components#30)mre
- f5f131c5Record AP29 autoplay comparisons and passing gatesmre
- 51c38187Gate media autoplay on first load and after client mountmre
- a3f2223dRecord successful B44 deployment and live proofmre
- 06c1e021Record passing B44 browser rerunmre
- c9861533Record B44 component proof and browser gate blockermre
- 1b7413beIgnore detached media events and space demo option outputsmre
- ca3b4959Re-vendor complete Hybriel plugins and runtime to day44mre
- df9e7df9Last-item checks run in the browser gate (components#26 fixed on day41); media-player loop is a plain Booleanmre
- 895a5afcRe-vendor complete Hybriel plugins and runtime to day41mre
- 16006bb3Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 88397fc3Re-vendor complete Hybriel plugins and runtime to day39mre
- 9b872cedRecord IC28 deployment and live icon verificationmre
- 46fefaa7Count the icons entry in the offline home-page checkmre
- c7e14cabRecord IC28 rerun and unchanged-main baseline comparisonmre
- 5e090ffdRecord IC28 review evidence and gate resultsmre
- adfe2c4dAdd shuffle, repeat and repeatOne shared iconsmre
- c96709c8media-player: skip = false and repeat = 'one' options (jukebox#19)mre