Skip to content

Commit

Permalink
🚧 Work in progress - Move tests to Maestro
Browse files Browse the repository at this point in the history
  • Loading branch information
igorescodro committed May 5, 2024
1 parent 2d93045 commit 100be14
Show file tree
Hide file tree
Showing 14 changed files with 173 additions and 54 deletions.
11 changes: 11 additions & 0 deletions .github/maestro/category/AddCategory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
appId: com.escodro.alkaa
env:
CATEGORY_NAME: "Books"
---
- launchApp:
clearState: true
- tapOn: "Categories"
- tapOn: "Add category"
- inputText: ${CATEGORY_NAME}
- tapOn: "Save"
- assertVisible: ${CATEGORY_NAME}
12 changes: 12 additions & 0 deletions .github/maestro/category/RemoveCategory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
appId: com.escodro.alkaa
env:
CATEGORY_NAME: "Gifts"
---
- runFlow:
file: "AddCategory.yaml"
env:
CATEGORY_NAME: ${CATEGORY_NAME}
- tapOn: ${CATEGORY_NAME}
- tapOn: "Remove"
- tapOn: "Remove"
- assertNotVisible: ${CATEGORY_NAME}
15 changes: 15 additions & 0 deletions .github/maestro/category/RenameCategory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appId: com.escodro.alkaa
env:
CATEGORY_NAME: "Movies"
---
- runFlow:
file: "AddCategory.yaml"
env:
CATEGORY_NAME: ${CATEGORY_NAME}
- tapOn: ${CATEGORY_NAME}
- tapOn: ${CATEGORY_NAME}
- eraseText
- inputText: "Cinema"
- tapOn: "Save"
- assertVisible: "Cinema"

