Skip to content

Commit

Permalink
onboarding polling to wait for lotties
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Manrique committed Nov 1, 2024
1 parent 05c09ab commit 27bdbe7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import com.jmp.examsfeature.presentation.list.screens.ExamsScreenTestTags.EMPTY_
import com.jmp.onboardingfeature.OnboardingCarouselScreenTestTags.FIRST_ONBOARDING_LOTTIE
import com.jmp.onboardingfeature.OnboardingCarouselScreenTestTags.NEXT_BUTTON
import com.jmp.onboardingfeature.OnboardingCarouselScreenTestTags.ONBOARDING_SCREEN_NAME
import com.jmp.onboardingfeature.OnboardingCarouselScreenTestTags.SECOND_ONBOARDING_LOTTIE
import com.jmp.onboardingfeature.OnboardingCarouselScreenTestTags.SKIP_BUTTON
import com.jmp.onboardingfeature.OnboardingCarouselScreenTestTags.THIRD_ONBOARDING_LOTTIE
import com.jmp.xtudent.core.TestUtils.waitForNode
import com.jmp.xtudent.features.exams.list.screen.ExamsScreen

Expand Down Expand Up @@ -42,9 +44,21 @@ open class OnboardingCarouselScreen(
}

fun waitUntilFirstLottieIsLoaded(): OnboardingCarouselScreen = apply {
waitUntilLottieIsLoaded(FIRST_ONBOARDING_LOTTIE)
}

fun waitUntilSecondLottieIsLoaded(): OnboardingCarouselScreen = apply {
waitUntilLottieIsLoaded(SECOND_ONBOARDING_LOTTIE)
}

fun waitUntilThirdLottieIsLoaded(): OnboardingCarouselScreen = apply {
waitUntilLottieIsLoaded(THIRD_ONBOARDING_LOTTIE)
}

private fun waitUntilLottieIsLoaded(testTag: String): OnboardingCarouselScreen = apply {
waitUntil {
composeTestRule
.onNodeWithTag(FIRST_ONBOARDING_LOTTIE)
.onNodeWithTag(testTag)
.fetchSemanticsNode()
.config
.getOrNull(SemanticsProperties.ProgressBarRangeInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ open class OnboardingCarouselScreenTest : UiTest() {
@Test
fun shouldOpenOnboardingCarouselScreen() = runTest {
onOnboardingCarouselScreen()
.waitUntilFirstLottieIsLoaded()

compareScreenshot(composeRule)
}
Expand All @@ -30,6 +31,7 @@ open class OnboardingCarouselScreenTest : UiTest() {
fun shouldNavigateToSecondOnboardingSlide() = runTest {
onOnboardingCarouselScreen()
.tapOnNextButton()
.waitUntilSecondLottieIsLoaded()

compareScreenshot(composeRule)
}
Expand All @@ -39,6 +41,7 @@ open class OnboardingCarouselScreenTest : UiTest() {
onOnboardingCarouselScreen()
.tapOnNextButton()
.tapOnNextButton()
.waitUntilThirdLottieIsLoaded()

compareScreenshot(composeRule)
}
Expand Down

0 comments on commit 27bdbe7

Please sign in to comment.