From 1dc2c06ee45e226982d75cfc8723e81228b4571f Mon Sep 17 00:00:00 2001 From: Siddharth Date: Sun, 5 Apr 2026 16:04:01 -0700 Subject: [PATCH] fix: revert e2e test to fire-and-forget setCurrentVideoPath with reload Restore the original test approach that was passing: fire-and-forget setCurrentVideoPath, catch the switchToEditor context close, and reload the editor window for WebCodecs initialization. --- tests/e2e/gif-export.spec.ts | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/tests/e2e/gif-export.spec.ts b/tests/e2e/gif-export.spec.ts index 8493f2e..0ff0b77 100644 --- a/tests/e2e/gif-export.spec.ts +++ b/tests/e2e/gif-export.spec.ts @@ -70,23 +70,14 @@ test("exports a GIF from a loaded video", async () => { fs.mkdirSync(recordingsDir, { recursive: true }); fs.copyFileSync(TEST_VIDEO, testVideoInRecordings); - try { - await hudWindow.evaluate(async (videoPath: string) => { - await window.electronAPI.setCurrentVideoPath(videoPath); + await hudWindow.evaluate((videoPath: string) => { + window.electronAPI.setCurrentVideoPath(videoPath); + try { window.electronAPI.switchToEditor(); - }, testVideoInRecordings); - } catch (error) { - // Expected: switchToEditor() closes the HUD window, which terminates - // the Playwright page context before evaluate() can resolve. - if ( - !( - error instanceof Error && - error.message.includes("Target page, context or browser has been closed") - ) - ) { - throw error; + } catch { + // Expected: HUD window closes during this call, killing the context. } - } + }, testVideoInRecordings); // ── 3. Switch to the editor window. This closes the HUD and opens // a new BrowserWindow with ?windowType=editor. @@ -95,9 +86,13 @@ test("exports a GIF from a loaded video", async () => { timeout: 15_000, }); + // WebCodecs (VideoEncoder) may not be registered in the renderer on first + // load of a second BrowserWindow. A single reload ensures the feature is + // fully initialized before we start encoding. + await editorWindow.reload(); await editorWindow.waitForLoadState("domcontentloaded"); await expect(editorWindow.getByText("Loading video...")).not.toBeVisible({ - timeout: 30_000, + timeout: 15_000, }); // ── 5. Select GIF as the export format.