Files
google-labs-jules[bot]andPR0M3TH3AN ecd59b616b test: fix video modal tests and add missing polyfills
- Added `scrollTo`, `HTMLMediaElement.prototype.pause`, and `load` polyfills in `tests/video-modal-accessibility.test.mjs` (via `setupModal`) and `tests/test-setup.mjs`.
- Added defensive check in `ModalManager.teardown` to prevent `TypeError` when removing event listeners.
- Updated `tests/video-modal-moderation.test.mjs` to use correct selector `[data-moderation-bar]` and updated assertions for moderation overlay visibility (override state).
- Created `tests/test-setup.mjs` to handle early global polyfills for dependencies like `floating-ui`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-27 02:09:22 +00:00

34 lines
881 B
JavaScript

import { JSDOM } from "jsdom";
const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>", {
url: "https://example.com",
pretendToBeVisual: true,
});
globalThis.window = dom.window;
globalThis.document = dom.window.document;
try {
Object.defineProperty(globalThis, "navigator", {
value: dom.window.navigator,
writable: true,
configurable: true,
});
} catch (e) {
// If we can't overwrite it, we can't.
}
globalThis.HTMLElement = dom.window.HTMLElement;
globalThis.Element = dom.window.Element;
globalThis.Node = dom.window.Node;
// Pre-stub scrollTo
try {
dom.window.scrollTo = () => {};
} catch (e) {}
// Stub pause/load early as well, just in case
if (dom.window.HTMLMediaElement && dom.window.HTMLMediaElement.prototype) {
dom.window.HTMLMediaElement.prototype.pause = () => {};
dom.window.HTMLMediaElement.prototype.load = () => {};
}