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