The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(web_chat): migrate event assertions to typed accessors
Steven Enamakelf081a26da46b
diff --git a/crates/openhuman-core/src/channels/providers/relay/channel_tests.rs b/crates/openhuman-core/src/channels/providers/relay/channel_tests.rsindex cc372029d9..64e8e9e36a 100644--- a/crates/openhuman-core/src/channels/providers/relay/channel_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/channel_tests.rs@@ -14,18 +14,24 @@ fn sink() -> RelayChannel {#[test]fn the_outbound_event_names_the_chat_and_carries_the_text() {let event = sink().outbound_event(&SendMessage::new("hi there", "-100"));- assert_eq!(event.event, CHANNEL_OUTBOUND_EVENT);- assert_eq!(event.client_id, "gw-1");- assert_eq!(event.thread_id, "channel:telegram/42/-100");- assert_eq!(event.request_id, "req-1");- assert_eq!(event.full_response.as_deref(), Some("hi there"));- let structured = event.structured.expect("structured");+ assert_eq!(event.event_name(), CHANNEL_OUTBOUND_EVENT);+ assert_eq!(event.context().client_id, "gw-1");+ assert_eq!(event.context().thread_id, "channel:telegram/42/-100");+ assert_eq!(event.context().request_id, "req-1");+ let (full_response, structured) = match event {+ crate::web_chat::WebChannelEvent::ChannelOutbound {+ full_response,+ structured,+ ..+ } => (full_response, structured),+ other => panic!("expected channel_outbound event, got {other:?}"),+ };+ assert_eq!(full_response.as_deref(), Some("hi there"));+ let structured = structured.expect("structured");assert_eq!(structured["kind"], CHANNEL_OUTBOUND_EVENT);assert_eq!(structured["channel"], "telegram");assert_eq!(structured["chat_id"], "-100");assert_eq!(structured["reply_to_message_id"], "m-1");- assert!(event.agent.is_none(), "stamped at publish, not here");- assert!(event.profile.is_none(), "stamped at publish, not here");let wire = serde_json::to_value(sink().outbound_event(&SendMessage::new("x", "-100"))).expect("serialize");@@ -67,11 +73,11 @@ async fn send_publishes_under_the_callers_stamp_and_records_the_text() {let event = loop {let event = events.recv().await.expect("event");- if event.request_id == "req-stamp" {+ if event.context().request_id == "req-stamp" {break event;}};- assert_eq!(event.event, CHANNEL_OUTBOUND_EVENT);+ assert_eq!(event.event_name(), CHANNEL_OUTBOUND_EVENT);assert_eq!(event.agent.as_deref(), Some("u-relay-test"));assert!(event.belongs_to("u-relay-test"));assert!(!event.belongs_to("u-someone-else"));diff --git a/crates/openhuman-core/src/core/runtime/subscribers_tests.rs b/crates/openhuman-core/src/core/runtime/subscribers_tests.rsindex 6765b7b61d..51a78d423b 100644--- a/crates/openhuman-core/src/core/runtime/subscribers_tests.rs+++ b/crates/openhuman-core/src/core/runtime/subscribers_tests.rs@@ -252,21 +252,19 @@ fn proactive_message_reaches_web_on_channelless_core_boot() {.recv().await.expect("web event stream should remain open");- if event.event == "proactive_message"- && event.full_response.as_deref()- == Some("Your morning briefing is ready.")- {+ if matches!(+ event.wire_event(),+ crate::web_chat::WebChannelEvent::ProactiveMessage {+ full_response, ..+ } if full_response == "Your morning briefing is ready."+ ) {break event;}}}).await.expect("proactive message should reach the web event stream");- assert_eq!(event.event, "proactive_message");- assert_eq!(- event.full_response.as_deref(),- Some("Your morning briefing is ready.")- );+ assert_eq!(event.event_name(), "proactive_message");});return;}@@ -350,21 +348,19 @@ fn proactive_message_is_scoped_to_originating_saas_profile() {.recv().await.expect("web event stream should remain open");- if event.event == "proactive_message"- && event.full_response.as_deref()- == Some("Your morning briefing is ready.")- {+ if matches!(+ event.wire_event(),+ crate::web_chat::WebChannelEvent::ProactiveMessage {+ full_response, ..+ } if full_response == "Your morning briefing is ready."+ ) {break event;}}}).await.expect("proactive message should reach the web event stream");- assert_eq!(event.event, "proactive_message");- assert_eq!(- event.full_response.as_deref(),- Some("Your morning briefing is ready.")- );+ assert_eq!(event.event_name(), "proactive_message");assert!(event.belongs_to_profile("proactive-test"));assert!(!event.belongs_to_profile("another-profile"));});diff --git a/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs b/crates/openhuman-core/src/flows/ops_builder_repair_tests.rsindex c69b242e18..7d7e0db82c 100644--- a/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs+++ b/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs@@ -100,17 +100,18 @@ fn repair_backend_failure_returns_no_proposal_before_starting_the_builder() {let done = loop {match events.try_recv() {- Ok(event) if event.request_id == request_id => break event,+ Ok(event) if event.context().request_id == request_id => break event,Ok(_) | Err(tokio::sync::broadcast::error::TryRecvError::Lagged(_)) => continue,Err(error) => panic!("missing streamed backend-repair event: {error}"),}};- assert_eq!(done.event, "chat_done");- assert_eq!(done.thread_id, "backend-repair-thread");- assert!(done- .full_response- .as_deref()- .expect("terminal response text")- .contains("workflow was not changed"));+ assert_eq!(done.event_name(), "chat_done");+ assert_eq!(done.context().thread_id, "backend-repair-thread");+ assert!(matches!(+ done.wire_event(),+ crate::web_chat::WebChannelEvent::ChatDone {+ full_response, ..+ } if full_response.contains("workflow was not changed")+ ));});}diff --git a/crates/openhuman-core/src/profiles/lease_tests.rs b/crates/openhuman-core/src/profiles/lease_tests.rsindex 1f97068c42..dcfe74d96f 100644--- a/crates/openhuman-core/src/profiles/lease_tests.rs+++ b/crates/openhuman-core/src/profiles/lease_tests.rs@@ -212,8 +212,11 @@ async fn renewal_keeps_the_lease_and_a_lost_lease_fences_the_profile() {let cancelled_for = tokio::time::timeout(Duration::from_secs(10), async {loop {match events.recv().await {- Ok(event) if event.event == "chat_cancelled" && event.thread_id == "t1" => {- return event.client_id;+ Ok(event)+ if event.event_name() == "chat_cancelled"+ && event.context().thread_id == "t1" =>+ {+ return event.context().client_id.clone();}Ok(_) | Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => continue,Err(error) => panic!("event stream closed: {error}"),