use std::fs;
const ACT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/src/act.rs");
#[test]
fn every_selector_command_answers_for_ocr() {
let src = fs::read_to_string(ACT).expect("act.rs");
let bodies: Vec<&str> = src.split("pub async fn cmd_").skip(1).collect();
let takers: Vec<&&str> = bodies
.iter()
.filter(|b| b.contains("parse_selector(&selector_str)"))
.collect();
assert!(
takers.len() >= 5,
"only {} command(s) parse a selector — this test is reading air",
takers.len()
);
for body in takers {
let name = body.split('(').next().unwrap_or("?");
assert!(
body.contains("ocr_needle") || body.contains("scroll_until("),
"cmd_{name} takes a selector and never asks whether it is an OCR \
needle. It will hand one to the resolver, which answers 'not \
found' for text that is on the screen"
);
}
}
#[test]
fn the_ocr_constants_are_not_copied() {
let src = fs::read_to_string(ACT).expect("act.rs");
assert!(
src.contains("OCR_RECOGNITION_LEVEL"),
"the CLI names the shared constant"
);
assert!(
!src.contains("\"accurate\""),
"a second copy of the recognition level is a literal that will differ"
);
}