From 845838b67f1e8cc79957cbde3aa86d9cabf5bfed Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Thu, 7 Dec 2023 17:38:36 +0100 Subject: [PATCH] Fix `assertUnreadLessThan` and `assertUnreadGreaterThan` (#12012) --- playwright/e2e/read-receipts/index.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/playwright/e2e/read-receipts/index.ts b/playwright/e2e/read-receipts/index.ts index d49dd188dc..efa93dc9d4 100644 --- a/playwright/e2e/read-receipts/index.ts +++ b/playwright/e2e/read-receipts/index.ts @@ -470,7 +470,13 @@ class Helpers { */ async assertUnreadLessThan(room: string | { name: string }, lessThan: number) { const tile = this.getRoomListTile(room); - expect(parseInt(await tile.locator(".mx_NotificationBadge_count").textContent(), 10)).toBeLessThan(lessThan); + // https://playwright.dev/docs/test-assertions#expectpoll + // .toBeLessThan doesn't have a retry mechanism, so we use .poll + await expect + .poll(async () => { + return parseInt(await tile.locator(".mx_NotificationBadge_count").textContent(), 10); + }) + .toBeLessThan(lessThan); } /** @@ -482,9 +488,13 @@ class Helpers { */ async assertUnreadGreaterThan(room: string | { name: string }, greaterThan: number) { const tile = this.getRoomListTile(room); - expect(parseInt(await tile.locator(".mx_NotificationBadge_count").textContent(), 10)).toBeGreaterThan( - greaterThan, - ); + // https://playwright.dev/docs/test-assertions#expectpoll + // .toBeGreaterThan doesn't have a retry mechanism, so we use .poll + await expect + .poll(async () => { + return parseInt(await tile.locator(".mx_NotificationBadge_count").textContent(), 10); + }) + .toBeGreaterThan(greaterThan); } /**