1007
1008
"opens the feedback disclosure on a suggestion" true
1008
1009
(contains ~substring:"<details class=\"feedback-disclosure\" open"
1009
1010
prompted) );
1011
+
Added:
] );
1012
+
Added:
( "web.profile",
1013
+
Added:
[
1014
+
Added:
( "the profile page offers username and password forms",
1015
+
Added:
`Quick,
1016
+
Added:
fun () ->
1017
+
Added:
let c = client () in
1018
+
Added:
let _ = sign_in_new c in
1019
+
Added:
let page = body (get c "/profile") in
1020
+
Added:
Alcotest.(check bool)
1021
+
Added:
"starts with a page heading" true
1022
+
Added:
(contains ~substring:"<h1>Profile</h1>" page);
1023
+
Added:
Alcotest.(check bool)
1024
+
Added:
"posts a username change to its route" true
1025
+
Added:
(contains ~substring:"action=\"/profile/username\"" page);
1026
+
Added:
Alcotest.(check bool)
1027
+
Added:
"posts a password change to its route" true
1028
+
Added:
(contains ~substring:"action=\"/profile/password\"" page);
1029
+
Added:
Alcotest.(check bool)
1030
+
Added:
"prefills the current username" true
1031
+
Added:
(contains ~substring:"value=\"lifter\"" page);
1032
+
Added:
Alcotest.(check bool)
1033
+
Added:
"asks for the current password" true
1034
+
Added:
(contains ~substring:"name=\"current\"" page) );
1035
+
Added:
( "changing the username updates the profile and the navigation",
1036
+
Added:
`Quick,
1037
+
Added:
fun () ->
1038
+
Added:
let c = client () in
1039
+
Added:
let _ = sign_in_new c in
1040
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
1041
+
Added:
let changed =
1042
+
Added:
post c "/profile/username"
1043
+
Added:
[ ("dream.csrf", token); ("username", "athlete") ]
1044
+
Added:
in
1045
+
Added:
Alcotest.(check int)
1046
+
Added:
"redirects after the change" 303 (status changed);
1047
+
Added:
Alcotest.(check bool)
1048
+
Added:
"redirects back to the profile with a notice" true
1049
+
Added:
(List.mem "/profile?changed=username"
1050
+
Added:
(Dream.headers changed "Location"));
1051
+
Added:
let page = body (get c "/profile?changed=username") in
1052
+
Added:
Alcotest.(check bool)
1053
+
Added:
"confirms the change" true
1054
+
Added:
(contains ~substring:"Username changed" page);
1055
+
Added:
Alcotest.(check bool)
1056
+
Added:
"shows the new name in the profile control" true
1057
+
Added:
(contains ~substring:">athlete</a>" page) );
1058
+
Added:
( "a taken username is refused with an inline error",
1059
+
Added:
`Quick,
1060
+
Added:
fun () ->
1061
+
Added:
let c = client () in
1062
+
Added:
let _ = sign_in_new c in
1063
+
Added:
(* Register a second account in the same store, via a client that
1064
+
Added:
shares the app but keeps its own cookie jar. *)
1065
+
Added:
let other = { c with jar = [] } in
1066
+
Added:
let _ = register other ~username:"taken" ~password:"heavyduty1" in
1067
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
1068
+
Added:
let refused =
1069
+
Added:
post c "/profile/username"
1070
+
Added:
[ ("dream.csrf", token); ("username", "taken") ]
1071
+
Added:
in
1072
+
Added:
Alcotest.(check int)
1073
+
Added:
"renders an invalid response" 400 (status refused);
1074
+
Added:
Alcotest.(check bool)
1075
+
Added:
"explains the name is taken" true
1076
+
Added:
(contains ~substring:"already registered" (body refused)) );
1077
+
Added:
( "changing the password requires the current one",
1078
+
Added:
`Quick,
1079
+
Added:
fun () ->
1080
+
Added:
let c = client () in
1081
+
Added:
let _ = sign_in_new c in
1082
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
1083
+
Added:
let refused =
1084
+
Added:
post c "/profile/password"
1085
+
Added:
[
1086
+
Added:
("dream.csrf", token);
1087
+
Added:
("current", "wrongpass");
1088
+
Added:
("next", "newsecret1");
1089
+
Added:
]
1090
+
Added:
in
1091
+
Added:
Alcotest.(check int)
1092
+
Added:
"renders an invalid response" 400 (status refused);
1093
+
Added:
Alcotest.(check bool)
1094
+
Added:
"explains the current password is wrong" true
1095
+
Added:
(contains ~substring:"current password is not correct"
1096
+
Added:
(body refused));
1097
+
Added:
(* Now change it with the correct current password. *)
1098
+
Added:
let token = Option.get (csrf_token (body (get c "/profile"))) in
1099
+
Added:
let changed =
1100
+
Added:
post c "/profile/password"
1101
+
Added:
[
1102
+
Added:
("dream.csrf", token);
1103
+
Added:
("current", "heavyduty1");
1104
+
Added:
("next", "newsecret1");
1105
+
Added:
]
1106
+
Added:
in
1107
+
Added:
Alcotest.(check int)
1108
+
Added:
"redirects after the change" 303 (status changed);
1109
+
Added:
Alcotest.(check bool)
1110
+
Added:
"redirects back to the profile with a notice" true
1111
+
Added:
(List.mem "/profile?changed=password"
1112
+
Added:
(Dream.headers changed "Location")) );
1010
1113
] );
1011
1114
]
1012
1115