/** 诊断 3:用 CDP 真鼠标事件点地图覆盖层标记(票 46 走查的进入路径)。 */ import { cdpLaunch } from '../../../../cockpit-shell-panel-layout/verify/cdp-driver.mjs' const CHROME = process.env.CHROME_PATH || 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' const sleep = (ms) => new Promise((r) => setTimeout(r, ms)) const browser = await cdpLaunch({ executablePath: CHROME, headless: true, width: 1680, height: 950 }) const page = await browser.newPage() await page.goto('http://127.0.0.1:8000/#/cockpit', { timeout: 60000 }) await sleep(2000) await page.click('[data-cockpit-intro]').catch(() => {}) await page.waitForFunction(() => ['ready', 'failed', 'disabled'].includes(document.querySelector('.cockpit-shell__map .map-canvas')?.dataset.mapEngine || ''), { timeout: 60000 }) await sleep(5000) const box = await page.evaluate(() => { const node = document.querySelector('[data-marker-overlay-code="CBWS202610150001"]') if (!node) return null const inner = node.querySelector('svg') || node.firstElementChild || node const r = inner.getBoundingClientRect() const nr = node.getBoundingClientRect() return { nodeRect: { x: nr.x, y: nr.y, w: nr.width, h: nr.height }, innerTag: inner.tagName, rect: { x: r.x, y: r.y, w: r.width, h: r.height }, cx: r.x + r.width / 2, cy: r.y + r.height / 2, pe: getComputedStyle(node).pointerEvents } }) console.log('box:', JSON.stringify(box)) if (box && Number.isFinite(box.cx)) { const x = box.cx const y = box.cy await page._dispatchMouse('mouseMoved', x, y) await sleep(120) await page._dispatchMouse('mousePressed', x, y, { button: 'left', buttons: 1, clickCount: 1 }) await sleep(60) await page._dispatchMouse('mouseReleased', x, y, { button: 'left', buttons: 0, clickCount: 1 }) await sleep(3500) const card = await page.evaluate(() => { const c = document.querySelector('[data-point-detail]') return c ? { level: c.dataset.detailLevel, point: c.dataset.pointCode, kpis: [...c.querySelectorAll('[data-point-kpi]')].map((n) => `${n.dataset.pointKpi}=${n.querySelector('b')?.textContent?.trim()}`) } : null }) console.log('after real-mouse click:', JSON.stringify(card)) } await browser.close()