Files
google-labs-jules[bot]andPR0M3TH3AN d8a9e5940f Fix documented known issues in tests
- Refactor `popover.spec.ts` to use shared helper functions in `helpers/popoverUtils.ts`, resolving potential ReferenceErrors.
- Add `ensureTestAssets` check to E2E tests (`ui-modals.spec.ts`, `popover.spec.ts`) to verify `css/tailwind.generated.css` exists before running, preventing confusing 404 errors.
- Fix visual regression instability in `kitchen-sink.spec.ts` by enforcing explicit viewport dimensions and resetting body margins in injected styles.
- Update `KNOWN_ISSUES.md` to remove the resolved issues.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-04 21:04:07 +00:00

58 lines
1.6 KiB
TypeScript

import type { Page } from "@playwright/test";
export async function ensureTestAssets(page: Page): Promise<void> {
const cssResponse = await page.request.head("/css/tailwind.generated.css");
if (!cssResponse.ok()) {
throw new Error(
"Test asset check failed: css/tailwind.generated.css is missing (404). Run `npm run build:css` before testing.",
);
}
}
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);
}