fix(test): add Compose waitUntil synchronization in ChatViewModelScopeTest
This commit is contained in:
parent
c691d558f2
commit
97f2f929c3
1 changed files with 23 additions and 4 deletions
|
|
@ -1,11 +1,11 @@
|
|||
package app.hermes.mobile.feature.chat
|
||||
|
||||
import androidx.compose.ui.test.assertExists
|
||||
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performTextInput
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import app.hermes.mobile.MainActivity
|
||||
import org.junit.Rule
|
||||
|
|
@ -20,11 +20,25 @@ class ChatViewModelScopeTest {
|
|||
|
||||
@Test
|
||||
fun testChatStateSurvivesRecreation() {
|
||||
// Create session
|
||||
// Wait for New Session button and click
|
||||
composeTestRule.waitUntil(5000) {
|
||||
composeTestRule.onAllNodesWithText("New Session", substring = true, ignoreCase = true)
|
||||
.fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
composeTestRule.onNodeWithText("New Session", ignoreCase = true).performClick()
|
||||
|
||||
// Wait for Create dialog button and click
|
||||
composeTestRule.waitUntil(5000) {
|
||||
composeTestRule.onAllNodesWithText("Create", substring = true, ignoreCase = true)
|
||||
.fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
composeTestRule.onNodeWithText("Create", ignoreCase = true).performClick()
|
||||
|
||||
composeTestRule.onNodeWithText("Message Hermes…", ignoreCase = true).assertIsDisplayed()
|
||||
// Wait for ChatScreen input placeholder
|
||||
composeTestRule.waitUntil(5000) {
|
||||
composeTestRule.onAllNodesWithText("Message Hermes…", substring = true, ignoreCase = true)
|
||||
.fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText("Message Hermes…", ignoreCase = true)
|
||||
.performTextInput("Draft prompt before rotation")
|
||||
|
|
@ -33,6 +47,11 @@ class ChatViewModelScopeTest {
|
|||
composeTestRule.activityRule.scenario.recreate()
|
||||
composeTestRule.waitForIdle()
|
||||
|
||||
// Verify text state persisted across recreation
|
||||
composeTestRule.waitUntil(5000) {
|
||||
composeTestRule.onAllNodesWithText("Draft prompt before rotation", substring = true)
|
||||
.fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
composeTestRule.onNodeWithText("Draft prompt before rotation", substring = true).assertExists()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue