test(e2e): deselect by clicking a corner away from the shape (#975)

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.
This commit is contained in:
Dayuan Jiang
2026-10-10 23:53:30 +09:00
committed by GitHub
parent d1ee1594f1
commit 213b672e92
+20 -3
View File
@@ -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)