Files
site-portfolio/shver.mjs
T

33 lines
1.6 KiB
JavaScript

import puppeteer from 'puppeteer';
const b = await puppeteer.launch({ args:['--no-sandbox','--disable-setuid-sandbox','--use-gl=angle','--enable-unsafe-swiftshader'] });
const p = await b.newPage();
await p.setViewport({width:1280,height:1000});
const errs=[]; p.on('console',m=>{if(m.type()==='error')errs.push(m.text())}); p.on('pageerror',e=>errs.push('PE '+e.message));
await p.goto('http://10.200.201.3:4175/_lab/neu-card.html',{waitUntil:'load',timeout:60000});
await new Promise(r=>setTimeout(r,1500));
const geo = await p.evaluate(()=>{
const li=document.querySelector('#sec-shader li');
const card=li.querySelector('.contact-card');
const canvas=li.querySelector('canvas');
return {
liH: Math.round(li.getBoundingClientRect().height),
cardH: Math.round(card.getBoundingClientRect().height),
canvasInCard: canvas ? card.contains(canvas) : false,
canvasPE: canvas ? getComputedStyle(canvas).pointerEvents : 'no-canvas',
cardPE: getComputedStyle(card).pointerEvents,
};
});
// hover + click test
const link = await p.$('#sec-shader a.contact-card');
const box = await link.boundingBox();
await p.mouse.move(box.x+box.width/2, box.y+box.height/2);
await new Promise(r=>setTimeout(r,200));
const hoverTransform = await p.evaluate(()=>getComputedStyle(document.querySelector('#sec-shader a.contact-card')).transform);
// click -> should open new tab (we block navigation, just check no error)
const newTarget = await Promise.race([
new Promise(res=>p.once('popup', t=>res('popup'))),
new Promise(res=>setTimeout(()=>res('none'), 800))
]);
console.log(JSON.stringify({geo, hoverTransform, newTarget, errs}, null, 1));
await b.close();