Files
bitvid/tests/e2e/helpers/uiTestUtils.ts
T
google-labs-jules[bot] 8c1395d946 test: stabilize modal and popover e2e tests
- Consolidate reduced motion logic into `applyReducedMotion` and add `waitForRAF` helper.
- Replace arbitrary timeouts with `waitForRAF` in popover tests.
- Fix popover placement test by enforcing small viewport.
- Fix popover stress test by relaxing overlay visibility checks and using force clicks.
- Fix login modal NIP-46 test by mocking `nostrClient` and using force clicks.
- Fix video modal test by relaxing visibility checks for the close button.
- Ensure modals are initialized via `staticModalAccessibility.js` in component isolation tests.
2026-01-22 22:49:43 +00:00

49 lines
1.3 KiB
TypeScript

import type { Page } from "@playwright/test";
export async function applyReducedMotion(page: Page): Promise<void> {
await page.emulateMedia({ reducedMotion: "reduce" });
await page.addStyleTag({
content: `
* {
transition: none !important;
animation: none !important;
animation-duration: 0s !important;
animation-delay: 0s !important;
transition-duration: 0s !important;
transition-delay: 0s !important;
}
`,
});
}
export async function waitForRAF(page: Page, cycles = 2): Promise<void> {
await page.evaluate(async (count) => {
for (let i = 0; i < count; i++) {
await new Promise((resolve) => requestAnimationFrame(resolve));
}
}, cycles);
}
export function failOnConsoleErrors(page: Page): void {
page.on("console", (message) => {
if (message.type() === "error") {
throw new Error(`Console error: ${message.text()}`);
}
});
page.on("pageerror", (error) => {
throw error;
});
}
export async function forceOpenModal(page: Page, selector: string): Promise<void> {
await page.evaluate((modalSelector) => {
const element = document.querySelector(modalSelector);
if (!element) {
return;
}
element.classList.remove("hidden");
element.setAttribute("data-open", "true");
}, selector);
}