24 lines
935 B
JavaScript
24 lines
935 B
JavaScript
// Rôle : stabilise les gestes pointeur Playwright face aux chargements différés et aux déplacements de mise en page.
|
|
import { expect } from "@playwright/test";
|
|
|
|
export async function waitForLazyModules(page) {
|
|
await expect(page.locator(".module-loading-fallback")).toHaveCount(0);
|
|
}
|
|
|
|
export async function startPointerDrag(page, source) {
|
|
await expect(source).toBeVisible();
|
|
await waitForLazyModules(page);
|
|
await source.scrollIntoViewIfNeeded();
|
|
const box = await source.boundingBox();
|
|
expect(box).not.toBeNull();
|
|
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
|
await page.mouse.down();
|
|
return box;
|
|
}
|
|
|
|
export async function movePointerTo(page, target, { x = 0.5, y = 0.5, steps = 5 } = {}) {
|
|
await target.scrollIntoViewIfNeeded();
|
|
const box = await target.boundingBox();
|
|
expect(box).not.toBeNull();
|
|
await page.mouse.move(box.x + box.width * x, box.y + box.height * y, { steps });
|
|
}
|