mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-05 08:09:38 +08:00
test: 等待裁剪弹窗打开动画结束再测量并拖动下边手柄
This commit is contained in:
@@ -63,6 +63,8 @@ async function assertBottomCropHandle(page: Page) {
|
||||
const selection = cropper.locator('.ReactCrop__crop-selection');
|
||||
const handle = cropper.locator('.ReactCrop__drag-handle.ord-se');
|
||||
await expect(selection).toBeVisible();
|
||||
// 等进入动画结束再量位置与拖动,避免 zoom-in-95 缩放期间坐标与高度偏移
|
||||
await expect.poll(() => cropper.evaluate((el) => el.getAnimations().length)).toBe(0);
|
||||
const viewportBox = await viewport.boundingBox();
|
||||
const selectionBox = await selection.boundingBox();
|
||||
const handleBox = await handle.boundingBox();
|
||||
@@ -72,7 +74,7 @@ async function assertBottomCropHandle(page: Page) {
|
||||
const before = selectionBox.height;
|
||||
await page.mouse.move(handleBox.x + handleBox.width / 2, handleBox.y + handleBox.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(handleBox.x + handleBox.width / 2, handleBox.y + handleBox.height / 2 - 40);
|
||||
await page.mouse.move(handleBox.x + handleBox.width / 2, handleBox.y + handleBox.height / 2 - 40, { steps: 5 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await selection.boundingBox())?.height ?? 0).toBeLessThan(before - 10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user