Skip to content

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

chore: files changed crates/openhuman-core/src/config/schema/tools/browser_tests.rs

Steven Enamakela0769218734e
diff --git a/crates/openhuman-core/src/config/schema/tools/browser_tests.rs b/crates/openhuman-core/src/config/schema/tools/browser_tests.rs
new file mode 100644
index 0000000000..e7a6db6487
--- /dev/null
+++ b/crates/openhuman-core/src/config/schema/tools/browser_tests.rs
@@ -0,0 +1,67 @@
+use super::*;
+
+fn with_unattended(actions: &[&str]) -> BrowserConfig {
+ BrowserConfig {
+ unattended_actions: actions.iter().map(|action| (*action).to_owned()).collect(),
+ ..BrowserConfig::default()
+ }
+}
+
+#[test]
+fn unattended_actions_default_to_none() {
+ let config = BrowserConfig::default();
+ assert!(config.unattended_actions.is_empty());
+ for kind in UNATTENDED_BROWSER_ACTIONS {
+ assert!(!config.allows_unattended(kind), "{kind}");
+ }
+}
+
+#[test]
+fn unattended_actions_parse_from_toml_and_default_when_absent() {
+ let parsed: BrowserConfig = toml::from_str(r#"unattended_actions = ["click", "press"]"#).unwrap();
+ assert_eq!(parsed.unattended_actions, vec!["click", "press"]);
+ let absent: BrowserConfig = toml::from_str("enabled = true").unwrap();
+ assert!(absent.unattended_actions.is_empty());
+}
+
+#[test]
+fn only_listed_known_kinds_are_allowed_unattended() {
+ let config = with_unattended(&["click", " Press ", "task_step"]);
+ assert!(config.allows_unattended("click"));
+ assert!(config.allows_unattended("press"));
+ assert!(config.allows_unattended("task_step"));
+ assert!(!config.allows_unattended("fill"));
+ assert!(!config.allows_unattended("type"));
+}
+
+#[test]
+fn unknown_unattended_names_are_reported_and_never_allow_anything() {
+ let config = with_unattended(&["click", "navigate", "hover", "*", ""]);
+ assert_eq!(
+ config.unknown_unattended_actions(),
+ vec!["navigate", "hover", "*", ""]
+ );
+ assert!(!config.allows_unattended("navigate"));
+ assert!(!config.allows_unattended("hover"));
+ assert!(!config.allows_unattended("*"));
+ assert!(with_unattended(&["double_click", "select", "check"])
+ .unknown_unattended_actions()
+ .is_empty());
+}
+
+#[test]
+fn known_unattended_names_match_the_gated_action_wire_names() {
+ assert_eq!(
+ UNATTENDED_BROWSER_ACTIONS,
+ &[
+ "click",
+ "double_click",
+ "fill",
+ "type",
+ "press",
+ "select",
+ "check",
+ "task_step"
+ ]
+ );
+}