Issue#41 Remove waitForIdle since onNode already calls it
This commit is contained in:
parent
f03c9f7bf2
commit
a4b1e50f0f
3 changed files with 2 additions and 16 deletions
|
|
@ -71,7 +71,6 @@ class AuthComposeInstrumentedTest : KoinTest {
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
navigationRobot.assertHomeScreen()
|
navigationRobot.assertHomeScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +84,6 @@ class AuthComposeInstrumentedTest : KoinTest {
|
||||||
.assertUsername("banan")
|
.assertUsername("banan")
|
||||||
.clickOnLogin()
|
.clickOnLogin()
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.password_is_invalid)
|
robot.assertErrorIsShown(R.string.password_is_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -102,7 +100,6 @@ class AuthComposeInstrumentedTest : KoinTest {
|
||||||
.assertPassword("banan")
|
.assertPassword("banan")
|
||||||
.clickOnLogin()
|
.clickOnLogin()
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.username_is_invalid)
|
robot.assertErrorIsShown(R.string.username_is_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -128,7 +125,6 @@ class AuthComposeInstrumentedTest : KoinTest {
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.credentials_invalid)
|
robot.assertErrorIsShown(R.string.credentials_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -154,7 +150,6 @@ class AuthComposeInstrumentedTest : KoinTest {
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.something_went_wrong)
|
robot.assertErrorIsShown(R.string.something_went_wrong)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
|
||||||
|
|
@ -220,12 +220,12 @@ composeTestRule.mainClock.autoAdvance = true // Let clock auto advance again
|
||||||
|
|
||||||
Lastly we check the navigation was correct, meaning we should be on the home screen:
|
Lastly we check the navigation was correct, meaning we should be on the home screen:
|
||||||
```kotlin
|
```kotlin
|
||||||
composeTestRule.waitForIdle() // wait for login network call idling resource
|
|
||||||
navigationRobot.assertHomeScreen()
|
navigationRobot.assertHomeScreen()
|
||||||
```
|
```
|
||||||
|
|
||||||
> waitForIdle is necessary to wait for the Coroutine then the Network Call to finish. The Network call is running on OkHttps's own thread, so we use IdlingResources to synchronize with it. This is done in the ComposeNetworkSynchronizationTestRule.
|
> Note: Any node interactions call waitForIdle which waits for the Coroutine then the Network Call to finish. The Network call is running on OkHttps's own thread, so we use IdlingResources to synchronize with it. This is done in the ComposeNetworkSynchronizationTestRule.
|
||||||
> waitForIdle blocks the current thread while the Resources are busy. There is an alternative awaitIdle() which can be useful in runTest suspendable tests, feel free to look inside the Interface of ComposeTestRule.
|
> waitForIdle blocks the current thread while the Resources are busy. There is an alternative awaitIdle() which can be useful in runTest suspendable tests, feel free to look inside the Interface of ComposeTestRule.
|
||||||
|
> If you don't interact with a node but want to synchronize, then you will need waitForIdle. For example to verify something was called or written into like FakeLocalStorage in this example
|
||||||
> Basically since we have OkHttpIdlingResource as an EspressoIdlingResource we adapt that to Compose's IdlingResource class and register it with the ComposeTestRule and unregister it at the end.
|
> Basically since we have OkHttpIdlingResource as an EspressoIdlingResource we adapt that to Compose's IdlingResource class and register it with the ComposeTestRule and unregister it at the end.
|
||||||
|
|
||||||
### 2. `emptyPasswordShowsProperErrorMessage`
|
### 2. `emptyPasswordShowsProperErrorMessage`
|
||||||
|
|
@ -247,7 +247,6 @@ robot.setUsername("banan")
|
||||||
|
|
||||||
Finally we let coroutines go and verify the error is shown and we have not navigated:
|
Finally we let coroutines go and verify the error is shown and we have not navigated:
|
||||||
```kotlin
|
```kotlin
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.password_is_invalid)
|
robot.assertErrorIsShown(R.string.password_is_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -267,7 +266,6 @@ robot
|
||||||
.assertPassword("banan")
|
.assertPassword("banan")
|
||||||
.clickOnLogin()
|
.clickOnLogin()
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.username_is_invalid)
|
robot.assertErrorIsShown(R.string.username_is_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -300,7 +298,6 @@ composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
Now at the end verify the error is shown properly:
|
Now at the end verify the error is shown properly:
|
||||||
```kotlin
|
```kotlin
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.credentials_invalid)
|
robot.assertErrorIsShown(R.string.credentials_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -330,7 +327,6 @@ composeTestRule.mainClock.advanceTimeByFrame()
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.something_went_wrong)
|
robot.assertErrorIsShown(R.string.something_went_wrong)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ class AuthComposeInstrumentedTest {
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
navigationRobot.assertHomeScreen()
|
navigationRobot.assertHomeScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +100,6 @@ class AuthComposeInstrumentedTest {
|
||||||
.assertUsername("banan")
|
.assertUsername("banan")
|
||||||
.clickOnLogin()
|
.clickOnLogin()
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.password_is_invalid)
|
robot.assertErrorIsShown(R.string.password_is_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -118,7 +116,6 @@ class AuthComposeInstrumentedTest {
|
||||||
.assertPassword("banan")
|
.assertPassword("banan")
|
||||||
.clickOnLogin()
|
.clickOnLogin()
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.username_is_invalid)
|
robot.assertErrorIsShown(R.string.username_is_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -144,7 +141,6 @@ class AuthComposeInstrumentedTest {
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.credentials_invalid)
|
robot.assertErrorIsShown(R.string.credentials_invalid)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
@ -170,7 +166,6 @@ class AuthComposeInstrumentedTest {
|
||||||
robot.assertLoading()
|
robot.assertLoading()
|
||||||
composeTestRule.mainClock.autoAdvance = true
|
composeTestRule.mainClock.autoAdvance = true
|
||||||
|
|
||||||
composeTestRule.waitForIdle()
|
|
||||||
robot.assertErrorIsShown(R.string.something_went_wrong)
|
robot.assertErrorIsShown(R.string.something_went_wrong)
|
||||||
.assertNotLoading()
|
.assertNotLoading()
|
||||||
navigationRobot.assertAuthScreen()
|
navigationRobot.assertAuthScreen()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue