use std::process::Command;
fn smix() -> Command {
Command::new(env!("CARGO_BIN_EXE_smix"))
}
fn wait_for_help() -> String {
let out = smix()
.args(["wait-for", "--help"])
.output()
.expect("run smix");
format!(
"{}{}",
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr)
)
}
#[test]
fn absent_is_a_flag() {
let help = wait_for_help();
assert!(
help.contains("--absent"),
"`smix wait-for` has no `--absent`. MCP has smix_assert_not_visible \
and the CLI has no way to wait for an element to go.\n{help}"
);
}
#[test]
fn absent_help_says_it_waits_until_the_element_is_gone() {
let help = wait_for_help();
assert!(
help.contains("gone") || help.contains("until it is absent") || help.contains("disappear"),
"`--absent`'s help does not say it waits UNTIL the element is gone. \
Read quickly, the flag name alone suggests waiting for something \
that is already absent, which would be a command that returns \
immediately.\n{help}"
);
}
#[test]
fn absent_does_not_exit_zero_when_it_cannot_answer() {
let out = smix()
.args(["wait-for", "id:nothing-here", "--absent", "--port", "1"])
.output()
.expect("run smix");
let said = format!(
"{}{}",
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr)
);
assert!(
!out.status.success(),
"`smix wait-for --absent` exited 0 with no runner to ask. An \
assertion that cannot fail is a print statement."
);
assert!(
!said.contains("unexpected argument") && !said.contains("unrecognized"),
"the failure was the argument parser refusing `--absent`, not the \
command running and failing.\n{said}"
);
}