From 126b216d449031f3445fcbf5c5a772f9ec0ed090 Mon Sep 17 00:00:00 2001 From: Valere Fedronic Date: Tue, 6 Jan 2026 16:49:48 +0100 Subject: [PATCH] fix flaky test by waiting for chat panel before counting messages (#31633) * fix flaky test by waiting for chat panel before counting messages * improve test stability by waiting for visibility before elements count() --- playwright/e2e/voip/element-call.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/playwright/e2e/voip/element-call.spec.ts b/playwright/e2e/voip/element-call.spec.ts index 7c2494d2ae..18bf0c33c0 100644 --- a/playwright/e2e/voip/element-call.spec.ts +++ b/playwright/e2e/voip/element-call.spec.ts @@ -647,6 +647,10 @@ test.describe("Element Call", () => { // For this test we want to display the chat area alongside the widget await page.getByRole("button", { name: "Chat" }).click(); + // Wait for the right panel to show the timeline. + await expect( + page.locator(".mx_RightPanel .mx_TimelineCard").getByText("Alice created and configured the room."), + ).toBeVisible(); await page .locator('iframe[title="Element Call"]') @@ -654,7 +658,12 @@ test.describe("Element Call", () => { .getByRole("button", { name: "Send Room Message" }) .click(); - const messageSent = await page.getByText("I sent this once!!").count(); + const timelineLocator = page.locator(".mx_RightPanel .mx_TimelineCard"); + // First wait for the message to appear in the timeline then + // check the count. This improves test stability as we know the message has been sent. + await expect(timelineLocator.getByText("I sent this once!!")).toBeVisible(); + + const messageSent = await timelineLocator.getByText("I sent this once!!").count(); expect(messageSent).toBe(1); });