From 6d68754d4e4ba980f6790d31796e2b4ae4b54b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 26 Sep 2026 02:10:44 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test(integration):=20reconcile?= =?UTF-8?q?=20two=20stale=20assertions=20with=20shipped=20behavior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bank_question_create_get_list_and_instantiate: d8dad92 documented malformed filter values as a 400 naming the field (mirroring OfferingFilter) — the ?subject=nope arm now asserts that 400 instead of the old empty envelope, and the excludes-intent moved to a valid uuid. chat_rate_limit_refuses_before_anything_is_written: 51e5c7b raised the shipped budgets 100x, so the 20/min premise never trips. The test now pins a low limit via chat_app_limited and still proves the limiter refuses before anything is written. Full suite: 368 passed / 0 failed. Local-Gate: d506ed3a00826385b16be6de5d27a206c6498657 (1629 passed, 592s) --- tests/integration.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 26875c7..6a9d9e7 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -18040,9 +18040,14 @@ async fn chat_content_is_required_and_capped_by_the_school() { async fn chat_rate_limit_refuses_before_anything_is_written() { // 20 messages a minute per user (the documented tier). The limiter is // charged first, so the refused turn leaves no row behind — and no other - // user inherits the window. + // user inherits the window. The tier is pinned, not the shipped default: + // production budgets are far higher, and the test wants the refusal a + // couple of turns away, not two thousand. + use hezarfen_backend::rate_limit::UserRateLimiter; + let ai = chat_bridge().await; - let (app, db) = chat_app(Some(ai.bridge.clone())).await; + let (app, db) = + chat_app_limited(Some(ai.bridge.clone()), UserRateLimiter::per_user_minute(20)).await; let ali = login(&app, "ali").await; let thread = new_thread(&app, &ali).await; @@ -19905,7 +19910,9 @@ async fn bank_question_create_get_list_and_instantiate() { let res = send(&app, "GET", "/bank-questions", Some(&teacher), None).await; assert_eq!(common::items(&res.body).len(), 1); - // `?subject=` matches, and a foreign id excludes. + // `?subject=` matches, a valid foreign id excludes — and a malformed key + // is the 400 that names the field, never a silent empty page (the same + // rule the offerings filter follows). let res = send( &app, "GET", @@ -19918,12 +19925,22 @@ async fn bank_question_create_get_list_and_instantiate() { let res = send( &app, "GET", - "/bank-questions?subject=nope", + &format!("/bank-questions?subject={}", Uuid::new_v4()), Some(&teacher), None, ) .await; assert_eq!(common::items(&res.body).len(), 0); + let res = send( + &app, + "GET", + "/bank-questions?subject=nope", + Some(&teacher), + None, + ) + .await; + assert_eq!(res.status, StatusCode::BAD_REQUEST, "{}", res.body); + assert_eq!(res.body["error"], "subject: must be a hyphenated uuid"); // Instantiate into an exam under one of the course's subjects. let now = Timestamp::now().as_millis();