Skip to content

Commit b5302d5

Browse files
authored
SERP Settings Sync: Align feature flag names with other platforms (#7159)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1207908166761516/task/1211978534005008?focus=true ### Description This pull request refactors feature flag usage across the browser and DuckChat modules by replacing references to `SettingsPageFeature` with the new `SerpSettingsFeature` interface, and introduces a new toggle for controlling the visibility of the "Hide AI Generated Images" option in DuckChat settings. **Feature flag refactoring:** * Replaced all usages of `SettingsPageFeature` with `SerpSettingsFeature` in `BrowserTabViewModel`, `DuckDuckGoRequestRewriter`, dependency injection (`BrowserModule`), and related test files to standardize feature flag handling for SERP settings. * Updated constructor parameters and usages in affected classes and test setups to use `SerpSettingsFeature` instead of `SettingsPageFeature`. * Modified logic to use `storeSerpSettings()` from `SerpSettingsFeature` in place of `serpSettingsSync()` from `SettingsPageFeature` for feature checks. **DuckChat settings improvements:** * Added a new toggle `showHideAiGeneratedImages()` to `DuckChatFeature` to control visibility of the "Hide AI Generated Images" option in AI Features Settings. Updated `DuckChatSettingsViewModel` to use this toggle for UI logic and navigation. **Test updates:** * Updated all affected unit tests to use `SerpSettingsFeature` for feature flag mocking and assertions, ensuring consistency and coverage for the new interface and toggle. ### Steps to test this PR _Hide AI Generated Images Toggle_ - [x] Enable `showHideAiGeneratedImages` feature toggle - [x] Open Settings -> AI Features - [x] Check AI-Generated Images option is visible - [x] Click it - [x] SERP Settings should open - [x] Disable `showHideAiGeneratedImages` feature toggle - [x] Open Settings -> AI Features - [x] Check AI-Generated Images option is **NOT** visible _storeSerpSettings Toggle_ - [x] Clear data and launch app - [x] Enable `storeSerpSettings` feature toggle - [x] Navigate to "Duck AI Testing url" listed [here](https://app.asana.com/1/137249556945/project/1207908166761516/task/1212002071627290?focus=true) - [x] Do a search e.g. "FPL" - [x] Filter logs for "SERP-SETTINGS" - [x] Check `IsNativeDuckAiEnabledHandler` has fired - [x] Open Settings - [x] Press back - [x] In the logs `SubscriptionEventData` should be sent - [x] Click SERP settings cog - [x] Click "Manage" by "AI Features" - [x] Click "Open Duck.ai Settings" - [x] Check logs for "OpenNativeSettingsHandler" and native AI Features screen should open - [x] Navigate to "SERP Settings Testing URL" - [x] Do a search e.g. "FPL" - [x] Check GetNativeSettingsHandler fires - [x] Check UpdateNativeSettingsHandler fires ### UI changes N/A
1 parent 6b4648f commit b5302d5

File tree

23 files changed

+175
-97
lines changed

23 files changed

+175
-97
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ import com.duckduckgo.savedsites.api.models.SavedSite.Favorite
289289
import com.duckduckgo.savedsites.impl.SavedSitesPixelName
290290
import com.duckduckgo.serp.logos.api.SerpEasterEggLogosToggles
291291
import com.duckduckgo.serp.logos.api.SerpLogo
292-
import com.duckduckgo.settings.api.SettingsPageFeature
292+
import com.duckduckgo.settings.api.SerpSettingsFeature
293293
import com.duckduckgo.site.permissions.api.SitePermissionsManager
294294
import com.duckduckgo.site.permissions.api.SitePermissionsManager.LocationPermissionRequest
295295
import com.duckduckgo.site.permissions.api.SitePermissionsManager.SitePermissionQueryResponse
@@ -623,10 +623,9 @@ class BrowserTabViewModelTest {
623623
private val mockDeviceAppLookup: DeviceAppLookup = mock()
624624

625625
private val mockDuckAiFullScreenMode = MutableStateFlow(false)
626-
private val mockDuckAiFullScreenModeEnabled = MutableStateFlow(false)
627626

628627
private lateinit var fakeContentScopeScriptsSubscriptionEventPluginPoint: FakeContentScopeScriptsSubscriptionEventPluginPoint
629-
private var fakeSettingsPageFeature = FakeFeatureToggleFactory.create(SettingsPageFeature::class.java)
628+
private var serpSettingsFeature = FakeFeatureToggleFactory.create(SerpSettingsFeature::class.java)
630629

631630
@Before
632631
fun before() =
@@ -864,7 +863,7 @@ class BrowserTabViewModelTest {
864863
autoconsentPixelManager = mockAutoconsentPixelManager,
865864
omnibarRepository = mockOmnibarFeatureRepository,
866865
contentScopeScriptsSubscriptionEventPluginPoint = fakeContentScopeScriptsSubscriptionEventPluginPoint,
867-
settingsPageFeature = fakeSettingsPageFeature,
866+
serpSettingsFeature = serpSettingsFeature,
868867
)
869868

870869
testee.loadData("abc", null, false, false)
@@ -7924,7 +7923,7 @@ class BrowserTabViewModelTest {
79247923

79257924
@Test
79267925
fun whenOnViewResumedWithNoPluginsThenNoSubscriptionEventsSent() = runTest {
7927-
fakeSettingsPageFeature.serpSettingsSync().setRawStoredState(State(enable = true))
7926+
serpSettingsFeature.storeSerpSettings().setRawStoredState(State(enable = true))
79287927

79297928
testee.onViewResumed()
79307929

@@ -7936,7 +7935,7 @@ class BrowserTabViewModelTest {
79367935

79377936
@Test
79387937
fun whenOnViewResumedWithPluginsThenSubscriptionEventsSent() = runTest {
7939-
fakeSettingsPageFeature.serpSettingsSync().setRawStoredState(State(enable = true))
7938+
serpSettingsFeature.storeSerpSettings().setRawStoredState(State(enable = true))
79407939
val events = mutableListOf<SubscriptionEventData>().apply {
79417940
add(
79427941
SubscriptionEventData(
@@ -7973,7 +7972,7 @@ class BrowserTabViewModelTest {
79737972

79747973
@Test
79757974
fun whenOnViewResumedWithPluginsAndSerpSettingsFeatureFlagOffThenNoEventsSent() = runTest {
7976-
fakeSettingsPageFeature.serpSettingsSync().setRawStoredState(State(enable = false))
7975+
serpSettingsFeature.storeSerpSettings().setRawStoredState(State(enable = false))
79777976
val events = mutableListOf<SubscriptionEventData>().apply {
79787977
add(
79797978
SubscriptionEventData(

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ import com.duckduckgo.savedsites.impl.dialogs.EditSavedSiteDialogFragment.Delete
352352
import com.duckduckgo.savedsites.impl.dialogs.EditSavedSiteDialogFragment.EditSavedSiteListener
353353
import com.duckduckgo.serp.logos.api.SerpEasterEggLogosToggles
354354
import com.duckduckgo.serp.logos.api.SerpLogo
355-
import com.duckduckgo.settings.api.SettingsPageFeature
355+
import com.duckduckgo.settings.api.SerpSettingsFeature
356356
import com.duckduckgo.site.permissions.api.SitePermissionsManager
357357
import com.duckduckgo.site.permissions.api.SitePermissionsManager.LocationPermissionRequest
358358
import com.duckduckgo.site.permissions.api.SitePermissionsManager.SitePermissionQueryResponse
@@ -495,7 +495,7 @@ class BrowserTabViewModel @Inject constructor(
495495
private val autoconsentPixelManager: AutoconsentPixelManager,
496496
private val omnibarRepository: OmnibarRepository,
497497
private val contentScopeScriptsSubscriptionEventPluginPoint: PluginPoint<ContentScopeScriptsSubscriptionEventPlugin>,
498-
private val settingsPageFeature: SettingsPageFeature,
498+
private val serpSettingsFeature: SerpSettingsFeature,
499499
) : ViewModel(),
500500
WebViewClientListener,
501501
EditSavedSiteListener,
@@ -943,7 +943,7 @@ class BrowserTabViewModel @Inject constructor(
943943
command.value = Command.RefreshOmnibar
944944
}
945945

946-
if (settingsPageFeature.serpSettingsSync().isEnabled()) {
946+
if (serpSettingsFeature.storeSerpSettings().isEnabled()) {
947947
viewModelScope.launch {
948948
contentScopeScriptsSubscriptionEventPluginPoint.getPlugins().forEach { plugin ->
949949
_subscriptionEventDataChannel.send(plugin.getSubscriptionEventData())

app/src/main/java/com/duckduckgo/app/browser/DuckDuckGoRequestRewriter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.duckduckgo.common.utils.AppUrl.ParamKey
2424
import com.duckduckgo.common.utils.AppUrl.ParamValue
2525
import com.duckduckgo.duckchat.api.DuckChat
2626
import com.duckduckgo.experiments.api.VariantManager
27-
import com.duckduckgo.settings.api.SettingsPageFeature
27+
import com.duckduckgo.settings.api.SerpSettingsFeature
2828
import logcat.logcat
2929

3030
interface RequestRewriter {
@@ -40,7 +40,7 @@ class DuckDuckGoRequestRewriter(
4040
private val appReferrerDataStore: AppReferrerDataStore,
4141
private val duckChat: DuckChat,
4242
private val androidConfigFeatures: AndroidBrowserConfigFeature,
43-
private val settingsPageFeature: SettingsPageFeature,
43+
private val serpSettingsFeature: SerpSettingsFeature,
4444
) : RequestRewriter {
4545

4646
private val hideDuckAiSerpKillSwitch by lazy { androidConfigFeatures.hideDuckAiInSerpKillSwitch().isEnabled() }
@@ -82,7 +82,7 @@ class DuckDuckGoRequestRewriter(
8282
val sourceValue = if (appReferrerDataStore.installedFromEuAuction) ParamValue.SOURCE_EU_AUCTION else ParamValue.SOURCE
8383

8484
builder.appendQueryParameter(ParamKey.HIDE_SERP, ParamValue.HIDE_SERP)
85-
if (!settingsPageFeature.serpSettingsSync().isEnabled()) {
85+
if (!serpSettingsFeature.storeSerpSettings().isEnabled()) {
8686
// Once serpSettingsSync feature is permanently enabled this can be removed.
8787
if (!duckChat.isEnabled() && hideDuckAiSerpKillSwitch) {
8888
builder.appendQueryParameter(ParamKey.HIDE_DUCK_AI, ParamValue.HIDE_DUCK_AI)

app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import com.duckduckgo.privacy.config.api.AmpLinks
9595
import com.duckduckgo.privacy.config.api.Gpc
9696
import com.duckduckgo.privacy.config.api.TrackingParameters
9797
import com.duckduckgo.request.filterer.api.RequestFilterer
98-
import com.duckduckgo.settings.api.SettingsPageFeature
98+
import com.duckduckgo.settings.api.SerpSettingsFeature
9999
import com.duckduckgo.subscriptions.api.Subscriptions
100100
import com.duckduckgo.user.agent.api.UserAgentProvider
101101
import dagger.Module
@@ -117,7 +117,7 @@ class BrowserModule {
117117
appReferrerDataStore: AppReferrerDataStore,
118118
duckChat: DuckChat,
119119
androidBrowserConfigFeature: AndroidBrowserConfigFeature,
120-
settingsPageFeature: SettingsPageFeature,
120+
serpSettingsFeature: SerpSettingsFeature,
121121
): RequestRewriter {
122122
return DuckDuckGoRequestRewriter(
123123
urlDetector,
@@ -126,7 +126,7 @@ class BrowserModule {
126126
appReferrerDataStore,
127127
duckChat,
128128
androidBrowserConfigFeature,
129-
settingsPageFeature,
129+
serpSettingsFeature,
130130
)
131131
}
132132

app/src/test/java/com/duckduckgo/app/browser/DuckDuckGoRequestRewriterTest.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ import com.duckduckgo.duckchat.api.DuckChat
3030
import com.duckduckgo.experiments.api.VariantManager
3131
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
3232
import com.duckduckgo.feature.toggles.api.Toggle.State
33-
import com.duckduckgo.settings.api.SettingsPageFeature
34-
import org.junit.Assert.*
33+
import com.duckduckgo.settings.api.SerpSettingsFeature
34+
import org.junit.Assert.assertEquals
35+
import org.junit.Assert.assertFalse
36+
import org.junit.Assert.assertTrue
3537
import org.junit.Before
3638
import org.junit.Test
3739
import org.junit.runner.RunWith
@@ -47,7 +49,7 @@ class DuckDuckGoRequestRewriterTest {
4749
private val mockVariantManager: VariantManager = mock()
4850
private val mockAppReferrerDataStore: AppReferrerDataStore = mock()
4951
private val duckChat: DuckChat = mock()
50-
private val settingsPageFeature: SettingsPageFeature = FakeFeatureToggleFactory.create(SettingsPageFeature::class.java)
52+
private val serpSettingsFeature: SerpSettingsFeature = FakeFeatureToggleFactory.create(SerpSettingsFeature::class.java)
5153
private val androidBrowserConfigFeature: AndroidBrowserConfigFeature = FakeFeatureToggleFactory.create(AndroidBrowserConfigFeature::class.java)
5254
private lateinit var builder: Uri.Builder
5355

@@ -66,7 +68,7 @@ class DuckDuckGoRequestRewriterTest {
6668
mockAppReferrerDataStore,
6769
duckChat,
6870
androidBrowserConfigFeature,
69-
settingsPageFeature,
71+
serpSettingsFeature,
7072
)
7173
builder = Uri.Builder()
7274
}
@@ -157,7 +159,7 @@ class DuckDuckGoRequestRewriterTest {
157159

158160
@Test
159161
fun whenSerpSettingsSyncIsEnabledThenDoNotHideDuckAi() {
160-
settingsPageFeature.serpSettingsSync().setRawStoredState(State(true))
162+
serpSettingsFeature.storeSerpSettings().setRawStoredState(State(true))
161163
whenever(duckChat.isEnabled()).thenReturn(false)
162164
androidBrowserConfigFeature.hideDuckAiInSerpKillSwitch().setRawStoredState(State(true))
163165

app/src/test/java/com/duckduckgo/app/browser/QueryUrlConverterTest.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ import com.duckduckgo.duckchat.api.DuckChat
2828
import com.duckduckgo.experiments.api.VariantManager
2929
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
3030
import com.duckduckgo.feature.toggles.api.Toggle.State
31-
import com.duckduckgo.settings.api.SettingsPageFeature
32-
import org.junit.Assert.*
31+
import com.duckduckgo.settings.api.SerpSettingsFeature
32+
import org.junit.Assert.assertEquals
33+
import org.junit.Assert.assertFalse
34+
import org.junit.Assert.assertNotNull
35+
import org.junit.Assert.assertTrue
3336
import org.junit.Before
3437
import org.junit.Test
3538
import org.junit.runner.RunWith
@@ -44,7 +47,7 @@ class QueryUrlConverterTest {
4447
private val mockAppReferrerDataStore: AppReferrerDataStore = mock()
4548
private val duckChat: DuckChat = mock()
4649
private val androidBrowserConfigFeature: AndroidBrowserConfigFeature = FakeFeatureToggleFactory.create(AndroidBrowserConfigFeature::class.java)
47-
private val settingsPageFeature: SettingsPageFeature = FakeFeatureToggleFactory.create(SettingsPageFeature::class.java)
50+
private val serpSettingsFeature: SerpSettingsFeature = FakeFeatureToggleFactory.create(SerpSettingsFeature::class.java)
4851
private val requestRewriter =
4952
DuckDuckGoRequestRewriter(
5053
DuckDuckGoUrlDetectorImpl(),
@@ -53,7 +56,7 @@ class QueryUrlConverterTest {
5356
mockAppReferrerDataStore,
5457
duckChat,
5558
androidBrowserConfigFeature,
56-
settingsPageFeature,
59+
serpSettingsFeature,
5760
)
5861
private val testee: QueryUrlConverter = QueryUrlConverter(requestRewriter)
5962

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/feature/DuckChatFeature.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,10 @@ interface DuckChatFeature {
116116
*/
117117
@Toggle.DefaultValue(DefaultFeatureValue.INTERNAL)
118118
fun duckAiVoiceSearch(): Toggle
119+
120+
/**
121+
* @return `true` when the "Hide AI Generated Images" option should be visible in AI Features Settings.
122+
*/
123+
@Toggle.DefaultValue(DefaultFeatureValue.INTERNAL)
124+
fun showHideAiGeneratedImages(): Toggle
119125
}

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/messaging/IsNativeDuckAiEnabledHandler.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.duckduckgo.js.messaging.api.JsMessage
2727
import com.duckduckgo.js.messaging.api.JsMessageCallback
2828
import com.duckduckgo.js.messaging.api.JsMessageHandler
2929
import com.duckduckgo.js.messaging.api.JsMessaging
30-
import com.duckduckgo.settings.api.SettingsPageFeature
30+
import com.duckduckgo.settings.api.SerpSettingsFeature
3131
import com.squareup.anvil.annotations.ContributesMultibinding
3232
import kotlinx.coroutines.CoroutineScope
3333
import kotlinx.coroutines.launch
@@ -45,7 +45,7 @@ import javax.inject.Inject
4545
class IsNativeDuckAiEnabledHandler @Inject constructor(
4646
private val dispatcherProvider: DispatcherProvider,
4747
@AppCoroutineScope private val appScope: CoroutineScope,
48-
private val settingsPageFeature: SettingsPageFeature,
48+
private val serpSettingsFeature: SerpSettingsFeature,
4949
private val duckChat: DuckChat,
5050
) : ContentScopeJsMessageHandlersPlugin {
5151

@@ -57,7 +57,7 @@ class IsNativeDuckAiEnabledHandler @Inject constructor(
5757
jsMessageCallback: JsMessageCallback?,
5858
) {
5959
appScope.launch(dispatcherProvider.main()) {
60-
if (settingsPageFeature.serpSettingsSync().isEnabled()) {
60+
if (serpSettingsFeature.storeSerpSettings().isEnabled()) {
6161
logcat { "SERP-SETTINGS: IsNativeDuckAiEnabledHandler processing message" }
6262
val response = JSONObject().apply {
6363
put("enabled", duckChat.isEnabled())

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/ui/settings/DuckChatSettingsViewModel.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.duckduckgo.duckchat.api.DuckChatNativeSettingsNoParams
2525
import com.duckduckgo.duckchat.api.DuckChatSettingsNoParams
2626
import com.duckduckgo.duckchat.impl.DuckChatInternal
2727
import com.duckduckgo.duckchat.impl.R
28+
import com.duckduckgo.duckchat.impl.feature.DuckChatFeature
2829
import com.duckduckgo.duckchat.impl.inputscreen.ui.metrics.discovery.InputScreenDiscoveryFunnel
2930
import com.duckduckgo.duckchat.impl.pixel.DuckChatPixelName
3031
import com.duckduckgo.duckchat.impl.ui.settings.DuckChatSettingsViewModel.Command.OpenLink
@@ -53,6 +54,7 @@ class DuckChatSettingsViewModel @AssistedInject constructor(
5354
private val inputScreenDiscoveryFunnel: InputScreenDiscoveryFunnel,
5455
private val settingsPageFeature: SettingsPageFeature,
5556
private val dispatcherProvider: DispatcherProvider,
57+
private val duckChatFeature: DuckChatFeature,
5658
) : ViewModel() {
5759
private val commandChannel = Channel<Command>(capacity = 1, onBufferOverflow = DROP_OLDEST)
5860
val commands = commandChannel.receiveAsFlow()
@@ -73,15 +75,15 @@ class DuckChatSettingsViewModel @AssistedInject constructor(
7375
duckChat.observeEnableDuckChatUserSetting(),
7476
duckChat.observeInputScreenUserSettingEnabled(),
7577
duckChat.observeFullscreenModeUserSetting(),
76-
flowOf(settingsPageFeature.hideAiGeneratedImagesOption().isEnabled()).flowOn(dispatcherProvider.io()),
77-
) { isDuckChatUserEnabled, isInputScreenEnabled, isFullScreenModeEnabled, isHideAiGeneratedImagesOptionVisible ->
78+
flowOf(duckChatFeature.showHideAiGeneratedImages().isEnabled()).flowOn(dispatcherProvider.io()),
79+
) { isDuckChatUserEnabled, isInputScreenEnabled, isFullScreenModeEnabled, showHideAiGeneratedImagesOption ->
7880
ViewState(
7981
isDuckChatUserEnabled = isDuckChatUserEnabled,
8082
isInputScreenEnabled = isInputScreenEnabled,
8183
shouldShowShortcuts = isDuckChatUserEnabled,
8284
shouldShowInputScreenToggle = isDuckChatUserEnabled && duckChat.isInputScreenFeatureAvailable(),
8385
isSearchSectionVisible = isSearchSectionVisible(duckChatActivityParams),
84-
isHideGeneratedImagesOptionVisible = isHideAiGeneratedImagesOptionVisible,
86+
isHideGeneratedImagesOptionVisible = showHideAiGeneratedImagesOption,
8587
shouldShowFullScreenModeToggle = duckChat.isDuckChatFullScreenModeFeatureAvailable(),
8688
isFullScreenModeEnabled = isFullScreenModeEnabled,
8789
)
@@ -143,19 +145,19 @@ class DuckChatSettingsViewModel @AssistedInject constructor(
143145

144146
fun duckChatSearchAISettingsClicked() {
145147
viewModelScope.launch {
146-
val hideAiGeneratedImagesOptionEnabled = withContext(dispatcherProvider.io()) {
147-
settingsPageFeature.hideAiGeneratedImagesOption().isEnabled()
148+
val showHideAiGeneratedImages = withContext(dispatcherProvider.io()) {
149+
duckChatFeature.showHideAiGeneratedImages().isEnabled()
148150
}
149151

150152
if (settingsPageFeature.embeddedSettingsWebView().isEnabled()) {
151153
commandChannel.send(
152154
OpenLink(
153-
link = if (hideAiGeneratedImagesOptionEnabled) {
155+
link = if (showHideAiGeneratedImages) {
154156
DUCK_CHAT_SEARCH_AI_SETTINGS_LINK_EMBEDDED
155157
} else {
156158
LEGACY_DUCK_CHAT_SEARCH_AI_SETTINGS_LINK_EMBEDDED
157159
},
158-
titleRes = if (hideAiGeneratedImagesOptionEnabled) {
160+
titleRes = if (showHideAiGeneratedImages) {
159161
R.string.duckAiSerpSettingsTitle
160162
} else {
161163
R.string.duck_chat_assist_settings_title

duckchat/duckchat-impl/src/test/kotlin/com/duckduckgo/duckchat/impl/messaging/IsNativeDuckAiEnabledHandlerTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.duckduckgo.duckchat.impl.messaging.fakes.FakeJsMessaging
2323
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
2424
import com.duckduckgo.feature.toggles.api.Toggle
2525
import com.duckduckgo.js.messaging.api.JsMessage
26-
import com.duckduckgo.settings.api.SettingsPageFeature
26+
import com.duckduckgo.settings.api.SerpSettingsFeature
2727
import kotlinx.coroutines.test.runTest
2828
import org.json.JSONObject
2929
import org.junit.Assert.assertEquals
@@ -39,15 +39,15 @@ class IsNativeDuckAiEnabledHandlerTest {
3939
val coroutineTestRule: CoroutineTestRule = CoroutineTestRule()
4040

4141
private val fakeDuckChat = FakeDuckChat(enabled = true)
42-
private val settingsPageFeature = FakeFeatureToggleFactory.create(SettingsPageFeature::class.java)
42+
private val serpSettingsFeature = FakeFeatureToggleFactory.create(SerpSettingsFeature::class.java)
4343
private lateinit var handler: IsNativeDuckAiEnabledHandler
4444

4545
@Before
4646
fun setUp() {
4747
handler = IsNativeDuckAiEnabledHandler(
4848
dispatcherProvider = coroutineTestRule.testDispatcherProvider,
4949
appScope = coroutineTestRule.testScope,
50-
settingsPageFeature = settingsPageFeature,
50+
serpSettingsFeature = serpSettingsFeature,
5151
duckChat = fakeDuckChat,
5252
)
5353
}
@@ -74,7 +74,7 @@ class IsNativeDuckAiEnabledHandlerTest {
7474
@Test
7575
fun `when id is null then no response is sent`() = runTest {
7676
@Suppress("DenyListedApi")
77-
settingsPageFeature.serpSettingsSync().setRawStoredState(Toggle.State(enable = true))
77+
serpSettingsFeature.storeSerpSettings().setRawStoredState(Toggle.State(enable = true))
7878
fakeDuckChat.setEnabled(true)
7979

8080
val fakeJsMessaging = FakeJsMessaging()
@@ -96,7 +96,7 @@ class IsNativeDuckAiEnabledHandlerTest {
9696
@Test
9797
fun `when id is not null then response is sent`() = runTest {
9898
@Suppress("DenyListedApi")
99-
settingsPageFeature.serpSettingsSync().setRawStoredState(Toggle.State(enable = true))
99+
serpSettingsFeature.storeSerpSettings().setRawStoredState(Toggle.State(enable = true))
100100
fakeDuckChat.setEnabled(true)
101101

102102
val fakeJsMessaging = FakeJsMessaging()

0 commit comments

Comments
 (0)