From 369ef222fd913fdf8c156dee1fd9ee8ddd31b94a Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Fri, 28 May 2021 02:51:00 +0400 Subject: [PATCH] [fenix] Close https://github.com/mozilla-mobile/fenix/issues/19459: Use Store.waitUntilIdle in intermittent failing test (https://github.com/mozilla-mobile/fenix/pull/19683) --- .../fenix/nimbus/NimbusBranchesControllerTest.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesControllerTest.kt b/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesControllerTest.kt index 1784e11ae..6f436f4b3 100644 --- a/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesControllerTest.kt @@ -7,7 +7,8 @@ package org.mozilla.fenix.nimbus import io.mockk.mockk import io.mockk.verify import mozilla.components.service.nimbus.NimbusApi -import mozilla.components.support.test.mock +import mozilla.components.support.test.libstate.ext.waitUntilIdle +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import org.mozilla.experiments.nimbus.Branch @@ -23,7 +24,7 @@ class NimbusBranchesControllerTest { @Before fun setup() { - nimbusBranchesStore = mock() + nimbusBranchesStore = NimbusBranchesStore(NimbusBranchesState(emptyList())) controller = NimbusBranchesController(nimbusBranchesStore, experiments, experimentId) } @@ -36,9 +37,12 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) + nimbusBranchesStore.waitUntilIdle() + verify { experiments.optInWithBranch(experimentId, branch.slug) - nimbusBranchesStore.dispatch(NimbusBranchesAction.UpdateSelectedBranch(branch.slug)) } + + assertEquals(branch.slug, nimbusBranchesStore.state.selectedBranch) } }