forge
Explore
Log in

Don't you dare go Hollow

Reconcile two stale assertions with shipped behavior

Browse files at this commit

6d68754d4e4ba980f6790d31796e2b4ae4b54b34Ahmet Kaan GümüşParent: 62f10ea
  • test
    • reconcile two stale assertions with shipped behavior
Show full message
🧪 test(integration): reconcile two stale assertions with shipped behavior

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.rsmodified+21 -4
@@ -18040,9 +18040,14 @@ async fn chat_content_is_required_and_capped_by_the_school() {
1804018040 async fn chat_rate_limit_refuses_before_anything_is_written() {
1804118041 // 20 messages a minute per user (the documented tier). The limiter is
1804218042 // charged first, so the refused turn leaves no row behind — and no other
18043- // user inherits the window.
18043+ // user inherits the window. The tier is pinned, not the shipped default:
18044+ // production budgets are far higher, and the test wants the refusal a
18045+ // couple of turns away, not two thousand.
18046+ use hezarfen_backend::rate_limit::UserRateLimiter;
18047+
1804418048 let ai = chat_bridge().await;
18045- let (app, db) = chat_app(Some(ai.bridge.clone())).await;
18049+ let (app, db) =
18050+ chat_app_limited(Some(ai.bridge.clone()), UserRateLimiter::per_user_minute(20)).await;
1804618051 let ali = login(&app, "ali").await;
1804718052 let thread = new_thread(&app, &ali).await;
1804818053
@@ -19905,7 +19910,9 @@ async fn bank_question_create_get_list_and_instantiate() {
1990519910 let res = send(&app, "GET", "/bank-questions", Some(&teacher), None).await;
1990619911 assert_eq!(common::items(&res.body).len(), 1);
1990719912
19908- // `?subject=` matches, and a foreign id excludes.
19913+ // `?subject=` matches, a valid foreign id excludes — and a malformed key
19914+ // is the 400 that names the field, never a silent empty page (the same
19915+ // rule the offerings filter follows).
1990919916 let res = send(
1991019917 &app,
1991119918 "GET",
@@ -19918,12 +19925,22 @@ async fn bank_question_create_get_list_and_instantiate() {
1991819925 let res = send(
1991919926 &app,
1992019927 "GET",
19921- "/bank-questions?subject=nope",
19928+ &format!("/bank-questions?subject={}", Uuid::new_v4()),
1992219929 Some(&teacher),
1992319930 None,
1992419931 )
1992519932 .await;
1992619933 assert_eq!(common::items(&res.body).len(), 0);
19934+ let res = send(
19935+ &app,
19936+ "GET",
19937+ "/bank-questions?subject=nope",
19938+ Some(&teacher),
19939+ None,
19940+ )
19941+ .await;
19942+ assert_eq!(res.status, StatusCode::BAD_REQUEST, "{}", res.body);
19943+ assert_eq!(res.body["error"], "subject: must be a hyphenated uuid");
1992719944
1992819945 // Instantiate into an exam under one of the course's subjects.
1992919946 let now = Timestamp::now().as_millis();