Skip to content

Commit ea83273

Browse files
committed
Merge branch 'trunk' into feat/WOOMOB-673-generate-screenshots-for-pos-tab
2 parents 3993404 + b91595b commit ea83273

File tree

220 files changed

+929
-1601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+929
-1601
lines changed

Modules/.swiftpm/xcode/xcshareddata/xcschemes/Yosemite.xcscheme

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@
2727
buildConfiguration = "Debug"
2828
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2929
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30-
shouldUseLaunchSchemeArgsEnv = "YES"
31-
shouldAutocreateTestPlan = "YES">
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<TestPlans>
32+
<TestPlanReference
33+
reference = "container:Tests/YosemiteTests/YosemiteTests.xctestplan"
34+
default = "YES">
35+
</TestPlanReference>
36+
</TestPlans>
3237
</TestAction>
3338
<LaunchAction
3439
buildConfiguration = "Debug"

Modules/Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/Package.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ let package = Package(
8989
.package(url: "https://github.com/markiv/SwiftUI-Shimmer", from: "1.0.0"),
9090
.package(url: "https://github.com/nalexn/ViewInspector", from: "0.10.0"),
9191
.package(url: "https://github.com/onevcat/Kingfisher", from: "7.6.2"),
92+
.package(url: "https://github.com/pmusolino/Wormholy", from: "2.0.0"),
9293
.package(url: "https://github.com/pavolkmet/ScrollViewSectionKit", from: "1.2.0"),
9394
.package(url: "https://github.com/Quick/Nimble.git", from: "13.0.0"),
9495
.package(url: "https://github.com/simibac/ConfettiSwiftUI.git", from: "1.0.0"),
@@ -266,6 +267,21 @@ let package = Package(
266267
dependencies: [.target(name: "WordPressShared")],
267268
resources: [.process("Resources")]
268269
),
270+
.testTarget(
271+
name: "YosemiteTests",
272+
dependencies: [
273+
"Codegen",
274+
"Fakes",
275+
"TestKit",
276+
"WooFoundation",
277+
"WordPressShared",
278+
"Yosemite"
279+
],
280+
resources: [
281+
.process("Resources"),
282+
.process("../NetworkingTests/Responses")
283+
]
284+
)
269285
]
270286
)
271287

@@ -297,7 +313,6 @@ enum XcodeTargetNames {
297313
static let wooCommerceWatchApp = "Woo Watch App"
298314
static let wordPressAuthenticator = "WordPressAuthenticator"
299315
static let wordPressAuthenticatorTests = "WordPressAuthenticatorTests"
300-
static let yosemiteTests = "YosemiteTests"
301316
}
302317

303318
enum XcodeSupport {
@@ -313,7 +328,6 @@ enum XcodeSupport {
313328
XcodeTargetNames.wooCommerceWatchApp,
314329
XcodeTargetNames.wordPressAuthenticator,
315330
XcodeTargetNames.wordPressAuthenticatorTests,
316-
XcodeTargetNames.yosemiteTests
317331
].map { .supportingProduct(forXcodeTarget: $0) }
318332
}
319333

@@ -374,6 +388,7 @@ enum XcodeSupport {
374388
.product(name: "Shimmer", package: "SwiftUI-Shimmer"),
375389
.product(name: "StripeTerminal", package: "stripe-terminal-ios"),
376390
.product(name: "WordPressEditor", package: "AztecEditor-iOS"),
391+
.product(name: "Wormholy", package: "Wormholy"),
377392
.product(name: "ZendeskSupportSDK", package: "support_sdk_ios"),
378393
]
379394
),
@@ -439,17 +454,6 @@ enum XcodeSupport {
439454
XcodeTargetNames.wordPressAuthenticator.asDependency,
440455
]
441456
),
442-
.xcodeTarget(
443-
XcodeTargetNames.yosemiteTests,
444-
dependencies: [
445-
"Codegen",
446-
"Fakes",
447-
"TestKit",
448-
"WooFoundation",
449-
"WordPressShared",
450-
"Yosemite"
451-
]
452-
)
453457
]
454458
}
455459
}

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
5555
case .splitViewInProductsTab:
5656
return true
5757
case .subscriptionsInOrderCreationUI:
58-
return buildConfig == .localDeveloper || buildConfig == .alpha
58+
// Feature paused pdqJU4-4mn-p2#comment-2067
59+
return false
5960
case .subscriptionsInOrderCreationCustomers:
60-
// Feature paused pfoUAQ-zw-p2#comment-510.
61+
// Feature paused pdqJU4-4mn-p2#comment-2067
6162
return false
6263
case .pointOfSale:
6364
return buildConfig == .localDeveloper || buildConfig == .alpha

