From d341bdfdc5150123243416d7d3ce6f53a183b54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 13 Jul 2026 16:18:42 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(exams):=20open=20lifecycle,=20?= =?UTF-8?q?retake=20limits,=20rejoin=20door?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Integration: open exams sit anytime without a deadline, retakes wipe the sheet and respect a live-edited limit (0 = unlimited), open + duration_ms caps each sitting, sync retakes inside the window feed the monitor's attempt/attempts_used/left_at. E2E: walk-out stamps left_at and a closed rejoin door blocks re-entry and REST saves (finish stays allowed) until the teacher reopens it; open-mode room runs untimed and re-enters on attempt #2 with a blank sheet. --- tests/e2e.rs | 228 ++++++++++++++++++++++ tests/integration.rs | 450 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 657 insertions(+), 21 deletions(-) diff --git a/tests/e2e.rs b/tests/e2e.rs index 98a2f8d..36ec359 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -1015,3 +1015,231 @@ async fn exam_room_expires_mid_session() { assert_eq!(sheet["answers"][0]["selected"], 1); assert_eq!(sheet["auto_score"]["earned"], 10); } + +/// The student's latest attempt as their own REST view sees it. +async fn my_attempt(room: &ExamRoom) -> Value { + room.student + .get(format!("{}/exams/{}/attempt", room.base, room.exam_id)) + .send() + .await + .unwrap() + .json() + .await + .unwrap() +} + +/// Wait (bounded) for the room teardown to stamp `left_at` — the socket close +/// and the server's stamp race, so poll the REST view briefly. +async fn wait_for_left_at(room: &ExamRoom) -> i64 { + for _ in 0..50 { + let attempt = my_attempt(room).await; + if let Some(left_at) = attempt["left_at"].as_i64() { + return left_at; + } + tokio::time::sleep(std::time::Duration::from_millis(100)).await; + } + panic!("left_at was never stamped after the socket closed"); +} + +/// The rejoin door: with `allow_rejoin` off, walking out of the room stamps +/// `left_at` and locks re-entry and further saves (REST included) — finish +/// stays possible — until the teacher flips the door back open, which lets +/// the student reconnect (clearing `left_at`) and keep answering. +#[tokio::test] +async fn exam_room_rejoin_door_is_the_teachers_call() { + let room = exam_room_fixture(600_000).await; + + // Close the door before anyone sits. + let res = room + .teacher + .patch(format!("{}/exams/{}", room.base, room.exam_id)) + .json(&json!({ "allow_rejoin": false })) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::OK); + + let res = room + .student + .post(format!("{}/exams/{}/attempt", room.base, room.exam_id)) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::CREATED); + + // First entry is fine — the door only matters after a walk-out. + let mut ws = ws_open(&room.base, &room.exam_id, Some(&room.cookie)) + .await + .expect("first entry"); + let state = ws_next_frame(&mut ws).await.expect("connect state"); + assert_eq!(state["status"], "in_progress", "{state}"); + assert_eq!(state["attempt"], 1, "{state}"); + ws.close(None).await.unwrap(); + let left_at = wait_for_left_at(&room).await; + assert!(left_at > 0); + + // Locked out: no REST saves, no re-entry. + let res = room + .student + .post(format!( + "{}/exams/{}/attempt/answers", + room.base, room.exam_id + )) + .json(&json!({ "question_id": room.question_id, "selected": 1 })) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::CONFLICT); + assert_eq!( + ws_open(&room.base, &room.exam_id, Some(&room.cookie)) + .await + .expect_err("rejoin is closed"), + 409 + ); + + // The teacher reopens the door live; the student walks back in, which + // clears the stamp, and answering works again. + let res = room + .teacher + .patch(format!("{}/exams/{}", room.base, room.exam_id)) + .json(&json!({ "allow_rejoin": true })) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::OK); + let mut ws = ws_open(&room.base, &room.exam_id, Some(&room.cookie)) + .await + .expect("rejoin after the teacher reopened"); + ws_next_frame(&mut ws).await.expect("state after rejoin"); + let attempt = my_attempt(&room).await; + assert!( + attempt["left_at"].is_null(), + "re-entry clears left_at: {attempt}" + ); + ws_send( + &mut ws, + json!({ "type": "answer", "question_id": room.question_id, "selected": 1 }), + ) + .await; + ws_frame_of_type(&mut ws, "saved").await; + + // Walking out again with the door open: stamped, but REST saves still + // land — rejoin is allowed, the stamp is just presence. + ws.close(None).await.unwrap(); + wait_for_left_at(&room).await; + let res = room + .student + .post(format!( + "{}/exams/{}/attempt/answers", + room.base, room.exam_id + )) + .json(&json!({ "question_id": room.question_id, "selected": 0 })) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::OK); + + // A locked-out student can still submit what they saved: close the door + // once more and finish over REST. + let res = room + .teacher + .patch(format!("{}/exams/{}", room.base, room.exam_id)) + .json(&json!({ "allow_rejoin": false })) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::OK); + let res = room + .student + .post(format!( + "{}/exams/{}/attempt/finish", + room.base, room.exam_id + )) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::OK, "finish is exempt from rejoin"); +} + +/// An `open`-mode exam room: no deadline in the state frames, and a retake +/// (attempt #2) enters the room with a blank sheet after the first sitting is +/// submitted. +#[tokio::test] +async fn exam_room_open_mode_runs_untimed_and_retakes() { + let room = exam_room_fixture(600_000).await; + + // A second, open exam in the same course: two sittings, no window. + let exam: Value = room + .teacher + .post(format!("{}/courses/{}/exams", room.base, room.course_id)) + .json(&json!({ + "title": "practice", "kind": "quiz", "weight": 1, + "mode": "open", "max_attempts": 2, + })) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + let exam_id = exam["id"].as_str().unwrap().to_string(); + let question: Value = room + .teacher + .post(format!("{}/exams/{exam_id}/questions", room.base)) + .json(&json!({ "text": "3 + 3?", "kind": "choice", "points": 5, + "choices": ["5", "6"], "correct": 1 })) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + let question_id = question["id"].as_str().unwrap().to_string(); + + let res = room + .student + .post(format!("{}/exams/{exam_id}/attempt", room.base)) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::CREATED); + + let mut ws = ws_open(&room.base, &exam_id, Some(&room.cookie)) + .await + .expect("open-mode room"); + let state = ws_next_frame(&mut ws).await.expect("connect state"); + assert_eq!(state["status"], "in_progress", "{state}"); + assert_eq!(state["attempt"], 1, "{state}"); + assert!(state["deadline"].is_null(), "{state}"); + assert!(state["remaining_ms"].is_null(), "{state}"); + + ws_send( + &mut ws, + json!({ "type": "answer", "question_id": question_id, "selected": 1 }), + ) + .await; + ws_frame_of_type(&mut ws, "saved").await; + ws_send(&mut ws, json!({ "type": "finish" })).await; + ws_frame_of_type(&mut ws, "finished").await; + assert!(ws_next_frame(&mut ws).await.is_none(), "room closes"); + + // Retake: sitting #2, blank sheet, fresh room. + let res = room + .student + .post(format!("{}/exams/{exam_id}/attempt", room.base)) + .send() + .await + .unwrap(); + assert_eq!(res.status(), StatusCode::CREATED); + let body: Value = res.json().await.unwrap(); + assert_eq!(body["attempt"], 2); + assert_eq!(body["answered"], 0); + + let mut ws = ws_open(&room.base, &exam_id, Some(&room.cookie)) + .await + .expect("room for the retake"); + let state = ws_next_frame(&mut ws).await.expect("state"); + assert_eq!(state["attempt"], 2, "{state}"); + assert_eq!(state["answered"], 0, "{state}"); + ws.close(None).await.unwrap(); +} diff --git a/tests/integration.rs b/tests/integration.rs index 337cecc..6de09a8 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -73,7 +73,15 @@ async fn register_validates_input() { } // Interior characters are an allowlist: lowercase, digits, . _ - only. - for bad in ["a b", "a\nb", "a\u{1b}[31mb", "ac", "a@b.c", "a/b", "a\"b"] { + for bad in [ + "a b", + "a\nb", + "a\u{1b}[31mb", + "ac", + "a@b.c", + "a/b", + "a\"b", + ] { let ugly = json!({ "username": bad, "password": "secret1" }); let res = send(&app, "POST", "/auth/register", None, Some(ugly)).await; assert_eq!(res.status, StatusCode::BAD_REQUEST, "{bad:?} accepted"); @@ -123,7 +131,10 @@ async fn register_rejects_reserved_usernames() { let res = send(&app, "POST", "/auth/register", None, Some(creds)).await; assert_eq!(res.status, StatusCode::BAD_REQUEST, "{name} accepted"); let msg = res.body["error"].as_str().unwrap_or_default(); - assert!(msg.contains("reserved"), "unexpected error for {name}: {msg}"); + assert!( + msg.contains("reserved"), + "unexpected error for {name}: {msg}" + ); } // The reservation is registration-only policy: the seeded bootstrap admin @@ -3425,7 +3436,8 @@ async fn exam_scheduling_validates_and_echoes() { assert_eq!(res.body["mode"], "async"); assert_eq!(res.body["duration_ms"].as_i64(), Some(5_400_000)); - // Unscheduled: every schedule field stays null (pre-schedule behavior). + // Unscheduled: every schedule field stays null (pre-schedule behavior), + // and the attempt policy shows its defaults. let res = create_exam_with( &app, &teacher, @@ -3438,6 +3450,28 @@ async fn exam_scheduling_validates_and_echoes() { assert!(res.body["starts_at"].is_null()); assert!(res.body["ends_at"].is_null()); assert!(res.body["duration_ms"].is_null()); + assert_eq!(res.body["max_attempts"], 1); + assert_eq!(res.body["allow_rejoin"], true); + + // Open: no window at all; an optional per-attempt duration is fine, and + // the attempt policy echoes what was asked for. + let res = create_exam_with( + &app, + &teacher, + &course, + json!({ + "title": "practice", "kind": "quiz", "weight": 1, "mode": "open", + "duration_ms": 5_400_000, "max_attempts": 0, "allow_rejoin": false, + }), + ) + .await; + assert_eq!(res.status, StatusCode::CREATED, "{}", res.body); + assert_eq!(res.body["mode"], "open"); + assert!(res.body["starts_at"].is_null()); + assert!(res.body["ends_at"].is_null()); + assert_eq!(res.body["duration_ms"].as_i64(), Some(5_400_000)); + assert_eq!(res.body["max_attempts"], 0); + assert_eq!(res.body["allow_rejoin"], false); // Inconsistent schedules are rejected as a unit. for (label, body) in [ @@ -3500,6 +3534,24 @@ async fn exam_scheduling_validates_and_echoes() { json!({ "title": "x", "kind": "quiz", "weight": 1, "mode": "sync", "starts_at": now + 3_600_000, "ends_at": now - 3_600_000 }), ), + ( + "open with a window", + json!({ "title": "x", "kind": "quiz", "weight": 1, "mode": "open", + "starts_at": now + 60_000, "ends_at": now + 120_000 }), + ), + ( + "open with only an ends_at", + json!({ "title": "x", "kind": "quiz", "weight": 1, "mode": "open", + "ends_at": now + 120_000 }), + ), + ( + "negative attempt limit", + json!({ "title": "x", "kind": "quiz", "weight": 1, "max_attempts": -1 }), + ), + ( + "attempt limit over the cap", + json!({ "title": "x", "kind": "quiz", "weight": 1, "max_attempts": 101 }), + ), ] { let res = create_exam_with(&app, &teacher, &course, body).await; assert_eq!(res.status, StatusCode::BAD_REQUEST, "{label}: {}", res.body); @@ -4181,6 +4233,316 @@ async fn attempts_cascade_with_exam_and_course_deletion() { ); } +/// An `open` exam is sittable anytime — no window, no deadline — and +/// `max_attempts` meters the retakes: every terminal attempt can be followed +/// by a fresh sitting (blank answer sheet) until the limit is spent, and the +/// limit is live-editable, `0` meaning unlimited. +#[tokio::test] +async fn open_exams_sit_anytime_and_retakes_respect_the_limit() { + let (app, db) = app_and_db().await; + let teacher = login_as(&app, &db, "open_t", "teacher").await; + let student = login(&app, "omer").await; + let student_id = me_id(&app, &student).await; + let course = create_course(&app, &teacher, "practice").await; + enroll(&app, &teacher, &course, &student_id).await; + let exam = scheduled_exam( + &app, + &teacher, + &course, + json!({ "title": "drill", "kind": "quiz", "weight": 1, + "mode": "open", "max_attempts": 2 }), + ) + .await; + let question = create_question( + &app, + &teacher, + &exam, + json!({ "text": "2 + 2?", "kind": "choice", "points": 10, + "choices": ["3", "4"], "correct": 1 }), + ) + .await; + + // First sitting starts right away — no window to wait for — and runs + // without a deadline: it can only end by submission. + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CREATED, "{}", res.body); + assert_eq!(res.body["attempt"], 1); + assert_eq!(res.body["attempts_used"], 1); + assert_eq!(res.body["max_attempts"], 2); + assert_eq!(res.body["status"], "in_progress"); + assert!(res.body["deadline"].is_null()); + assert!(res.body["remaining_ms"].is_null()); + + // Answer, then re-"start": the running attempt resumes (200), same clock. + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt/answers"), + Some(&student), + Some(json!({ "question_id": question, "selected": 1 })), + ) + .await; + assert_eq!(res.status, StatusCode::OK, "{}", res.body); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + assert_eq!(res.body["attempt"], 1); + assert_eq!(res.body["answered"], 1); + + // Submit, then start again: sitting #2, and the retake wiped the sheet. + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt/finish"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK, "{}", res.body); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CREATED, "{}", res.body); + assert_eq!(res.body["attempt"], 2); + assert_eq!(res.body["attempts_used"], 2); + assert_eq!(res.body["answered"], 0, "retake starts from a blank sheet"); + let res = send( + &app, + "GET", + &format!("/exams/{exam}/attempt/questions"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + assert!( + res.body[0]["answer"].is_null(), + "wiped answer resurfaced: {}", + res.body + ); + + // The limit is spent after sitting #2 ends: no third start. + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt/finish"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CONFLICT, "{}", res.body); + + // …until the teacher raises it live. `0` = unlimited: sitting #3 opens. + let res = send( + &app, + "PATCH", + &format!("/exams/{exam}"), + Some(&teacher), + Some(json!({ "max_attempts": 0 })), + ) + .await; + assert_eq!(res.status, StatusCode::OK, "{}", res.body); + assert_eq!(res.body["max_attempts"], 0); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CREATED, "{}", res.body); + assert_eq!(res.body["attempt"], 3); + assert_eq!(res.body["max_attempts"], 0); + + // Lowering the limit below what's used never kills the running attempt — + // it only blocks the next start once this one is over. + let res = send( + &app, + "PATCH", + &format!("/exams/{exam}"), + Some(&teacher), + Some(json!({ "max_attempts": 1 })), + ) + .await; + assert_eq!(res.status, StatusCode::OK); + let res = send( + &app, + "GET", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + assert_eq!(res.body["status"], "in_progress"); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt/finish"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CONFLICT, "{}", res.body); +} + +/// An `open` exam with a `duration_ms` gives each sitting its own countdown +/// (`started_at + duration`), and retakes inside a sync window restart the +/// sheet while the monitor tracks the latest sitting. +#[tokio::test] +async fn open_duration_and_sync_retakes_shape_the_deadline_and_monitor() { + let (app, db) = app_and_db().await; + let teacher = login_as(&app, &db, "dur_t", "teacher").await; + let student = login(&app, "duru").await; + let student_id = me_id(&app, &student).await; + let course = create_course(&app, &teacher, "timing").await; + enroll(&app, &teacher, &course, &student_id).await; + + // Open + duration: the deadline is exactly start + budget. + let timed = scheduled_exam( + &app, + &teacher, + &course, + json!({ "title": "sprint", "kind": "quiz", "weight": 1, + "mode": "open", "duration_ms": 60_000 }), + ) + .await; + let res = send( + &app, + "POST", + &format!("/exams/{timed}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CREATED, "{}", res.body); + let started_at = res.body["started_at"].as_i64().expect("started_at"); + assert_eq!(res.body["deadline"].as_i64(), Some(started_at + 60_000)); + let remaining = res.body["remaining_ms"].as_i64().expect("remaining_ms"); + assert!( + remaining > 0 && remaining <= 60_000, + "remaining {remaining}" + ); + + // Sync exam with retakes: sitting #2 opens inside the window and the + // monitor shows the latest sitting plus the usage count. + let now = Timestamp::now().as_millis(); + let ends = now + 600_000; + let exam = scheduled_exam( + &app, + &teacher, + &course, + json!({ "title": "final", "kind": "final", "weight": 1, + "mode": "sync", "starts_at": now - 1_000, "ends_at": ends, + "max_attempts": 3 }), + ) + .await; + for _ in 0..2 { + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CREATED, "{}", res.body); + assert_eq!(res.body["deadline"].as_i64(), Some(ends)); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt/finish"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK, "{}", res.body); + } + let res = send( + &app, + "GET", + &format!("/exams/{exam}/live"), + Some(&teacher), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + assert_eq!(res.body["counts"]["submitted"], 1); + let row = &res.body["students"][0]; + assert_eq!(row["user"]["username"], "duru"); + assert_eq!(row["attempt"], 2); + assert_eq!(row["attempts_used"], 2); + assert!(row["left_at"].is_null()); + + // The third sitting is the last: the window still gates retakes, so once + // it shuts (or the limit is spent) starting conflicts. + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CREATED); + assert_eq!(res.body["attempt"], 3); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt/finish"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::OK); + let res = send( + &app, + "POST", + &format!("/exams/{exam}/attempt"), + Some(&student), + None, + ) + .await; + assert_eq!(res.status, StatusCode::CONFLICT, "{}", res.body); +} + #[tokio::test] async fn live_stream_is_sse_and_teacher_scoped() { let (app, db) = app_and_db().await; @@ -6495,14 +6857,7 @@ async fn search_rejects_a_blank_query() { login(&app, "alice").await; // Whitespace-only (url-encoded spaces) -> 400, not the full user list. - let res = send( - &app, - "GET", - "/users/search?q=%20%20", - Some(&teacher), - None, - ) - .await; + let res = send(&app, "GET", "/users/search?q=%20%20", Some(&teacher), None).await; assert_eq!(res.status, StatusCode::BAD_REQUEST); // Missing `q` entirely is a deserialization failure, not a wildcard. @@ -6604,8 +6959,8 @@ async fn settings_validation_rejects_bad_lists_and_bands() { let manager = login_as(&app, &db, "val.manager", "manager").await; let bad = [ - json!({ "exam_kinds": [] }), // a school needs at least one kind - json!({ "exam_kinds": [" "] }), // blank entry + json!({ "exam_kinds": [] }), // a school needs at least one kind + json!({ "exam_kinds": [" "] }), // blank entry json!({ "exam_kinds": ["Lab", "lab"] }), // case-insensitive duplicate json!({ "attendance_statuses": ["present", "absent", "late"] }), // core dropped json!({ "grade_bands": [{ "min": 50, "label": "CC" }] }), // no band starts at 0 @@ -6615,7 +6970,14 @@ async fn settings_validation_rejects_bad_lists_and_bands() { json!({ "grade_bands": [{ "min": 0, "label": " " }] }), ]; for body in bad { - let res = send(&app, "PATCH", "/settings", Some(&manager), Some(body.clone())).await; + let res = send( + &app, + "PATCH", + "/settings", + Some(&manager), + Some(body.clone()), + ) + .await; assert_eq!(res.status, StatusCode::BAD_REQUEST, "should reject {body}"); } @@ -6860,7 +7222,14 @@ async fn terms_crud_gates_and_links_to_courses() { "starts_at": 1_600_000_000_000_i64, "ends_at": 1_610_000_000_000_i64, }); - let res = send(&app, "POST", "/terms", Some(&teacher), Some(past_term.clone())).await; + let res = send( + &app, + "POST", + "/terms", + Some(&teacher), + Some(past_term.clone()), + ) + .await; assert_eq!(res.status, StatusCode::FORBIDDEN); let res = send(&app, "POST", "/terms", Some(&manager), Some(past_term)).await; assert_eq!(res.status, StatusCode::CREATED); @@ -6954,11 +7323,25 @@ async fn terms_crud_gates_and_links_to_courses() { assert_eq!(res.body["term"].as_str(), Some(term.as_str())); // Deleting the term unlinks its courses but never deletes them. - let res = send(&app, "DELETE", &format!("/terms/{term}"), Some(&manager), None).await; + let res = send( + &app, + "DELETE", + &format!("/terms/{term}"), + Some(&manager), + None, + ) + .await; assert_eq!(res.status, StatusCode::NO_CONTENT); let res = send(&app, "GET", &format!("/terms/{term}"), Some(&student), None).await; assert_eq!(res.status, StatusCode::NOT_FOUND); - let res = send(&app, "GET", &format!("/courses/{course}"), Some(&teacher), None).await; + let res = send( + &app, + "GET", + &format!("/courses/{course}"), + Some(&teacher), + None, + ) + .await; assert_eq!(res.status, StatusCode::OK); assert_eq!(res.body["title"], "History II"); assert_eq!(res.body["term"], serde_json::Value::Null); @@ -7088,14 +7471,39 @@ async fn terms_list_newest_first_require_auth_and_unlink_in_bulk() { .await; let unrelated = id_of(&res.body); - let res = send(&app, "DELETE", &format!("/terms/{newer}"), Some(&manager), None).await; + let res = send( + &app, + "DELETE", + &format!("/terms/{newer}"), + Some(&manager), + None, + ) + .await; assert_eq!(res.status, StatusCode::NO_CONTENT); for course in &linked { - let res = send(&app, "GET", &format!("/courses/{course}"), Some(&teacher), None).await; - assert_eq!(res.body["term"], serde_json::Value::Null, "unlinked {course}"); + let res = send( + &app, + "GET", + &format!("/courses/{course}"), + Some(&teacher), + None, + ) + .await; + assert_eq!( + res.body["term"], + serde_json::Value::Null, + "unlinked {course}" + ); } - let res = send(&app, "GET", &format!("/courses/{unrelated}"), Some(&teacher), None).await; + let res = send( + &app, + "GET", + &format!("/courses/{unrelated}"), + Some(&teacher), + None, + ) + .await; assert_eq!(res.body["term"].as_str(), Some(older.as_str())); }