Bug 1862085 - Use different rc onboarding description based on tld

fenix/122.0
rahulsainani 7 months ago committed by mergify[bot]
parent 2c0bf2acdb
commit f1f96ed867

@ -14,6 +14,8 @@ import java.net.URISyntaxException
private const val AMAZON_COM = "amazon.com"
private const val BEST_BUY_COM = "bestbuy.com"
private const val WALMART_COM = "walmart.com"
private const val AMAZON_DE = "amazon.de"
private const val AMAZON_FR = "amazon.fr"
private val defaultVendorsList = enumValues<ProductVendor>().toList()
/**
@ -57,6 +59,7 @@ class DefaultReviewQualityCheckVendorsService(
host.contains(AMAZON_COM) -> createProductVendorsList(ProductVendor.AMAZON)
host.contains(BEST_BUY_COM) -> createProductVendorsList(ProductVendor.BEST_BUY)
host.contains(WALMART_COM) -> createProductVendorsList(ProductVendor.WALMART)
host.contains(AMAZON_DE) || host.contains(AMAZON_FR) -> listOf(ProductVendor.AMAZON)
else -> defaultVendorsList
}
}

@ -35,7 +35,7 @@ import org.mozilla.fenix.shopping.ui.ext.displayName
import org.mozilla.fenix.shopping.ui.ext.headingResource
import org.mozilla.fenix.theme.FirefoxTheme
const val PLACEHOLDER_URL = "www.fakespot.com"
private const val MAX_SUPPORTED_VENDORS_PER_TLD = 3
/**
* A placeholder UI for review quality check contextual onboarding. The actual UI will be
@ -97,7 +97,7 @@ fun ReviewQualityCheckContextualOnboarding(
linkTextStates = listOf(
LinkTextState(
text = learnMoreText,
url = PLACEHOLDER_URL,
url = "",
onClick = {
onLearnMoreClick()
},
@ -127,7 +127,7 @@ fun ReviewQualityCheckContextualOnboarding(
linkTextStates = listOf(
LinkTextState(
text = privacyPolicyText,
url = PLACEHOLDER_URL,
url = "",
onClick = {
onPrivacyPolicyClick()
},
@ -144,7 +144,7 @@ fun ReviewQualityCheckContextualOnboarding(
linkTextStates = listOf(
LinkTextState(
text = termsOfUseText,
url = PLACEHOLDER_URL,
url = "",
onClick = {
onTermsOfUseClick()
},
@ -194,13 +194,22 @@ private fun createDescriptionString(
) = buildAnnotatedString {
val retailerNames = retailers.map { it.displayName() }
val description = stringResource(
id = R.string.review_quality_check_contextual_onboarding_description,
retailerNames[0],
stringResource(R.string.app_name),
retailerNames[1],
retailerNames[2],
)
val description = if (retailers.size == MAX_SUPPORTED_VENDORS_PER_TLD) {
stringResource(
id = R.string.review_quality_check_contextual_onboarding_description,
retailerNames[0],
stringResource(R.string.app_name),
retailerNames[1],
retailerNames[2],
)
} else {
stringResource(
id = R.string.review_quality_check_contextual_onboarding_description_one_vendor,
retailerNames.first(),
stringResource(R.string.app_name),
)
}
append(description)
retailerNames.forEach { retailer ->

@ -2221,6 +2221,8 @@
<string name="review_quality_check_contextual_onboarding_title">Try our trusted guide to product reviews</string>
<!-- Description for review quality check contextual onboarding card. The first and last two parameters are for retailer names (e.g. Amazon, Walmart). The second parameter is for the name of the application (e.g. Firefox). -->
<string name="review_quality_check_contextual_onboarding_description">See how reliable product reviews are on %1$s before you buy. Review checker, an experimental feature from %2$s, is built right into the browser. It works on %3$s and %4$s, too.</string>
<!-- Description for review quality check contextual onboarding card. The first parameters is for retailer name (e.g. Amazon). The second parameter is for the name of the application (e.g. Firefox). -->
<string name="review_quality_check_contextual_onboarding_description_one_vendor">See how reliable product reviews are on %1$s before you buy. Review Checker, an experimental feature from %2$s, is built right into the browser.</string>
<!-- Paragraph presenting review quality check feature. First parameter is the Fakespot product name. Second parameter is for clickable text defined in review_quality_check_contextual_onboarding_learn_more_link. In the phrase "Fakespot by Mozilla", "by" can be localized. Does not need to stay by. -->
<string name="review_quality_check_contextual_onboarding_learn_more">Using the power of %1$s by Mozilla, we help you avoid biased and inauthentic reviews. Our AI model is always improving to protect you as you shop. %2$s</string>
<!-- Clickable text from the contextual onboarding card that links to review quality check support article. -->

@ -15,7 +15,7 @@ import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.ProductVendor
class DefaultReviewQualityCheckVendorsServiceTest {
@Test
fun `WHEN selected tab is an amazon page THEN amazon is first in product vendors list`() =
fun `WHEN selected tab is an amazon_com page THEN amazon is first in product vendors list`() =
runTest {
val tab = createTab(
url = "https://www.amazon.com/product",
@ -135,6 +135,70 @@ class DefaultReviewQualityCheckVendorsServiceTest {
ProductVendor.WALMART,
)
assertEquals(expected, actual)
}
@Test
fun `WHEN selected tab is an amazon_de page THEN amazon is first in product vendors list`() =
runTest {
val tab = createTab(
url = "https://www.amazon.de/product",
id = "test-tab",
)
val browserState = BrowserState(
tabs = listOf(tab),
selectedTabId = tab.id,
)
val tested = DefaultReviewQualityCheckVendorsService(BrowserStore(browserState))
val actual = tested.productVendors()
val expected = listOf(ProductVendor.AMAZON)
assertEquals(expected, actual)
}
@Test
fun `WHEN selected tab is an amazon_fr page THEN amazon is first in product vendors list`() =
runTest {
val tab = createTab(
url = "https://www.amazon.fr/product",
id = "test-tab",
)
val browserState = BrowserState(
tabs = listOf(tab),
selectedTabId = tab.id,
)
val tested = DefaultReviewQualityCheckVendorsService(BrowserStore(browserState))
val actual = tested.productVendors()
val expected = listOf(ProductVendor.AMAZON)
assertEquals(expected, actual)
}
@Test
fun `WHEN selected tab is an amazon_in page THEN default product vendors list is returned`() =
runTest {
val tab = createTab(
url = "https://www.amazon.in/product",
id = "test-tab",
)
val browserState = BrowserState(
tabs = listOf(tab),
selectedTabId = tab.id,
)
val tested = DefaultReviewQualityCheckVendorsService(BrowserStore(browserState))
val actual = tested.productVendors()
val expected = listOf(
ProductVendor.AMAZON,
ProductVendor.BEST_BUY,
ProductVendor.WALMART,
)
assertEquals(expected, actual)
}
}

Loading…
Cancel
Save