508
507
Alcotest.(check bool)
509
508
"the imported workout title is shown" true
510
509
(Option.is_some (index_from ~needle:"Legs" page 0));
510
+
Added:
(* The title shows verbatim: no "Imported" text is appended to it,
511
+
Added:
and the old source tag is gone. *)
512
+
Added:
Alcotest.(check bool)
513
+
Added:
"no source tag on the title" false
514
+
Added:
(Option.is_some (index_from ~needle:"logbook-source-tag" page 0));
515
+
Added:
Alcotest.(check bool)
516
+
Added:
"the title is not suffixed with Imported" false
517
+
Added:
(Option.is_some (index_from ~needle:"Legs Imported" page 0));
511
518
(* The import spans 10:00-11:00, so its duration is relevant and
512
519
shown, like a native workout. *)
513
520
Alcotest.(check bool)
514
521
"the imported workout duration is shown" true
515
522
(Option.is_some (index_from ~needle:"60 min" page 0));
523
+
Added:
(* An import's status and detail live in a three-dot menu, whose
524
+
Added:
drawer lists the imported exercise, its effort, and the progress
525
+
Added:
since it was last performed (here a first performance). *)
516
526
Alcotest.(check bool)
517
-
Removed:
"it carries the Imported tag" true
518
-
Removed:
(Option.is_some (index_from ~needle:"logbook-source-tag" page 0));
527
+
Added:
"the import three-dot menu drawer is present" true
528
+
Added:
(Option.is_some
529
+
Added:
(index_from ~needle:"logbook-import-drawer" page 0));
519
530
Alcotest.(check bool)
531
+
Added:
"the imported exercise is listed" true
532
+
Added:
(Option.is_some (index_from ~needle:"Squats" page 0));
533
+
Added:
Alcotest.(check bool)
534
+
Added:
"a first performance is marked as such" true
535
+
Added:
(Option.is_some (index_from ~needle:"first performance" page 0));
536
+
Added:
Alcotest.(check bool)
520
537
"a read-only import offers no delete action" false
521
538
(Option.is_some (index_from ~needle:"?delete=" page 0)) );
539
+
Added:
( "an imported exercise shows progress since it was last performed",
540
+
Added:
`Quick,
541
+
Added:
fun () ->
542
+
Added:
(* Two imports of the same exercise on different days. The later
543
+
Added:
one's menu reports the load gain since the earlier performance,
544
+
Added:
not "first performance". *)
545
+
Added:
let c, repo = client_with_repo () in
546
+
Added:
let _ = register c ~username:"lifter" ~password:"heavyduty1" in
547
+
Added:
let trainee = the_trainee repo ~username:"lifter" in
548
+
Added:
let header =
549
+
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"
550
+
Added:
in
551
+
Added:
let source =
552
+
Added:
header
553
+
Added:
^ "Legs,\"01 Jan 2024, 10:00\",\"01 Jan 2024, 11:00\",,Barbell \
554
+
Added:
Squat,,,0,failure,100,8,,,\r\n"
555
+
Added:
^ "Legs,\"08 Jan 2024, 10:00\",\"08 Jan 2024, 11:00\",,Barbell \
556
+
Added:
Squat,,,0,failure,110,8,,,\r\n"
557
+
Added:
in
558
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
559
+
Added:
let _ =
560
+
Added:
post_multipart c "/profile/import"
561
+
Added:
~file:(Some ("csv", "workouts.csv", source))
562
+
Added:
~fields:[ ("dream.csrf", token); ("utc_offset_seconds", "0") ]
563
+
Added:
in
564
+
Added:
let batch =
565
+
Added:
List.hd
566
+
Added:
(Lwt_main.run
567
+
Added:
(Memory_repo.import_batches repo trainee.Trainee.id))
568
+
Added:
in
569
+
Added:
let bid =
570
+
Added:
Workout_import.batch_id_to_string
571
+
Added:
(Workout_import.batch_identity batch)
572
+
Added:
in
573
+
Added:
let review = "/profile/import/" ^ bid in
574
+
Added:
(* Map the exercise in both workouts, then promote the whole batch. *)
575
+
Added:
List.iter
576
+
Added:
(fun w ->
577
+
Added:
let wid =
578
+
Added:
Workout_import.workout_id_to_string
579
+
Added:
(Workout_import.workout_identity w)
580
+
Added:
in
581
+
Added:
let t = Option.get (csrf_token (body (get c review))) in
582
+
Added:
ignore
583
+
Added:
(post c
584
+
Added:
(Printf.sprintf "/profile/import/%s/workouts/%s/map" bid
585
+
Added:
wid)
586
+
Added:
[
587
+
Added:
("dream.csrf", t);
588
+
Added:
("source_name", "Barbell Squat");
589
+
Added:
("exercise_id", "squats");
590
+
Added:
]))
591
+
Added:
(Workout_import.batch_workouts batch);
592
+
Added:
let t = Option.get (csrf_token (body (get c review))) in
593
+
Added:
let _ =
594
+
Added:
post c
595
+
Added:
(Printf.sprintf "/profile/import/%s/promote" bid)
596
+
Added:
[ ("dream.csrf", t) ]
597
+
Added:
in
598
+
Added:
Alcotest.(check int)
599
+
Added:
"both imports promoted" 2
600
+
Added:
(List.length
601
+
Added:
(Lwt_main.run
602
+
Added:
(Memory_repo.imported_records repo trainee.Trainee.id)));
603
+
Added:
let page = body (get c "/logbook") in
604
+
Added:
(* The later import gained 10 kg over the earlier one. *)
605
+
Added:
Alcotest.(check bool)
606
+
Added:
"the load gain since last performed is shown" true
607
+
Added:
(Option.is_some (index_from ~needle:"+10 kg" page 0)) );
522
608
] );
523
609
]