Non-student role match + name-arm filter coverage
Browse files at this commite0b0b73b1cef93f295d9ca1408560455df6c7f3bParent: 2a51ca1- test
- non-student role match + name-arm filter coverage
1 changed file +45 -0
- tests/e2e.rs +45 -0
tests/e2e.rsmodified+45 -0
| @@ -217,6 +217,51 @@ async fn full_user_journey() { | |||
| 217 | .unwrap(); | 217 | .unwrap(); |
| 218 | assert_eq!(res.status(), StatusCode::BAD_REQUEST); | 218 | assert_eq!(res.status(), StatusCode::BAD_REQUEST); |
| 219 | 219 | ||
| 220 | + // The filter also *includes* on non-student roles: ali is the teacher. | ||
| 221 | + let found: Value = ali | ||
| 222 | + .get(format!("{base}/users/search?q=al&role=teacher")) | ||
| 223 | + .send() | ||
| 224 | + .await | ||
| 225 | + .unwrap() | ||
| 226 | + .json() | ||
| 227 | + .await | ||
| 228 | + .unwrap(); | ||
| 229 | + assert_eq!(found.as_array().unwrap().len(), 1); | ||
| 230 | + assert_eq!(found[0]["username"], "ali"); | ||
| 231 | + | ||
| 232 | + // Search matches profile names too, and the role filter applies to those | ||
| 233 | + // hits as well: "lic" only exists in ali's freshly set name, not in any | ||
| 234 | + // username, so it appears under `role=teacher` and not `role=student`. | ||
| 235 | + let res = ali | ||
| 236 | + .patch(format!("{base}/users/me")) | ||
| 237 | + .json(&json!({ "name": "Alice" })) | ||
| 238 | + .send() | ||
| 239 | + .await | ||
| 240 | + .unwrap(); | ||
| 241 | + assert_eq!(res.status(), StatusCode::OK); | ||
| 242 | + | ||
| 243 | + let found: Value = ali | ||
| 244 | + .get(format!("{base}/users/search?q=lic&role=teacher")) | ||
| 245 | + .send() | ||
| 246 | + .await | ||
| 247 | + .unwrap() | ||
| 248 | + .json() | ||
| 249 | + .await | ||
| 250 | + .unwrap(); | ||
| 251 | + assert_eq!(found.as_array().unwrap().len(), 1); | ||
| 252 | + assert_eq!(found[0]["username"], "ali"); | ||
| 253 | + assert_eq!(found[0]["display_name"], "Alice"); | ||
| 254 | + | ||
| 255 | + let found: Value = ali | ||
| 256 | + .get(format!("{base}/users/search?q=lic&role=student")) | ||
| 257 | + .send() | ||
| 258 | + .await | ||
| 259 | + .unwrap() | ||
| 260 | + .json() | ||
| 261 | + .await | ||
| 262 | + .unwrap(); | ||
| 263 | + assert!(found.as_array().unwrap().is_empty()); | ||
| 264 | + | ||
| 220 | let res = veli | 265 | let res = veli |
| 221 | .get(format!("{base}/users/search?q=ali")) | 266 | .get(format!("{base}/users/search?q=ali")) |
| 222 | .send() | 267 | .send() |