Skip to content

Commit

Permalink
Only show broken site prompt if RC is on
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisBarreiro committed Oct 28, 2024
1 parent ba3670c commit 9d2ea88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ import com.duckduckgo.autofill.api.domain.app.LoginCredentials
import com.duckduckgo.autofill.api.email.EmailManager
import com.duckduckgo.autofill.api.passwordgeneration.AutomaticSavedLoginsMonitor
import com.duckduckgo.autofill.impl.AutofillFireproofDialogSuppressor
import com.duckduckgo.brokensite.api.BrokenSitePrompt
import com.duckduckgo.browser.api.UserBrowserProperties
import com.duckduckgo.browser.api.brokensite.BrokenSiteContext
import com.duckduckgo.common.test.CoroutineTestRule
Expand Down Expand Up @@ -492,6 +493,7 @@ class BrowserTabViewModelTest {
private val mockHighlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager = mock()
private var fakeAndroidConfigBrowserFeature = FakeFeatureToggleFactory.create(AndroidBrowserConfigFeature::class.java)
private val mockAutocompleteTabsFeature: AutocompleteTabsFeature = mock()
private val mockBrokenSitePrompt: BrokenSitePrompt = mock()

@Before
fun before() = runTest {
Expand Down Expand Up @@ -540,6 +542,7 @@ class BrowserTabViewModelTest {
whenever(changeOmnibarPositionFeature.refactor()).thenReturn(mockEnabledToggle)
whenever(mockAutocompleteTabsFeature.self()).thenReturn(mockEnabledToggle)
whenever(mockAutocompleteTabsFeature.self().isEnabled()).thenReturn(true)
whenever(mockBrokenSitePrompt.isFeatureEnabled()).thenReturn(false)

remoteMessagingModel = givenRemoteMessagingModel(mockRemoteMessagingRepository, mockPixel, coroutineRule.testDispatcherProvider)

Expand All @@ -559,6 +562,7 @@ class BrowserTabViewModelTest {
subscriptions = mock(),
duckPlayer = mockDuckPlayer,
highlightsOnboardingExperimentManager = mockHighlightsOnboardingExperimentManager,
brokenSitePrompt = mockBrokenSitePrompt,
)

val siteFactory = SiteFactoryImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.duckduckgo.app.trackerdetection.model.TrackerStatus
import com.duckduckgo.app.trackerdetection.model.TrackerType
import com.duckduckgo.app.trackerdetection.model.TrackingEvent
import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.brokensite.api.BrokenSitePrompt
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.test.InstantSchedulersRule
import com.duckduckgo.duckplayer.api.DuckPlayer
Expand Down Expand Up @@ -116,6 +117,8 @@ class CtaViewModelTest {

private val mockHighlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager = mock()

private val mockBrokenSitePrompt: BrokenSitePrompt = mock()

private val requiredDaxOnboardingCtas: List<CtaId> = listOf(
CtaId.DAX_INTRO,
CtaId.DAX_DIALOG_SERP,
Expand Down Expand Up @@ -149,6 +152,7 @@ class CtaViewModelTest {
whenever(mockDuckPlayer.getUserPreferences()).thenReturn(UserPreferences(false, AlwaysAsk))
whenever(mockDuckPlayer.isYouTubeUrl(any())).thenReturn(false)
whenever(mockDuckPlayer.isSimulatedYoutubeNoCookie(anyString())).thenReturn(false)
whenever(mockBrokenSitePrompt.isFeatureEnabled()).thenReturn(false)

testee = CtaViewModel(
appInstallStore = mockAppInstallStore,
Expand All @@ -166,6 +170,7 @@ class CtaViewModelTest {
subscriptions = mockSubscriptions,
duckPlayer = mockDuckPlayer,
highlightsOnboardingExperimentManager = mockHighlightsOnboardingExperimentManager,
brokenSitePrompt = mockBrokenSitePrompt,
)
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.duckduckgo.app.statistics.pixels.Pixel
import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Unique
import com.duckduckgo.app.tabs.model.TabRepository
import com.duckduckgo.app.widget.ui.WidgetCapabilities
import com.duckduckgo.brokensite.api.BrokenSitePrompt
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.duckplayer.api.DuckPlayer
Expand Down Expand Up @@ -71,6 +72,7 @@ class CtaViewModel @Inject constructor(
private val subscriptions: Subscriptions,
private val duckPlayer: DuckPlayer,
private val highlightsOnboardingExperimentManager: HighlightsOnboardingExperimentManager,
private val brokenSitePrompt: BrokenSitePrompt,
) {
@ExperimentalCoroutinesApi
@VisibleForTesting
Expand Down Expand Up @@ -302,7 +304,7 @@ class CtaViewModel @Inject constructor(
return null
}

if (!daxOnboardingActive() || hideTips() || extendedOnboardingFeatureToggles.noBrowserCtas().isEnabled()) {
if ((!daxOnboardingActive() || hideTips() || extendedOnboardingFeatureToggles.noBrowserCtas().isEnabled()) && brokenSitePrompt.isFeatureEnabled()) {
// TODO (cbarreiro) Add logic to decide whether or not to show the prompt
return BrokenSitePromptDialogCta()
}
Expand Down

0 comments on commit 9d2ea88

Please sign in to comment.