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

Commit

Permalink
Test that we ignore search terms/referrer in case of a direct load
Browse files Browse the repository at this point in the history
  • Loading branch information
Grisha Kruglov committed Sep 28, 2021
1 parent 5aae5b7 commit a035a01
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import io.mockk.slot
import io.mockk.verify
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.components.browser.state.action.ContentAction
import mozilla.components.browser.state.action.EngineAction
import mozilla.components.browser.state.action.MediaSessionAction
import mozilla.components.browser.state.action.SearchAction
import mozilla.components.browser.state.action.TabListAction
Expand Down Expand Up @@ -159,6 +160,30 @@ class HistoryMetadataMiddlewareTest {
}
}

@Test
fun `GIVEN a normal tab with history state WHEN directly loaded THEN search terms and referrer not recorded`() {
val tab = createTab("https://mozilla.org")
store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking()
setupGoogleSearchEngine()

val historyState = listOf(
HistoryItem("firefox", "https://google.com?q=mozilla+website"),
HistoryItem("mozilla", "https://mozilla.org")
)
store.dispatch(EngineAction.LoadUrlAction(tab.id, tab.content.url))
store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)).joinBlocking()

verify {
service.createMetadata(any(), null, null)
}

// Once direct load is "consumed", we're looking up the history stack again.
store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)).joinBlocking()
verify {
service.createMetadata(any(), eq("mozilla website"), eq("https://google.com?q=mozilla+website"))
}
}

@Test
fun `GIVEN private tab WHEN loading completed THEN no meta data is recorded`() {
val tab = createTab("https://mozilla.org", private = true)
Expand Down

0 comments on commit a035a01

Please sign in to comment.