Fence session lifetimes and cancel owned previews on tool changes
This commit is contained in:
@@ -192,6 +192,20 @@ try {
|
||||
await call('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });
|
||||
await call('Input.dispatchMouseEvent', { type: 'mouseReleased', x: moved.x + 35, y: moved.y + 25, button: 'left', buttons: 0 });
|
||||
await pause(100); assert.equal(documents.get(root).elements.get('b').geometry.x, 500); assert.equal(calls.filter(call => call.method === 'POST' && call.path.endsWith('/model/operations')).length, beforeCancel);
|
||||
const toolPoint=await evaluate(`(()=>{const r=document.querySelector('.react-flow__node[data-id=b]').getBoundingClientRect();return {x:r.x+80,y:r.y+30}})()`);
|
||||
await call('Input.dispatchMouseEvent',{type:'mousePressed',...toolPoint,button:'left',buttons:1,clickCount:1});
|
||||
await call('Input.dispatchMouseEvent',{type:'mouseMoved',x:toolPoint.x+35,y:toolPoint.y+25,button:'left',buttons:1});
|
||||
await until(`!!window.__fixtureActualEngine.sessions.getSnapshot().gesture`,'tool-switch drag did not acquire preview');
|
||||
await evaluate(`document.querySelector('[data-headless-canvas]').focus()`);
|
||||
await call('Input.dispatchKeyEvent',{type:'keyDown',key:'h',code:'KeyH',windowsVirtualKeyCode:72});await call('Input.dispatchKeyEvent',{type:'keyUp',key:'h',code:'KeyH',windowsVirtualKeyCode:72});
|
||||
await until(`[...window.__fixtureActualEngine.sessions.getSnapshot().views.values()][0]?.tool==='pan'&&!window.__fixtureActualEngine.sessions.getSnapshot().gesture`,'H did not cancel the owned drag when switching tools');
|
||||
await call('Input.dispatchMouseEvent',{type:'mouseReleased',x:toolPoint.x+35,y:toolPoint.y+25,button:'left',buttons:0});await pause(100);
|
||||
assert.equal(documents.get(root).elements.get('b').geometry.x,500);assert.equal(calls.filter(call=>call.method==='POST'&&call.path.endsWith('/model/operations')).length,beforeCancel,'late pointerup committed a drag canceled by switching tools');
|
||||
await call('Input.dispatchKeyEvent',{type:'keyDown',key:'v',code:'KeyV',windowsVirtualKeyCode:86});await call('Input.dispatchKeyEvent',{type:'keyUp',key:'v',code:'KeyV',windowsVirtualKeyCode:86});
|
||||
await until(`[...window.__fixtureActualEngine.sessions.getSnapshot().views.values()][0]?.tool==='select'`,'V did not restore the selection tool');
|
||||
await until(`document.querySelector('[aria-label="选择工具(V)"]')?.getAttribute('aria-pressed')==='true'`,'selection tool did not render');
|
||||
await until(`(()=>{const n=document.querySelector('.react-flow__node[data-id=b]'),m=new DOMMatrix(n.style.transform);return Math.abs(m.m41-500)<.01&&!n.classList.contains('dragging');})()`,'canceled native node did not return to its committed position');
|
||||
console.log('PASS actual drag-to-pan tool switch cancels preview and late pointerup produces no document request');
|
||||
const corner = await evaluate(`(()=>{const r=document.querySelector('.react-flow__node[data-id=b] [aria-label="拖动右下角调整大小"]').getBoundingClientRect();return {x:r.x+r.width/2,y:r.y+r.height/2}})()`);
|
||||
await call('Input.dispatchMouseEvent', { type: 'mousePressed', x: corner.x, y: corner.y, button: 'left', buttons: 1, clickCount: 1 });
|
||||
await call('Input.dispatchMouseEvent', { type: 'mouseMoved', x: corner.x + 20, y: corner.y + 10, button: 'left', buttons: 1 });
|
||||
|
||||
Reference in New Issue
Block a user