open Support let suite = [ ( "web.errors", [ ( "form error keys are phrased for the trainee and never leak raw", `Quick, fun () -> (* Library keys are phrased through Dream_html's exported constants, and a key with no wording reads as a generic message rather than the key itself. *) let text = Hito_web.Decode.errors_to_text in Alcotest.(check string) "a library key is phrased" "Enter a value." (text [ ("load", Dream_html.Form.error_required) ]); Alcotest.(check string) "a whole-number key is phrased" "Enter a valid whole number." (text [ ("reps", Dream_html.Form.error_expected_int) ]); let unknown = text [ ("reps", "error.something.new") ] in Alcotest.(check bool) "an unknown key does not leak" false (Option.is_some (index_from ~needle:"error." unknown 0)); Alcotest.(check string) "an unknown key reads as a generic message" "Enter a valid value." unknown ); ( "an unknown path responds 404", `Quick, fun () -> let c = client () in let _ = sign_in_new c in Alcotest.(check int) "responds 404" 404 (status (get c "/no-such-page")) ); ( "the 404 response never depends on a session", `Quick, fun () -> let c = client () in Alcotest.(check int) "unauthenticated 404" 404 (status (get c "/deep/unknown/path")) ); ] ); ]