4 changes: 4 additions & 0 deletions .github/maestro/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flows:
- category/*
- home/*
- task/*
21 changes: 21 additions & 0 deletions .github/maestro/home/BottomNavigation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
appId: com.escodro.alkaa
---
- launchApp
- assertVisible:
text: "Tasks"
index: 0
- tapOn:
text: "Search"
- assertVisible:
text: "Search"
index: 0
- tapOn:
text: "Categories"
- assertVisible:
text: "Categories"
index: 0
- tapOn:
text: "More"
- assertVisible:
text: "More"
index: 0
13 changes: 13 additions & 0 deletions .github/maestro/task/AddTask.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
appId: com.escodro.alkaa
---
- launchApp:
clearState: true
- tapOn: "Add task"
- inputText: ${TASK_NAME}
- runFlow:
when:
platform: iOS
commands:
- tapOn: "Done"
- tapOn: "Add"
- assertVisible: ${TASK_NAME}
14 changes: 14 additions & 0 deletions .github/maestro/task/EditTaskDescription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
appId: com.escodro.alkaa
env:
TASK_NAME: "Listen to music"
---
- runFlow:
file: "AddTask.yaml"
env:
TASK_NAME: ${TASK_NAME}
- tapOn: ${TASK_NAME}
- tapOn: "Description"
- inputText: "My description"
- tapOn: "Back"
- tapOn: ${TASK_NAME}
- assertVisible: "My description"
15 changes: 15 additions & 0 deletions .github/maestro/task/EditTaskName.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appId: com.escodro.alkaa
env:
TASK_NAME: "Watter plants"
---
- runFlow:
file: "AddTask.yaml"
env:
TASK_NAME: ${TASK_NAME}
- tapOn: ${TASK_NAME}
- tapOn: ${TASK_NAME}
- eraseText
- inputText: "Water plants"
- tapOn: "Back" # hide keyboard
- tapOn: "Back"
- assertVisible: "Water plants"
15 changes: 15 additions & 0 deletions .github/maestro/task/SelectCategory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appId: com.escodro.alkaa
env:
TASK_NAME: "Buy Rachel's gift"
---
- runFlow:
file: "AddTask.yaml"
env:
TASK_NAME: ${TASK_NAME}
- tapOn: ${TASK_NAME}
- tapOn: "Personal"
- tapOn: "Back"
- tapOn: "Personal"
- assertVisible: ${TASK_NAME}
- tapOn: "Work"
- assertNotVisible: ${TASK_NAME}
44 changes: 7 additions & 37 deletions .github/workflows/android_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install Maestro
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
Expand All @@ -45,43 +50,8 @@ jobs:
script: |
adb logcat -c
adb logcat > logcat.txt &
./gradlew connectedAndroidTest --stacktrace
- name: Save Test Results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: test-results
path: |
/Users/runner/work/alkaa/alkaa/app/build/reports/androidTests/
./logcat.txt
retention-days: 7

android-test-gmd:
name: "Gradle Managed Devices"
runs-on: macos-latest
timeout-minutes: 80

strategy:
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Run instrumented tests
run: ./gradlew cleanManagedDevices --unused-only &&
./gradlew alkaaDevicesGroupDebugAndroidTest -Dorg.gradle.workers.max=1
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
./gradlew installDebug
maestro test .github/maestro
- name: Save Test Results
uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.escodro.category.presentation.semantics.color
import com.escodro.categoryapi.model.Category
import com.escodro.designsystem.components.AlkaaDialog
import com.escodro.designsystem.components.AlkaaInputTextField
Expand Down Expand Up @@ -250,6 +249,7 @@ private fun CategorySaveButton(currentColor: Color, onClick: () -> Unit) {
onClick = onClick,
colors = ButtonDefaults.buttonColors(containerColor = colorState.value),
modifier = Modifier
.testTag(currentColor.toArgb().toString())
.fillMaxWidth()
.height(48.dp),
) {
Expand All @@ -275,7 +275,7 @@ private fun CategoryColorItem(
.size(32.dp)
.clip(CircleShape)
.background(color = color)
.semantics { this.color = color }
.testTag(color.toArgb().toString())
.selectable(
role = Role.RadioButton,
selected = isSelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.escodro.categoryapi.model.Category
import com.escodro.categoryapi.presentation.CategoryState
Expand Down Expand Up @@ -93,7 +95,9 @@ private fun CategoryItemChip(
FilterChip(
selected = isSelected,
label = { Text(text = category.name) },
modifier = Modifier.padding(end = 8.dp),
modifier = Modifier.padding(end = 8.dp).semantics {
contentDescription = category.name
},
colors = FilterChipDefaults.filterChipColors(
selectedContainerColor = Color(category.color),
selectedLabelColor = MaterialTheme.colorScheme.background,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.TextFieldValue
import com.escodro.alarmapi.AlarmPermission
Expand Down Expand Up @@ -57,14 +59,14 @@ internal fun TaskDetailScreen(
) {
val id = TaskId(taskId)
val detailViewState by
remember(detailViewModel, taskId) {
detailViewModel.loadTaskInfo(taskId = id)
}.collectAsState(initial = TaskDetailState.Loading)
remember(detailViewModel, taskId) {
detailViewModel.loadTaskInfo(taskId = id)
}.collectAsState(initial = TaskDetailState.Loading)

val categoryViewState by
remember(categoryViewModel, taskId) {
categoryViewModel.loadCategories()
}.collectAsState(initial = CategoryState.Loading)
remember(categoryViewModel, taskId) {
categoryViewModel.loadCategories()
}.collectAsState(initial = CategoryState.Loading)

val taskDetailActions = TaskDetailActions(
onTitleChange = { title -> detailViewModel.updateTitle(id, title) },
Expand Down Expand Up @@ -185,13 +187,15 @@ private fun TaskDescriptionTextField(text: String?, onDescriptionChange: (String
val textState = remember { mutableStateOf(TextFieldValue(text ?: "")) }

TextField(
modifier = Modifier.fillMaxWidth(),
leadingIcon = {
LeadingIcon(
imageVector = Icons.Default.Description,
contentDescription = stringResource(MR.strings.task_detail_cd_icon_description),
)
modifier = Modifier.fillMaxWidth().semantics {
contentDescription = textState.value.text
},
// leadingIcon = {
// LeadingIcon(
// imageVector = Icons.Default.Description,
// contentDescription = stringResource(MR.strings.task_detail_cd_icon_description),
// )
// },
value = textState.value,
onValueChange = {
onDescriptionChange(it.text)
Expand Down
23 changes: 22 additions & 1 deletion shared/src/iosMain/kotlin/com/escodro/shared/Main.ios.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
package com.escodro.shared

import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.ui.platform.AccessibilityDebugLogger
import androidx.compose.ui.platform.AccessibilitySyncOptions
import androidx.compose.ui.window.ComposeUIViewController

@OptIn(ExperimentalComposeApi::class)
@Suppress("Unused", "FunctionName")
fun MainViewController() = ComposeUIViewController { AlkaaMultiplatformApp() }
fun MainViewController() = ComposeUIViewController(
configure = {
accessibilitySyncOptions = AccessibilitySyncOptions.Always(AccessibilityDebugLoggerImpl())
},
) {
AlkaaMultiplatformApp()
}

@OptIn(ExperimentalComposeApi::class)
private class AccessibilityDebugLoggerImpl : AccessibilityDebugLogger {
override fun log(message: Any?) {
if (message == null) {
println()
} else {
println(message)
}
}
}

0 comments on commit 100be14

Please sign in to comment.