Created
May 7, 2026 19:50
-
-
Save LethalMaus/3d1f8206803078c7e2d36d17fbcb264c to your computer and use it in GitHub Desktop.
Dejavu mapping repro test for article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package dev.repro.dejavu | |
| import androidx.activity.ComponentActivity | |
| import androidx.compose.runtime.getValue | |
| import androidx.compose.runtime.mutableStateOf | |
| import androidx.compose.runtime.setValue | |
| import androidx.compose.ui.test.junit4.ComposeTestRule | |
| import androidx.compose.ui.test.onNodeWithTag | |
| import androidx.test.ext.junit.runners.AndroidJUnit4 | |
| import dejavu.assertRecompositions | |
| import dejavu.assertStable | |
| import dejavu.createRecompositionTrackingRule | |
| import dejavu.resetRecompositionCounts | |
| import org.junit.Rule | |
| import org.junit.Test | |
| import org.junit.runner.RunWith | |
| @RunWith(AndroidJUnit4::class) | |
| class ReproTest { | |
| @get:Rule | |
| val composeRule = createRecompositionTrackingRule<ComponentActivity>() | |
| @Test | |
| fun changingRetryState_recomposesStatusCard_only() { | |
| var isRetrying by mutableStateOf(false) | |
| composeRule.setContent { | |
| ReproScreen(isRetrying = isRetrying) | |
| } | |
| composeRule.resetAndWait() | |
| composeRule.runOnIdle { | |
| isRetrying = true | |
| } | |
| composeRule.waitForIdle() | |
| composeRule.onNodeWithTag(REPRO_STATUS_CARD_TAG).assertRecompositions(atLeast = 1) | |
| composeRule.onNodeWithTag(REPRO_TOP_BAR_TAG).assertStable() | |
| } | |
| } | |
| private fun ComposeTestRule.resetAndWait() { | |
| waitForIdle() | |
| resetRecompositionCounts() | |
| waitForIdle() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment