|
|
|
@ -47,6 +47,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState,
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -73,6 +74,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState,
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -99,6 +101,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState,
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -125,6 +128,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -153,6 +157,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = updatedRecentTabs,
|
|
|
|
|
recentBookmarks = updatedBookmarks,
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -188,6 +193,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = updatedRecentTabs,
|
|
|
|
|
recentBookmarks = updatedBookmarks,
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -240,6 +246,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -267,6 +274,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -294,6 +302,7 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
recentTabs = store.state.recentTabs,
|
|
|
|
|
recentBookmarks = listOf(updatedBookmark),
|
|
|
|
|
recentHistory = store.state.recentHistory,
|
|
|
|
|
recentSyncedTabState = store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
@ -308,14 +317,14 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
deviceType = mock(),
|
|
|
|
|
title = "",
|
|
|
|
|
url = "https://www.mozilla.org",
|
|
|
|
|
previewImageUrl = ""
|
|
|
|
|
previewImageUrl = null
|
|
|
|
|
)
|
|
|
|
|
val allowedTab = RecentSyncedTab(
|
|
|
|
|
deviceDisplayName = "",
|
|
|
|
|
deviceType = mock(),
|
|
|
|
|
title = "",
|
|
|
|
|
url = "https://github.com",
|
|
|
|
|
previewImageUrl = ""
|
|
|
|
|
previewImageUrl = null
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
every { mockSettings.homescreenBlocklist } returns setOf(blockedHost.stripAndHash())
|
|
|
|
@ -341,4 +350,105 @@ class BlocklistMiddlewareTest {
|
|
|
|
|
(store.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.single()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `WHEN the recent synced tab state is changed to None or Loading THEN the middleware does not change the state`() {
|
|
|
|
|
val blockedHost = "https://www.mozilla.org"
|
|
|
|
|
every { mockSettings.homescreenBlocklist } returns setOf(blockedHost.stripAndHash())
|
|
|
|
|
val middleware = BlocklistMiddleware(blocklistHandler)
|
|
|
|
|
val store = AppStore(
|
|
|
|
|
AppState(),
|
|
|
|
|
middlewares = listOf(middleware)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
store.dispatch(
|
|
|
|
|
AppAction.RecentSyncedTabStateChange(
|
|
|
|
|
RecentSyncedTabState.None
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
|
assertEquals(RecentSyncedTabState.None, store.state.recentSyncedTabState)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `WHEN all recently synced submitted tabs are blocked THEN the recent synced tab state should be set to None`() {
|
|
|
|
|
val blockedHost = "https://www.mozilla.org"
|
|
|
|
|
val blockedTab = RecentSyncedTab(
|
|
|
|
|
deviceDisplayName = "",
|
|
|
|
|
deviceType = mock(),
|
|
|
|
|
title = "",
|
|
|
|
|
url = "https://www.mozilla.org",
|
|
|
|
|
previewImageUrl = null
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
every { mockSettings.homescreenBlocklist } returns setOf(blockedHost.stripAndHash())
|
|
|
|
|
val middleware = BlocklistMiddleware(blocklistHandler)
|
|
|
|
|
val store = AppStore(
|
|
|
|
|
AppState(),
|
|
|
|
|
middlewares = listOf(middleware)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
store.dispatch(
|
|
|
|
|
AppAction.RecentSyncedTabStateChange(
|
|
|
|
|
RecentSyncedTabState.Success(
|
|
|
|
|
listOf(blockedTab)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
RecentSyncedTabState.None,
|
|
|
|
|
store.state.recentSyncedTabState
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `WHEN the most recent used synced tab is blocked THEN the following recent synced tabs remain ordered`() {
|
|
|
|
|
val tabUrls = listOf("link1", "link2", "link3")
|
|
|
|
|
val currentTabs = listOf(
|
|
|
|
|
RecentSyncedTab(
|
|
|
|
|
deviceDisplayName = "device1",
|
|
|
|
|
deviceType = mock(),
|
|
|
|
|
title = "",
|
|
|
|
|
url = tabUrls[0],
|
|
|
|
|
previewImageUrl = null
|
|
|
|
|
),
|
|
|
|
|
RecentSyncedTab(
|
|
|
|
|
deviceDisplayName = "",
|
|
|
|
|
deviceType = mock(),
|
|
|
|
|
title = "",
|
|
|
|
|
url = tabUrls[1],
|
|
|
|
|
previewImageUrl = null
|
|
|
|
|
),
|
|
|
|
|
RecentSyncedTab(
|
|
|
|
|
deviceDisplayName = "",
|
|
|
|
|
deviceType = mock(),
|
|
|
|
|
title = "",
|
|
|
|
|
url = tabUrls[2],
|
|
|
|
|
previewImageUrl = null
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
val store = AppStore(
|
|
|
|
|
AppState(recentSyncedTabState = RecentSyncedTabState.Success(currentTabs)),
|
|
|
|
|
middlewares = listOf(BlocklistMiddleware(blocklistHandler))
|
|
|
|
|
)
|
|
|
|
|
val updateSlot = slot<Set<String>>()
|
|
|
|
|
every { mockSettings.homescreenBlocklist = capture(updateSlot) } returns Unit
|
|
|
|
|
every { mockSettings.homescreenBlocklist } returns setOf(tabUrls[0].stripAndHash())
|
|
|
|
|
|
|
|
|
|
store.dispatch(
|
|
|
|
|
AppAction.RemoveRecentSyncedTab(
|
|
|
|
|
currentTabs.first()
|
|
|
|
|
)
|
|
|
|
|
).joinBlocking()
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
2, (store.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.size
|
|
|
|
|
)
|
|
|
|
|
assertEquals(setOf(tabUrls[0].stripAndHash()), updateSlot.captured)
|
|
|
|
|
assertEquals(
|
|
|
|
|
currentTabs[1],
|
|
|
|
|
(store.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.firstOrNull()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|