test: wait for grid reconciliation between drags

This commit is contained in:
ajnart committed 2026-08-14 11:07:06 +02:00
1 parent 36de8131c8
commit 0cb75982fc
1 file changed
+11
+11
View File
@@ -321,6 +321,8 @@ describe("Board grid", () => {
await firstItem.evaluate((element) => element.scrollIntoView({ block: "center", behavior: "instant" }));
await dragLocatorByAsync(page, getEditorEntry(firstItem), 0, logicalCellPitch * canvasScale + 2);
await expect(firstItem).toHaveAttribute("data-grid-y", String(targetRow));
await waitForControlledGridReconciliationAsync(firstItem);
await expect(firstItem).toHaveAttribute("data-grid-y", String(targetRow));
}
await expect(firstItem).toHaveAttribute("data-grid-y", "8");
expect(gridLayoutsOverlap(await readGridLayoutAsync(firstItem), await readGridLayoutAsync(belowItem))).toBe(
@@ -867,6 +869,15 @@ const dragLocatorByAsync = async (page: Page, locator: Locator, deltaX: number,
await dragLocatorToAsync(page, locator, box.x + box.width / 2 + deltaX, box.y + box.height / 2 + deltaY);
};
const waitForControlledGridReconciliationAsync = async (locator: Locator) => {
await locator.evaluate(
() =>
new Promise<void>((resolve) => {
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
}),
);
};
const dragLocatorToAsync = async (page: Page, locator: Locator, targetX: number, targetY: number) => {
const box = await expectBoundingBoxAsync(locator);
const startX = box.x + box.width / 2;