Reconcile two stale assertions with shipped behavior
Browse files at this commit6d68754d4e4ba980f6790d31796e2b4ae4b54b34Parent: 62f10ea- test
- reconcile two stale assertions with shipped behavior
1 changed file +21 -4
- tests/integration.rs +21 -4
tests/integration.rsmodified+21 -4
| @@ -18040,9 +18040,14 @@ async fn chat_content_is_required_and_capped_by_the_school() { | ||
| 18040 | 18040 | async fn chat_rate_limit_refuses_before_anything_is_written() { |
| 18041 | 18041 | // 20 messages a minute per user (the documented tier). The limiter is |
| 18042 | 18042 | // 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 | 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 | 18051 | let ali = login(&app, "ali").await; |
| 18047 | 18052 | let thread = new_thread(&app, &ali).await; |
| 18048 | 18053 | |
| @@ -19905,7 +19910,9 @@ async fn bank_question_create_get_list_and_instantiate() { | ||
| 19905 | 19910 | let res = send(&app, "GET", "/bank-questions", Some(&teacher), None).await; |
| 19906 | 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 | 19916 | let res = send( |
| 19910 | 19917 | &app, |
| 19911 | 19918 | "GET", |
| @@ -19918,12 +19925,22 @@ async fn bank_question_create_get_list_and_instantiate() { | ||
| 19918 | 19925 | let res = send( |
| 19919 | 19926 | &app, |
| 19920 | 19927 | "GET", |
| 19921 | - "/bank-questions?subject=nope", | |
| 19928 | + &format!("/bank-questions?subject={}", Uuid::new_v4()), | |
| 19922 | 19929 | Some(&teacher), |
| 19923 | 19930 | None, |
| 19924 | 19931 | ) |
| 19925 | 19932 | .await; |
| 19926 | 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 | 19945 | // Instantiate into an exam under one of the course's subjects. |
| 19929 | 19946 | let now = Timestamp::now().as_millis(); |