turn an assertion as retryable with expect.poll

This commit is contained in:
Valere
2026-04-22 18:06:12 +02:00
parent 1b9682869a
commit 5c4d6d0317
6 changed files with 62 additions and 71 deletions

View File

@@ -127,15 +127,23 @@ async function expectVideoTilesCount(page: Page, count: number): Promise<void> {
// There should be 5 video elements, visible and autoplaying
await expect(page.locator("video")).toHaveCount(count);
const blockDisplayCount = await page
.locator("video")
.evaluateAll(
(videos: Element[]) =>
videos.filter(
(v: Element) => window.getComputedStyle(v).display === "block",
).length,
);
expect(blockDisplayCount).toBe(count);
await expect
.poll(
async () => {
return await page
.locator("video")
.evaluateAll(
(videos: Element[]) =>
videos.filter(
(v: Element) => window.getComputedStyle(v).display === "block",
).length,
);
},
{
timeout: 10000,
},
)
.toBe(count);
}
export const SpaHelpers = {