feat(enhance): discard, tests against a mock ComfyUI, docs (#192)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 authored and cameron committed 2026-10-30 19:41:05 +00:00
1 parent 3a21761cfe
commit 97d9301a71
10 files changed
+1165 -48

No files matched your search

+21 -9
View File
@@ -184,9 +184,7 @@ impl Template {
let user_text = prompt.map(str::trim).filter(|t| !t.is_empty());
match (&self.prompt, user_text) {
(None, Some(_)) => {
return Err(FillError(
"this template doesn't take a prompt".to_string(),
));
return Err(FillError("this template doesn't take a prompt".to_string()));
}
(Some(_), None) if self.prompt_required() => {
return Err(FillError(
@@ -344,7 +342,9 @@ mod tests {
#[test]
fn missing_required_titles_are_rejected_with_a_clear_message() {
let no_source = RESTORE.replace("imageapi:source", "something else");
let err = load(&no_source, PromptMode::Append).unwrap_err().to_string();
let err = load(&no_source, PromptMode::Append)
.unwrap_err()
.to_string();
assert!(err.contains("imageapi:source"), "{err}");
let no_save = RESTORE.replace("imageapi:save", "something else");
let err = load(&no_save, PromptMode::Append).unwrap_err().to_string();
@@ -372,7 +372,9 @@ mod tests {
let mut v: Value = serde_json::from_str(RESTORE).unwrap();
v["13"]["inputs"] = json!({"prompt": "base"});
let t = Template::from_value(cfg("t", PromptMode::Append), v).unwrap();
let f = t.fill("Z:\\a.jpg", Some("more"), None, &mut seeds()).unwrap();
let f = t
.fill("Z:\\a.jpg", Some("more"), None, &mut seeds())
.unwrap();
assert_eq!(input(&f.prompt, "13", "prompt"), "base more");
}
@@ -393,7 +395,9 @@ mod tests {
assert_eq!(input(&f.prompt, "36", "require_approval"), true);
// KSampler.seed and TextGenerate's sampling_mode.seed, both fresh.
let a = input(&f.prompt, "5", "seed").as_u64().unwrap();
let b = input(&f.prompt, "14", "sampling_mode.seed").as_u64().unwrap();
let b = input(&f.prompt, "14", "sampling_mode.seed")
.as_u64()
.unwrap();
assert!(a > 1000 && b > 1000 && a != b);
assert_ne!(a, 774744764437710);
// Two fills with a real RNG differ.
@@ -433,7 +437,9 @@ mod tests {
#[test]
fn default_join_is_a_single_space_sentence() {
let t = load(RESTORE, PromptMode::Append).unwrap();
let f = t.fill("p", Some("Make it warmer."), None, &mut seeds()).unwrap();
let f = t
.fill("p", Some("Make it warmer."), None, &mut seeds())
.unwrap();
let text = input(&f.prompt, "13", "value").as_str().unwrap();
assert!(text.ends_with("Remove any phone interface overlays. Make it warmer."));
}
@@ -444,7 +450,9 @@ mod tests {
let err = t.fill("p", None, None, &mut seeds()).unwrap_err();
assert!(err.0.contains("instruction"));
assert!(t.fill("p", Some(" "), None, &mut seeds()).is_err());
let f = t.fill("p", Some("make it black and white"), None, &mut seeds()).unwrap();
let f = t
.fill("p", Some("make it black and white"), None, &mut seeds())
.unwrap();
assert_eq!(input(&f.prompt, "13", "value"), "make it black and white");
}
@@ -482,7 +490,11 @@ mod tests {
assert!(!wf.contains_key("38"));
// No input anywhere still links to node 38, and the leftover export
// path can't leak.
assert!(!serde_json::to_string(&f.prompt).unwrap().contains("[\"38\""));
assert!(
!serde_json::to_string(&f.prompt)
.unwrap()
.contains("[\"38\"")
);
assert!(wf["36"]["inputs"].get("reference_1").is_none());
// Links to other nodes survive.
assert_eq!(input(&f.prompt, "36", "source"), &json!(["37", 1]));