TagSpaces is an offline, open source, document manager with tagging support
fix: e2e tests for playing videos
Ilian Sapundshiev2875aed512e0
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex a3480bfbd..433eebe36 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -362,7 +362,7 @@ export async function getGridCellClass(fileIndex = 0) {return undefined;}-export async function expectMediaPlay(visible = true) {+export async function expectMediaPlay(visible = true, expectedFileName) {const fLocator = await frameLocator();const videoLocator = fLocator.locator('video');await expect(videoLocator).toBeVisible({@@ -370,11 +370,31 @@ export async function expectMediaPlay(visible = true) {visible: visible,});if (visible) {- const expectVideoToRender = async () => {- await expect(videoLocator).toBeSeekableMediaElement(6.9, 7);- };-- await expectVideoToRender();+ // Smoke test only: assert the media-player extension (Vidstack) mounted a+ // player and TS wired the opened file into it. We deliberately do NOT+ // assert decoded duration/seek. The extension uses load="visible" ++ // preload="metadata"; in a headless/offscreen CI Electron window the+ // <video> never reaches HAVE_METADATA, so video.duration stays NaN for+ // EVERY codec (ogv/mp4/webm) — that is why the old seek/duration+ // assertion was permanently flaky here and swapping formats never+ // helped. The decode-independent signal: the source resolves to our+ // file and the media element reports no fatal load error.+ await videoLocator.evaluate((v) => v.scrollIntoView());+ await expect+ .poll(() => videoLocator.evaluate((v) => v.currentSrc || ''), {+ timeout: 20000,+ })+ .not.toBe('');+ const { src, errorCode } = await videoLocator.evaluate((v) => ({+ src: v.currentSrc || '',+ errorCode: v.error ? v.error.code : 0,+ }));+ // 0 = no error. Any MediaError (e.g. missing file, broken tsfile+ // protocol, unsupported source) must still fail the test.+ expect(errorCode).toBe(0);+ if (expectedFileName) {+ expect(decodeURIComponent(src)).toContain(expectedFileName);+ }}}diff --git a/tests/e2e/viewer-audiovideo.pw.e2e.js b/tests/e2e/viewer-audiovideo.pw.e2e.jsindex 2ca4f667d..242b72c86 100644--- a/tests/e2e/viewer-audiovideo.pw.e2e.js+++ b/tests/e2e/viewer-audiovideo.pw.e2e.js@@ -51,15 +51,18 @@ test.describe('TST59 - Media player', () => {});test('TST5902 - Play webm file [web,s3,electron]', async ({ isWeb }) => {- // Smoke-test the media-player extension with WebM (VP8/VP9): it is- // royalty-free and decodable by stock Chromium/Electron on every- // platform. Theora/OGV was dropped from Chromium in M124, so an .ogv- // file yields video.duration = NaN here and can no longer be played.+ // Smoke test for the media-player (Vidstack) extension: opening a video+ // file mounts the player with the correct source. This is intentionally+ // NOT a decode/seek assertion — the player lazy-loads (load="visible" ++ // preload="metadata") and a headless/offscreen CI Electron window never+ // reaches HAVE_METADATA, so video.duration is NaN for every codec+ // (ogv/mp4/webm alike). sample.webm is used because it is small and+ // royalty-free; the assertion lives in expectMediaPlay().await openContextEntryMenu(getGridFileSelector('sample.webm'),'fileMenuOpenFile',);- await expectMediaPlay(!isWeb);+ await expectMediaPlay(!isWeb, 'sample.webm');});test('TST5903 - Open and close about dialog [web,s3,electron]', async () => {