️(app-desk) add infinite scrool to teams list

If we have a big list of teams, we need to add infinite
scroll to avoid loading all the teams at once.
This commit is contained in:
Anthony LC
2024-02-02 13:12:03 +01:00
committed by Anthony LC
parent fafffd2391
commit 47ffa60a94
9 changed files with 280 additions and 85 deletions

View File

@@ -0,0 +1,21 @@
import { Locator } from '@playwright/test';
export async function waitForElementCount(
locator: Locator,
count: number,
timeout: number,
) {
let elapsedTime = 0;
const interval = 200; // Check every 200 ms
while (elapsedTime < timeout) {
const currentCount = await locator.count();
if (currentCount >= count) {
return true;
}
await locator.page().waitForTimeout(interval); // Wait for the interval before checking again
elapsedTime += interval;
}
throw new Error(
`Timeout after ${timeout}ms waiting for element count to be at least ${count}`,
);
}