From e0b0b73b1cef93f295d9ca1408560455df6c7f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 12 Jul 2026 23:26:27 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(users):=20non-student=20role?= =?UTF-8?q?=20match=20+=20name-arm=20filter=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both role-filter cases used the student side; now teacher-positive match and name-fragment hits under a role filter are pinned, via a first e2e use of PATCH /users/me. --- tests/e2e.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/e2e.rs b/tests/e2e.rs index be3d5ee..91733a6 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -217,6 +217,51 @@ async fn full_user_journey() { .unwrap(); assert_eq!(res.status(), StatusCode::BAD_REQUEST); + // The filter also *includes* on non-student roles: ali is the teacher. + let found: Value = ali + .get(format!("{base}/users/search?q=al&role=teacher")) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + assert_eq!(found.as_array().unwrap().len(), 1); + assert_eq!(found[0]["username"], "ali"); + + // Search matches profile names too, and the role filter applies to those + // hits as well: "lic" only exists in ali's freshly set name, not in any + // username, so it appears under `role=teacher` and not `role=student`. + let res = ali + .patch(format!("{base}/users/me")) + .json(&json!({ "name": "Alice" })) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::OK); + + let found: Value = ali + .get(format!("{base}/users/search?q=lic&role=teacher")) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + assert_eq!(found.as_array().unwrap().len(), 1); + assert_eq!(found[0]["username"], "ali"); + assert_eq!(found[0]["display_name"], "Alice"); + + let found: Value = ali + .get(format!("{base}/users/search?q=lic&role=student")) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + assert!(found.as_array().unwrap().is_empty()); + let res = veli .get(format!("{base}/users/search?q=ali")) .send()