fix(timeline): cancel stranded drag interactions
This commit is contained in:
@@ -1303,6 +1303,61 @@ test.describe("Timeline", () => {
|
||||
expect(result.rightEdgeGain).toBeGreaterThan(48);
|
||||
});
|
||||
|
||||
test("allocation resize cancels cleanly when the window loses focus mid-drag", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/timeline?startDate=2026-04-01&days=31", {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await expect(
|
||||
page.locator("[data-timeline-entry-type='allocation'][data-allocation-id]").first(),
|
||||
).toBeVisible();
|
||||
|
||||
const allocationSegment = await findVisibleAllocationSegmentForResize(
|
||||
page,
|
||||
"[data-timeline-entry-type='allocation'][data-allocation-id]",
|
||||
);
|
||||
expect(allocationSegment).toBeTruthy();
|
||||
|
||||
const allocation = page.locator(allocationSegmentSelector(allocationSegment!));
|
||||
await allocation.scrollIntoViewIfNeeded();
|
||||
|
||||
const initialBox = await readBoundingBox(allocation);
|
||||
const pointerY = initialBox.y + initialBox.height / 2;
|
||||
const startX = initialBox.x + initialBox.width - 3;
|
||||
|
||||
await page.mouse.move(startX, pointerY);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(startX + 72, pointerY, { steps: 6 });
|
||||
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = await allocation.boundingBox();
|
||||
return box ? Math.round(box.width) : null;
|
||||
})
|
||||
.toBeGreaterThan(Math.round(initialBox.width + 36));
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.dispatchEvent(new Event("blur"));
|
||||
});
|
||||
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = await allocation.boundingBox();
|
||||
return box ? Math.round(box.width) : null;
|
||||
})
|
||||
.toBe(Math.round(initialBox.width));
|
||||
|
||||
await page.mouse.up();
|
||||
|
||||
const secondResize = await measureAllocationResizeGap(
|
||||
page,
|
||||
allocationSegmentSelector(allocationSegment!),
|
||||
);
|
||||
expect(secondResize.widthGain).toBeGreaterThan(64);
|
||||
expect(secondResize.rightEdgeGain).toBeGreaterThan(48);
|
||||
});
|
||||
|
||||
test("allocation start resize shows a live preview before mouseup", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user