-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional field to commands #1946
Add optional field to commands #1946
Conversation
cb1069f
to
c483645
Compare
Hey @tokou, thanks a ton! I love the work done here!
I was also thinking about it recently. I think a new state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to add optional
to all existing commands. We already have label
argument on all commands.
Also, we won't spend time deciding if a specific command can fail or not.
maestro-studio/server/src/main/java/maestro/studio/DeviceService.kt
Outdated
Show resolved
Hide resolved
maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt
Show resolved
Hide resolved
maestro-orchestra-models/src/main/java/maestro/orchestra/MaestroConfig.kt
Outdated
Show resolved
Hide resolved
maestro-cli/src/main/java/maestro/cli/report/HtmlTestSuiteReporter.kt
Outdated
Show resolved
Hide resolved
Make label and optional mandatory for future commands
c483645
to
1a2d833
Compare
accidentally re-added it during merge conflicts resolution
Restarting tests because of a flake: Also occurred in: Reported as #2005 |
That workflow run failure is a false positive from #2005, safe to ignore for now. |
@tokou This gets messed up with `optio Take this flow as an example: # This flow is to ensure that commands with optional flag are not failing the flow.
appId: com.example.example
tags:
- android
- passing
---
- launchApp:
clearState: true
- assertTrue:
condition: ${ false }
label: Warn
optional: true
- tapOn:
id: non-existent-id
optional: true
- doubleTapOn:
id: non-existent-id
optional: true
- longPressOn:
id: non-existent-id
optional: true
- copyTextFrom:
id: non-existent-id
optional: true
- launchApp:
appId: non.existend.app.id
optional: true
- tapOn:
id: non-existent-id
repeat: 3
delay: 500
optional: true
- scrollUntilVisible:
element:
id: non-existent-id
optional: true Results in: ./maestro-cli/build/install/maestro/bin/maestro test e2e/workspaces/demo_app/commands_optional_tournee.yaml
Running on emulator-5554
║
║ > Flow
║
║ ✅ Launch app "com.example.example" with clear state
║ ⚠️ Warn (warned)
║ ✅ Tap on (Optional) id: non-existent-id
║ ✅ Double tap on (Optional) id: non-existent-id
║ ✅ Long press on (Optional) id: non-existent-id
║ ⚠️ Copy text from element with (Optional) id: non-existent-id (warned)
║ ⚠️ Launch app "non.existend.app.id" (warned)
║ ✅ Tap x3 on (Optional) id: non-existent-id
║ ⚠️ Scrolling DOWN until (Optional) id: non-existent-id is visible. (warned)
║ |
Action taken: I am getting rid of |
Possible breaking change investigationRemoving I created the following flow to test this hypothesis: appId: com.example.example
tags:
- android
- passing
---
- launchApp:
clearState: true
- tapOn: Nesting Test
- assertVisible:
id: level-0
- assertVisible:
id: level-0
containsChild:
id: level-1
containsChild:
id: level-2
containsChild:
id: level-3
optional: true and the following hierarchy (app source code):
without level-3 The above flow fails on latest Maestro v1.38.1, which is not what I expected. I expected it to pass, given that
So the conclusion is: there will be no breaking change, because what I thought will break, doesn't work. |
Same goes for appId: com.example.example
tags:
- android
- passing
---
- launchApp:
clearState: true
- tapOn: Nesting Test
- assertVisible:
id: level-0
- assertVisible:
id: level-0
containsChild:
id: level-1
containsChild:
id: level-2
rightOf:
text: nothing
optional: true |
Proposed changes
optional
flag to all commands without exceptionexecuteCommand
in Orchestra to throw aCommandSkipped
exception in case of an errorI'm not sure of the direction taken here and have some questions:
optional
to every single command? I feel like some command never fail 🤔optional
inElementSelector
? Or is there a case where it makes sense to have it?CommandSkipped
exception but is the skipped state the same as an optional command failing? Should I create a separate state?Testing
optional: true
commands to076_optional_assertion.yml
./gradlew test
Formats
I ran
./maestro-cli/build/install/maestro/bin/maestro test maestro-test/src/test/resources/076_optional_assertion.yaml
Issues fixed
Fixes #1778
Fixes #1969