From 57f12d3d1c5dc6af0815d8a593fa4d4c953d4935 Mon Sep 17 00:00:00 2001 From: Timo K Date: Tue, 14 Apr 2026 16:23:05 +0200 Subject: [PATCH] fix race in playwright sticky test --- playwright/reconnect.spec.ts | 2 +- playwright/spa-call-sticky.spec.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/playwright/reconnect.spec.ts b/playwright/reconnect.spec.ts index 1a8f2c28..e6d5f715 100644 --- a/playwright/reconnect.spec.ts +++ b/playwright/reconnect.spec.ts @@ -13,7 +13,7 @@ test.skip( 'This test is not working on firefox, page.keyboard.press("Tab") not reliable in headless mode', ); -test("can only interact with header and footer while reconnecting", async ({ +test("can not interact with media tiles while reconnecting (only with header and footer)", async ({ page, }) => { await page.goto("/"); diff --git a/playwright/spa-call-sticky.spec.ts b/playwright/spa-call-sticky.spec.ts index 246b4a73..65cf06ed 100644 --- a/playwright/spa-call-sticky.spec.ts +++ b/playwright/spa-call-sticky.spec.ts @@ -29,6 +29,9 @@ async function setupTwoUserSpaCall( let androlHasSentStickyEvent = false; + const { promise: stickyAndrolPromise, resolve: stickyAndrolResolve } = + Promise.withResolvers(); + await interceptEventSend( page, // This room is not encrypted, so the event is sent in clear @@ -36,6 +39,9 @@ async function setupTwoUserSpaCall( (req) => { androlHasSentStickyEvent = androlHasSentStickyEvent || isStickySend(req.url()); + if (androlHasSentStickyEvent) { + stickyAndrolResolve(); + } }, ); @@ -53,6 +59,8 @@ async function setupTwoUserSpaCall( let pevaraHasSentStickyEvent = false; + const { promise: stickyPevaraPromise, resolve: stickyPevaraResolve } = + Promise.withResolvers(); await interceptEventSend( guestPage, // This room is not encrypted, so the event is sent in clear @@ -60,6 +68,9 @@ async function setupTwoUserSpaCall( (req) => { pevaraHasSentStickyEvent = pevaraHasSentStickyEvent || isStickySend(req.url()); + if (pevaraHasSentStickyEvent) { + stickyPevaraResolve(); + } }, ); @@ -70,7 +81,9 @@ async function setupTwoUserSpaCall( "2_0", ); // Assert both sides have sent sticky membership events + await stickyAndrolPromise; expect(androlHasSentStickyEvent).toEqual(true); + await stickyPevaraPromise; expect(pevaraHasSentStickyEvent).toEqual(true); return { guestPage };