test: repair native acceptance entry portability T01-T03
This commit is contained in:
1 parent
9724fc70bc
commit
f3be60bf2d
6 files changed
+335
-58
No files matched your search
@@ -199,15 +199,52 @@ createRoot(document.getElementById('root')).render(
|
||||
|
||||
const verifyCurrentActionStyles = async theme => {
|
||||
const selector = '[data-recommendation-id=archify] .sm-use-btn'
|
||||
const inspect = () => read(`(()=>{const b=document.querySelector(${JSON.stringify(selector)});const s=getComputedStyle(b);return{width:s.width,height:s.height,background:s.backgroundColor,color:s.color,outline:s.outline,focused:document.activeElement===b,hover:b.matches(':hover')}})()`)
|
||||
// Selector :hover can be false despite a trusted mouse entry and applied CSS
|
||||
// (B02 Windows evidence). Keep it diagnostic, never as the success predicate.
|
||||
const inspect = (point = null) => read(`(()=>{
|
||||
const b=document.querySelector(${JSON.stringify(selector)}),p=${JSON.stringify(point)};
|
||||
const hit=p?document.elementFromPoint(p.x,p.y):null;
|
||||
const describe=e=>e?{tag:e.tagName,id:e.id,className:e.getAttribute('class')}:null;
|
||||
if(!b)return{missing:true,hitTarget:describe(hit)};
|
||||
const s=getComputedStyle(b),r=b.getBoundingClientRect();
|
||||
return{width:s.width,height:s.height,background:s.backgroundColor,color:s.color,outline:s.outline,
|
||||
focused:document.activeElement===b,hover:b.matches(':hover'),pointerEvents:s.pointerEvents,
|
||||
rect:{x:r.x,y:r.y,width:r.width,height:r.height},hitTarget:describe(hit),
|
||||
hitWithinAction:!!hit&&(hit===b||b.contains(hit)),pointerEntry:window.__qaHoverProbe?.entry??null};
|
||||
})()`)
|
||||
win.webContents.sendInputEvent({type:'mouseMove',x:1,y:1})
|
||||
await read(`document.activeElement?.blur()`); await pause(200)
|
||||
const normal = await inspect()
|
||||
check(theme + ' use action default background is transparent', normal.background, value => value === 'rgba(0, 0, 0, 0)' || value === 'transparent')
|
||||
const point = await read(`(()=>{const r=document.querySelector(${JSON.stringify(selector)}).getBoundingClientRect();return{x:Math.round(r.x+r.width/2),y:Math.round(r.y+r.height/2)}})()`)
|
||||
win.webContents.sendInputEvent({type:'mouseMove',...point});await pause(200)
|
||||
const hover = await inspect()
|
||||
check(theme + ' pointer enters use action', hover.hover, true)
|
||||
// Arm only after moving off the action, so prior themes/entries cannot pass.
|
||||
await read(`(()=>{
|
||||
const b=document.querySelector(${JSON.stringify(selector)});
|
||||
const probe=window.__qaHoverProbe={entry:null};
|
||||
const listener=event=>{probe.entry={isTrusted:event.isTrusted,pointerType:event.pointerType,
|
||||
targetIsAction:event.target===b,x:event.clientX,y:event.clientY}};
|
||||
b.addEventListener('pointerenter',listener);
|
||||
probe.cleanup=()=>b.removeEventListener('pointerenter',listener);
|
||||
})()`)
|
||||
let hover
|
||||
try {
|
||||
win.webContents.sendInputEvent({type:'mouseMove',...point})
|
||||
const deadline = Date.now() + 10000
|
||||
while (true) {
|
||||
hover = await inspect(point)
|
||||
if (hover.pointerEntry?.isTrusted === true && hover.pointerEntry.pointerType === 'mouse'
|
||||
&& hover.pointerEntry.targetIsAction && hover.hitWithinAction
|
||||
&& hover.background !== normal.background) break
|
||||
if (Date.now() >= deadline) {
|
||||
throw Error(theme + ' native hover timeout: ' + JSON.stringify({selector,point,normal,last: hover}))
|
||||
}
|
||||
await pause(50)
|
||||
}
|
||||
} finally {
|
||||
await read('window.__qaHoverProbe?.cleanup(); delete window.__qaHoverProbe')
|
||||
}
|
||||
check(theme + ' trusted mouse pointer enters use action', hover.pointerEntry.isTrusted && hover.pointerEntry.pointerType === 'mouse' && hover.pointerEntry.targetIsAction, true)
|
||||
check(theme + ' pointer hit target is the action or its descendant', hover.hitWithinAction, true)
|
||||
check(theme + ' hover has a distinct background', hover.background !== normal.background, true)
|
||||
await capture('installed-use-' + theme + '-hover')
|
||||
win.webContents.sendInputEvent({type:'mouseMove',x:1,y:1})
|
||||
|
||||
Reference in new issue
Block a user