[OCaml] High Intensity Training Online
test assert the middle tab returns to Routine on cancel
Cancelling a workout discards the in-progress session, so the routine page renders with logging off and the middle navigation tab reverts from "Current workout" to "Routine". This behaviour follows from the cancel fix; add a regression test that pins it: the tab reads "Current workout" while logging and "Routine" after cancellation. No production change; no doctrine bearing.
test/test_web.ml
@@ -883,6 +883,32 @@
883
883
Alcotest.(check int)
884
884
"the discarded workout has no record" 404
885
885
(status (get c "/logbook/w1")) );
886
Added:
( "the middle navigation tab returns to Routine after cancellation",
887
Added:
`Quick,
888
Added:
fun () ->
889
Added:
let c = client () in
890
Added:
let _ = sign_in_new c in
891
Added:
let token = Option.get (csrf_token (body (get c "/"))) in
892
Added:
let _ = post c "/routines/ideal/select" [ ("dream.csrf", token) ] in
893
Added:
let token = Option.get (csrf_token (body (get c "/"))) in
894
Added:
let _ =
895
Added:
post c "/workout" [ ("dream.csrf", token); ("override", "false") ]
896
Added:
in
897
Added:
(* While logging, the middle tab reads Current workout. *)
898
Added:
let logging_page = body (get c "/workout") in
899
Added:
Alcotest.(check bool)
900
Added:
"middle tab reads Current workout while logging" true
901
Added:
(contains ~substring:"Current workout" logging_page);
902
Added:
(* Cancel, then land on the routine tab. *)
903
Added:
let token = Option.get (csrf_token (body (get c "/workout"))) in
904
Added:
let _ = post c "/workout/cancel" [ ("dream.csrf", token) ] in
905
Added:
let routine_page = body (get c "/routine") in
906
Added:
Alcotest.(check bool)
907
Added:
"middle tab reverts to Routine after cancellation" true
908
Added:
(contains ~substring:">Routine<" routine_page);
909
Added:
Alcotest.(check bool)
910
Added:
"middle tab no longer reads Current workout" false
911
Added:
(contains ~substring:"Current workout" routine_page) );
886
912
( "the saved logbook view does not offer a cancel control",
887
913
`Quick,
888
914
fun () ->