@@ -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