Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(openhuman-embed): adapt event assertions to enum-based channel events

Steven Enamakel3b947e0c0ad8
diff --git a/crates/openhuman-embed/tests/facades.rs b/crates/openhuman-embed/tests/facades.rs
index 6004c61ecc..ab69389ac0 100644
--- a/crates/openhuman-embed/tests/facades.rs
+++ b/crates/openhuman-embed/tests/facades.rs
@@ -8,7 +8,7 @@ use openhuman_embed::artifacts::{
create_artifact, finalize_artifact, resolve_ready_file, ArtifactKind, ArtifactStatus, FileRoots,
};
use openhuman_embed::chat_surface::{
- publish_web_channel_event, subscribe_web_channel_events, WebChannelEvent,
+ publish_web_channel_event, subscribe_web_channel_events, WebChannelEvent, WebEventContext,
};
use openhuman_embed::identity::{peek_credential_user_identity, UserIdentity};
@@ -74,22 +74,32 @@ async fn an_artifact_resolves_only_once_ready_and_only_under_its_roots() {
#[tokio::test]
async fn web_channel_events_reach_a_subscriber_with_a_timestamp() {
let mut events = subscribe_web_channel_events();
- publish_web_channel_event(WebChannelEvent {
- event: "facade_probe".into(),
- thread_id: "thread-facade".into(),
- ..WebChannelEvent::default()
+ publish_web_channel_event(WebChannelEvent::UserError {
+ context: WebEventContext {
+ client_id: "facade".into(),
+ thread_id: "thread-facade".into(),
+ request_id: "facade-request".into(),
+ ..WebEventContext::default()
+ },
+ error_type: Some("facade_probe".into()),
+ error_source: None,
});
let received = loop {
let event = tokio::time::timeout(Duration::from_secs(5), events.recv())
.await
.expect("an event arrives")
.expect("bus open");
- if event.event == "facade_probe" {
+ if matches!(
+ event.wire_event(),
+ WebChannelEvent::UserError {
+ error_type: Some(error_type), ..
+ } if error_type == "facade_probe"
+ ) {
break event;
}
};
- assert_eq!(received.thread_id, "thread-facade");
- assert!(received.ts.is_some(), "the publisher stamps ts");
+ assert_eq!(received.context().thread_id, "thread-facade");
+ assert!(received.context().ts.is_some(), "the publisher stamps ts");
}
#[test]
diff --git a/crates/openhuman-embed/tests/profile_host_capabilities.rs b/crates/openhuman-embed/tests/profile_host_capabilities.rs
index 0ee50149a6..3abcfcc83a 100644
--- a/crates/openhuman-embed/tests/profile_host_capabilities.rs
+++ b/crates/openhuman-embed/tests/profile_host_capabilities.rs
@@ -330,7 +330,7 @@ async fn scenario() {
tokio::time::timeout(Duration::from_secs(30), async {
loop {
let event = events.recv().await.unwrap();
- if event.event == "channel_outbound" {
+ if event.event_name() == "channel_outbound" {
break;
}
}
diff --git a/crates/openhuman-embed/tests/saas_profiles.rs b/crates/openhuman-embed/tests/saas_profiles.rs
index f505375143..0f7ed214d1 100644
--- a/crates/openhuman-embed/tests/saas_profiles.rs
+++ b/crates/openhuman-embed/tests/saas_profiles.rs
@@ -193,19 +193,21 @@ async fn scenario() {
let outbound = tokio::time::timeout(TURN, async {
loop {
let event = bob_events.recv().await.expect("bob's events");
- if event.event == "channel_outbound" {
+ if event.event_name() == "channel_outbound" {
return event;
}
}
})
.await
.expect("bob's relayed reply");
- assert_eq!(outbound.thread_id, relayed.thread_id);
+ assert_eq!(outbound.context().thread_id, relayed.thread_id);
assert!(
- outbound
- .full_response
- .as_deref()
- .is_some_and(|t| t.contains("hello from telegram")),
+ matches!(
+ outbound.wire_event(),
+ openhuman_embed::chat_surface::WebChannelEvent::ChannelOutbound {
+ full_response: Some(text), ..
+ } if text.contains("hello from telegram")
+ ),
"{outbound:?}"
);
let again = bob_h
@@ -239,7 +241,7 @@ async fn scenario() {
while let Ok(Some(event)) =
tokio::time::timeout(Duration::from_millis(50), alice_events.recv()).await
{
- assert_ne!(event.thread_id, relayed.thread_id, "leaked: {event:?}");
+ assert_ne!(event.context().thread_id, relayed.thread_id, "leaked: {event:?}");
}
// ── the process is locked to SaaS ───────────────────────────────────