fix(fermata): empty masked text becomes [fermata]; a Monitor without a command is left alone; tests for the CRLF and JSON-escaped spellings
This commit is contained in:
@@ -301,3 +301,36 @@ fn the_note_stands_beside_the_heuristic_warning() {
|
||||
assert!(context.starts_with(NOTE) && context.contains("WARNING"), "{context}");
|
||||
assert!(!context.contains("ghp_"), "{context}");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Empty text and a Monitor without a command
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn the_absent_style_leaves_no_empty_text() {
|
||||
let p = project(&[(".env", &format!("API_TOKEN={SECRET}\n")), (".botsecrets", &styled("absent"))]);
|
||||
let todo = json!({"oldTodos": [], "newTodos": [{"content": SECRET, "status": "pending", "activeForm": "Working"}]});
|
||||
let out = p.post("TodoWrite", todo);
|
||||
assert_eq!(out["hookSpecificOutput"]["updatedToolOutput"]["newTodos"][0]["content"], "[fermata]", "{out}");
|
||||
|
||||
let mcp = json!({"content": [{"type": "text", "text": SECRET}]});
|
||||
let out = p.post("mcp__srv__t", mcp);
|
||||
assert_eq!(out["hookSpecificOutput"]["updatedToolOutput"]["content"][0]["text"], "[fermata]", "{out}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_monitor_without_a_command_is_left_alone() {
|
||||
let p = project(&[]);
|
||||
let output = Command::cargo_bin("fermata")
|
||||
.unwrap()
|
||||
.args(["hook", "--event", "pre-tool-use", "--harness", "claude"])
|
||||
.current_dir(p.dir.path())
|
||||
.env("HOME", p.home.path())
|
||||
.write_stdin(json!({"tool_name": "Monitor", "tool_input": {"ws": "wss://example.test/x"}}).to_string())
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.clone();
|
||||
assert_eq!(output.stdout, b"{}");
|
||||
assert!(output.stderr.is_empty(), "{}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user