fix: guard video.play() for jsdom and fix Hls mock case mismatch
CI / test (pull_request) Successful in 16s

- Defensive null check on video.play() return value (jsdom returns undefined)
- Fix test mock: win.Hls (not win.HLS) to match viewer.js window.Hls reference
- All 39/39 tests now pass
This commit is contained in:
Hermes Agent committed 2026-08-11 04:42:28 +00:00
1 parent 23a2af6cad
commit 0d4b62c485
2 files changed
+6 -4

No files matched your search

+4 -2
View File
@@ -37,7 +37,8 @@ function playHls(video, manifestUrl, panel) {
if (!window.Hls || !window.Hls.isSupported()) {
console.log('[goon-viewer] Native HLS support detected, using direct source');
video.src = manifestUrl;
video.play().catch(() => { /* autoplay blocked — user interaction required */ });
const p = video.play();
if (p) p.catch(() => { /* autoplay blocked — user interaction required */ });
return;
}
@@ -55,7 +56,8 @@ function playHls(video, manifestUrl, panel) {
hls.on(window.Hls.Events.MANIFEST_PARSED, () => {
console.log('[goon-viewer] HLS manifest parsed, playing');
video.play().catch(() => { /* autoplay blocked */ });
const p = video.play();
if (p) p.catch(() => { /* autoplay blocked */ });
});
hls.on(window.Hls.Events.LEVEL_SWITCHED, () => {