@ -45,10 +45,12 @@ class OnboardingMapperTest {
@Test
@Test
fun showNotificationTrue _showAddWidgetFalse _pagesToDisplay _returnsSortedListOfAllConvertedPages _withoutAddWidgetPage ( ) {
fun showNotificationTrue _showAddWidgetFalse _pagesToDisplay _returnsSortedListOfAllConvertedPages _withoutAddWidgetPage ( ) {
val expected = listOf ( defaultBrowserPageUiData , syncPageUiData , notificationPageUiData )
val expected = listOf ( defaultBrowserPageUiData WithPrivacyCaption , syncPageUiData , notificationPageUiData )
assertEquals (
assertEquals (
expected ,
expected ,
unsortedAllKnownCardData . toPageUiData (
unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = true ,
showNotificationPage = true ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -59,10 +61,12 @@ class OnboardingMapperTest {
@Test
@Test
fun showNotificationFalse _showAddWidgetFalse _pagesToDisplay _returnsSortedListOfConvertedPages _withoutNotificationPage _and _addWidgetPage ( ) {
fun showNotificationFalse _showAddWidgetFalse _pagesToDisplay _returnsSortedListOfConvertedPages _withoutNotificationPage _and _addWidgetPage ( ) {
val expected = listOf ( defaultBrowserPageUiData , syncPageUiData )
val expected = listOf ( defaultBrowserPageUiData WithPrivacyCaption , syncPageUiData )
assertEquals (
assertEquals (
expected ,
expected ,
unsortedAllKnownCardData . toPageUiData (
unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -71,12 +75,77 @@ class OnboardingMapperTest {
)
)
}
}
@Test
fun pagesToDisplay _returnsSortedListOfConvertedPages _withPrivacyCaption _alwaysOnFirstPage ( ) {
var result = unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
func = evalFunction ,
)
assertEquals ( result [ 0 ] . privacyCaption , privacyCaption )
result = unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = false ,
showNotificationPage = true ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
func = evalFunction ,
)
assertEquals ( result [ 0 ] . privacyCaption , privacyCaption )
assertEquals ( result [ 1 ] . privacyCaption , null )
result = unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = true ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
func = evalFunction ,
)
assertEquals ( result [ 0 ] . privacyCaption , privacyCaption )
assertEquals ( result [ 1 ] . privacyCaption , null )
assertEquals ( result [ 2 ] . privacyCaption , null )
result = unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = false ,
showNotificationPage = false ,
showAddWidgetPage = true ,
jexlConditions = jexlConditions ,
func = evalFunction ,
)
assertEquals ( result [ 0 ] . privacyCaption , privacyCaption )
assertEquals ( result [ 1 ] . privacyCaption , null )
}
@Test
fun showDefaultBrowserPageFalse _showNotificationFalse _showAddWidgetTrue _pagesToDisplay _returnsSortedListOfAllConvertedPages ( ) {
val expected = listOf ( addSearchWidgetPageUiDataWithPrivacyCaption , syncPageUiData )
assertEquals (
expected ,
unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = false ,
showNotificationPage = false ,
showAddWidgetPage = true ,
jexlConditions = jexlConditions ,
func = evalFunction ,
) ,
)
}
@Test
@Test
fun showNotificationFalse _showAddWidgetTrue _pagesToDisplay _returnsSortedListOfAllConvertedPages _withoutNotificationPage ( ) {
fun showNotificationFalse _showAddWidgetTrue _pagesToDisplay _returnsSortedListOfAllConvertedPages _withoutNotificationPage ( ) {
val expected = listOf ( defaultBrowserPageUiData , addSearchWidgetPageUiData , syncPageUiData )
val expected = listOf ( defaultBrowserPageUiData WithPrivacyCaption , addSearchWidgetPageUiData , syncPageUiData )
assertEquals (
assertEquals (
expected ,
expected ,
unsortedAllKnownCardData . toPageUiData (
unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = true ,
showAddWidgetPage = true ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -88,7 +157,7 @@ class OnboardingMapperTest {
@Test
@Test
fun showNotificationTrue _and _showAddWidgetTrue _pagesToDisplay _returnsSortedListOfConvertedPages ( ) {
fun showNotificationTrue _and _showAddWidgetTrue _pagesToDisplay _returnsSortedListOfConvertedPages ( ) {
val expected = listOf (
val expected = listOf (
defaultBrowserPageUiData ,
defaultBrowserPageUiData WithPrivacyCaption ,
addSearchWidgetPageUiData ,
addSearchWidgetPageUiData ,
syncPageUiData ,
syncPageUiData ,
notificationPageUiData ,
notificationPageUiData ,
@ -96,6 +165,8 @@ class OnboardingMapperTest {
assertEquals (
assertEquals (
expected ,
expected ,
unsortedAllKnownCardData . toPageUiData (
unsortedAllKnownCardData . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = true ,
showNotificationPage = true ,
showAddWidgetPage = true ,
showAddWidgetPage = true ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -107,11 +178,13 @@ class OnboardingMapperTest {
@Test
@Test
fun cardConditionsMatchJexlConditions _shouldDisplayCard _returnsConvertedPage ( ) {
fun cardConditionsMatchJexlConditions _shouldDisplayCard _returnsConvertedPage ( ) {
val jexlConditions = mapOf ( " ALWAYS " to " true " , " NEVER " to " false " )
val jexlConditions = mapOf ( " ALWAYS " to " true " , " NEVER " to " false " )
val expected = listOf ( defaultBrowserPageUiData )
val expected = listOf ( defaultBrowserPageUiData WithPrivacyCaption )
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( defaultBrowserCardData ) . toPageUiData (
listOf ( defaultBrowserCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -128,6 +201,8 @@ class OnboardingMapperTest {
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( addSearchWidgetCardDataNoConditions ) . toPageUiData (
listOf ( addSearchWidgetCardDataNoConditions ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -144,6 +219,8 @@ class OnboardingMapperTest {
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( defaultBrowserCardData ) . toPageUiData (
listOf ( defaultBrowserCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -155,11 +232,13 @@ class OnboardingMapperTest {
@Test
@Test
fun prerequisitesMatchJexlConditions _shouldDisplayCard _returnsConvertedPage ( ) {
fun prerequisitesMatchJexlConditions _shouldDisplayCard _returnsConvertedPage ( ) {
val jexlConditions = mapOf ( " ALWAYS " to " true " )
val jexlConditions = mapOf ( " ALWAYS " to " true " )
val expected = listOf ( defaultBrowserPageUiData )
val expected = listOf ( defaultBrowserPageUiData WithPrivacyCaption )
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( defaultBrowserCardData ) . toPageUiData (
listOf ( defaultBrowserCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -176,6 +255,8 @@ class OnboardingMapperTest {
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( defaultBrowserCardData ) . toPageUiData (
listOf ( defaultBrowserCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -192,6 +273,8 @@ class OnboardingMapperTest {
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( addSearchWidgetCardDataNoConditions ) . toPageUiData (
listOf ( addSearchWidgetCardDataNoConditions ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -203,11 +286,13 @@ class OnboardingMapperTest {
@Test
@Test
fun noDisqualifiers _shouldDisplayCard _returnsConvertedPage ( ) {
fun noDisqualifiers _shouldDisplayCard _returnsConvertedPage ( ) {
val jexlConditions = mapOf ( " ALWAYS " to " true " , " NEVER " to " false " )
val jexlConditions = mapOf ( " ALWAYS " to " true " , " NEVER " to " false " )
val expected = listOf ( defaultBrowserPageUiData )
val expected = listOf ( defaultBrowserPageUiData WithPrivacyCaption )
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( defaultBrowserCardDataNoDisqualifiers ) . toPageUiData (
listOf ( defaultBrowserCardDataNoDisqualifiers ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -219,11 +304,13 @@ class OnboardingMapperTest {
@Test
@Test
fun disqualifiersMatchJexlConditions _shouldDisplayCard _returnsConvertedPage ( ) {
fun disqualifiersMatchJexlConditions _shouldDisplayCard _returnsConvertedPage ( ) {
val jexlConditions = mapOf ( " NEVER " to " false " )
val jexlConditions = mapOf ( " NEVER " to " false " )
val expected = listOf ( syncPageUiData )
val expected = listOf ( syncPageUiData WithPrivacyCaption )
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( syncCardData ) . toPageUiData (
listOf ( syncCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -240,6 +327,8 @@ class OnboardingMapperTest {
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( notificationCardData ) . toPageUiData (
listOf ( notificationCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -251,11 +340,13 @@ class OnboardingMapperTest {
@Test
@Test
fun noPrerequisites _shouldDisplayCard _returnsConvertedPage ( ) {
fun noPrerequisites _shouldDisplayCard _returnsConvertedPage ( ) {
val jexlConditions = mapOf ( " ALWAYS " to " true " , " NEVER " to " false " )
val jexlConditions = mapOf ( " ALWAYS " to " true " , " NEVER " to " false " )
val expected = listOf ( syncPageUiData )
val expected = listOf ( syncPageUiData WithPrivacyCaption )
assertEquals (
assertEquals (
expected ,
expected ,
listOf ( syncCardData ) . toPageUiData (
listOf ( syncCardData ) . toPageUiData (
privacyCaption = privacyCaption ,
showDefaultBrowserPage = true ,
showNotificationPage = false ,
showNotificationPage = false ,
showAddWidgetPage = false ,
showAddWidgetPage = false ,
jexlConditions = jexlConditions ,
jexlConditions = jexlConditions ,
@ -264,24 +355,34 @@ class OnboardingMapperTest {
)
)
}
}
}
}
val privacyCaption : Caption = mockk ( relaxed = true )
private val defaultBrowserPageUiData = OnboardingPageUiData (
private val defaultBrowserPageUiData WithPrivacyCaption = OnboardingPageUiData (
type = OnboardingPageUiData . Type . DEFAULT _BROWSER ,
type = OnboardingPageUiData . Type . DEFAULT _BROWSER ,
imageRes = R . drawable . ic _onboarding _welcome ,
imageRes = R . drawable . ic _onboarding _welcome ,
title = " default browser title " ,
title = " default browser title " ,
description = " default browser body with link text " ,
description = " default browser body " ,
linkText = " link text " ,
primaryButtonLabel = " default browser primary button text " ,
primaryButtonLabel = " default browser primary button text " ,
secondaryButtonLabel = " default browser secondary button text " ,
secondaryButtonLabel = " default browser secondary button text " ,
privacyCaption = privacyCaption ,
)
)
private val addSearchWidgetPageUiData = OnboardingPageUiData (
private val addSearchWidgetPageUiData = OnboardingPageUiData (
type = OnboardingPageUiData . Type . ADD _SEARCH _WIDGET ,
type = OnboardingPageUiData . Type . ADD _SEARCH _WIDGET ,
imageRes = R . drawable . ic _onboarding _search _widget ,
imageRes = R . drawable . ic _onboarding _search _widget ,
title = " add search widget title " ,
title = " add search widget title " ,
description = " add search widget body with link text " ,
description = " add search widget body " ,
linkText = " link text " ,
primaryButtonLabel = " add search widget primary button text " ,
secondaryButtonLabel = " add search widget secondary button text " ,
privacyCaption = null ,
)
private val addSearchWidgetPageUiDataWithPrivacyCaption = OnboardingPageUiData (
type = OnboardingPageUiData . Type . ADD _SEARCH _WIDGET ,
imageRes = R . drawable . ic _onboarding _search _widget ,
title = " add search widget title " ,
description = " add search widget body " ,
primaryButtonLabel = " add search widget primary button text " ,
primaryButtonLabel = " add search widget primary button text " ,
secondaryButtonLabel = " add search widget secondary button text " ,
secondaryButtonLabel = " add search widget secondary button text " ,
privacyCaption = privacyCaption ,
)
)
private val syncPageUiData = OnboardingPageUiData (
private val syncPageUiData = OnboardingPageUiData (
type = OnboardingPageUiData . Type . SYNC _SIGN _IN ,
type = OnboardingPageUiData . Type . SYNC _SIGN _IN ,
@ -290,6 +391,16 @@ private val syncPageUiData = OnboardingPageUiData(
description = " sync body " ,
description = " sync body " ,
primaryButtonLabel = " sync primary button text " ,
primaryButtonLabel = " sync primary button text " ,
secondaryButtonLabel = " sync secondary button text " ,
secondaryButtonLabel = " sync secondary button text " ,
privacyCaption = null ,
)
private val syncPageUiDataWithPrivacyCaption = OnboardingPageUiData (
type = OnboardingPageUiData . Type . SYNC _SIGN _IN ,
imageRes = R . drawable . ic _onboarding _sync ,
title = " sync title " ,
description = " sync body " ,
primaryButtonLabel = " sync primary button text " ,
secondaryButtonLabel = " sync secondary button text " ,
privacyCaption = privacyCaption ,
)
)
private val notificationPageUiData = OnboardingPageUiData (
private val notificationPageUiData = OnboardingPageUiData (
type = OnboardingPageUiData . Type . NOTIFICATION _PERMISSION ,
type = OnboardingPageUiData . Type . NOTIFICATION _PERMISSION ,
@ -298,14 +409,14 @@ private val notificationPageUiData = OnboardingPageUiData(
description = " notification body " ,
description = " notification body " ,
primaryButtonLabel = " notification primary button text " ,
primaryButtonLabel = " notification primary button text " ,
secondaryButtonLabel = " notification secondary button text " ,
secondaryButtonLabel = " notification secondary button text " ,
privacyCaption = null ,
)
)
private val defaultBrowserCardData = OnboardingCardData (
private val defaultBrowserCardData = OnboardingCardData (
cardType = OnboardingCardType . DEFAULT _BROWSER ,
cardType = OnboardingCardType . DEFAULT _BROWSER ,
imageRes = R . drawable . ic _onboarding _welcome ,
imageRes = R . drawable . ic _onboarding _welcome ,
title = StringHolder ( null , " default browser title " ) ,
title = StringHolder ( null , " default browser title " ) ,
body = StringHolder ( null , " default browser body with link text " ) ,
body = StringHolder ( null , " default browser body " ) ,
linkText = StringHolder ( null , " link text " ) ,
primaryButtonLabel = StringHolder ( null , " default browser primary button text " ) ,
primaryButtonLabel = StringHolder ( null , " default browser primary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " default browser secondary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " default browser secondary button text " ) ,
ordering = 10 ,
ordering = 10 ,
@ -317,8 +428,7 @@ private val defaultBrowserCardDataNoDisqualifiers = OnboardingCardData(
cardType = OnboardingCardType . DEFAULT _BROWSER ,
cardType = OnboardingCardType . DEFAULT _BROWSER ,
imageRes = R . drawable . ic _onboarding _welcome ,
imageRes = R . drawable . ic _onboarding _welcome ,
title = StringHolder ( null , " default browser title " ) ,
title = StringHolder ( null , " default browser title " ) ,
body = StringHolder ( null , " default browser body with link text " ) ,
body = StringHolder ( null , " default browser body " ) ,
linkText = StringHolder ( null , " link text " ) ,
primaryButtonLabel = StringHolder ( null , " default browser primary button text " ) ,
primaryButtonLabel = StringHolder ( null , " default browser primary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " default browser secondary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " default browser secondary button text " ) ,
ordering = 10 ,
ordering = 10 ,
@ -330,8 +440,7 @@ private val addSearchWidgetCardDataNoConditions = OnboardingCardData(
cardType = OnboardingCardType . ADD _SEARCH _WIDGET ,
cardType = OnboardingCardType . ADD _SEARCH _WIDGET ,
imageRes = R . drawable . ic _onboarding _search _widget ,
imageRes = R . drawable . ic _onboarding _search _widget ,
title = StringHolder ( null , " add search widget title " ) ,
title = StringHolder ( null , " add search widget title " ) ,
body = StringHolder ( null , " add search widget body with link text " ) ,
body = StringHolder ( null , " add search widget body " ) ,
linkText = StringHolder ( null , " link text " ) ,
primaryButtonLabel = StringHolder ( null , " add search widget primary button text " ) ,
primaryButtonLabel = StringHolder ( null , " add search widget primary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " add search widget secondary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " add search widget secondary button text " ) ,
ordering = 15 ,
ordering = 15 ,
@ -343,8 +452,7 @@ private val addSearchWidgetCardData = OnboardingCardData(
cardType = OnboardingCardType . ADD _SEARCH _WIDGET ,
cardType = OnboardingCardType . ADD _SEARCH _WIDGET ,
imageRes = R . drawable . ic _onboarding _search _widget ,
imageRes = R . drawable . ic _onboarding _search _widget ,
title = StringHolder ( null , " add search widget title " ) ,
title = StringHolder ( null , " add search widget title " ) ,
body = StringHolder ( null , " add search widget body with link text " ) ,
body = StringHolder ( null , " add search widget body " ) ,
linkText = StringHolder ( null , " link text " ) ,
primaryButtonLabel = StringHolder ( null , " add search widget primary button text " ) ,
primaryButtonLabel = StringHolder ( null , " add search widget primary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " add search widget secondary button text " ) ,
secondaryButtonLabel = StringHolder ( null , " add search widget secondary button text " ) ,
ordering = 15 ,
ordering = 15 ,