Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Tests: list_fonts checks the query's contract, not a count of one (#149)

bflatasticf9b6edb4e81a
diff --git a/crates/automation/src/tests.rs b/crates/automation/src/tests.rs
index dc2a6f1e9..dd236dada 100644
--- a/crates/automation/src/tests.rs
+++ b/crates/automation/src/tests.rs
@@ -400,10 +400,15 @@ fn list_fonts_lists_families_with_styles() {
let all = call_json(&mut s, "list_fonts", json!({}));
let fams = all["families"].as_array().unwrap();
assert!(fams.iter().any(|f| f["family"] == "Inter" && f["origin"] == "bundled"), "{all}");
+ // The query filters by substring: the bundled JetBrains Mono, and any installed family whose
+ // name contains it (JetBrainsMono Nerd Font…) (#149).
let one = call_json(&mut s, "list_fonts", json!({"query": "jetbrains"}));
- assert_eq!(one["count"], 1, "{one}");
- assert_eq!(one["families"][0]["family"], "JetBrains Mono");
- assert!(one["families"][0]["styles"].as_array().unwrap().contains(&json!("Regular")), "{one}");
+ let matched = one["families"].as_array().unwrap();
+ assert_eq!(one["count"].as_u64(), Some(matched.len() as u64), "{one}");
+ assert!(matched.iter().all(|f| f["family"].as_str().unwrap().to_lowercase().contains("jetbrains")), "{one}");
+ assert!(matched.len() < fams.len(), "the query filters: {one}");
+ let mono = matched.iter().find(|f| f["family"] == "JetBrains Mono").unwrap_or_else(|| panic!("{one}"));
+ assert!(mono["styles"].as_array().unwrap().contains(&json!("Regular")), "{one}");
}
/// Trained models over MCP (Roto Brush and face tracking): listed with their authors and
@@ -428,12 +433,7 @@ fn trained_models_over_mcp() {
fn agents_doc_tools_table_is_current() {
// (Checkouts may have CRLF line endings.)
let doc = include_str!("../../../docs/agents.md").replace("\r\n", "\n");
- let table: String = doc
- .split("### Tools")
- .nth(1)
- .and_then(|t| t.split("\n\n").nth(1))
- .unwrap_or_default()
- .to_string();
+ let table: String = doc.split("### Tools").nth(1).and_then(|t| t.split("\n\n").nth(1)).unwrap_or_default().to_string();
assert!(table.starts_with("| Tool |"), "no Tools table");
let mut missing = vec![];
for t in crate::tools::catalogue() {