diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ext/ProductVendor.kt b/app/src/main/java/org/mozilla/fenix/shopping/ext/ProductVendor.kt new file mode 100644 index 0000000000..d7787c88d2 --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/shopping/ext/ProductVendor.kt @@ -0,0 +1,20 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.shopping.ext + +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource +import org.mozilla.fenix.R +import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.ProductVendor + +/** + * Returns the display string corresponding to the particular [ProductVendor]. + */ +@Composable +fun ProductVendor.displayName(): String = when (this) { + ProductVendor.AMAZON -> stringResource(id = R.string.review_quality_check_retailer_name_amazon) + ProductVendor.BEST_BUY -> stringResource(id = R.string.review_quality_check_retailer_name_bestbuy) + ProductVendor.WALMART -> stringResource(id = R.string.review_quality_check_retailer_name_walmart) +} diff --git a/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckPreferencesMiddleware.kt b/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckPreferencesMiddleware.kt index 14ac950fce..81d77073d7 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckPreferencesMiddleware.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckPreferencesMiddleware.kt @@ -53,7 +53,10 @@ class ReviewQualityCheckPreferencesMiddleware( reviewQualityCheckPreferences.productRecommendationsEnabled() val updateUserPreferences = if (hasUserOptedIn) { - ReviewQualityCheckAction.OptInCompleted(isProductRecommendationsEnabled) + ReviewQualityCheckAction.OptInCompleted( + isProductRecommendationsEnabled = isProductRecommendationsEnabled, + productVendor = reviewQualityCheckVendorsService.productVendor(), + ) } else { val productVendors = reviewQualityCheckVendorsService.productVendors() ReviewQualityCheckAction.OptOutCompleted(productVendors) @@ -67,7 +70,10 @@ class ReviewQualityCheckPreferencesMiddleware( val isProductRecommendationsEnabled = reviewQualityCheckPreferences.productRecommendationsEnabled() store.dispatch( - ReviewQualityCheckAction.OptInCompleted(isProductRecommendationsEnabled), + ReviewQualityCheckAction.OptInCompleted( + isProductRecommendationsEnabled = isProductRecommendationsEnabled, + productVendor = reviewQualityCheckVendorsService.productVendor(), + ), ) // Update the preference diff --git a/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckVendorsService.kt b/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckVendorsService.kt index 3e1decb948..947d850eb6 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckVendorsService.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/middleware/ReviewQualityCheckVendorsService.kt @@ -25,6 +25,11 @@ interface ReviewQualityCheckVendorsService { * Returns the list of product vendors in order. */ fun productVendors(): List + + /** + * Returns the product's vendor. + */ + fun productVendor(): ProductVendor } /** @@ -54,6 +59,8 @@ class DefaultReviewQualityCheckVendorsService( } } + override fun productVendor(): ProductVendor = productVendors().first() + /** * Creates list of product vendors using the firstVendor param as the first item in the list. */ diff --git a/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckAction.kt b/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckAction.kt index 796881acb0..18c6f1e55e 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckAction.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckAction.kt @@ -58,7 +58,10 @@ sealed interface ReviewQualityCheckAction : Action { * @property isProductRecommendationsEnabled Reflects the user preference update to display * recommended product. Null when product recommendations feature is disabled. */ - data class OptInCompleted(val isProductRecommendationsEnabled: Boolean?) : UpdateAction + data class OptInCompleted( + val isProductRecommendationsEnabled: Boolean?, + val productVendor: ReviewQualityCheckState.ProductVendor, + ) : UpdateAction /** * Triggered as a result of [Init] when user has opted out of shopping experience. diff --git a/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckState.kt b/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckState.kt index b4cdbd7120..9749b7208d 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckState.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckState.kt @@ -46,6 +46,7 @@ sealed interface ReviewQualityCheckState : State { data class OptedIn( val productReviewState: ProductReviewState = ProductReviewState.Loading, val productRecommendationsPreference: Boolean?, + val productVendor: ProductVendor, ) : ReviewQualityCheckState { /** diff --git a/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStore.kt b/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStore.kt index c6ac64de77..e44aa6f266 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStore.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStore.kt @@ -47,6 +47,7 @@ private fun mapStateForUpdateAction( } else { ReviewQualityCheckState.OptedIn( productRecommendationsPreference = action.isProductRecommendationsEnabled, + productVendor = action.productVendor, ) } } diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ui/NoAnalysis.kt b/app/src/main/java/org/mozilla/fenix/shopping/ui/NoAnalysis.kt index 83859aa1fd..5f0cb53285 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/ui/NoAnalysis.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/ui/NoAnalysis.kt @@ -32,6 +32,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import org.mozilla.fenix.R import org.mozilla.fenix.compose.annotation.LightDarkPreview +import org.mozilla.fenix.shopping.store.ReviewQualityCheckState import org.mozilla.fenix.theme.FirefoxTheme /** @@ -39,6 +40,7 @@ import org.mozilla.fenix.theme.FirefoxTheme * * @param isAnalyzing Whether or not the displayed product is being analyzed. * @param productRecommendationsEnabled The current state of the product recommendations toggle. + * @param productVendor The vendor of the product. * @param onAnalyzeClick Invoked when the user clicks on the check review button. * @param onReviewGradeLearnMoreClick Invoked when the user clicks to learn more about review grades. * @param onOptOutClick Invoked when the user opts out of the review quality check feature. @@ -51,6 +53,7 @@ import org.mozilla.fenix.theme.FirefoxTheme fun NoAnalysis( isAnalyzing: Boolean, productRecommendationsEnabled: Boolean?, + productVendor: ReviewQualityCheckState.ProductVendor, onAnalyzeClick: () -> Unit, onReviewGradeLearnMoreClick: () -> Unit, onOptOutClick: () -> Unit, @@ -64,6 +67,7 @@ fun NoAnalysis( ReviewQualityNoAnalysisCard(isAnalyzing, onAnalyzeClick) ReviewQualityInfoCard( + productVendor = productVendor, onLearnMoreClick = onReviewGradeLearnMoreClick, ) @@ -173,6 +177,7 @@ private fun NoAnalysisPreview() { ) { NoAnalysis( isAnalyzing = isAnalyzing, + productVendor = ReviewQualityCheckState.ProductVendor.AMAZON, onAnalyzeClick = { isAnalyzing = !isAnalyzing }, productRecommendationsEnabled = false, onReviewGradeLearnMoreClick = {}, diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysis.kt b/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysis.kt index 7dc15390d9..15471eadce 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysis.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysis.kt @@ -51,6 +51,7 @@ import java.util.SortedMap * * @param productRecommendationsEnabled The current state of the product recommendations toggle. * @param productAnalysis The product analysis to display. + * @param productVendor The vendor of the product. * @param onOptOutClick Invoked when the user opts out of the review quality check feature. * @param onProductRecommendationsEnabledStateChange Invoked when the user changes the product * recommendations toggle state. @@ -63,6 +64,7 @@ import java.util.SortedMap fun ProductAnalysis( productRecommendationsEnabled: Boolean?, productAnalysis: AnalysisPresent, + productVendor: ReviewQualityCheckState.ProductVendor, onOptOutClick: () -> Unit, onReanalyzeClick: () -> Unit, onProductRecommendationsEnabledStateChange: (Boolean) -> Unit, @@ -121,6 +123,7 @@ fun ProductAnalysis( } ReviewQualityInfoCard( + productVendor = productVendor, modifier = Modifier.fillMaxWidth(), onLearnMoreClick = onReviewGradeLearnMoreClick, ) @@ -379,6 +382,7 @@ private enum class Highlight( private class ProductAnalysisPreviewModel( val productRecommendationsEnabled: Boolean?, val productAnalysis: AnalysisPresent, + val productVendor: ReviewQualityCheckState.ProductVendor, ) { constructor( productRecommendationsEnabled: Boolean? = false, @@ -416,6 +420,7 @@ private class ProductAnalysisPreviewModel( ), recommendedProductState: ReviewQualityCheckState.RecommendedProductState = ReviewQualityCheckState.RecommendedProductState.Initial, + productVendor: ReviewQualityCheckState.ProductVendor = ReviewQualityCheckState.ProductVendor.AMAZON, ) : this( productRecommendationsEnabled = productRecommendationsEnabled, productAnalysis = AnalysisPresent( @@ -427,6 +432,7 @@ private class ProductAnalysisPreviewModel( highlights = highlights, recommendedProductState = recommendedProductState, ), + productVendor = productVendor, ) } @@ -469,6 +475,7 @@ private fun ProductAnalysisPreview( ProductAnalysis( productRecommendationsEnabled = productRecommendationsEnabled, productAnalysis = model.productAnalysis, + productVendor = model.productVendor, onOptOutClick = {}, onReanalyzeClick = {}, onProductRecommendationsEnabledStateChange = { diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysisError.kt b/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysisError.kt index 688e68dca5..0ee4660357 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysisError.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/ui/ProductAnalysisError.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import org.mozilla.fenix.R import org.mozilla.fenix.compose.annotation.LightDarkPreview +import org.mozilla.fenix.shopping.store.ReviewQualityCheckState import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState import org.mozilla.fenix.theme.FirefoxTheme @@ -25,6 +26,7 @@ import org.mozilla.fenix.theme.FirefoxTheme * * @param error The error state to display. * @param productRecommendationsEnabled The current state of the product recommendations toggle. + * @param productVendor The vendor of the product. * @param onReviewGradeLearnMoreClick Invoked when the user clicks to learn more about review grades. * @param onOptOutClick Invoked when the user opts out of the review quality check feature. * @param onProductRecommendationsEnabledStateChange Invoked when the user changes the product @@ -37,6 +39,7 @@ import org.mozilla.fenix.theme.FirefoxTheme fun ProductAnalysisError( error: ProductReviewState.Error, productRecommendationsEnabled: Boolean?, + productVendor: ReviewQualityCheckState.ProductVendor, onReviewGradeLearnMoreClick: () -> Unit, onOptOutClick: () -> Unit, onProductRecommendationsEnabledStateChange: (Boolean) -> Unit, @@ -85,6 +88,7 @@ fun ProductAnalysisError( ) ReviewQualityInfoCard( + productVendor = productVendor, onLearnMoreClick = onReviewGradeLearnMoreClick, ) @@ -114,6 +118,7 @@ private fun ProductAnalysisErrorPreview() { ProductAnalysisError( error = ProductReviewState.Error.NetworkError, productRecommendationsEnabled = true, + productVendor = ReviewQualityCheckState.ProductVendor.AMAZON, onReviewGradeLearnMoreClick = {}, onOptOutClick = {}, onProductRecommendationsEnabledStateChange = {}, diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckBottomSheet.kt b/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckBottomSheet.kt index e90a0b0547..f77434ce53 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckBottomSheet.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckBottomSheet.kt @@ -116,6 +116,7 @@ private fun ProductReview( ProductAnalysis( productRecommendationsEnabled = state.productRecommendationsPreference, productAnalysis = productReviewState, + productVendor = state.productVendor, onOptOutClick = onOptOutClick, onReanalyzeClick = onReanalyzeClick, onProductRecommendationsEnabledStateChange = onProductRecommendationsEnabledStateChange, @@ -128,6 +129,7 @@ private fun ProductReview( ProductAnalysisError( error = productReviewState, productRecommendationsEnabled = state.productRecommendationsPreference, + productVendor = state.productVendor, onReviewGradeLearnMoreClick = onReviewGradeLearnMoreClick, onOptOutClick = onOptOutClick, onProductRecommendationsEnabledStateChange = onProductRecommendationsEnabledStateChange, @@ -142,8 +144,9 @@ private fun ProductReview( is ReviewQualityCheckState.OptedIn.ProductReviewState.NoAnalysisPresent -> { NoAnalysis( - productRecommendationsEnabled = state.productRecommendationsPreference, isAnalyzing = productReviewState.isReanalyzing, + productRecommendationsEnabled = state.productRecommendationsPreference, + productVendor = state.productVendor, onAnalyzeClick = onReanalyzeClick, onReviewGradeLearnMoreClick = onReviewGradeLearnMoreClick, onOptOutClick = onOptOutClick, diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckContextualOnboarding.kt b/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckContextualOnboarding.kt index 7d4a4f5868..7d3aa49d07 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckContextualOnboarding.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityCheckContextualOnboarding.kt @@ -24,7 +24,10 @@ import androidx.compose.ui.unit.dp import org.mozilla.fenix.R import org.mozilla.fenix.compose.LinkText import org.mozilla.fenix.compose.LinkTextState +import org.mozilla.fenix.compose.annotation.LightDarkPreview import org.mozilla.fenix.compose.button.PrimaryButton +import org.mozilla.fenix.shopping.ext.displayName +import org.mozilla.fenix.shopping.store.ReviewQualityCheckState import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.ProductVendor import org.mozilla.fenix.theme.FirefoxTheme @@ -166,25 +169,18 @@ fun ReviewQualityCheckContextualOnboarding( private fun createDescriptionString( retailers: List, ) = buildAnnotatedString { - val retailerNames = retailers.map { - when (it) { - ProductVendor.AMAZON -> R.string.review_quality_check_retailer_name_amazon - ProductVendor.BEST_BUY -> R.string.review_quality_check_retailer_name_bestbuy - ProductVendor.WALMART -> R.string.review_quality_check_retailer_name_walmart - } - } + val retailerNames = retailers.map { it.displayName() } val description = stringResource( id = R.string.review_quality_check_contextual_onboarding_description, - stringResource(retailerNames[0]), + retailerNames[0], stringResource(R.string.app_name), - stringResource(retailerNames[1]), - stringResource(retailerNames[2]), + retailerNames[1], + retailerNames[2], ) append(description) - retailerNames.forEach { - val retailer = stringResource(id = it) + retailerNames.forEach { retailer -> val start = description.indexOf(retailer) addStyle( @@ -194,3 +190,22 @@ private fun createDescriptionString( ) } } + +@Composable +@LightDarkPreview +private fun ProductAnalysisPreview() { + FirefoxTheme { + ReviewQualityCheckScaffold( + onRequestDismiss = {}, + ) { + ReviewQualityCheckContextualOnboarding( + productVendors = ReviewQualityCheckState.NotOptedIn().productVendors, + onPrimaryButtonClick = {}, + onLearnMoreClick = {}, + onPrivacyPolicyClick = {}, + onTermsOfUseClick = {}, + onSecondaryButtonClick = {}, + ) + } + } +} diff --git a/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityInfoCard.kt b/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityInfoCard.kt index b07501c5f1..ba7d56bb4d 100644 --- a/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityInfoCard.kt +++ b/app/src/main/java/org/mozilla/fenix/shopping/ui/ReviewQualityInfoCard.kt @@ -20,22 +20,27 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp import org.mozilla.fenix.R -import org.mozilla.fenix.compose.ClickableSubstringLink +import org.mozilla.fenix.compose.LinkText +import org.mozilla.fenix.compose.LinkTextState import org.mozilla.fenix.compose.annotation.LightDarkPreview import org.mozilla.fenix.compose.parseHtml +import org.mozilla.fenix.shopping.ext.displayName import org.mozilla.fenix.shopping.store.ReviewQualityCheckState import org.mozilla.fenix.theme.FirefoxTheme /** * Info card UI containing an explanation of the review quality. * + * @param productVendor The vendor of the product. * @param modifier Modifier to apply to the layout. * @param onLearnMoreClick Invoked when the user clicks to learn more about review grades. */ @Composable fun ReviewQualityInfoCard( + productVendor: ReviewQualityCheckState.ProductVendor, modifier: Modifier = Modifier, onLearnMoreClick: () -> Unit, ) { @@ -44,15 +49,17 @@ fun ReviewQualityInfoCard( modifier = modifier, ) { ReviewQualityInfo( + productVendor = productVendor, modifier = Modifier.fillMaxWidth(), onLearnMoreClick = onLearnMoreClick, ) } } -@Suppress("Deprecation") +@Suppress("LongMethod") @Composable private fun ReviewQualityInfo( + productVendor: ReviewQualityCheckState.ProductVendor, modifier: Modifier = Modifier, onLearnMoreClick: () -> Unit, ) { @@ -60,11 +67,15 @@ private fun ReviewQualityInfo( modifier = modifier, verticalArrangement = Arrangement.spacedBy(24.dp), ) { + val letterGradeText = + stringResource(id = R.string.review_quality_check_info_review_grade_header) val adjustedGradingText = stringResource(id = R.string.review_quality_check_explanation_body_adjusted_grading) - // Any and all text formatting (bullets, inline substring bolding, etc.) will be handled as - // follow-up when the copy is finalized. - // Bug 1848219 + val highlightsText = stringResource( + id = R.string.review_quality_check_explanation_body_highlights, + productVendor.displayName(), + ) + Text( text = stringResource( id = R.string.review_quality_check_explanation_body_reliability, @@ -74,19 +85,10 @@ private fun ReviewQualityInfo( style = FirefoxTheme.typography.body2, ) - val link = stringResource( - id = R.string.review_quality_check_info_learn_more_link, - stringResource(R.string.shopping_product_name), - ) - val text = stringResource(R.string.review_quality_check_info_learn_more, link) - val linkStartIndex = text.indexOf(link) - val linkEndIndex = linkStartIndex + link.length - ClickableSubstringLink( - text = text, - textStyle = FirefoxTheme.typography.body2, - clickableStartIndex = linkStartIndex, - clickableEndIndex = linkEndIndex, - onClick = onLearnMoreClick, + Text( + text = remember(letterGradeText) { parseHtml(letterGradeText) }, + color = FirefoxTheme.colors.textPrimary, + style = FirefoxTheme.typography.body2, ) ReviewGradingScaleInfo( @@ -94,7 +96,7 @@ private fun ReviewQualityInfo( ReviewQualityCheckState.Grade.A, ReviewQualityCheckState.Grade.B, ), - info = stringResource(id = R.string.review_quality_check_info_grade_info_AB), + info = stringResource(id = R.string.review_quality_check_info_grade_info_AB_2), modifier = Modifier.fillMaxWidth(), ) @@ -109,7 +111,7 @@ private fun ReviewQualityInfo( ReviewQualityCheckState.Grade.D, ReviewQualityCheckState.Grade.F, ), - info = stringResource(id = R.string.review_quality_check_info_grade_info_DF), + info = stringResource(id = R.string.review_quality_check_info_grade_info_DF_2), modifier = Modifier.fillMaxWidth(), ) @@ -118,6 +120,35 @@ private fun ReviewQualityInfo( color = FirefoxTheme.colors.textPrimary, style = FirefoxTheme.typography.body2, ) + + Text( + text = remember(highlightsText) { parseHtml(highlightsText) }, + color = FirefoxTheme.colors.textPrimary, + style = FirefoxTheme.typography.body2, + ) + + val link = stringResource( + id = R.string.review_quality_check_info_learn_more_link, + stringResource(R.string.shopping_product_name), + ) + val text = stringResource(R.string.review_quality_check_info_learn_more, link) + LinkText( + text = text, + linkTextStates = listOf( + LinkTextState( + text = link, + url = "", + onClick = { + onLearnMoreClick() + }, + ), + ), + style = FirefoxTheme.typography.body2.copy( + color = FirefoxTheme.colors.textPrimary, + ), + linkTextColor = FirefoxTheme.colors.textAccent, + linkTextDecoration = TextDecoration.Underline, + ) } } @@ -159,6 +190,7 @@ private fun ReviewQualityInfoCardPreview() { .padding(all = 16.dp), ) { ReviewQualityInfoCard( + productVendor = ReviewQualityCheckState.ProductVendor.AMAZON, modifier = Modifier.fillMaxWidth(), onLearnMoreClick = {}, ) @@ -177,6 +209,7 @@ private fun ReviewQualityInfoPreview() { .padding(all = 16.dp), ) { ReviewQualityInfo( + productVendor = ReviewQualityCheckState.ProductVendor.AMAZON, modifier = Modifier.fillMaxWidth(), onLearnMoreClick = {}, ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1450a3a566..07d49c8cf6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2120,17 +2120,21 @@ We use AI technology from %s by Mozilla to check the reliability of product reviews. This will only help you assess review quality, not product quality. - letter grade from A to F.]]> + letter grade from A to F.]]> - Reliable reviews. We believe the reviews are likely from real customers who left honest, unbiased reviews. + Reliable reviews. We believe the reviews are likely from real customers who left honest, unbiased reviews. + + We believe the reviews to be reliable. We believe there’s a mix of reliable and unreliable reviews. - Unreliable reviews. We believe the reviews are likely fake or from biased reviewers. + Unreliable reviews. We believe the reviews are likely fake or from biased reviewers. + + We believe the reviews are unreliable. adjusted rating is based only on reviews we believe to be reliable.]]> - Highlights are from %s reviews within the last 80 days that we believe to be reliable.]]> + Highlights are from %s reviews within the last 80 days that we believe to be reliable.]]> Learn more about %s. diff --git a/app/src/test/java/org/mozilla/fenix/shopping/ReviewQualityCheckBottomSheetStateFeatureTest.kt b/app/src/test/java/org/mozilla/fenix/shopping/ReviewQualityCheckBottomSheetStateFeatureTest.kt index 66215bcbb5..afaf7c33f9 100644 --- a/app/src/test/java/org/mozilla/fenix/shopping/ReviewQualityCheckBottomSheetStateFeatureTest.kt +++ b/app/src/test/java/org/mozilla/fenix/shopping/ReviewQualityCheckBottomSheetStateFeatureTest.kt @@ -32,8 +32,12 @@ class ReviewQualityCheckBottomSheetStateFeatureTest { ) tested.start() - store.dispatch(ReviewQualityCheckAction.OptInCompleted(isProductRecommendationsEnabled = true)) - .joinBlocking() + store.dispatch( + ReviewQualityCheckAction.OptInCompleted( + isProductRecommendationsEnabled = true, + productVendor = ReviewQualityCheckState.ProductVendor.WALMART, + ), + ).joinBlocking() store.dispatch(ReviewQualityCheckAction.OptOutCompleted(emptyList())).joinBlocking() assertFalse(isInvoked) diff --git a/app/src/test/java/org/mozilla/fenix/shopping/fake/FakeReviewQualityCheckVendorsService.kt b/app/src/test/java/org/mozilla/fenix/shopping/fake/FakeReviewQualityCheckVendorsService.kt index 9d1caaa349..fe978fe407 100644 --- a/app/src/test/java/org/mozilla/fenix/shopping/fake/FakeReviewQualityCheckVendorsService.kt +++ b/app/src/test/java/org/mozilla/fenix/shopping/fake/FakeReviewQualityCheckVendorsService.kt @@ -15,4 +15,6 @@ class FakeReviewQualityCheckVendorsService( ), ) : ReviewQualityCheckVendorsService { override fun productVendors(): List = productVendors + + override fun productVendor(): ProductVendor = productVendors().first() } diff --git a/app/src/test/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStoreTest.kt b/app/src/test/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStoreTest.kt index d108bf6b34..1113c4406d 100644 --- a/app/src/test/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStoreTest.kt +++ b/app/src/test/java/org/mozilla/fenix/shopping/store/ReviewQualityCheckStoreTest.kt @@ -83,7 +83,10 @@ class ReviewQualityCheckStoreTest { tested.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() - val expected = ReviewQualityCheckState.OptedIn(productRecommendationsPreference = false) + val expected = ReviewQualityCheckState.OptedIn( + productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, + ) assertEquals(expected, tested.state) assertEquals(true, cfrConditionUpdated) } @@ -124,7 +127,10 @@ class ReviewQualityCheckStoreTest { dispatcher.scheduler.advanceUntilIdle() tested.waitUntilIdle() - val expected = ReviewQualityCheckState.OptedIn(productRecommendationsPreference = null) + val expected = ReviewQualityCheckState.OptedIn( + productRecommendationsPreference = null, + productVendor = ProductVendor.BEST_BUY, + ) assertEquals(expected, tested.state) // Even if toggle action is dispatched, state is not changed @@ -150,7 +156,10 @@ class ReviewQualityCheckStoreTest { tested.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() - val expected = ReviewQualityCheckState.OptedIn(productRecommendationsPreference = true) + val expected = ReviewQualityCheckState.OptedIn( + productRecommendationsPreference = true, + productVendor = ProductVendor.BEST_BUY, + ) assertEquals(expected, tested.state) } @@ -171,7 +180,10 @@ class ReviewQualityCheckStoreTest { tested.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() - val expected = ReviewQualityCheckState.OptedIn(productRecommendationsPreference = false) + val expected = ReviewQualityCheckState.OptedIn( + productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, + ) assertEquals(expected, tested.state) } @@ -197,6 +209,7 @@ class ReviewQualityCheckStoreTest { val expected = ReviewQualityCheckState.OptedIn( productReviewState = ProductAnalysisTestData.analysisPresent(), productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, ) assertEquals(expected, tested.state) } @@ -221,6 +234,7 @@ class ReviewQualityCheckStoreTest { val expected = ReviewQualityCheckState.OptedIn( productReviewState = ReviewQualityCheckState.OptedIn.ProductReviewState.Error.GenericError, productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, ) assertEquals(expected, tested.state) } @@ -245,6 +259,7 @@ class ReviewQualityCheckStoreTest { val expected = ReviewQualityCheckState.OptedIn( productReviewState = ReviewQualityCheckState.OptedIn.ProductReviewState.Error.NetworkError, productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, ) assertEquals(expected, tested.state) } @@ -271,6 +286,7 @@ class ReviewQualityCheckStoreTest { val expected = ReviewQualityCheckState.OptedIn( productReviewState = ReviewQualityCheckState.OptedIn.ProductReviewState.Error.GenericError, productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, ) assertEquals(expected, tested.state) } @@ -313,6 +329,7 @@ class ReviewQualityCheckStoreTest { analysisStatus = AnalysisStatus.NEEDS_ANALYSIS, ), productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, ) assertEquals(expected, tested.state) } @@ -341,6 +358,7 @@ class ReviewQualityCheckStoreTest { val expected = ReviewQualityCheckState.OptedIn( productReviewState = ProductAnalysisTestData.analysisPresent(), productRecommendationsPreference = false, + productVendor = ProductVendor.BEST_BUY, ) assertEquals(expected, tested.state) }