@@ -579,6 +579,69 @@ describe("registerRoutineTools", () => {
579579 expect ( response . content ) . toHaveLength ( 1 ) ;
580580 } ) ;
581581
582+ it ( "update-routine omits rep_range when repRange does not contain values" , async ( ) => {
583+ const { server, tool } = createMockServer ( ) ;
584+ const routine : Routine = {
585+ id : "updated-routine" ,
586+ title : "Updated Routine" ,
587+ folder_id : null ,
588+ created_at : "2025-03-26T19:00:00Z" ,
589+ updated_at : "2025-03-26T19:30:00Z" ,
590+ exercises : [ ] ,
591+ } ;
592+ const updateRoutineMock = vi . fn ( ) . mockResolvedValue ( routine ) ;
593+ const hevyClient : HevyClient = {
594+ updateRoutine : updateRoutineMock ,
595+ } as unknown as HevyClient ;
596+
597+ registerRoutineTools ( server , hevyClient ) ;
598+ const { handler } = getToolRegistration ( tool , "update-routine" ) ;
599+
600+ await handler ( {
601+ routineId : "routine-123" ,
602+ title : "Updated Routine" ,
603+ exercises : [
604+ {
605+ exerciseTemplateId : "template-id" ,
606+ supersetId : null ,
607+ restSeconds : 90 ,
608+ sets : [
609+ {
610+ type : "normal" as const ,
611+ weightKg : 100 ,
612+ reps : 10 ,
613+ repRange : { start : null , end : null } ,
614+ } ,
615+ ] ,
616+ } ,
617+ ] ,
618+ } as Record < string , unknown > ) ;
619+
620+ expect ( updateRoutineMock ) . toHaveBeenCalledWith (
621+ "routine-123" ,
622+ expect . objectContaining ( {
623+ routine : expect . objectContaining ( {
624+ exercises : [
625+ expect . objectContaining ( {
626+ sets : [ expect . objectContaining ( { reps : 10 } ) ] ,
627+ } ) ,
628+ ] ,
629+ } ) ,
630+ } ) ,
631+ ) ;
632+
633+ const updatePayload = updateRoutineMock . mock . calls [ 0 ] ?. [ 1 ] as {
634+ routine : {
635+ exercises : Array < {
636+ sets : Array < Record < string , unknown > > ;
637+ } > ;
638+ } ;
639+ } ;
640+ expect ( updatePayload . routine . exercises [ 0 ] ?. sets [ 0 ] ) . not . toHaveProperty (
641+ "rep_range" ,
642+ ) ;
643+ } ) ;
644+
582645 it ( "update-routine includes a rep range display warning when repRange is provided" , async ( ) => {
583646 const { server, tool } = createMockServer ( ) ;
584647 const routine : Routine = {
@@ -685,7 +748,6 @@ describe("registerRoutineTools", () => {
685748 distance_meters : null ,
686749 duration_seconds : null ,
687750 custom_metric : null ,
688- rep_range : null ,
689751 } ,
690752 ] ,
691753 } ,
0 commit comments