From 0f056d1165b1ea761a5dcfe7b265fe8ea2393115 Mon Sep 17 00:00:00 2001 From: Amanjeet Singh Date: Tue, 19 Sep 2023 18:48:01 +0530 Subject: [PATCH] fix: force cast breaking deserialization of copyText --- .../orchestra/yaml/YamlFluentCommand.kt | 18 ++++++++---- .../orchestra/yaml/YamlCommandReaderTest.kt | 29 ++++++++++++++++++- .../024_string_non_string_commands.yaml | 5 ++++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/maestro-orchestra/src/main/java/maestro/orchestra/yaml/YamlFluentCommand.kt b/maestro-orchestra/src/main/java/maestro/orchestra/yaml/YamlFluentCommand.kt index 69f8c1dea9..8fd3987c6b 100644 --- a/maestro-orchestra/src/main/java/maestro/orchestra/yaml/YamlFluentCommand.kt +++ b/maestro-orchestra/src/main/java/maestro/orchestra/yaml/YamlFluentCommand.kt @@ -526,12 +526,20 @@ data class YamlFluentCommand( private fun copyTextFromCommand( copyText: YamlElementSelectorUnion ): MaestroCommand { - return MaestroCommand( - CopyTextFromCommand( - selector = toElementSelector(copyText), - label = (copyText as YamlElementSelector).label + return if (copyText is StringElementSelector) { + MaestroCommand( + CopyTextFromCommand( + selector = toElementSelector(copyText) + ) ) - ) + } else { + MaestroCommand( + CopyTextFromCommand( + selector = toElementSelector(copyText), + label = (copyText as? YamlElementSelector)?.label + ) + ) + } } private fun scrollUntilVisibleCommand(yaml: YamlScrollUntilVisible): MaestroCommand { 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 c2f7410576..44e0b907b1 100644 --- a/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt +++ b/maestro-orchestra/src/test/java/maestro/orchestra/yaml/YamlCommandReaderTest.kt @@ -566,7 +566,34 @@ internal class YamlCommandReaderTest { ), EvalScriptCommand( scriptString = "false == false" - ) + ), + TapOnElementCommand( + ElementSelector( + textRegex = "Hello", + ), + retryIfNoChange = true, + waitUntilVisible = false, + longPress = false + ), + TapOnElementCommand( + selector = ElementSelector(textRegex = "Hello"), + repeat = TapRepeat(2, TapOnElementCommand.DEFAULT_REPEAT_DELAY), + retryIfNoChange = true, + waitUntilVisible = false, + longPress = false + ), + TapOnElementCommand( + selector = ElementSelector(textRegex = "Hello"), + longPress = true, + retryIfNoChange = true, + waitUntilVisible = false + ), + AssertConditionCommand( + condition = Condition( + visible = ElementSelector(textRegex = "Hello"), + ), + ), + CopyTextFromCommand(ElementSelector(textRegex = "Hello")) ) } diff --git a/maestro-orchestra/src/test/resources/YamlCommandReaderTest/024_string_non_string_commands.yaml b/maestro-orchestra/src/test/resources/YamlCommandReaderTest/024_string_non_string_commands.yaml index 72915ec843..a95f92cc31 100644 --- a/maestro-orchestra/src/test/resources/YamlCommandReaderTest/024_string_non_string_commands.yaml +++ b/maestro-orchestra/src/test/resources/YamlCommandReaderTest/024_string_non_string_commands.yaml @@ -12,3 +12,8 @@ appId: com.example.app - evalScript: 2 + 1 - evalScript: 2 - evalScript: false == false +- tapOn: "Hello" +- doubleTapOn: "Hello" +- longPressOn: "Hello" +- assertVisible: "Hello" +- copyTextFrom: "Hello"