Modules/Sources/Networking/Mapper/ProductListMapper.swift

Lines changed: 0 additions & 41 deletions
This file was deleted.

Modules/Sources/Networking/Remote/WooShippingRemote.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ public enum WooShippingPackageType: String {
88
/// Protocol for `WooShippingRemote` mainly used for mocking.
99
///
1010
public protocol WooShippingRemoteProtocol {
11+
func checkCreationEligibility(siteID: Int64,
12+
orderID: Int64,
13+
completion: @escaping (Result<ShippingLabelCreationEligibilityResponse, Error>) -> Void)
1114
func createPackage(siteID: Int64,
1215
customPackage: WooShippingCustomPackage?,
1316
predefinedOption: WooShippingPredefinedSavedOption?,
@@ -82,6 +85,25 @@ public protocol WooShippingRemoteProtocol {
8285
///
8386
public final class WooShippingRemote: Remote, WooShippingRemoteProtocol {
8487

88+
/// Checks eligibility for shipping label creation.
89+
/// - Parameters:
90+
/// - siteID: Remote ID of the site.
91+
/// - orderID: Remote ID of the order that owns the shipping labels.
92+
/// - completion: Closure to be executed upon completion.
93+
public func checkCreationEligibility(siteID: Int64,
94+
orderID: Int64,
95+
completion: @escaping (Result<ShippingLabelCreationEligibilityResponse, Error>) -> Void) {
96+
let path = "\(Path.eligibility)/\(orderID)"
97+
let request = JetpackRequest(wooApiVersion: .wooShipping,
98+
method: .get,
99+
siteID: siteID,
100+
path: path,
101+
parameters: nil,
102+
availableAsRESTRequest: true)
103+
let mapper = ShippingLabelCreationEligibilityMapper()
104+
enqueue(request, mapper: mapper, completion: completion)
105+
}
106+
85107
/// Creates a new custom package.
86108
/// - Parameters:
87109
/// - siteID: Remote ID of the site that owns the shipping label.
@@ -564,6 +586,7 @@ public final class WooShippingRemote: Remote, WooShippingRemoteProtocol {
564586
// MARK: Constants
565587
private extension WooShippingRemote {
566588
enum Path {
589+
static let eligibility = "eligibility"
567590
static let packages = "packages"
568591
static let rates = "label/rate"
569592
static let accountSettings = "account/settings"

Modules/Sources/Yosemite/Actions/WooShippingAction.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import Foundation
22
import Networking
33

44
public enum WooShippingAction: Action {
5+
/// Checks whether an order is eligible for shipping label creation.
6+
///
7+
case checkCreationEligibility(siteID: Int64,
8+
orderID: Int64,
9+
onCompletion: (_ isEligible: Bool) -> Void)
10+
511
/// Creates a custom package or activated a carrier package with provided package details.
612
///
713
case createPackage(siteID: Int64,

Modules/Sources/Yosemite/Stores/WooShippingStore.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public final class WooShippingStore: Store {
3030
}
3131

3232
switch action {
33+
case let .checkCreationEligibility(siteID, orderID, onCompletion):
34+
checkCreationEligibility(siteID: siteID, orderID: orderID, onCompletion: onCompletion)
3335
case .createPackage(let siteID, let customPackage, let predefinedOption, let completion):
3436
createPackage(siteID: siteID, customPackage: customPackage, predefinedOption: predefinedOption, completion: completion)
3537
case let .deletePackage(siteID, packageID, packageType, completion):
@@ -98,6 +100,34 @@ public final class WooShippingStore: Store {
98100
}
99101

100102
private extension WooShippingStore {
103+
/// Checks whether an order is eligible for shipping label creation.
104+
///
105+
func checkCreationEligibility(siteID: Int64,
106+
orderID: Int64,
107+
onCompletion: @escaping (_ isEligible: Bool) -> Void) {
108+
remote.checkCreationEligibility(siteID: siteID,
109+
orderID: orderID) { result in
110+
switch result {
111+
case .success(let eligibility):
112+
if !eligibility.isEligible {
113+
if let reason = eligibility.reason {
114+
DDLogError("Order \(orderID) not eligible for shipping label creation: \(reason)")
115+
} else {
116+
DDLogError("Order \(orderID) not eligible for shipping label creation")
117+
}
118+
}
119+
onCompletion(eligibility.isEligible)
120+
case .failure(let error):
121+
if error as? DotcomError == .noRestRoute {
122+
DDLogError("⚠️ Endpoint for shipping label creation eligibility is unreachable for order: \(orderID). WC Shipping plugin may be missing.")
123+
} else {
124+
DDLogError("⛔️ Error checking shipping label creation eligibility for order \(orderID): \(error)")
125+
}
126+
onCompletion(false)
127+
}
128+
}
129+
}
130+
101131
func createPackage(siteID: Int64,
102132
customPackage: WooShippingCustomPackage? = nil,
103133
predefinedOption: WooShippingPredefinedSavedOption? = nil,

Modules/Tests/NetworkingTests/Mapper/ProductListMapperTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import XCTest
33
@testable import NetworkingCore
44

55

6-
/// ProductListMapper Unit Tests
6+
/// ListMapper<Product> Unit Tests
77
///
88
final class ProductListMapperTests: XCTestCase {
99
private enum ProductListMapperTestsError: Error {
@@ -230,17 +230,17 @@ final class ProductListMapperTests: XCTestCase {
230230
///
231231
private extension ProductListMapperTests {
232232

233-
/// Returns the ProductListMapper output upon receiving `filename` (Data Encoded)
233+
/// Returns the ListMapper<Product> output upon receiving `filename` (Data Encoded)
234234
///
235235
func mapProducts(from filename: String) throws -> [Product] {
236236
guard let response = Loader.contentsOf(filename) else {
237237
throw ProductListMapperTestsError.unableToLoadFile
238238
}
239239

240-
return try ProductListMapper(siteID: dummySiteID).map(response: response)
240+
return try ListMapper<Product>(siteID: dummySiteID).map(response: response)
241241
}
242242

243-
/// Returns the ProductListMapper output upon receiving `products-load-all` and `products-load-all-without-data`
243+
/// Returns the ListMapper<Product> output upon receiving `products-load-all` and `products-load-all-without-data`
244244
///
245245
func mapLoadAllProductsResponse() throws -> [[Product]] {
246246
let products = try mapProducts(from: "products-load-all")

Modules/Tests/NetworkingTests/Mapper/ProductReviewListMapperTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ private extension ProductReviewListMapperTests {
7474
return try! ProductReviewListMapper(siteID: dummySiteID).map(response: response)
7575
}
7676

77-
/// Returns the ProductListMapper output upon receiving `reviews-all`
77+
/// Returns the ProductReviewListMapper output upon receiving `reviews-all`
7878
///
7979
func mapLoadAllProductReviewsResponse() -> [ProductReview] {
8080
return mapProductReviews(from: "reviews-all")
8181
}
8282

83-
/// Returns the ProductListMapper output upon receiving `reviews-all-without-data`
83+
/// Returns the ProductReviewListMapper output upon receiving `reviews-all-without-data`
8484
///
8585
func mapLoadAllProductReviewsResponseWithoutDataEnvelope() -> [ProductReview] {
8686
return mapProductReviews(from: "reviews-all-without-data")

0 commit comments

Comments
 (0)