SIGN IN SIGN UP

fix(cli): wait positional <TARGET> auto-detects CSS selector vs ref (#74) (#77)

* fix(cli): wait positional <TARGET> auto-detects CSS selector vs ref (#74)

Previously, `tauri-pilot wait "#trigger"` was forwarded to the bridge
with `target: "#trigger"` and then looked up via `idMap.get` — so a
plain CSS selector always timed out even when the element existed
(snapshot was never run, so `idMap` was empty).

The CLI now routes the positional through a shared `build_wait_params`
helper that calls `parse_target` (the same routing every other
element-targeting command already used): `@x` becomes a `ref`, anything
else becomes a `selector`. The `--selector` flag still wins over the
positional. The MCP `wait` tool and the `wait` scenario step now share
this helper too, and the scenario step finally honors the TOML
`ref = "..."` field that the rest of the actions already accepted.

The bridge `waitFor` reads `options.ref` instead of `options.target`,
matching the field name `resolveTarget` uses everywhere else, and
rejects up-front when neither `selector` nor `ref` is provided
(including the `@`-alone edge case) instead of silently hanging on a
`MutationObserver` until the timeout.

Tests: 9 new unit tests in `main.rs` cover `#sel`, `.cls`,
`[data-x=y]`, `@ref`, coords fallback, explicit-selector precedence,
`--gone`, the no-target case, and the empty-ref-from-`@`-alone edge.
`cargo test --workspace` passes (252 tests), `cargo clippy --workspace
--all-targets -- -D warnings` clean, `cargo fmt --check` clean.

Closes #74

* fix: address PR review comments

- CHANGELOG: add missing `[#74]` link reference (coderabbit + cubic).
- docs/reference/cli.md: clarify `wait` does not accept coordinate
  targets, only snapshot refs and CSS selectors (coderabbit).
- scenario.rs: reject TOML `wait` steps that set both `target` and
  `ref` instead of silently dropping `ref` via `or()` (greptile).

---------

Co-authored-by: Mathieu Piton <27002047+mpiton@users.noreply.github.com>
M
Mathieu committed
51dbfeb4fe2aa1bbc19a68e7a3dfdb7203b60ceb
Parent: e4cd836
Committed by GitHub <noreply@github.com> on 4/25/2026, 9:28:15 AM