@ -384,7 +384,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN a list of history highlights and groups WHEN updateState is called THEN emit RecentHistoryChange` ( ) {
val feature = spyk ( RecentVisitsFeature ( homeStore , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) ))
val feature = spyk ( RecentVisitsFeature ( homeStore , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false ))
val expected = List < RecentHistoryHighlight > ( 1 ) { mockk ( ) }
every { feature . getCombinedHistory ( any ( ) , any ( ) ) } returns expected
@ -398,7 +398,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN highlights visits exist in search groups WHEN getCombined is called THEN remove the highlights already in groups` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 4 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 4 )
val directDupeVisits = getSearchFromHistoryMetadataItems ( 2 ) . map {
@ -422,7 +422,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN fewer than needed highlights and search groups WHEN getCombined is called THEN the result is sorted by date` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 4 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 4 )
val expected = directVisits . reversed ( ) . toRecentHistoryHighlights ( )
@ -441,7 +441,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN more highlights are newer than search groups WHEN getCombined is called THEN then return an even split then sorted by date` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 5 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 14 )
val expected = directVisits . takeLast ( 5 ) . reversed ( ) . toRecentHistoryHighlights ( ) +
@ -457,7 +457,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN more search groups are newer than highlights WHEN getCombined is called THEN then return an even split then sorted by date` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 14 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 5 )
val expected = visitsFromSearch . takeLast ( 4 ) . toIndividualRecentHistoryGroups ( ) +
@ -473,7 +473,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN all highlights have metadata WHEN getHistoryHighlights is called THEN return a list of highlights with an inferred last access time` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
@ -490,7 +490,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN not all highlights have metadata WHEN getHistoryHighlights is called THEN set 0 for the highlights with not found last access time` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
val highlightsWithUnknownAccessTime = directVisits . toHistoryHighlightsInternal ( ) . take ( 5 ) . map {
@ -511,7 +511,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN multiple metadata records for the same highlight WHEN getHistoryHighlights is called THEN set the latest access time from multiple available` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
val newerDirectVisits = directVisits . mapIndexed { index , item ->
@ -533,7 +533,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN multiple metadata entries only for direct accessed pages WHEN getHistorySearchGroups is called THEN return an empty list` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
val result = feature . getHistorySearchGroups ( directVisits )
@ -543,7 +543,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN multiple metadata entries WHEN getHistorySearchGroups is called THEN group all entries by their search term` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
@ -556,7 +556,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN multiple metadata entries for the same url WHEN getHistorySearchGroups is called THEN entries are deduped` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val newerVisitsFromSearch = visitsFromSearch . map { it . copy ( updatedAt = it . updatedAt * 2 ) }
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
@ -575,7 +575,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN highlights and search groups WHEN getSortedHistory is called THEN sort descending all items based on the last access time` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 )
val expected = directVisits . reversed ( ) . toRecentHistoryHighlights ( )
@ -594,7 +594,7 @@ class RecentVisitsFeatureTest {
@Test
fun `GIVEN highlights don't have a valid title WHEN getSortedHistory is called THEN the url is set as title` ( ) {
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) )
val feature = RecentVisitsFeature ( mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , mockk ( ) , false )
val visitsFromSearch = getSearchFromHistoryMetadataItems ( 10 )
val directVisits = getDirectVisitsHistoryMetadataItems ( 10 ) . mapIndexed { index , item ->
when ( index % 3 ) {
@ -646,6 +646,7 @@ class RecentVisitsFeatureTest {
lazy { historyHightlightsStorage } ,
CoroutineScope ( testDispatcher ) ,
testDispatcher ,
false
)
assertEquals ( emptyList < RecentHistoryGroup > ( ) , homeStore . state . recentHistory )