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() {
18040 async fn chat_rate_limit_refuses_before_anything_is_written() {18040 async fn chat_rate_limit_refuses_before_anything_is_written() {
18041 // 20 messages a minute per user (the documented tier). The limiter is18041 // 20 messages a minute per user (the documented tier). The limiter is
18042 // charged first, so the refused turn leaves no row behind — and no other18042 // 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+
18044 let ai = chat_bridge().await;18048 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;
18046 let ali = login(&app, "ali").await;18051 let ali = login(&app, "ali").await;
18047 let thread = new_thread(&app, &ali).await;18052 let thread = new_thread(&app, &ali).await;
18048 18053
@@ -19905,7 +19910,9 @@ async fn bank_question_create_get_list_and_instantiate() {
19905 let res = send(&app, "GET", "/bank-questions", Some(&teacher), None).await;19910 let res = send(&app, "GET", "/bank-questions", Some(&teacher), None).await;
19906 assert_eq!(common::items(&res.body).len(), 1);19911 assert_eq!(common::items(&res.body).len(), 1);
19907 19912
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).
19909 let res = send(19916 let res = send(
19910 &app,19917 &app,
19911 "GET",19918 "GET",
@@ -19918,12 +19925,22 @@ async fn bank_question_create_get_list_and_instantiate() {
19918 let res = send(19925 let res = send(
19919 &app,19926 &app,
19920 "GET",19927 "GET",
19921- "/bank-questions?subject=nope",19928+ &format!("/bank-questions?subject={}", Uuid::new_v4()),
19922 Some(&teacher),19929 Some(&teacher),
19923 None,19930 None,
19924 )19931 )
19925 .await;19932 .await;
19926 assert_eq!(common::items(&res.body).len(), 0);19933 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");
19927 19944
19928 // Instantiate into an exam under one of the course's subjects.19945 // Instantiate into an exam under one of the course's subjects.
19929 let now = Timestamp::now().as_millis();19946 let now = Timestamp::now().as_millis();