From f9b6edb4e81aa04df6bad77b27c81f74ed1b98ee Mon Sep 17 00:00:00 2001 From: bflatastic Date: Wed, 7 Oct 2026 12:01:30 +0700 Subject: [PATCH] Tests: list_fonts checks the query's contract, not a count of one (#149) With installed families whose names contain the query (JetBrainsMono Nerd Font and its variants) the test expected exactly one match and failed. It now checks that every match contains the query, the count agrees, the query filters, and the bundled JetBrains Mono is there with its Regular style. Co-Authored-By: Claude Opus 5.5 --- crates/automation/src/tests.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/automation/src/tests.rs b/crates/automation/src/tests.rs index dc2a6f1e..dd236dad 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() {