Skip to content

Commit f51b1a7

Browse files
authored
Address a couple of unit and UI tests failures (#5434)
2 parents ed32197 + e63ad81 commit f51b1a7

File tree

17 files changed

+843
-17
lines changed

17 files changed

+843
-17
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,8 @@ extension Site {
13141314
description: .fake(),
13151315
url: .fake(),
13161316
plan: .fake(),
1317+
isJetpackThePluginInstalled: .fake(),
1318+
isJetpackConnected: .fake(),
13171319
isWooCommerceActive: .fake(),
13181320
isWordPressStore: .fake(),
13191321
timezone: .fake(),

Hardware/HardwareTests/AirPrintReceipt/ReceiptRendererTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private extension ReceiptRendererTest {
4040
amount: 1,
4141
formattedAmount: "1",
4242
currency: "USD",
43-
date: .init(),
43+
date: .init(timeIntervalSince1970: 1636970486),
4444
storeName: "Test Store",
4545
cardDetails: .init(
4646
last4: "1234",

Networking/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,8 @@ extension Site {
11511151
description: CopiableProp<String> = .copy,
11521152
url: CopiableProp<String> = .copy,
11531153
plan: CopiableProp<String> = .copy,
1154+
isJetpackThePluginInstalled: CopiableProp<Bool> = .copy,
1155+
isJetpackConnected: CopiableProp<Bool> = .copy,
11541156
isWooCommerceActive: CopiableProp<Bool> = .copy,
11551157
isWordPressStore: CopiableProp<Bool> = .copy,
11561158
timezone: CopiableProp<String> = .copy,
@@ -1161,6 +1163,8 @@ extension Site {
11611163
let description = description ?? self.description
11621164
let url = url ?? self.url
11631165
let plan = plan ?? self.plan
1166+
let isJetpackThePluginInstalled = isJetpackThePluginInstalled ?? self.isJetpackThePluginInstalled
1167+
let isJetpackConnected = isJetpackConnected ?? self.isJetpackConnected
11641168
let isWooCommerceActive = isWooCommerceActive ?? self.isWooCommerceActive
11651169
let isWordPressStore = isWordPressStore ?? self.isWordPressStore
11661170
let timezone = timezone ?? self.timezone
@@ -1172,6 +1176,8 @@ extension Site {
11721176
description: description,
11731177
url: url,
11741178
plan: plan,
1179+
isJetpackThePluginInstalled: isJetpackThePluginInstalled,
1180+
isJetpackConnected: isJetpackConnected,
11751181
isWooCommerceActive: isWooCommerceActive,
11761182
isWordPressStore: isWordPressStore,
11771183
timezone: timezone,

Networking/Networking/Model/Site.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
2525
///
2626
public let plan: String
2727

28+
/// Whether the site has Jetpack-the-plugin installed.
29+
///
30+
public let isJetpackThePluginInstalled: Bool
31+
32+
/// Whether the site is connected to Jetpack, either through Jetpack-the-plugin or other plugins that include Jetpack Connection Package.
33+
///
34+
public let isJetpackConnected: Bool
35+
2836
/// Indicates if there is a WooCommerce Store Active.
2937
///
3038
public let isWooCommerceActive: Bool
@@ -50,6 +58,8 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
5058
let name = try siteContainer.decode(String.self, forKey: .name)
5159
let description = try siteContainer.decode(String.self, forKey: .description)
5260
let url = try siteContainer.decode(String.self, forKey: .url)
61+
let isJetpackThePluginInstalled = try siteContainer.decode(Bool.self, forKey: .isJetpackThePluginInstalled)
62+
let isJetpackConnected = try siteContainer.decode(Bool.self, forKey: .isJetpackConnected)
5363

5464
let optionsContainer = try siteContainer.nestedContainer(keyedBy: OptionKeys.self, forKey: .options)
5565
let isWordPressStore = try optionsContainer.decode(Bool.self, forKey: .isWordPressStore)
@@ -62,6 +72,8 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
6272
description: description,
6373
url: url,
6474
plan: String(), // Not created on init. Added in supplementary API request.
75+
isJetpackThePluginInstalled: isJetpackThePluginInstalled,
76+
isJetpackConnected: isJetpackConnected,
6577
isWooCommerceActive: isWooCommerceActive,
6678
isWordPressStore: isWordPressStore,
6779
timezone: timezone,
@@ -75,6 +87,8 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
7587
description: String,
7688
url: String,
7789
plan: String,
90+
isJetpackThePluginInstalled: Bool,
91+
isJetpackConnected: Bool,
7892
isWooCommerceActive: Bool,
7993
isWordPressStore: Bool,
8094
timezone: String,
@@ -84,13 +98,22 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
8498
self.description = description
8599
self.url = url
86100
self.plan = plan
101+
self.isJetpackThePluginInstalled = isJetpackThePluginInstalled
102+
self.isJetpackConnected = isJetpackConnected
87103
self.isWordPressStore = isWordPressStore
88104
self.isWooCommerceActive = isWooCommerceActive
89105
self.timezone = timezone
90106
self.gmtOffset = gmtOffset
91107
}
92108
}
93109

110+
public extension Site {
111+
/// Whether the site is connected to Jetpack with Jetpack Connection Package, and not with Jetpack-the-plugin.
112+
///
113+
var isJetpackCPConnected: Bool {
114+
isJetpackConnected && !isJetpackThePluginInstalled
115+
}
116+
}
94117

95118
/// Defines all of the Site CodingKeys.
96119
///
@@ -103,6 +126,8 @@ private extension Site {
103126
case url = "URL"
104127
case options = "options"
105128
case plan = "plan"
129+
case isJetpackThePluginInstalled = "jetpack"
130+
case isJetpackConnected = "jetpack_connection"
106131
}
107132

108133
enum OptionKeys: String, CodingKey {

Networking/Networking/Remote/AccountRemote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class AccountRemote: Remote {
5353
public func loadSites(completion: @escaping (Result<[Site], Error>) -> Void) {
5454
let path = "me/sites"
5555
let parameters = [
56-
"fields": "ID,name,description,URL,options",
56+
"fields": "ID,name,description,URL,options,jetpack,jetpack_connection",
5757
"options": "timezone,is_wpcom_store,woocommerce_is_active,gmt_offset"
5858
]
5959

Networking/NetworkingTests/Responses/sites-malformed.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"description": "Testing Tagline",
77
"URL": "https:\/\/some-testing-url.testing.blog",
88
"jetpack": true,
9+
"jetpack_connection": true,
910
"updates": {
1011
"plugins": 3,
1112
"themes": 1,
@@ -20,6 +21,7 @@
2021
"description": "Your Favorite Blog",
2122
"URL": "https:\/\/thoughts.testing.blog",
2223
"jetpack": false,
24+
"jetpack_connection": true,
2325
"options": {
2426
"timezone": "",
2527
"gmt_offset": -4,

Networking/NetworkingTests/Responses/sites.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"description": "Testing Tagline",
77
"URL": "https:\/\/some-testing-url.testing.blog",
88
"jetpack": true,
9+
"jetpack_connection": true,
910
"options": {
1011
"timezone": "",
1112
"gmt_offset": 3.5,
@@ -144,6 +145,7 @@
144145
"description": "Your Favorite Blog",
145146
"URL": "https:\/\/thoughts.testing.blog",
146147
"jetpack": false,
148+
"jetpack_connection": true,
147149
"options": {
148150
"timezone": "",
149151
"gmt_offset": -4,

Storage/Storage.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@
245245
028296F1237D404F00E84012 /* GenericAttribute+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GenericAttribute+CoreDataProperties.swift"; sourceTree = "<group>"; };
246246
0284BD8725BAC75500D00C06 /* Model 43.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 43.xcdatamodel"; sourceTree = "<group>"; };
247247
0284BD8825BAC83700D00C06 /* WooCommerceModelV42toV43.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = WooCommerceModelV42toV43.xcmappingmodel; sourceTree = "<group>"; };
248+
028A81022740E1B400F04D15 /* Model 58.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 58.xcdatamodel"; sourceTree = "<group>"; };
248249
028F00652331605000E6C283 /* Model 20.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 20.xcdatamodel"; sourceTree = "<group>"; };
249250
029DE8AD25C115860046EFF5 /* Model 44.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 44.xcdatamodel"; sourceTree = "<group>"; };
250251
02A098262480D160002F8C7A /* MockCrashLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockCrashLogger.swift; sourceTree = "<group>"; };
@@ -1692,6 +1693,7 @@
16921693
B59E11D820A9D00C004121A4 /* WooCommerce.xcdatamodeld */ = {
16931694
isa = XCVersionGroup;
16941695
children = (
1696+
028A81022740E1B400F04D15 /* Model 58.xcdatamodel */,
16951697
313FC0B62732EE520067408D /* Model 57.xcdatamodel */,
16961698
31C1D22D2727204200EDEE49 /* Model 56.xcdatamodel */,
16971699
DE126D1026CE5A28007F901D /* Model 55.xcdatamodel */,
@@ -1750,7 +1752,7 @@
17501752
746A9D14214071F90013F6FF /* Model 2.xcdatamodel */,
17511753
B59E11D920A9D00C004121A4 /* Model.xcdatamodel */,
17521754
);
1753-
currentVersion = 313FC0B62732EE520067408D /* Model 57.xcdatamodel */;
1755+
currentVersion = 028A81022740E1B400F04D15 /* Model 58.xcdatamodel */;
17541756
path = WooCommerce.xcdatamodeld;
17551757
sourceTree = "<group>";
17561758
versionGroupType = wrapper.xcdatamodel;

Storage/Storage/Model/MIGRATIONS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

5+
## Model 58 (Release 8.1.0.0)
6+
- @jaclync 2021-11-15
7+
- Added `isJetpackConnected` attribute to `Site` entity.
8+
- Added `isJetpackThePluginInstalled` attribute to `Site` entity.
9+
510
## Model 57 (Release 8.0.0.0)
611
- @allendav 2021-11-03
712
- Added `isLive` attribute to `PaymentGatewayAccount` entity

Storage/Storage/Model/Site+CoreDataProperties.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,11 @@ extension Site {
1616
@NSManaged public var isWordPressStore: NSNumber?
1717
@NSManaged public var timezone: String?
1818
@NSManaged public var gmtOffset: Double
19+
@NSManaged public var isJetpackConnected: Bool
20+
@NSManaged public var isJetpackThePluginInstalled: Bool
21+
22+
}
23+
24+
extension Site: Identifiable {
25+
1926
}

0 commit comments

Comments
 (0)