From df23d49993ae940d05648ea52cdfd52354a1dac3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mariusz=20=C5=9Apiewak?= <dus7@users.noreply.github.com>
Date: Wed, 7 Feb 2024 12:01:20 +0100
Subject: [PATCH] Check subfeature state before reading rollout data (#2152)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Task/Issue URL:
https://app.asana.com/0/414235014887631/1206494747562366/f

**Description:**
This fix comprises of two parts:

##### Fix subfeature state resolution logic
Rollout state is checked before the global subfeature state, resulting
in reporting invalid reason for it being disabled. This rearranges the
rollout check so it’s performed as the last one.

##### Fix (flaky) test
Because the test subject was given a real randomizer, it produced mixed
results - in 85% of chances leaning towards an invalid value. Passing
mocked randomizer makes it stable.

**Steps to test this PR:**
1. Ensure CI is green

---
###### Internal references:
[Pull Request Review
Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
[Pull Request
Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)
---
 DuckDuckGo.xcodeproj/project.pbxproj                      | 2 +-
 .../xcshareddata/swiftpm/Package.resolved                 | 8 ++++----
 LocalPackages/DataBrokerProtection/Package.swift          | 2 +-
 LocalPackages/LoginItems/Package.swift                    | 2 +-
 LocalPackages/NetworkProtectionMac/Package.swift          | 2 +-
 LocalPackages/PixelKit/Package.swift                      | 2 +-
 LocalPackages/Subscription/Package.swift                  | 2 +-
 LocalPackages/SwiftUIExtensions/Package.swift             | 2 +-
 LocalPackages/SyncUI/Package.swift                        | 2 +-
 LocalPackages/SystemExtensionManager/Package.swift        | 2 +-
 LocalPackages/XPCHelper/Package.swift                     | 2 +-
 11 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj
index 2f39f7878f..9ccf26f59c 100644
--- a/DuckDuckGo.xcodeproj/project.pbxproj
+++ b/DuckDuckGo.xcodeproj/project.pbxproj
@@ -13259,7 +13259,7 @@
 			repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
 			requirement = {
 				kind = exactVersion;
-				version = 104.2.0;
+				version = 104.2.1;
 			};
 		};
 		AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index cd3dcf0df1..b8dafe40cf 100644
--- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -14,8 +14,8 @@
       "kind" : "remoteSourceControl",
       "location" : "https://github.com/duckduckgo/BrowserServicesKit",
       "state" : {
-        "revision" : "d0741645b44448d655b1f56eba464f463f294e4f",
-        "version" : "104.2.0"
+        "branch" : "mariusz/fix-rollout-check",
+        "revision" : "b11b744048cf0538ff04ee434772fde0ff81f9d7"
       }
     },
     {
@@ -32,8 +32,8 @@
       "kind" : "remoteSourceControl",
       "location" : "https://github.com/duckduckgo/duckduckgo-autofill.git",
       "state" : {
-        "revision" : "03d3e3a959dd75afbe8c59b5a203ea676d37555d",
-        "version" : "10.1.0"
+        "revision" : "b972bc0ab6ee1d57a0a18a197dcc31e40ae6ac57",
+        "version" : "10.0.3"
       }
     },
     {
diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift
index a3d51312a5..e140ebb2ec 100644
--- a/LocalPackages/DataBrokerProtection/Package.swift
+++ b/LocalPackages/DataBrokerProtection/Package.swift
@@ -29,7 +29,7 @@ let package = Package(
             targets: ["DataBrokerProtection"])
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
         .package(path: "../PixelKit"),
         .package(path: "../SwiftUIExtensions"),
         .package(path: "../XPCHelper")
diff --git a/LocalPackages/LoginItems/Package.swift b/LocalPackages/LoginItems/Package.swift
index 02c52da5cb..afd6b7851f 100644
--- a/LocalPackages/LoginItems/Package.swift
+++ b/LocalPackages/LoginItems/Package.swift
@@ -13,7 +13,7 @@ let package = Package(
         ),
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         .target(
diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift
index 6b4648845d..ab622e06d8 100644
--- a/LocalPackages/NetworkProtectionMac/Package.swift
+++ b/LocalPackages/NetworkProtectionMac/Package.swift
@@ -30,7 +30,7 @@ let package = Package(
         .library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"])
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
         .package(path: "../XPCHelper"),
         .package(path: "../SwiftUIExtensions")
     ],
diff --git a/LocalPackages/PixelKit/Package.swift b/LocalPackages/PixelKit/Package.swift
index 2b61ddca7b..74582e1f8b 100644
--- a/LocalPackages/PixelKit/Package.swift
+++ b/LocalPackages/PixelKit/Package.swift
@@ -20,7 +20,7 @@ let package = Package(
         )
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         .target(
diff --git a/LocalPackages/Subscription/Package.swift b/LocalPackages/Subscription/Package.swift
index 9e4720c0c8..9005aa8e8e 100644
--- a/LocalPackages/Subscription/Package.swift
+++ b/LocalPackages/Subscription/Package.swift
@@ -12,7 +12,7 @@ let package = Package(
             targets: ["Subscription"]),
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         .target(
diff --git a/LocalPackages/SwiftUIExtensions/Package.swift b/LocalPackages/SwiftUIExtensions/Package.swift
index 92650388fe..e422da6e6b 100644
--- a/LocalPackages/SwiftUIExtensions/Package.swift
+++ b/LocalPackages/SwiftUIExtensions/Package.swift
@@ -11,7 +11,7 @@ let package = Package(
         .library(name: "PreferencesViews", targets: ["PreferencesViews"]),
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         .target(
diff --git a/LocalPackages/SyncUI/Package.swift b/LocalPackages/SyncUI/Package.swift
index 55d0578985..25f609ee52 100644
--- a/LocalPackages/SyncUI/Package.swift
+++ b/LocalPackages/SyncUI/Package.swift
@@ -13,7 +13,7 @@ let package = Package(
     ],
     dependencies: [
         .package(path: "../SwiftUIExtensions"),
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         .target(
diff --git a/LocalPackages/SystemExtensionManager/Package.swift b/LocalPackages/SystemExtensionManager/Package.swift
index efa85bbcee..66dc717adb 100644
--- a/LocalPackages/SystemExtensionManager/Package.swift
+++ b/LocalPackages/SystemExtensionManager/Package.swift
@@ -16,7 +16,7 @@ let package = Package(
         ),
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         // Targets are the basic building blocks of a package, defining a module or a test suite.
diff --git a/LocalPackages/XPCHelper/Package.swift b/LocalPackages/XPCHelper/Package.swift
index 762d1483fd..bf6d052c30 100644
--- a/LocalPackages/XPCHelper/Package.swift
+++ b/LocalPackages/XPCHelper/Package.swift
@@ -30,7 +30,7 @@ let package = Package(
         .library(name: "XPCHelper", targets: ["XPCHelper"]),
     ],
     dependencies: [
-        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.0"),
+        .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "104.2.1"),
     ],
     targets: [
         .target(