Make recorder and dashboard regression tests deterministic

This commit is contained in:
webadderall
2026-09-23 16:37:58 +10:00
parent 25157c89e3
commit 6828f86425
2 changed files with 17 additions and 8 deletions
@@ -20,10 +20,15 @@ describe.skipIf(process.platform !== "darwin")("recorder process lifecycle", ()
source.indexOf("final class RecorderService"),
source.indexOf("guard CommandLine.arguments.count"),
);
const commands = source.slice(
source.indexOf("let service = RecorderService()"),
source.indexOf("if !service.waitUntilFinished()"),
);
const commands = source
.slice(
source.indexOf("let service = RecorderService()"),
source.indexOf("if !service.waitUntilFinished()"),
)
.replace(
"service.stop()",
"service.stop()\n\tservice.drainCommandsForTest()\n\tcommandsFinished.signal()",
);
writeFileSync(
join(directory, "main.swift"),
`
@@ -47,10 +52,14 @@ final class ScreenCaptureRecorder {
func resumeCapture() async -> Bool { true }
}
${service}
extension RecorderService {
func drainCommandsForTest() { queue.sync {} }
}
let commandsFinished = DispatchSemaphore(value: 0)
${commands}
let success = service.waitUntilFinished()
// Keep the process alive long enough to expose a queued second group release.
Thread.sleep(forTimeInterval: 0.2)
// Wait for the reader to enqueue stop AND for the serialized operations to finish.
commandsFinished.wait()
exit(success ? 0 : 1)
`,
);
+2 -2
View File
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
import path from "node:path";
import { hasFreshProjectThumbnail } from "../../electron/ipc/project/thumbnailFreshness";
import { expect, test } from "@playwright/test";
import { installDesktopBridge } from "./bridge";
import { installDesktopBridge, installDesktopBridgeOverrides } from "./bridge";
test("home dashboard searches, sorts, opens projects and returns to the editor", async ({
page,
@@ -746,7 +746,7 @@ test("sidebar cards, separate Import, and shortcut settings use the dashboard fl
test("empty filtered libraries do not prompt for a first recording", async ({ page }) => {
await installDesktopBridge(page);
await page.addInitScript(() => {
await installDesktopBridgeOverrides(page, () => {
window.electronAPI.getCurrentVideoPath = async () => ({ success: false });
});
await page.goto("/?windowType=editor");