Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

test: tighten export e2e guards

AjTheSpidey57eed2c8292b
diff --git a/tests/e2e/gif-export.spec.ts b/tests/e2e/gif-export.spec.ts
index c00dc4000..18277ccb6 100644
--- a/tests/e2e/gif-export.spec.ts
+++ b/tests/e2e/gif-export.spec.ts
@@ -48,6 +48,12 @@ async function exportFromLoadedVideo(format: "gif" | "mp4"): Promise<Buffer> {
ipcMain.handle(
"write-export-to-path",
(_event: Electron.IpcMainInvokeEvent, buffer: ArrayBuffer, filePath: string) => {
+ if (filePath !== targetPath) {
+ return {
+ success: false,
+ error: `Unexpected export path: ${filePath}`,
+ };
+ }
(globalThis as Record<string, unknown>)["__testExportData"] =
Buffer.from(buffer).toString("base64");
return { success: true, path: filePath };
@@ -63,13 +69,19 @@ async function exportFromLoadedVideo(format: "gif" | "mp4"): Promise<Buffer> {
fs.mkdirSync(recordingsDir, { recursive: true });
fs.copyFileSync(TEST_VIDEO, testVideoInRecordings);
+ await hudWindow.evaluate(
+ (videoPath: string) => window.electronAPI.setCurrentVideoPath(videoPath),
+ testVideoInRecordings,
+ );
try {
- await hudWindow.evaluate((videoPath: string) => {
- window.electronAPI.setCurrentVideoPath(videoPath);
- window.electronAPI.switchToEditor();
- }, testVideoInRecordings);
- } catch {
- // switchToEditor closes the HUD window before evaluate can resolve.
+ await hudWindow.evaluate(() => window.electronAPI.switchToEditor());
+ } catch (error) {
+ if (
+ !(error instanceof Error) ||
+ !/closed|destroyed|target page|target closed/i.test(error.message)
+ ) {
+ throw error;
+ }
}
const editorWindow = await app.waitForEvent("window", {