From 19404ff78208b091b987e4756a9cf6aa03e7f654 Mon Sep 17 00:00:00 2001 From: Vibin reddy Date: Wed, 23 Oct 2024 21:00:38 +0530 Subject: [PATCH] Fix timeout unit in ScrollUntilVisibleCommand The `timeout` in ScrollUntilVisibleCommand should be interpreted as milliseconds: https://maestro.mobile.dev/api-reference/commands/scrolluntilvisible Fixes https://github.com/mobile-dev-inc/maestro/issues/2108. This was broken by https://github.com/mobile-dev-inc/maestro/pull/2023. --- .../src/main/java/maestro/orchestra/Commands.kt | 5 ++--- .../java/maestro/orchestra/yaml/YamlCommandReaderTest.kt | 2 +- .../src/test/resources/117_scroll_until_visible_speed.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt b/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt index 9c59306b48..3656ce3d50 100644 --- a/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt +++ b/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt @@ -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 { @@ -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 diff --git a/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt b/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt index 19db099240..2e20c03f93 100644 --- a/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt +++ b/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt @@ -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", diff --git a/maestro-test/src/test/resources/117_scroll_until_visible_speed.js b/maestro-test/src/test/resources/117_scroll_until_visible_speed.js index cca0b994ac..9fdd6f6756 100644 --- a/maestro-test/src/test/resources/117_scroll_until_visible_speed.js +++ b/maestro-test/src/test/resources/117_scroll_until_visible_speed.js @@ -3,9 +3,9 @@ output.speed = { } output.timeout = { - slow: 20 + slow: 20000 } output.element = { id: "maestro" -} \ No newline at end of file +}