Skip to content

Commit 967d7ed

Browse files
committed
fix: enhance ConsoleScreenTest with waitUntil conditions and update report paths in kmp.yml
1 parent c876ca7 commit 967d7ed

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

‎.github/workflows/kmp.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@ jobs:
5050
name: output-build-artifacts
5151
path: |
5252
core/data/db-sqldelight/build/reports
53-
ui/shared/build/reports
54-
ui/test/build/reports
53+
core/ui/build/reports
54+
core/test/ui/build/reports
55+
feature/backup/ui/build/reports
56+
feature/console/ui/build/reports
5557
app/android/build/reports
5658
app/desktop/build/reports
5759
app/ios-kit/build/reports
60+
app/web/build/reports
5861
5962
android_ui_test_job:
6063
name: Android UI-tests on emulator

‎core/test/ui/src/commonMain/kotlin/com/softartdev/notedelight/ext.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fun ComposeUiTest.waitUntilDisplayed(
3838
try {
3939
val sni = blockSNI()
4040
sni.assertIsDisplayed()
41-
} catch (_: AssertionError) {
41+
} catch (_: Throwable) {
4242
return@waitUntil false
4343
}
4444
return@waitUntil true
@@ -55,7 +55,7 @@ fun ComposeUiTest.waitAssert(
5555
) = waitUntil(conditionDescription = description, timeoutMillis = ASSERT_WAIT_TIMEOUT_MILLIS) {
5656
try {
5757
assert()
58-
} catch (_: AssertionError) {
58+
} catch (_: Throwable) {
5959
return@waitUntil false
6060
}
6161
return@waitUntil true
@@ -68,7 +68,7 @@ fun ComposeUiTest.waitUntilSelected(
6868
val sni = blockSNI().assertIsSelectable()
6969
try {
7070
sni.assertIsSelected()
71-
} catch (_: AssertionError) {
71+
} catch (_: Throwable) {
7272
return@waitUntil false
7373
}
7474
return@waitUntil true

‎core/test/ui/src/commonMain/kotlin/com/softartdev/notedelight/ui/settings/detail/ConsoleScreenTest.kt‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.softartdev.notedelight.ui.settings.detail
55
import androidx.compose.ui.test.ExperimentalTestApi
66
import androidx.compose.ui.test.assertIsDisplayed
77
import androidx.compose.ui.test.assertTextContains
8+
import androidx.compose.ui.test.hasTestTag
89
import androidx.compose.ui.test.onNodeWithTag
910
import androidx.compose.ui.test.performClick
1011
import androidx.compose.ui.test.v2.runComposeUiTest
@@ -28,15 +29,25 @@ abstract class ConsoleScreenTest {
2829
}
2930
// Open tips menu
3031
onNodeWithTag(CONSOLE_TIPS_BUTTON_TAG).assertIsDisplayed().performClick()
31-
waitForIdle()
32+
waitUntil(
33+
conditionDescription = "tip buttons exist",
34+
timeoutMillis = 10_000,
35+
) {
36+
onAllNodes(hasTestTag("${CONSOLE_TIP_COPY_PREFIX}0")).fetchSemanticsNodes().isNotEmpty() &&
37+
onAllNodes(hasTestTag("${CONSOLE_TIP_AUTOFILL_PREFIX}0")).fetchSemanticsNodes().isNotEmpty()
38+
}
3239
// Verify copy and autofill buttons exist for first tip
3340
onNodeWithTag("${CONSOLE_TIP_COPY_PREFIX}0").assertIsDisplayed()
3441
onNodeWithTag("${CONSOLE_TIP_AUTOFILL_PREFIX}0").assertIsDisplayed()
3542
// Tap autofill on first tip (PRAGMA cipher_version;)
3643
onNodeWithTag("${CONSOLE_TIP_AUTOFILL_PREFIX}0").performClick()
37-
waitForIdle()
44+
waitUntil(
45+
conditionDescription = "autofill action was dispatched",
46+
timeoutMillis = 10_000,
47+
) {
48+
actions.isNotEmpty()
49+
}
3850
// Verify autofill action was dispatched
39-
assertTrue(actions.isNotEmpty())
4051
val autofillAction = actions.last()
4152
assertTrue(autofillAction is ConsoleAction.UpdateInput)
4253
assertEquals("PRAGMA cipher_version;", autofillAction.text)
@@ -48,7 +59,12 @@ abstract class ConsoleScreenTest {
4859
}
4960
// Open tips menu
5061
onNodeWithTag(CONSOLE_TIPS_BUTTON_TAG).assertIsDisplayed().performClick()
51-
waitForIdle()
62+
waitUntil(
63+
conditionDescription = "tip copy button exists",
64+
timeoutMillis = 10_000,
65+
) {
66+
onAllNodes(hasTestTag("${CONSOLE_TIP_COPY_PREFIX}1")).fetchSemanticsNodes().isNotEmpty()
67+
}
5268
// Tap copy on second tip (SELECT sqlite3mc_version();)
5369
onNodeWithTag("${CONSOLE_TIP_COPY_PREFIX}1").assertIsDisplayed().performClick()
5470
waitForIdle()

0 commit comments

Comments
 (0)