// 菜单动作行为级验证: node scripts/verify-menu.mjs import puppeteer from 'puppeteer-core' const EDGE = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe' const token = process.argv[2] const browser = await puppeteer.launch({ executablePath: EDGE, headless: 'new', args: ['--window-size=1440,900', '--enable-unsafe-swiftshader', '--use-gl=angle', '--use-angle=swiftshader'], defaultViewport: { width: 1440, height: 900 }, }) const page = await browser.newPage() await page.goto(`http://localhost:8000/combine?token=${encodeURIComponent(token)}`, { waitUntil: 'networkidle2' }) await page.waitForSelector('.lib-item') await page.click('.lib-item') await new Promise(r => setTimeout(r, 600)) const box = await (await page.$('.canvas-box')).boundingBox() const cx = box.x + box.width / 2, cy = box.y + box.height / 2 // ① 右键 → 菜单 → 真实鼠标点击"顺时针旋转90°" await page.mouse.click(cx, cy, { button: 'right' }) await new Promise(r => setTimeout(r, 300)) const item0 = await page.$$('.ctx-item') const r0 = item0.length ? await item0[0].boundingBox() : null if (r0) await page.mouse.click(r0.x + r0.width / 2, r0.y + r0.height / 2) await new Promise(r => setTimeout(r, 400)) const hint1 = await page.$eval('.hud span', el => el.textContent) console.log('① 旋转后 hint:', hint1, '(原始 1800×1600 → 期望 1600×1800)') // ② 右键 → 真实鼠标点击"删除单元" await page.mouse.click(cx, cy, { button: 'right' }) await new Promise(r => setTimeout(r, 300)) const itemN = await page.$$('.ctx-item') const rN = itemN.length ? await itemN[itemN.length - 1].boundingBox() : null if (rN) await page.mouse.click(rN.x + rN.width / 2, rN.y + rN.height / 2) await new Promise(r => setTimeout(r, 400)) const hint2 = await page.$eval('.hud span', el => el.textContent) console.log('② 删除后 hint:', hint2, '(期望"拖入样板开始组合")') await page.screenshot({ path: 'D:/Code/huamenchuang/shots/v4-menu-actions.png' }) await browser.close() console.log('验证完成')