From 81516f3984d604f51eaa02b386ccbf7c06c16e0d Mon Sep 17 00:00:00 2001 From: "dayuan.jiang" Date: Sat, 10 Oct 2026 23:43:54 +0900 Subject: [PATCH] test(e2e): deselect by clicking a corner away from the shape The test clicked the canvas at (10, 10) to deselect. When the click on the shape before it needed retries, Playwright scrolled the shape into the container's top-left corner, so the next click landed on the shape and the selection stayed (seen on the main run of cd5352c and on #973). The new clickEmptyCanvas helper clicks the corner farthest from the shape. Reproduced locally by scrolling the shape into the corner: the old click keeps the selection, the helper clears it. --- tests/e2e/workspace.spec.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/e2e/workspace.spec.ts b/tests/e2e/workspace.spec.ts index 27712be5..73a88ed5 100644 --- a/tests/e2e/workspace.spec.ts +++ b/tests/e2e/workspace.spec.ts @@ -108,6 +108,25 @@ async function boxOf(locator: Locator) { return box } +/** + * Click the canvas where no shape is, to deselect: the corner of the + * container farthest from the shape. A fixed spot near the top-left corner + * is not safe, as a click on a shape may scroll it into that corner. + */ +async function clickEmptyCanvas(page: Page, shape: Locator) { + const container = getIframeContent(page).locator(".geDiagramContainer") + const box = await boxOf(container) + const shapeBox = await boxOf(shape) + const shapeX = shapeBox.x + shapeBox.width / 2 + const shapeY = shapeBox.y + shapeBox.height / 2 + await container.click({ + position: { + x: shapeX < box.x + box.width / 2 ? box.width - 20 : 20, + y: shapeY < box.y + box.height / 2 ? box.height - 20 : 20, + }, + }) +} + /** draw.io's own Undo button: draw.io sets "disabled" with nothing to undo */ function drawioUndo(page: Page) { return getIframeContent(page).locator('.geSimpleMainMenu a[title="Undo"]') @@ -4512,9 +4531,7 @@ test.describe("Edge cases", () => { }) await sendMessage(page, "Make this red") // Deselected while the diagram exports - await canvas - .locator(".geDiagramContainer") - .click({ position: { x: 10, y: 10 } }) + await clickEmptyCanvas(page, shape) await expect(chip).toHaveCount(0) await page.evaluate(() => (window as any).__releaseExports()) await waitForCompleteCount(page, 2)