@ -36,25 +36,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertEquals ( updatedBookmark , s tore. state . recentBookmarks [ 0 ] )
assertEquals ( updatedBookmark , appS tore. state . recentBookmarks [ 0 ] )
}
@Test
@ -63,25 +63,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( " https://www.github.org/ " . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertEquals ( updatedBookmark , s tore. state . recentBookmarks [ 0 ] )
assertEquals ( updatedBookmark , appS tore. state . recentBookmarks [ 0 ] )
}
@Test
@ -90,25 +90,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( " https://github.com/mozilla-mobile/fenix " . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertEquals ( updatedBookmark , s tore. state . recentBookmarks [ 0 ] )
assertEquals ( updatedBookmark , appS tore. state . recentBookmarks [ 0 ] )
}
@Test
@ -117,25 +117,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( " https://www.mozilla.org/ " . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertTrue ( s tore. state . recentBookmarks . isEmpty ( ) )
assertTrue ( appS tore. state . recentBookmarks . isEmpty ( ) )
}
@Test
@ -146,26 +146,26 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( blockedUrl . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = updatedRecentTabs ,
recentBookmarks = updatedBookmarks ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertTrue ( s tore. state . recentBookmarks . isEmpty ( ) )
assertTrue ( s tore. state . recentTabs . isEmpty ( ) )
assertTrue ( appS tore. state . recentBookmarks . isEmpty ( ) )
assertTrue ( appS tore. state . recentTabs . isEmpty ( ) )
}
@Test
@ -184,26 +184,26 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( blockedUrl . stripAndHash ( ) )
every { mockSettings . frecencyFilterQuery } returns " "
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = updatedRecentTabs ,
recentBookmarks = updatedBookmarks ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertEquals ( unblockedBookmark , s tore. state . recentBookmarks [ 0 ] )
assertEquals ( unblockedRecentTab , s tore. state . recentTabs [ 0 ] )
assertEquals ( unblockedBookmark , appS tore. state . recentBookmarks [ 0 ] )
assertEquals ( unblockedRecentTab , appS tore. state . recentTabs [ 0 ] )
}
@Test
@ -216,12 +216,12 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( ) andThen setOf ( removedUrl . stripAndHash ( ) )
every { mockSettings . homescreenBlocklist = capture ( updateSlot ) } returns Unit
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( recentBookmarks = listOf ( removedBookmark ) ) ,
middlewares = listOf ( middleware , captureMiddleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . RemoveRecentBookmark ( removedBookmark ) ,
) . joinBlocking ( )
@ -237,25 +237,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( " https:// $host " . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertTrue ( s tore. state . recentBookmarks . isEmpty ( ) )
assertTrue ( appS tore. state . recentBookmarks . isEmpty ( ) )
}
@Test
@ -265,25 +265,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( host . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertTrue ( s tore. state . recentBookmarks . isEmpty ( ) )
assertTrue ( appS tore. state . recentBookmarks . isEmpty ( ) )
}
@Test
@ -293,25 +293,25 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( " https:// $host " . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . Change (
topSites = s tore. state . topSites ,
mode = s tore. state . mode ,
collections = s tore. state . collections ,
showCollectionPlaceholder = s tore. state . showCollectionPlaceholder ,
recentTabs = s tore. state . recentTabs ,
topSites = appS tore. state . topSites ,
mode = appS tore. state . mode ,
collections = appS tore. state . collections ,
showCollectionPlaceholder = appS tore. state . showCollectionPlaceholder ,
recentTabs = appS tore. state . recentTabs ,
recentBookmarks = listOf ( updatedBookmark ) ,
recentHistory = s tore. state . recentHistory ,
recentSyncedTabState = s tore. state . recentSyncedTabState ,
recentHistory = appS tore. state . recentHistory ,
recentSyncedTabState = appS tore. state . recentSyncedTabState ,
) ,
) . joinBlocking ( )
assertTrue ( s tore. state . recentBookmarks . isEmpty ( ) )
assertTrue ( appS tore. state . recentBookmarks . isEmpty ( ) )
}
@Test
@ -335,12 +335,12 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( blockedHost . stripAndHash ( ) )
every { mockSettings . frecencyFilterQuery } returns " "
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . RecentSyncedTabStateChange (
RecentSyncedTabState . Success (
listOf (
@ -353,7 +353,7 @@ class BlocklistMiddlewareTest {
assertEquals (
allowedTab ,
( s tore. state . recentSyncedTabState as RecentSyncedTabState . Success ) . tabs . single ( ) ,
( appS tore. state . recentSyncedTabState as RecentSyncedTabState . Success ) . tabs . single ( ) ,
)
}
@ -362,18 +362,18 @@ class BlocklistMiddlewareTest {
val blockedHost = " https://www.mozilla.org "
every { mockSettings . homescreenBlocklist } returns setOf ( blockedHost . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . RecentSyncedTabStateChange (
RecentSyncedTabState . None ,
) ,
) . joinBlocking ( )
assertEquals ( RecentSyncedTabState . None , s tore. state . recentSyncedTabState )
assertEquals ( RecentSyncedTabState . None , appS tore. state . recentSyncedTabState )
}
@Test
@ -389,12 +389,12 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( blockedHost . stripAndHash ( ) )
val middleware = BlocklistMiddleware ( blocklistHandler )
val s tore = AppStore (
val appS tore = AppStore (
AppState ( ) ,
middlewares = listOf ( middleware ) ,
)
s tore. dispatch (
appS tore. dispatch (
AppAction . RecentSyncedTabStateChange (
RecentSyncedTabState . Success (
listOf ( blockedTab ) ,
@ -404,7 +404,7 @@ class BlocklistMiddlewareTest {
assertEquals (
RecentSyncedTabState . None ,
s tore. state . recentSyncedTabState ,
appS tore. state . recentSyncedTabState ,
)
}
@ -434,7 +434,7 @@ class BlocklistMiddlewareTest {
previewImageUrl = null ,
) ,
)
val s tore = AppStore (
val appS tore = AppStore (
AppState ( recentSyncedTabState = RecentSyncedTabState . Success ( currentTabs ) ) ,
middlewares = listOf ( BlocklistMiddleware ( blocklistHandler ) ) ,
)
@ -443,7 +443,7 @@ class BlocklistMiddlewareTest {
every { mockSettings . homescreenBlocklist } returns setOf ( tabUrls [ 0 ] . stripAndHash ( ) )
every { mockSettings . frecencyFilterQuery } returns " "
s tore. dispatch (
appS tore. dispatch (
AppAction . RemoveRecentSyncedTab (
currentTabs . first ( ) ,
) ,
@ -451,12 +451,12 @@ class BlocklistMiddlewareTest {
assertEquals (
2 ,
( s tore. state . recentSyncedTabState as RecentSyncedTabState . Success ) . tabs . size ,
( appS tore. state . recentSyncedTabState as RecentSyncedTabState . Success ) . tabs . size ,
)
assertEquals ( setOf ( tabUrls [ 0 ] . stripAndHash ( ) ) , updateSlot . captured )
assertEquals (
currentTabs [ 1 ] ,
( s tore. state . recentSyncedTabState as RecentSyncedTabState . Success ) . tabs . firstOrNull ( ) ,
( appS tore. state . recentSyncedTabState as RecentSyncedTabState . Success ) . tabs . firstOrNull ( ) ,
)
}
}