File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ jobs:
113113 - '**/*.sh'
114114 - '**/*.ps1'
115115 - '**/*.feature'
116+ - 'tests/e2e-cucumber/expectations.toml'
116117 - 'install*'
117118 - '.github/workflows/**'
118119 # THIRD_PARTY_NOTICES.txt staleness gate: anything that changes the
Original file line number Diff line number Diff line change @@ -6,8 +6,37 @@ pub mod capability;
66pub mod expectation;
77pub mod mock_server;
88
9+ pub fn chat_response_is_successful ( response : & serde_json:: Value ) -> bool {
10+ response
11+ . get ( "choices" )
12+ . and_then ( serde_json:: Value :: as_array)
13+ . is_some_and ( |choices| !choices. is_empty ( ) )
14+ }
15+
916// The report generator lives in its own lean crate (only maud + serde) so xtask
1017// can reuse it without pulling this harness's heavy tree. Re-export it under the
1118// original path so `e2e_cucumber::report::{generate, evaluate_xfail}` call sites
1219// keep working.
1320pub use e2e_report as report;
21+
22+ #[ cfg( test) ]
23+ mod tests {
24+ use super :: chat_response_is_successful;
25+
26+ #[ test]
27+ fn chat_success_requires_non_empty_choices_array ( ) {
28+ assert ! ( !chat_response_is_successful( & serde_json:: json!( { } ) ) ) ;
29+ assert ! ( !chat_response_is_successful(
30+ & serde_json:: json!( { "choices" : null} )
31+ ) ) ;
32+ assert ! ( !chat_response_is_successful(
33+ & serde_json:: json!( { "choices" : { } } )
34+ ) ) ;
35+ assert ! ( !chat_response_is_successful(
36+ & serde_json:: json!( { "choices" : [ ] } )
37+ ) ) ;
38+ assert ! ( chat_response_is_successful(
39+ & serde_json:: json!( { "choices" : [ { } ] } )
40+ ) ) ;
41+ }
42+ }
Original file line number Diff line number Diff line change @@ -54,7 +54,12 @@ async fn send_chat_with_tools(world: &mut E2eWorld) {
5454 . to_string ( ) ;
5555
5656 let chat_url = format ! ( "{endpoint}/chat/completions" ) ;
57- let client = reqwest:: Client :: new ( ) ;
57+ let client = reqwest:: Client :: builder ( )
58+ . timeout ( std:: time:: Duration :: from_secs (
59+ crate :: inference_timeout_for ( world) ,
60+ ) )
61+ . build ( )
62+ . expect ( "failed to build HTTP client" ) ;
5863 let chat_resp: serde_json:: Value = client
5964 . post ( & chat_url)
6065 . json ( & serde_json:: json!( {
@@ -152,8 +157,8 @@ async fn assert_privacy_notice_accurate(_world: &mut E2eWorld) {
152157async fn assert_chat_successful ( world : & mut E2eWorld ) {
153158 let resp = world. chat_response . as_ref ( ) . expect ( "no chat response" ) ;
154159 assert ! (
155- resp . get ( "choices" ) . is_some ( ) ,
156- "no choices in response: {resp}"
160+ e2e_cucumber :: chat_response_is_successful ( resp ) ,
161+ "no non-empty choices array in response: {resp}"
157162 ) ;
158163}
159164
You can’t perform that action at this time.
0 commit comments