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`. */