From a385c6e410079595c2abd073f807429d4e336fc5 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sun, 11 Oct 2026 18:52:23 +0200 Subject: [PATCH] test: read folder counts in one snapshot so a draining badge cannot hang the poll #1194 --- integration/tests/helpers/app.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/integration/tests/helpers/app.ts b/integration/tests/helpers/app.ts index 459a33261..fcb466a96 100644 --- a/integration/tests/helpers/app.ts +++ b/integration/tests/helpers/app.ts @@ -279,11 +279,17 @@ export interface FolderCounts { */ export async function folderCounts(page: Page, sel: FolderSelector): Promise { const row = folderRow(page, sel).first(); - const counts = row.locator('[data-testid="folder-counts"]'); - if ((await counts.count()) === 0) return { unread: 0, total: 0 }; - const unread = await counts.getAttribute('data-unread'); - const total = await counts.getAttribute('data-total'); - return { unread: Number(unread ?? 0), total: Number(total ?? 0) }; + // Read both attributes in one snapshot. The badge unmounts when a folder + // drains to zero, and a separate count() + getAttribute() can straddle that: + // getAttribute then waits for an element that never comes back and hangs the + // poll until its timeout (#1194). evaluateAll does not wait. + return row.locator('[data-testid="folder-counts"]').evaluateAll((els) => { + const el = els[0]; + return { + unread: Number(el?.getAttribute('data-unread') ?? 0), + total: Number(el?.getAttribute('data-total') ?? 0), + }; + }); } /** Poll until a folder's unread count reaches `expected`. */