Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 6x 6x 1x 1x 5x 5x 1x 1x 1x | import type { Page } from '@playwright/test';
/**
* Wait-helpers — settle-network, angular-stable (zone.js-aware), idle.
*/
export class DyE2E_WaitHelpers_Util {
/** Network idle (Playwright built-in wrap, default 500ms). */
static async waitForSettledNetwork(page: Page, timeout: number = 10_000): Promise<void> {
await page.waitForLoadState('networkidle', { timeout });
}
/**
* Angular-stable wait — zone.js-on keresztül. Akkor settle-el ha az NgZone
* `hasPendingMacrotasks` és `hasPendingMicrotasks` mind hamis.
*
* Wave-1: best-effort, ha nincs Angular vagy zone.js → fallback `waitForTimeout(50)`.
*/
static async waitForAngularStable(page: Page, timeout: number = 5_000): Promise<void> {
const start: number = Date.now();
while (Date.now() - start < timeout) {
const stable: boolean = await page.evaluate((): boolean => {
const w: any = window;
try {
if (w.getAllAngularRootElements && w.getAllAngularTestabilities) {
const tests: any[] = w.getAllAngularTestabilities();
return tests.every((t: any): boolean => t.isStable());
}
} catch (e: any) { /* fall-through */ }
return true; // No Angular present — assume stable
}).catch((): boolean => true);
if (stable) {
return;
}
await page.waitForTimeout(50);
}
}
/** Simple polling — vár amíg a `check` callback truthy-t ad. */
static async waitUntil<T>(check: () => Promise<T>, timeout: number = 5_000, interval: number = 100): Promise<T> {
const start: number = Date.now();
while (Date.now() - start < timeout) {
const v: T = await check();
if (v) {
return v;
}
await new Promise((resolve: (value: void) => void): void => { setTimeout((): void => resolve(), interval); });
}
throw new Error(`waitUntil timeout after ${timeout}ms`);
}
}
|