const FIXTURE: &str = include_str!("../../../test-fixtures/demo-app/main.swift");
fn identifiers() -> Vec<String> {
FIXTURE
.lines()
.filter_map(|l| {
let at = l.find("accessibilityIdentifier(\"")?;
let rest = &l[at + "accessibilityIdentifier(\"".len()..];
let end = rest.find('"')?;
Some(rest[..end].to_string())
})
.collect()
}
#[test]
fn the_original_three_are_untouched() {
let ids = identifiers();
for id in ["fixture-input", "fixture-submit", "fixture-result"] {
assert!(
ids.iter().any(|i| i == id),
"`{id}` is gone from the fixture. The flow that drives it did not \
change, so this would fail on the device instead of here.\nfound: \
{ids:?}"
);
}
}
#[test]
fn there_is_a_list_deeper_than_one_screen() {
let count = FIXTURE
.lines()
.find_map(|l| {
let at = l.find("let fixtureRowCount = ")?;
l[at + "let fixtureRowCount = ".len()..]
.trim()
.parse::<usize>()
.ok()
})
.unwrap_or(0);
assert!(
count >= 30,
"the fixture list has {count} rows. A scroll flow needs its target \
off screen at launch, or it passes without scrolling."
);
}
#[test]
fn there_is_a_navigation_stack_with_a_detail_screen() {
assert!(
FIXTURE.contains("NavigationStack"),
"the fixture has no NavigationStack, so a ported `nav-and-back` flow \
would not be driving the same thing the Settings one does."
);
let ids = identifiers();
assert!(
ids.iter().any(|i| i == "fixture-detail"),
"the fixture declares no `fixture-detail`. A nav flow needs \
something on the destination to assert, or arriving and not \
arriving look the same.\nfound: {ids:?}"
);
assert!(
ids.iter().any(|i| i == "fixture-detail-link"),
"the fixture declares no `fixture-detail-link` to tap.\nfound: {ids:?}"
);
}
#[test]
fn there_is_a_long_press_target() {
let ids = identifiers();
assert!(
ids.iter().any(|i| i == "fixture-longpress"),
"the fixture declares no `fixture-longpress`.\nfound: {ids:?}"
);
}