From e33aad6e1abba428a4df9276dd5d5d04cefaa3b7 Mon Sep 17 00:00:00 2001 From: rbondesson Date: Fri, 29 May 2026 10:05:33 +0200 Subject: [PATCH] Stabilise room-list drag helper geometry lookup (#33656) --- .../e2e/left-panel/room-list-panel/utils.ts | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/web/playwright/e2e/left-panel/room-list-panel/utils.ts b/apps/web/playwright/e2e/left-panel/room-list-panel/utils.ts index fbf2643ebf..57bdbec794 100644 --- a/apps/web/playwright/e2e/left-panel/room-list-panel/utils.ts +++ b/apps/web/playwright/e2e/left-panel/room-list-panel/utils.ts @@ -62,8 +62,12 @@ export async function dragRoomToSection(page: Page, roomName: string, sectionNam const source = sourceRow.locator("button").first(); const target = getSectionHeader(page, sectionName); - const sourceBox = await source.boundingBox(); - const targetBox = await target.boundingBox(); + await expect(sourceRow).toBeVisible(); + await expect(source).toBeVisible(); + await expect(target).toBeVisible(); + + const sourceBox = await getBoundingBox(source, `room ${roomName}`); + const targetBox = await getBoundingBox(target, `section ${sectionName}`); const sourceX = sourceBox.x + sourceBox.width / 2; const sourceY = sourceBox.y + sourceBox.height / 2; @@ -78,6 +82,30 @@ export async function dragRoomToSection(page: Page, roomName: string, sectionNam await page.mouse.up(); } +/** + * Wait for a locator to have stable viewport geometry and return its bounding box. + * + * Playwright's boundingBox() returns null when the element is not visible or is detached. + * Room list updates are driven by sync and virtualization, so a newly-created room or + * section can match the locator before it is ready for mouse coordinates. + */ +async function getBoundingBox( + locator: Locator, + description: string, +): Promise>>> { + await locator.scrollIntoViewIfNeeded(); + await expect + .poll(() => locator.boundingBox(), { message: `Expected ${description} to have a bounding box` }) + .not.toBeNull(); + + const box = await locator.boundingBox(); + if (!box) { + throw new Error(`Expected ${description} to have a bounding box`); + } + + return box; +} + /** * Get the primary filters container * @param page