"""Native pointer regression: reach and click the floating table copy button.""" import os,sys,time,json,tempfile from pathlib import Path os.environ.pop('QT_QPA_PLATFORM',None) os.environ['QTWEBENGINE_CHROMIUM_FLAGS']='--log-level=3' sys.path.insert(0,str(Path(__file__).resolve().parents[1])) from PySide6.QtWidgets import QApplication from PySide6.QtWebEngineWidgets import QWebEngineView from PySide6.QtCore import QPoint,Qt from PySide6.QtTest import QTest from PySide6.QtGui import QCursor from mdhelper.markdown_renderer import MarkdownRenderer app=QApplication([]) view=QWebEngineView();view.resize(850,450) view.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint,True) loaded=[];view.loadFinished.connect(loaded.append) def wait(condition): end=time.monotonic()+20 while not condition() and time.monotonic(){const t=document.querySelector('table').getBoundingClientRect(),b=document.querySelector('button').getBoundingClientRect();return {top:t.top,bottom:b.bottom,by:(b.top+b.bottom)/2,x:(b.left+b.right)/2}})()") target=view.windowHandle() js("(()=>{window.moves=[];document.addEventListener('mousemove',e=>window.moves.push([e.clientX,e.clientY,e.target.tagName]));return true})()") QCursor.setPos(target.mapToGlobal(QPoint(20,20)));QTest.qWait(150) for y in (bounds['top']+10,bounds['top']+1,(bounds['top']+bounds['bottom'])/2,bounds['by']): point=QPoint(round(bounds['x']),round(y)) QCursor.setPos(target.mapToGlobal(point));QTest.mouseMove(target,point);QTest.qWait(400) assert js("getComputedStyle(document.querySelector('.table-tools')).opacity")=='1', (y, js("({moves:window.moves,hover:[...document.querySelectorAll(':hover')].map(e=>e.className),width:innerWidth,height:innerHeight})"), app.platformName(), target.size(), view.size()) js("(()=>{window.copied=null;Object.defineProperty(navigator,'clipboard',{value:{writeText:async text=>{window.copied=text}}});return true})()") QTest.mouseClick(target,Qt.MouseButton.LeftButton,pos=QPoint(round(bounds['x']),round(bounds['by']))) QTest.qWait(200) assert js('window.copied')=='A\tB\nX\tY' print('Native hover and copy passed: continuous pointer path and expected table text.') finally: view.close()