Skip to content

Commit 3a4fefd

Browse files
committed
fix(qa): keep artifacts recorded by an earlier keep-box stop
1 parent 4bb5434 commit 3a4fefd

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎scripts/e2e/telegram-desktop-recorder.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ export async function stopRecorder(
722722
}
723723
const stopped: RecorderSession = {
724724
...session,
725-
artifacts,
725+
// Keep paths recorded by an earlier stop (--keep-box, then a later stop once
726+
// the lease expired); fresh copies overwrite their own entries.
727+
artifacts: { ...session.artifacts, ...artifacts },
726728
cleanupErrors: errors.length ? errors : undefined,
727729
keepBox: opts.keepBox,
728730
stoppedAt: new Date().toISOString(),

‎test/scripts/telegram-desktop-recorder.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,39 @@ describe("Telegram Desktop recorder session lifecycle", () => {
595595
expect(cropped).not.toHaveBeenCalled();
596596
});
597597

598+
it("keeps artifacts recorded by an earlier keep-box stop", async () => {
599+
const root = makeTempDir();
600+
const sessionPath = path.join(root, "recorder.json");
601+
writeRecorderSession(sessionPath, {
602+
...testSession(),
603+
artifacts: { previewGif: "/kept/motion.gif", video: "/kept/session.mp4" },
604+
keepBox: true,
605+
});
606+
const operations = {
607+
createCroppedMotionPreview: vi.fn(async () => ({ crop: "", fps: 24, outputWidth: 650 })),
608+
createMotionPreview: vi.fn(async () => ({})),
609+
inspectCrabbox: vi.fn(async () => {
610+
throw new Error("local-container lease not found: cbx_test123");
611+
}),
612+
runCommand: (async () => ({
613+
stderr: "",
614+
stdout: JSON.stringify({ ok: true }),
615+
})) as RunCommand,
616+
scpFromRemote: vi.fn(async () => undefined),
617+
sshRun: vi.fn(async () => ({ stderr: "", stdout: "" })),
618+
} satisfies RecorderOperations;
619+
620+
const stopped = await stopRecorder(
621+
root,
622+
{ command: "stop", keepBox: false, sessionPath },
623+
operations,
624+
);
625+
expect(stopped.artifacts).toEqual({
626+
previewGif: "/kept/motion.gif",
627+
video: "/kept/session.mp4",
628+
});
629+
});
630+
598631
it("still stops Crabbox and reports failure when local session termination fails", async () => {
599632
const root = makeTempDir();
600633
const sessionPath = path.join(root, "recorder.json");

0 commit comments

Comments
 (0)