Skip to content

Commit b403b71

Browse files
committed
chore: Improve UI test stability
- Increase the test timeout for `PrepopulateDbTestCase` from 2 to 3 minutes to prevent flakes. - Double the `ASSERT_WAIT_TIMEOUT_MILLIS` from 5,000 to 10,000 to give assertions more time to pass. - In `FlowAfterCryptTestCase`, explicitly wait for the confirm password dialog to close before proceeding. - Add `composeUiTest.awaitIdle()` in `SettingPasswordTestCase` after a button click to ensure the UI state updates before the next action.
1 parent 33acd0e commit b403b71

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import androidx.compose.ui.test.hasTestTag
1212
import androidx.compose.ui.test.waitUntilDoesNotExist
1313
import co.touchlab.kermit.Logger
1414

15-
const val ASSERT_WAIT_TIMEOUT_MILLIS: Long = 5_000
15+
const val ASSERT_WAIT_TIMEOUT_MILLIS: Long = 10_000
1616
const val MAX_RETRY_ATTEMPTS = 100
1717

1818
inline fun retryUntilDisplayed(

ui/test/src/commonMain/kotlin/com/softartdev/notedelight/ui/cases/FlowAfterCryptTestCase.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import androidx.compose.ui.test.performTextReplacement
1212
import co.touchlab.kermit.Logger
1313
import com.softartdev.notedelight.retryUntilDisplayed
1414
import com.softartdev.notedelight.ui.BaseTestCase
15+
import com.softartdev.notedelight.ui.dialog.security.CONFIRM_PASSWORD_DIALOG_TAG
1516
import com.softartdev.notedelight.ui.screen.MainTestScreen
1617
import com.softartdev.notedelight.waitAssert
1718
import com.softartdev.notedelight.waitUntilDisplayed
19+
import com.softartdev.notedelight.waitUntilNotExist
1820
import kotlinx.coroutines.test.TestResult
1921
import kotlinx.coroutines.test.runTest
2022

@@ -47,6 +49,8 @@ class FlowAfterCryptTestCase(
4749
confirmRepeatPasswordSNI.performTextReplacement(text = password)
4850
closeSoftKeyboard()
4951
confirmDialogButtonSNI.performClick()
52+
composeUiTest.awaitIdle()
53+
composeUiTest.waitUntilNotExist(tag = CONFIRM_PASSWORD_DIALOG_TAG)
5054
}
5155
composeUiTest.waitAssert("encrypt switch is ON", encryptionSwitchSNI::assertIsOn)
5256
pressBack()

ui/test/src/commonMain/kotlin/com/softartdev/notedelight/ui/cases/PrepopulateDbTestCase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PrepopulateDbTestCase(
2222
private val noteDAO: NoteDAO by KoinPlatform.getKoin().inject()
2323
private val createNoteUseCase: CreateNoteUseCase by KoinPlatform.getKoin().inject()
2424

25-
override fun invoke() = runTest(timeout = 2.minutes) {
25+
override fun invoke() = runTest(timeout = 3.minutes) {
2626
noteDAO.listFlow.test {
2727
var notes: List<Note> = awaitItem()
2828
assertEquals(0, notes.size)

ui/test/src/commonMain/kotlin/com/softartdev/notedelight/ui/cases/SettingPasswordTestCase.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class SettingPasswordTestCase(
8484

8585
confirmRepeatPasswordSNI.performTextReplacement(text = "1")
8686
confirmDialogButtonSNI.performClick()
87+
composeUiTest.awaitIdle()
8788
composeUiTest.waitUntilNotExist(tag = CONFIRM_PASSWORD_DIALOG_TAG)
8889
}
8990
logger.i { "SettingsTestScreen: proceeding to change password" }

0 commit comments

Comments
 (0)