Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jobs:
- '**/*.sh'
- '**/*.ps1'
- '**/*.feature'
- 'tests/e2e-cucumber/expectations.toml'
- 'install*'
- '.github/workflows/**'
# THIRD_PARTY_NOTICES.txt staleness gate: anything that changes the
Expand Down
29 changes: 29 additions & 0 deletions tests/e2e-cucumber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,37 @@ pub mod capability;
pub mod expectation;
pub mod mock_server;

pub fn chat_response_is_successful(response: &serde_json::Value) -> bool {
response
.get("choices")
.and_then(serde_json::Value::as_array)
.is_some_and(|choices| !choices.is_empty())
}

// The report generator lives in its own lean crate (only maud + serde) so xtask
// can reuse it without pulling this harness's heavy tree. Re-export it under the
// original path so `e2e_cucumber::report::{generate, evaluate_xfail}` call sites
// keep working.
pub use e2e_report as report;

#[cfg(test)]
mod tests {
use super::chat_response_is_successful;

#[test]
fn chat_success_requires_non_empty_choices_array() {
assert!(!chat_response_is_successful(&serde_json::json!({})));
assert!(!chat_response_is_successful(
&serde_json::json!({"choices": null})
));
assert!(!chat_response_is_successful(
&serde_json::json!({"choices": {}})
));
assert!(!chat_response_is_successful(
&serde_json::json!({"choices": []})
));
assert!(chat_response_is_successful(
&serde_json::json!({"choices": [{}]})
));
}
}
11 changes: 8 additions & 3 deletions tests/e2e-cucumber/tests/e2e/chat_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ async fn send_chat_with_tools(world: &mut E2eWorld) {
.to_string();

let chat_url = format!("{endpoint}/chat/completions");
let client = reqwest::Client::new();
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(
crate::inference_timeout_for(world),
))
.build()
.expect("failed to build HTTP client");
let chat_resp: serde_json::Value = client
.post(&chat_url)
.json(&serde_json::json!({
Expand Down Expand Up @@ -152,8 +157,8 @@ async fn assert_privacy_notice_accurate(_world: &mut E2eWorld) {
async fn assert_chat_successful(world: &mut E2eWorld) {
let resp = world.chat_response.as_ref().expect("no chat response");
assert!(
resp.get("choices").is_some(),
"no choices in response: {resp}"
e2e_cucumber::chat_response_is_successful(resp),
"no non-empty choices array in response: {resp}"
);
}

Expand Down
Loading