fix(tests): resolve JSDOM errors and tag sorting failures

- Update `tests/video-modal-accessibility.test.mjs` to unconditionally stub `HTMLMediaElement` methods (`pause`, `load`), fixing "Not implemented" errors in JSDOM.
- Refactor `VideoModal.normalizeVideoTags` to preserve tag casing while normalizing for deduplication (lowercase + strip #) and ensuring correct display format.
- Update `js/ui/components/tagPillList.js` to conditionally prepend `#` only if missing, preventing double-hashing (e.g., `##tag`).
- Remove unused `normalizeHashtag` import in `VideoModal.js`.
- Verify fixes with `tests/video-modal-tags.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-27 03:17:15 +00:00
1 parent 91b45abf9a
commit cf1c81e61e
3 files changed
+21 -25

No files matched your search

+5 -19
View File
@@ -33,9 +33,8 @@ export async function setupModal({ lazyLoad = false } = {}) {
// jsdom defines HTMLMediaElement but .pause/.load throw "Not implemented".
// Replace with safe no-ops for tests that just depend on calls happening.
if (window.HTMLMediaElement && window.HTMLMediaElement.prototype) {
const proto = window.HTMLMediaElement.prototype;
proto.pause = () => {};
proto.load = () => {};
window.HTMLMediaElement.prototype.pause = function () {};
window.HTMLMediaElement.prototype.load = function () {};
}
globalThis.HTMLElement = window.HTMLElement;
@@ -47,15 +46,6 @@ export async function setupModal({ lazyLoad = false } = {}) {
globalThis.Node = window.Node;
globalThis.EventTarget = window.EventTarget;
if (typeof window.HTMLMediaElement !== "undefined") {
window.HTMLMediaElement.prototype.pause = function () {};
window.HTMLMediaElement.prototype.load = function () {};
}
if (typeof window.HTMLVideoElement !== "undefined") {
window.HTMLVideoElement.prototype.pause = function () {};
window.HTMLVideoElement.prototype.load = function () {};
}
try {
Object.defineProperty(globalThis, "navigator", {
value: window.navigator,
@@ -458,13 +448,9 @@ async function setupPlaybackHarness() {
globalThis.Node = window.Node;
globalThis.EventTarget = window.EventTarget;
if (typeof window.HTMLMediaElement !== "undefined") {
if (!window.HTMLMediaElement.prototype.pause) {
window.HTMLMediaElement.prototype.pause = function () {};
}
if (!window.HTMLMediaElement.prototype.load) {
window.HTMLMediaElement.prototype.load = function () {};
}
if (window.HTMLMediaElement && window.HTMLMediaElement.prototype) {
window.HTMLMediaElement.prototype.pause = function () {};
window.HTMLMediaElement.prototype.load = function () {};
}
try {