Skip to content

Commit b9c63d3

Browse files
committed
test: align e2e tests with xa11y 0.7 + JSON observe default
After merging main (which flipped `observe --format` default to json in PR #23) on top of the xa11y 0.7 update, two test suites needed realignment: - tests/e2e_live.rs: tests asserting `<application` / `<` in observe stdout now pass `--format xml` explicitly, since the default is JSON. - tests/e2e_cli.rs: `test_scroll_without_element_no_state_needed` previously expected a missing-platform-tool failure, but xa11y 0.7 performs scroll natively on macOS/Windows/X11. The test now asserts the actual invariant (no observe-state required) by checking stderr doesn't mention "state" / "observe", so it works whether scroll succeeds (native input sim) or fails (Wayland's Unsupported error).
1 parent 27a7659 commit b9c63d3

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

tests/e2e_cli.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,17 @@ fn test_scroll_invalid_direction() {
196196

197197
#[test]
198198
fn test_scroll_without_element_no_state_needed() {
199-
// Scroll without --element should not require state, only platform tools
200-
let result = agent_desktop_cmd()
199+
// Scroll without --element should not require state.
200+
// On platforms with native input simulation (macOS/Windows/X11) it succeeds;
201+
// on Wayland it fails with an unsupported-platform error rather than a
202+
// missing-state error.
203+
let assert = agent_desktop_cmd()
201204
.args(["scroll", "--direction", "up"])
202-
.assert()
203-
.failure();
205+
.assert();
204206

205-
result.stderr(predicate::str::contains("xdotool").or(predicate::str::contains("screenshot tool").or(predicate::str::contains("scroll"))));
207+
assert
208+
.stderr(predicate::str::contains("state").not())
209+
.stderr(predicate::str::contains("observe").not());
206210
}
207211

208212
// =============================================================================

tests/e2e_live.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn screenshot_captures_a_file() {
5151
#[cfg(target_os = "linux")]
5252
fn observe_returns_xml() {
5353
agent_desktop()
54-
.arg("observe")
54+
.args(["observe", "--format", "xml"])
5555
.assert()
5656
.success()
5757
.stdout(predicate::str::contains("<application"));
@@ -61,7 +61,7 @@ fn observe_returns_xml() {
6161
#[cfg(target_os = "macos")]
6262
fn observe_returns_xml() {
6363
agent_desktop()
64-
.arg("observe")
64+
.args(["observe", "--format", "xml"])
6565
.assert()
6666
.success()
6767
.stdout(predicate::str::contains("<application"));
@@ -71,7 +71,7 @@ fn observe_returns_xml() {
7171
#[cfg(target_os = "linux")]
7272
fn observe_app_returns_elements() {
7373
agent_desktop()
74-
.args(["observe", "--app", "gedit"])
74+
.args(["observe", "--app", "gedit", "--format", "xml"])
7575
.assert()
7676
.success()
7777
.stdout(predicate::str::contains("<"));
@@ -81,7 +81,7 @@ fn observe_app_returns_elements() {
8181
#[cfg(target_os = "macos")]
8282
fn observe_app_finder_returns_elements() {
8383
agent_desktop()
84-
.args(["observe", "--app", "Finder"])
84+
.args(["observe", "--app", "Finder", "--format", "xml"])
8585
.assert()
8686
.success()
8787
.stdout(predicate::str::contains("<application"))
@@ -92,7 +92,7 @@ fn observe_app_finder_returns_elements() {
9292
#[cfg(target_os = "macos")]
9393
fn observe_app_textedit_returns_elements() {
9494
agent_desktop()
95-
.args(["observe", "--app", "TextEdit"])
95+
.args(["observe", "--app", "TextEdit", "--format", "xml"])
9696
.assert()
9797
.success()
9898
.stdout(predicate::str::contains("<"));
@@ -102,7 +102,7 @@ fn observe_app_textedit_returns_elements() {
102102
#[cfg(target_os = "windows")]
103103
fn observe_pid_returns_elements() {
104104
agent_desktop()
105-
.args(["observe", "--pid", &notepad_pid()])
105+
.args(["observe", "--pid", &notepad_pid(), "--format", "xml"])
106106
.assert()
107107
.success()
108108
.stdout(predicate::str::contains("<"));
@@ -185,7 +185,7 @@ fn observe_invalid_app_fails() {
185185
#[cfg(target_os = "windows")]
186186
fn observe_returns_xml() {
187187
agent_desktop()
188-
.arg("observe")
188+
.args(["observe", "--format", "xml"])
189189
.assert()
190190
.success()
191191
.stdout(predicate::str::contains("<application"));
@@ -435,7 +435,7 @@ fn interact_press_on_element() {
435435
#[cfg(target_os = "macos")]
436436
fn observe_textedit_returns_elements() {
437437
agent_desktop()
438-
.args(["observe", "--app", "TextEdit"])
438+
.args(["observe", "--app", "TextEdit", "--format", "xml"])
439439
.assert()
440440
.success()
441441
.stdout(predicate::str::contains("<"));

0 commit comments

Comments
 (0)