mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-30 16:16:19 +00:00
test: read folder counts in one snapshot so a draining badge cannot hang the poll #1194
This commit is contained in:
@@ -279,11 +279,17 @@ export interface FolderCounts {
|
||||
*/
|
||||
export async function folderCounts(page: Page, sel: FolderSelector): Promise<FolderCounts> {
|
||||
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`. */
|
||||
|
||||
Reference in New Issue
Block a user