diff --git a/Sources/BrowserServicesKit/FeatureFlagger/FeatureFlagLocalOverrides.swift b/Sources/BrowserServicesKit/FeatureFlagger/FeatureFlagLocalOverrides.swift index a4ecbc16c..47f085008 100644 --- a/Sources/BrowserServicesKit/FeatureFlagger/FeatureFlagLocalOverrides.swift +++ b/Sources/BrowserServicesKit/FeatureFlagger/FeatureFlagLocalOverrides.swift @@ -84,13 +84,16 @@ public protocol FeatureFlagLocalOverridesHandler { /// public protocol FeatureFlagLocalOverriding: AnyObject { - /// Handle to the feature flagged. + /// Handle to the feature flagger. /// /// It's used to query current, non-overriden state of a feature flag to /// decide about calling `FeatureFlagLocalOverridesHandler.flagDidChange` /// upon clearing an override. var featureFlagger: FeatureFlagger? { get set } + /// The action handler responding to feature flag changes. + var actionHandler: FeatureFlagLocalOverridesHandler { get } + /// Returns the current override for a feature flag, or `nil` if override is not set. func override(for featureFlag: Flag) -> Bool? @@ -116,9 +119,9 @@ public protocol FeatureFlagLocalOverriding: AnyObject { public final class FeatureFlagLocalOverrides: FeatureFlagLocalOverriding { - private var persistor: FeatureFlagLocalOverridesPersistor - private var actionHandler: FeatureFlagLocalOverridesHandler + public let actionHandler: FeatureFlagLocalOverridesHandler public weak var featureFlagger: FeatureFlagger? + private let persistor: FeatureFlagLocalOverridesPersistor public convenience init( keyValueStore: KeyValueStoring, diff --git a/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultFeatureFlaggerTests.swift b/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultFeatureFlaggerTests.swift index 95849f0da..57b8fd711 100644 --- a/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultFeatureFlaggerTests.swift +++ b/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultFeatureFlaggerTests.swift @@ -21,6 +21,7 @@ import TestUtils import XCTest final class CapturingFeatureFlagOverriding: FeatureFlagLocalOverriding { + var overrideCalls: [any FeatureFlagDescribing] = [] var toggleOverideCalls: [any FeatureFlagDescribing] = [] var clearOverrideCalls: [any FeatureFlagDescribing] = [] @@ -28,6 +29,7 @@ final class CapturingFeatureFlagOverriding: FeatureFlagLocalOverriding { var override: (any FeatureFlagDescribing) -> Bool? = { _ in nil } + var actionHandler: any FeatureFlagLocalOverridesHandler = CapturingFeatureFlagLocalOverridesHandler() weak var featureFlagger: FeatureFlagger? func override(for featureFlag: Flag) -> Bool? {