@@ -828,6 +828,119 @@ describe("CLI Commands", () => {
828828 } ) ;
829829 } ) ;
830830
831+ describe ( "set-handoff command" , ( ) => {
832+ it ( "should store handoff with status and summary" , async ( ) => {
833+ const taskId = db . createTask ( { title : "Test task" } ) ;
834+
835+ const program = createCli ( ) ;
836+ program . exitOverride ( ) ;
837+
838+ await program . parseAsync ( [
839+ "node" ,
840+ "test" ,
841+ "--json" ,
842+ "-d" ,
843+ tempDir ,
844+ "set-handoff" ,
845+ taskId ,
846+ "PASS" ,
847+ "Implementation complete" ,
848+ ] ) ;
849+
850+ const output = getConsoleOutput ( consoleLogSpy ) ;
851+ const parsed = JSON . parse ( output ) ;
852+ expect ( parsed . success ) . toBe ( true ) ;
853+
854+ // Reload to see changes made by CLI
855+ await db . reload ( ) ;
856+ const handoff = db . getTaskHandoff ( taskId ) ;
857+ expect ( handoff ) . toBeDefined ( ) ;
858+ expect ( handoff ?. status ) . toBe ( "PASS" ) ;
859+ expect ( handoff ?. summary ) . toBe ( "Implementation complete" ) ;
860+ } ) ;
861+
862+ it ( "should store handoff with files changed" , async ( ) => {
863+ const taskId = db . createTask ( { title : "Test task" } ) ;
864+
865+ const program = createCli ( ) ;
866+ program . exitOverride ( ) ;
867+
868+ await program . parseAsync ( [
869+ "node" ,
870+ "test" ,
871+ "--json" ,
872+ "-d" ,
873+ tempDir ,
874+ "set-handoff" ,
875+ taskId ,
876+ "PASS" ,
877+ "Added new feature" ,
878+ "--files" ,
879+ '["src/feature.ts","src/test.ts"]' ,
880+ ] ) ;
881+
882+ const output = getConsoleOutput ( consoleLogSpy ) ;
883+ const parsed = JSON . parse ( output ) ;
884+ expect ( parsed . success ) . toBe ( true ) ;
885+
886+ // Reload to see changes made by CLI
887+ await db . reload ( ) ;
888+ const handoff = db . getTaskHandoff ( taskId ) ;
889+ expect ( handoff ?. files_changed ) . toEqual ( [ "src/feature.ts" , "src/test.ts" ] ) ;
890+ } ) ;
891+
892+ it ( "should store handoff with full details" , async ( ) => {
893+ const taskId = db . createTask ( { title : "Test task" } ) ;
894+
895+ const program = createCli ( ) ;
896+ program . exitOverride ( ) ;
897+
898+ const fullDetails = "Full implementation report with all details" ;
899+
900+ await program . parseAsync ( [
901+ "node" ,
902+ "test" ,
903+ "--json" ,
904+ "-d" ,
905+ tempDir ,
906+ "set-handoff" ,
907+ taskId ,
908+ "FAIL" ,
909+ "Tests failed" ,
910+ "--details" ,
911+ fullDetails ,
912+ ] ) ;
913+
914+ const output = getConsoleOutput ( consoleLogSpy ) ;
915+ const parsed = JSON . parse ( output ) ;
916+ expect ( parsed . success ) . toBe ( true ) ;
917+
918+ // Reload to see changes made by CLI
919+ await db . reload ( ) ;
920+ const handoff = db . getTaskHandoff ( taskId , true ) ;
921+ expect ( handoff ?. full_details ) . toBe ( fullDetails ) ;
922+ } ) ;
923+
924+ it ( "should fail for non-existent task" , async ( ) => {
925+ const program = createCli ( ) ;
926+ program . exitOverride ( ) ;
927+
928+ await expect (
929+ program . parseAsync ( [
930+ "node" ,
931+ "test" ,
932+ "--json" ,
933+ "-d" ,
934+ tempDir ,
935+ "set-handoff" ,
936+ "non-existent" ,
937+ "PASS" ,
938+ "Summary" ,
939+ ] )
940+ ) . rejects . toThrow ( ) ;
941+ } ) ;
942+ } ) ;
943+
831944 describe ( "kanban command" , ( ) => {
832945 it ( "should have kanban command" , ( ) => {
833946 const program = createCli ( ) ;
0 commit comments