Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Close #20797: Fix intermittent test failures in ShortcutsSuggestionPr…
Browse files Browse the repository at this point in the history
…oviderTest
  • Loading branch information
jonalmeida committed Aug 14, 2021
1 parent 545a59a commit 0556e6b
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkStatic
import io.mockk.verifySequence
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import mozilla.components.browser.state.search.SearchEngine
Expand All @@ -19,8 +18,8 @@ import mozilla.components.browser.state.state.SearchState
import mozilla.components.browser.state.store.BrowserStore
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.mozilla.fenix.R

Expand Down Expand Up @@ -63,9 +62,10 @@ class ShortcutsSuggestionProviderTest {
)
)
)
val provider = ShortcutsSuggestionProvider(store, context, mockk(), mockk())
val provider = ShortcutsSuggestionProvider(store, context, {}, {})

val suggestions = provider.onInputChanged("")

assertEquals(3, suggestions.size)

assertEquals(provider, suggestions[0].provider)
Expand All @@ -83,7 +83,6 @@ class ShortcutsSuggestionProviderTest {
assertEquals("Search engine settings", suggestions[2].title)
}

@Ignore("See https://github.com/mozilla-mobile/fenix/issues/20797")
@Test
fun `callbacks are triggered when suggestions are clicked`() = runBlockingTest {
val engineOne = mockk<SearchEngine>(relaxed = true)
Expand All @@ -95,13 +94,13 @@ class ShortcutsSuggestionProviderTest {
)
)

val selectShortcutEngine = mockk<(SearchEngine) -> Unit>(relaxed = true)
val selectShortcutEngineSettings = mockk<() -> Unit>(relaxed = true)
var selectEngine: SearchEngine? = null
var selectShortcutEngineSettingsChanged = false
val provider = ShortcutsSuggestionProvider(
store,
context,
selectShortcutEngine,
selectShortcutEngineSettings
{ selectEngine = it },
{ selectShortcutEngineSettingsChanged = true }
)

val suggestions = provider.onInputChanged("")
Expand All @@ -110,9 +109,7 @@ class ShortcutsSuggestionProviderTest {
suggestions[0].onSuggestionClicked?.invoke()
suggestions[1].onSuggestionClicked?.invoke()

verifySequence {
selectShortcutEngine(engineOne)
selectShortcutEngineSettings()
}
assertEquals(engineOne, selectEngine)
assertTrue(selectShortcutEngineSettingsChanged)
}
}

0 comments on commit 0556e6b

Please sign in to comment.