Skip to content

Commit

Permalink
Fix timeout unit in ScrollUntilVisibleCommand (#2112)
Browse files Browse the repository at this point in the history
* Fix timeout unit in ScrollUntilVisibleCommand

The `timeout` in ScrollUntilVisibleCommand should be interpreted as milliseconds: https://maestro.mobile.dev/api-reference/commands/scrolluntilvisible

Fixes #2108.
This was broken by #2023.
  • Loading branch information
vibin authored Nov 9, 2024
1 parent 673e4ff commit 759d954
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
13 changes: 13 additions & 0 deletions e2e/workspaces/demo_app/scrollUntilVisible_timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
appId: com.example.example
tags:
- passing
---
- launchApp:
clearState: true
- evalScript: ${maestro.startTime = new Date()}
- scrollUntilVisible:
element: non-existent
timeout: 1000
optional: true
- evalScript: ${maestro.endTime = new Date()}
- assertTrue: ${maestro.endTime - maestro.startTime < 5000} # Far less than the 20000 default, but enough to allow for processing time
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ data class ScrollUntilVisibleCommand(
}

private fun String.timeoutToMillis(): String {
val timeout = if (this.toLong() < 0) { DEFAULT_TIMEOUT_IN_MILLIS.toLong() * 1000L } else this.toLong() * 1000L
return timeout.toString()
return if (this.toLong() < 0) { DEFAULT_TIMEOUT_IN_MILLIS } else this
}

override fun description(): String {
Expand All @@ -132,7 +131,7 @@ data class ScrollUntilVisibleCommand(
}

companion object {
const val DEFAULT_TIMEOUT_IN_MILLIS = "20"
const val DEFAULT_TIMEOUT_IN_MILLIS = "20000"
const val DEFAULT_SCROLL_DURATION = "40"
const val DEFAULT_ELEMENT_VISIBILITY_PERCENTAGE = 100
const val DEFAULT_CENTER_ELEMENT = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ internal class YamlCommandReaderTest {
ScrollUntilVisibleCommand(
selector = ElementSelector(textRegex = "Footer"),
direction = ScrollDirection.DOWN,
timeout = "20",
timeout = "20000",
scrollDuration = "40",
visibilityPercentage = 100,
label = "Scroll to the bottom",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ output.speed = {
}

output.timeout = {
slow: 20
slow: 20000
}

output.element = {
id: "maestro"
}
}

0 comments on commit 759d954

Please sign in to comment.