605
601
Alcotest.(check bool)
606
602
"the load gain since last performed is shown" true
607
603
(Option.is_some (index_from ~needle:"+10 kg" page 0)) );
604
+
Added:
( "the progress page charts an exercise with enough history",
605
+
Added:
`Quick,
606
+
Added:
fun () ->
607
+
Added:
(* Two promoted imports of the same exercise give two points, enough
608
+
Added:
to draw the dual-axis line chart. *)
609
+
Added:
let c, repo = client_with_repo () in
610
+
Added:
let _ = register c ~username:"lifter" ~password:"heavyduty1" in
611
+
Added:
let trainee = the_trainee repo ~username:"lifter" in
612
+
Added:
let header =
613
+
Added:
"title,start_time,end_time,description,exercise_title,superset_id,exercise_notes,set_index,set_type,weight_kg,reps,distance_km,duration_seconds,rpe\r\n"
614
+
Added:
in
615
+
Added:
let source =
616
+
Added:
header
617
+
Added:
^ "Legs,\"01 Jan 2024, 10:00\",\"01 Jan 2024, 11:00\",,Barbell \
618
+
Added:
Squat,,,0,failure,100,8,,,\r\n"
619
+
Added:
^ "Legs,\"08 Jan 2024, 10:00\",\"08 Jan 2024, 11:00\",,Barbell \
620
+
Added:
Squat,,,0,failure,110,8,,,\r\n"
621
+
Added:
in
622
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
623
+
Added:
let _ =
624
+
Added:
post_multipart c "/profile/import"
625
+
Added:
~file:(Some ("csv", "workouts.csv", source))
626
+
Added:
~fields:[ ("dream.csrf", token); ("utc_offset_seconds", "0") ]
627
+
Added:
in
628
+
Added:
let batch =
629
+
Added:
List.hd
630
+
Added:
(Lwt_main.run
631
+
Added:
(Memory_repo.import_batches repo trainee.Trainee.id))
632
+
Added:
in
633
+
Added:
let bid =
634
+
Added:
Workout_import.batch_id_to_string
635
+
Added:
(Workout_import.batch_identity batch)
636
+
Added:
in
637
+
Added:
let review = "/profile/import/" ^ bid in
638
+
Added:
List.iter
639
+
Added:
(fun w ->
640
+
Added:
let wid =
641
+
Added:
Workout_import.workout_id_to_string
642
+
Added:
(Workout_import.workout_identity w)
643
+
Added:
in
644
+
Added:
let t = Option.get (csrf_token (body (get c review))) in
645
+
Added:
ignore
646
+
Added:
(post c
647
+
Added:
(Printf.sprintf "/profile/import/%s/workouts/%s/map" bid
648
+
Added:
wid)
649
+
Added:
[
650
+
Added:
("dream.csrf", t);
651
+
Added:
("source_name", "Barbell Squat");
652
+
Added:
("exercise_id", "squats");
653
+
Added:
]))
654
+
Added:
(Workout_import.batch_workouts batch);
655
+
Added:
let t = Option.get (csrf_token (body (get c review))) in
656
+
Added:
let _ =
657
+
Added:
post c
658
+
Added:
(Printf.sprintf "/profile/import/%s/promote" bid)
659
+
Added:
[ ("dream.csrf", t) ]
660
+
Added:
in
661
+
Added:
(* The search submits the exercise name; the page returns its chart. *)
662
+
Added:
let page = body (get c "/progress?exercise=Squats") in
663
+
Added:
Alcotest.(check bool)
664
+
Added:
"the SVG chart is rendered" true
665
+
Added:
(Option.is_some (index_from ~needle:"progress-chart" page 0));
666
+
Added:
Alcotest.(check bool)
667
+
Added:
"the chart names the exercise" true
668
+
Added:
(Option.is_some (index_from ~needle:"Squats" page 0)) );
669
+
Added:
( "the progress page reports too little history to chart",
670
+
Added:
`Quick,
671
+
Added:
fun () ->
672
+
Added:
(* A single performance cannot draw a line. *)
673
+
Added:
let c, repo = client_with_repo () in
674
+
Added:
let _ = register c ~username:"lifter" ~password:"heavyduty1" in
675
+
Added:
let trainee = the_trainee repo ~username:"lifter" in
676
+
Added:
let header =
677
+
Added:
"title,start_time,end_time,description,exercise_title,superset_id,exercise_notes,set_index,set_type,weight_kg,reps,distance_km,duration_seconds,rpe\r\n"
678
+
Added:
in
679
+
Added:
let source =
680
+
Added:
header
681
+
Added:
^ "Legs,\"01 Jan 2024, 10:00\",\"01 Jan 2024, 11:00\",,Barbell \
682
+
Added:
Squat,,,0,failure,100,8,,,\r\n"
683
+
Added:
in
684
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
685
+
Added:
let _ =
686
+
Added:
post_multipart c "/profile/import"
687
+
Added:
~file:(Some ("csv", "workouts.csv", source))
688
+
Added:
~fields:[ ("dream.csrf", token); ("utc_offset_seconds", "0") ]
689
+
Added:
in
690
+
Added:
let batch =
691
+
Added:
List.hd
692
+
Added:
(Lwt_main.run
693
+
Added:
(Memory_repo.import_batches repo trainee.Trainee.id))
694
+
Added:
in
695
+
Added:
let bid =
696
+
Added:
Workout_import.batch_id_to_string
697
+
Added:
(Workout_import.batch_identity batch)
698
+
Added:
in
699
+
Added:
let wid =
700
+
Added:
Workout_import.workout_id_to_string
701
+
Added:
(Workout_import.workout_identity
702
+
Added:
(List.hd (Workout_import.batch_workouts batch)))
703
+
Added:
in
704
+
Added:
let review = "/profile/import/" ^ bid in
705
+
Added:
let t = Option.get (csrf_token (body (get c review))) in
706
+
Added:
let _ =
707
+
Added:
post c
708
+
Added:
(Printf.sprintf "/profile/import/%s/workouts/%s/map" bid wid)
709
+
Added:
[
710
+
Added:
("dream.csrf", t);
711
+
Added:
("source_name", "Barbell Squat");
712
+
Added:
("exercise_id", "squats");
713
+
Added:
]
714
+
Added:
in
715
+
Added:
let t = Option.get (csrf_token (body (get c review))) in
716
+
Added:
let _ =
717
+
Added:
post c
718
+
Added:
(Printf.sprintf "/profile/import/%s/workouts/%s/promote" bid wid)
719
+
Added:
[ ("dream.csrf", t) ]
720
+
Added:
in
721
+
Added:
let page = body (get c "/progress?exercise=Squats") in
722
+
Added:
Alcotest.(check bool)
723
+
Added:
"no chart is drawn for one point" false
724
+
Added:
(Option.is_some (index_from ~needle:"progress-chart" page 0));
725
+
Added:
Alcotest.(check bool)
726
+
Added:
"an insufficient-history message is shown" true
727
+
Added:
(Option.is_some (index_from ~needle:"Not enough history" page 0))
728
+
Added:
);
608
729
] );
609
730
]