Merge pull request #1275 from omdsh-dev/test/settle-selection-popup-resize

test(e2e): 等划选浮层在窗口缩放后重排再量几何(修 mount lane 间歇失败)
This commit is contained in:
Atlas Zeng authored and GitHub committed 2026-11-26 14:16:29 +08:00
commit d00f0211dd
1 file changed
+8 -1
+8 -1
View File
@@ -288,9 +288,16 @@ test('UI19 translates read-only body and comments inline and inserts without sen
await menu.screenshot({ path: info.outputPath('selection-translation-' + theme + '.png') })
}
await page.setViewportSize({ width: 390, height: 844 })
// The menu re-clamps from `useViewportSize`, which measures on the next
// animation frame after a resize; reading the box straight after
// setViewportSize() races that frame. Poll for the settled geometry so the
// assertion covers the re-clamp instead of the resize timing.
await expect.poll(async () => {
const box = await menu.boundingBox()
return box === null ? Number.POSITIVE_INFINITY : Math.round(box.x + box.width)
}, { message: 'the menu re-clamps inside the 390px viewport' }).toBeLessThanOrEqual(390)
const bounds = (await menu.boundingBox())!
expect(bounds.x).toBeGreaterThanOrEqual(0)
expect(bounds.x + bounds.width).toBeLessThanOrEqual(390)
await expect(footer.getByRole('menuitem', { name: 'Back', exact: true })).toBeVisible()
await expect(footer.getByRole('menuitem', { name: 'Copy', exact: true })).toBeVisible()
expect(await menu.evaluate(node => node.scrollWidth <= node.clientWidth)).toBe(true)