use crate::app::tests::Harness;
use crate::nav::tabs::Kind;
#[test]
fn the_raised_wall_resolves_before_the_derivation_reads_it() {
let mut h = Harness::new();
let (_c, mut rig) = h.model();
let raised = h.mint_named("ops", "c-9");
assert!(
!rig.model.workspaces().iter().any(|w| w.path == raised),
"the derivation has not read it — that is the whole premise"
);
rig.model.adopt_workspace(&raised);
assert_eq!(rig.model.focused_ws_name().as_deref(), Some("ops"));
assert_eq!(
rig.model.focused_workspace(),
Some(raised.clone()),
"the claim resolves the name the enumeration cannot"
);
assert_eq!(
rig.model.start_bare_inputs().workspace,
raised,
"so the composer's bare Enter fires into the wall just raised (bl-9acf)"
);
assert!(
rig.model
.focused_tree()
.is_some_and(|t| t.agents.is_empty()),
"and the centre pane paints an empty workspace, not a blank frame"
);
let bar = rig.tab_bar();
assert!(
bar.tabs
.iter()
.any(|t| t.name == "ops" && t.selected && t.kind == Kind::Named),
"the wall wears its own selected tab: {bar:?}"
);
}
#[test]
fn the_derivation_showing_the_wall_retires_the_claim() {
let mut h = Harness::new();
let (_c, mut rig) = h.model();
let raised = h.mint_named("ops", "c-9");
rig.model.adopt_workspace(&raised);
rig.tick();
assert_eq!(
rig.model
.workspaces()
.iter()
.filter(|w| w.path == raised)
.count(),
1,
"enumerated once — the claim went as the derivation arrived"
);
assert_eq!(
rig.model.focused_workspace(),
Some(raised),
"and the focus resolves off the derivation now, unchanged"
);
}
#[test]
fn a_start_into_an_enumerated_workspace_claims_nothing() {
let h = Harness::new();
let (_c, mut rig) = h.model();
let before = rig.model.workspaces().len();
rig.model.adopt_workspace(&h.ws);
assert_eq!(rig.model.focused_ws_name().as_deref(), Some("ws"));
assert_eq!(
rig.model.workspaces().len(),
before,
"nothing was folded: the derivation already showed it"
);
assert_eq!(rig.model.focused_workspace(), Some(h.ws.clone()));
}
#[test]
fn the_claim_never_doubles_a_wall_the_answer_already_carries() {
let mut h = Harness::new();
let (_c, mut rig) = h.model();
let raised = h.mint_named("ops", "c-9");
rig.model.adopt_workspace(&raised);
let claimed = crate::test_support::chrome::ws_rows(&rig.model);
assert_eq!(
claimed.iter().filter(|r| r.workspace == "ops").count(),
1,
"the claim leads the wall into the listing"
);
let answered = rig.model.raised_rows(claimed.clone());
assert_eq!(
answered.iter().filter(|r| r.workspace == "ops").count(),
1,
"and adds nothing to a listing that already has it"
);
assert_eq!(answered.len(), claimed.len(), "no row moved either");
}