Skip to content

Commit

Permalink
Fixed bug where tapOn: {int} wouldn't work. Added Twitter sign up flow (
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-zaitsev authored Aug 27, 2022
1 parent b119410 commit 9ed67a4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.node.TextNode
import com.fasterxml.jackson.databind.node.POJONode
import com.fasterxml.jackson.databind.node.ValueNode

@JsonDeserialize(using = YamlElementSelectorDeserializer::class)
interface YamlElementSelectorUnion
Expand All @@ -38,8 +39,8 @@ class YamlElementSelectorDeserializer : JsonDeserializer<YamlElementSelectorUnio
val mapper = parser.codec as ObjectMapper
val root: TreeNode = mapper.readTree(parser)

return if (root is TextNode) {
StringElementSelector(root.textValue())
return if (root is ValueNode && root !is POJONode) {
StringElementSelector(root.asText())
} else {
mapper.convertValue(root, YamlElementSelector::class.java)
}
Expand Down
22 changes: 22 additions & 0 deletions maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,28 @@ class IntegrationTest {
)
}

@Test
fun `Case 033 - Text with number`() {
// Given
val commands = readCommands("033_int_text")

val driver = driver {
element {
text = "2022"
bounds = Bounds(0, 0, 100, 100)
}
}

// When
Maestro(driver).use {
orchestra(it).runFlow(commands)
}

// Then
// No test failure
driver.assertHasEvent(Event.Tap(Point(50, 50)))
}

private fun orchestra(it: Maestro) = Orchestra(it, lookupTimeoutMs = 0L, optionalLookupTimeoutMs = 0L)

private fun driver(builder: FakeLayoutElement.() -> Unit): FakeDriver {
Expand Down
3 changes: 3 additions & 0 deletions maestro-test/src/test/resources/033_int_text.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appId: com.example.app
---
- tapOn: 2022
19 changes: 19 additions & 0 deletions recipies/twitter/android/create_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Gets user all the way up to OTP step in Twitter signup

appId: com.twitter.android
name: Create Account
---
- launchApp:
clearState: true
- tapOn: Create account
- tapOn: Skip for now
- inputText: ${NAME}
- tapOn:
id: com.twitter.android:id/phone_or_email_field
- tapOn: Use email instead
- inputText: ${EMAIL}
- tapOn: Date of birth
- longPressOn: 2021
- tapOn: Next
- tapOn: Next
- tapOn: Sign up

0 comments on commit 9ed67a4

Please sign in to comment.