diff --git a/CHANGELOG.md b/CHANGELOG.md index ef7837d2cb..20f4d0f131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Attention: don't forget to add the flag for F-Droid before release - [FIX] Relocate remote-controls button to infrared remotes screen - [FIX] Fap manifest caching - [FIX] Remote controls design issues +- [FIX] Fix flaky test - [CI] Fix merge-queue files diff - [CI] Add https://github.com/LionZXY/detekt-decompose-rule - [CI] Enabling detekt module for android and kmp modules diff --git a/components/faphub/installedtab/impl/src/test/kotlin/com/flipperdevices/faphub/installedtab/impl/viewmodel/InstalledFapsUidsProducerTest.kt b/components/faphub/installedtab/impl/src/test/kotlin/com/flipperdevices/faphub/installedtab/impl/viewmodel/InstalledFapsUidsProducerTest.kt index 1db5fff904..0fd6e3a4ba 100644 --- a/components/faphub/installedtab/impl/src/test/kotlin/com/flipperdevices/faphub/installedtab/impl/viewmodel/InstalledFapsUidsProducerTest.kt +++ b/components/faphub/installedtab/impl/src/test/kotlin/com/flipperdevices/faphub/installedtab/impl/viewmodel/InstalledFapsUidsProducerTest.kt @@ -12,11 +12,9 @@ import kotlinx.coroutines.cancelAndJoin import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import kotlinx.coroutines.plus -import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest import org.junit.Assert import org.junit.Before @@ -83,7 +81,7 @@ class InstalledFapsUidsProducerTest { } @Test - fun `reinvalidate don't refresh cache`() = runTest { + fun `reinvalidate don't refresh cache`() = runTest(UnconfinedTestDispatcher()) { fapManifestStateFlow.emit( FapManifestState.Loaded( items = persistentListOf(getTestManifest("TEST")), @@ -92,9 +90,11 @@ class InstalledFapsUidsProducerTest { ) val states = mutableListOf() - val stateSubscribeJob = underTest.getUidsStateFlow().onEach { - states.add(it) - }.launchIn(this + testScheduler) + val stateSubscribeJob = launch { + underTest.getUidsStateFlow().collect { + states.add(it) + } + } var job = launch { underTest.refresh(this, force = true) @@ -103,8 +103,6 @@ class InstalledFapsUidsProducerTest { it is FapInstalledUidsState.Loaded && it.faps.isNotEmpty() }.first() - advanceUntilIdle() - Assert.assertArrayEquals( arrayOf( FapInstalledUidsState.Loaded(faps = persistentListOf(), inProgress = true), @@ -134,7 +132,6 @@ class InstalledFapsUidsProducerTest { underTest.getUidsStateFlow().filter { it is FapInstalledUidsState.Loaded && it.faps.find { it.applicationUid == "TEST2" } != null }.first() - advanceUntilIdle() Assert.assertArrayEquals( arrayOf(