fix: defer coordinate parsing for swipe commands with script variables#3026
fix: defer coordinate parsing for swipe commands with script variables#3026vazidmansuri005 wants to merge 8 commits intomobile-dev-inc:mainfrom
Conversation
When using relativePoint output from other commands as swipe coordinates
(e.g., start: "${output.startPoint}"), the values were being parsed to
Point objects during YAML deserialization, before evaluateScripts() had
a chance to resolve the variables. This caused NumberFormatException.
The fix defers coordinate parsing to execution time when script variables
(${...}) are detected:
- YamlSwipeDeserializer skips validation for variable-containing values
- YamlFluentCommand stores raw strings instead of parsing to Point
- SwipeCommand gets new startPointStr/endPointStr fields that go through
evaluateScripts()
- Orchestra parses the evaluated strings at execution time
Fixes mobile-dev-inc#2149
|
Should this be draft until your testing is complete? This also feels like this would be worth both an automated test. I think your examples are incorrect (or possibly my memory) - I don't think assertVisible sets those values. |
Verifies that YAML swipe commands containing ${...} variables are parsed
with deferred coordinate resolution (startPointStr/endPointStr) instead
of being immediately parsed to Point objects.
|
Thanks for the review @Fishbowler — all three points addressed:
|
|
A Maestro dev environment is incredibly similar to a normal Maestro environment. Just run You've added a YAML parsing test that proves you can read the string from the YAML, but nothing to say that the point is then honoured - maybe a test elsewhere could go a little further? |
End-to-end test that verifies the full execution path: evalScript sets output variables → swipe command defers parsing → evaluateScripts() resolves variables → Orchestra parses evaluated strings and executes the swipe with correct coordinates.
|
Good point — added an integration test (
Thanks for the suggestion on |
|
Ran full E2E on iPhone 16 simulator (iOS 18.5) using locally built Maestro via Test 1 — Test 2 — absolute coordinate variables: Both pass. Marking manual testing as complete in the PR description. |
|
Hey @Fishbowler @amanjeetsingh150, could you please review this PR when you get a chance? Thanks! |
Summary
Fixes #2149 — The output of
relativePoint()JavaScript function can be used withtapOn(as thepointparameter) but cannot be used withswipe(asstart/endparameters). This is because swipe coordinate strings are parsed toPointobjects during YAML deserialization, beforeevaluateScripts()resolves${...}variables, causing aNumberFormatException.Root cause:
YamlFluentCommand.toCommand()callsstart.split(",").map { it.trim().toInt() }at parse time, which throws on${output.startPoint}.Fix: Defer coordinate parsing to execution time when script variables are detected:
YamlSwipeDeserializer— Detects${in start/end values and skips format validation, returning a rawYamlCoordinateSwipeYamlFluentCommand— When${is detected, stores raw strings instartPointStr/endPointStrinstead of parsing toPointSwipeCommand— NewstartPointStr/endPointStrfields that pass throughevaluateScripts()Orchestra— Parses the evaluated strings at execution time, supporting both absolute (x,y) and relative (x%,y%) coordinatesBefore (broken)
After (works)
Test plan
./gradlew :maestro-orchestra:test)compileKotlinfor bothmaestro-orchestraandmaestro-orchestra-models)swipe with script variables defers coordinate parsing— verifies YAML with${...}variables producesSwipeCommandwithstartPointStr/endPointStrCase 139 - Swipe with script variables— verifies full execution path through Orchestra with FakeDriverrelativePoint()and absolute coordinate variables both execute successfully viainstallLocally.sh