use super::fixture::world;
use super::painted;
use crate::cli_outbound::Cli;
#[test]
fn an_unselected_workspace_paints_the_birth_config_block() {
let (lernie, bl) = (Cli::new("lernie"), Cli::new("bl"));
let mut world = world();
let ws = world.ws.clone();
world.model.focus_workspace(&ws);
let out = painted(&mut world, &lernie, &bl);
assert!(out.contains("new conversation"), "block heading:\n{out}");
assert!(
out.contains("(none)"),
"the model dropdown shows what the branch head assigns — this world's head \
declares no worker role, and absence is a value:\n{out}"
);
assert!(
!out.contains("change…"),
"the row IS the selection: no affordance stands in front of it:\n{out}"
);
}
#[test]
fn the_work_directory_box_rides_the_block_pre_filled_and_leaves_the_composer() {
let (lernie, bl) = (Cli::new("lernie"), Cli::new("bl"));
let mut world = world();
let ws = world.ws.clone();
world.model.focus_workspace(&ws);
let home = world.state.actions.path_dir.clone();
assert!(!home.is_empty(), "the box is born holding the default");
let out = painted(&mut world, &lernie, &bl);
assert!(out.contains("work directory:"), "the block's row:\n{out}");
assert!(
out.contains(&home),
"pre-filled with the bare rung's own resolution:\n{out}"
);
assert!(
!out.contains("dir (optional)"),
"the composer no longer carries the same fact:\n{out}"
);
}
#[test]
fn a_work_directory_that_is_not_there_flags_red_at_the_field() {
let (lernie, bl) = (Cli::new("lernie"), Cli::new("bl"));
let mut world = world();
let ws = world.ws.clone();
world.model.focus_workspace(&ws);
let clean = painted(&mut world, &lernie, &bl);
assert!(
!clean.contains("work directory does not exist"),
"the seeded default is lawful and silent:\n{clean}"
);
let missing = world.ws.join("nonexistent-uat-dir");
world.state.actions.path_dir = missing.display().to_string();
let flagged = painted(&mut world, &lernie, &bl);
assert!(
flagged.contains(&format!(
"work directory does not exist: {}",
missing.display()
)),
"the refusal names the directory the operator typed:\n{flagged}"
);
assert!(
!flagged.contains("failed to spawn"),
"and nothing spawned to blame a binary for it:\n{flagged}"
);
}
#[test]
fn expanding_the_block_opens_the_one_picker_scoped_to_the_workspace_default() {
let (lernie, bl) = (Cli::new("lernie"), Cli::new("bl"));
let mut world = world();
let ws = world.ws.clone();
world.model.focus_workspace(&ws);
let _ = painted(&mut world, &lernie, &bl);
world.state.wall.picker.open = true;
let out = painted(&mut world, &lernie, &bl);
assert!(
out.contains("workspace default too"),
"the birth scope sentence, not the frozen-conversation one:\n{out}"
);
assert!(
out.contains("about to start"),
"and it names the conversation the pick governs:\n{out}"
);
assert!(
!out.contains("this one stays frozen"),
"the frozen clause names a conversation the block does not have:\n{out}"
);
}