Skip to content

Commit

Permalink
Custom labels for readability and CLI output (#1481)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeetsingh150 authored Nov 21, 2023
1 parent 4eca23f commit 0f6db93
Show file tree
Hide file tree
Showing 37 changed files with 915 additions and 129 deletions.
154 changes: 109 additions & 45 deletions maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ data class Condition(
val platform: Platform? = null,
val visible: ElementSelector? = null,
val notVisible: ElementSelector? = null,
val scriptCondition: String? = null
val scriptCondition: String? = null,
val label: String? = null,
) {

fun evaluateScripts(jsEngine: JsEngine): Condition {
Expand All @@ -20,6 +21,10 @@ data class Condition(
}

fun description(): String {
if(label != null){
return label
}

val descriptions = mutableListOf<String>()

platform?.let {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package maestro.orchestra.yaml

data class YamlActionBack(
val label: String? = null,
)

data class YamlActionClearKeychain(
val label: String? = null,
)

data class YamlActionHideKeyboard(
val label: String? = null,
)

data class YamlActionPasteText(
val label: String? = null,
)

data class YamlActionScroll(
val label: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package maestro.orchestra.yaml

import com.fasterxml.jackson.annotation.JsonCreator

data class YamlAssertTrue(
val condition: String? = null,
val label: String? = null,
){
companion object {

@JvmStatic
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
fun parse(condition: Any): YamlAssertTrue {
val evaluatedCondition = when (condition) {
is String -> condition
is Int, is Long, is Char, is Boolean, is Float, is Double -> condition.toString()
is Map<*, *> -> {
val evaluatedCondition = condition.getOrDefault("condition", "") as String
val label = condition.getOrDefault("label", "") as String
return YamlAssertTrue(evaluatedCondition, label)
}
else -> throw UnsupportedOperationException("Cannot deserialize assert true with data type ${condition.javaClass}")
}
return YamlAssertTrue(
condition = evaluatedCondition,
)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonCreator

data class YamlClearState(
val appId: String? = null,
val label: String? = null,
) {
companion object {
@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ data class YamlCondition(
val visible: YamlElementSelectorUnion? = null,
val notVisible: YamlElementSelectorUnion? = null,
val `true`: String? = null,
val label: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ data class YamlElementSelector(
val repeat: Int? = null,
val delay: Int? = null,
val waitToSettleTimeoutMs: Int? = null,
val childOf: YamlElementSelectorUnion? = null
val childOf: YamlElementSelectorUnion? = null,
val label: String? = null
) : YamlElementSelectorUnion
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package maestro.orchestra.yaml

import com.fasterxml.jackson.annotation.JsonCreator

data class YamlEraseText(val charactersToErase: Int? = null) {
data class YamlEraseText(
val charactersToErase: Int? = null,
val label: String? = null,
) {

companion object {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package maestro.orchestra.yaml

import com.fasterxml.jackson.annotation.JsonCreator
import java.lang.UnsupportedOperationException

data class YamlEvalScript(
val script: String,
val label: String? = null,
){
companion object {

@JvmStatic
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
fun parse(script: Any): YamlEvalScript {
val evalScript = when (script) {
is String -> script
is Map<*, *> -> {
val evaluatedScript = script.getOrDefault("script", "") as String
val label = script.getOrDefault("label", "") as String
return YamlEvalScript(evaluatedScript, label)
}
is Int, is Long, is Char, is Boolean, is Float, is Double -> script.toString()
else -> throw UnsupportedOperationException("Cannot deserialize evaluate script with data type ${script.javaClass}")
}
return YamlEvalScript(
script = evalScript,
)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ data class YamlExtendedWaitUntil(
val visible: YamlElementSelectorUnion? = null,
val notVisible: YamlElementSelectorUnion? = null,
val timeout: String? = null,
val label: String? = null
)
Loading

0 comments on commit 0f6db93

Please sign in to comment.