Skip to content

Commit

Permalink
Make manage test less flakey. (#10223)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynewstrom-stripe authored Feb 19, 2025
1 parent eb2329b commit 69cc19b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ internal class ManageActivity : AppCompatActivity() {
finish()
}
) {
val screen by manageNavigator.screen.collectAsState()
Box(modifier = Modifier.padding(bottom = 20.dp)) {
ScreenContent(manageNavigator, screen)
}
LaunchedEffect(screen) {
manageNavigator.result.collect { result ->
setManageResult()
finish()
var hasResult by remember { mutableStateOf(false) }
if (!hasResult) {
val screen by manageNavigator.screen.collectAsState()
Box(modifier = Modifier.padding(bottom = 20.dp)) {
ScreenContent(manageNavigator, screen)
}
LaunchedEffect(screen) {
manageNavigator.result.collect { result ->
setManageResult()
finish()
hasResult = true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ internal class ManageActivityTest {
editPage.waitUntilVisible()
editPage.setCardBrand("Visa")
editPage.update()
editPage.waitUntilMissing()
val updatedCbcCard = completedResultPaymentMethods().single()
assertThat(updatedCbcCard.card?.displayBrand).isEqualTo("visa")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ internal class EditPage(
}
}

fun waitUntilMissing() {
composeTestRule.waitUntil(timeoutMillis = 5_000) {
composeTestRule
.onAllNodes(hasTestTag(UPDATE_PM_SCREEN_TEST_TAG))
.fetchSemanticsNodes(atLeastOneRootRequired = false)
.isEmpty()
}
}

fun assertIsVisible() {
composeTestRule
.onNodeWithTag(UPDATE_PM_SCREEN_TEST_TAG)
Expand Down

0 comments on commit 69cc19b

Please sign in to comment.