Files
claw/tests/runtime_profile_test.rs
2026-03-30 08:29:44 +08:00

56 lines
2.0 KiB
Rust

use sgclaw::runtime::{RuntimeEngine, RuntimeProfile, ToolPolicy};
use sgclaw::config::{BrowserBackend, OfficeBackend, PlannerMode, SgClawSettings};
#[test]
fn browser_attached_profile_exposes_browser_surface_without_becoming_browser_only() {
let profile = RuntimeProfile::BrowserAttached;
let policy = ToolPolicy::for_profile(profile);
assert!(policy.allowed_tools.contains(&"browser_action".to_string()));
assert!(policy
.allowed_tools
.contains(&"superrpa_browser".to_string()));
assert!(policy.may_use_non_browser_tools);
}
#[test]
fn general_assistant_profile_does_not_require_browser_surface() {
let profile = RuntimeProfile::GeneralAssistant;
let policy = ToolPolicy::for_profile(profile);
assert!(!policy.requires_browser_surface);
}
#[test]
fn browser_attached_export_prompt_requires_openxml_completion() {
let engine = RuntimeEngine::new(RuntimeProfile::BrowserAttached);
let instruction = engine.build_instruction(
"读取知乎热榜数据,并导出 excel 文件",
Some("https://www.zhihu.com/hot"),
Some("知乎热榜"),
true,
);
assert!(instruction.contains("must call openxml_office"));
assert!(instruction.contains("Do not stop after describing how you will parse"));
assert!(instruction.contains("Never fabricate, simulate, or invent substitute hotlist data"));
assert!(instruction.contains("Do not repeat the same sentence or section"));
assert!(instruction.contains("final answer must include the generated local .xlsx path"));
}
#[test]
fn legacy_settings_default_to_plan_first_superrpa_and_openxml_backends() {
let settings = SgClawSettings::from_legacy_deepseek_fields(
"sk-test".to_string(),
"https://api.deepseek.com".to_string(),
"deepseek-chat".to_string(),
None,
)
.unwrap();
assert_eq!(settings.planner_mode, PlannerMode::ZeroclawPlanFirst);
assert_eq!(settings.browser_backend, BrowserBackend::SuperRpa);
assert_eq!(settings.office_backend, OfficeBackend::OpenXml);
}