Skip to content

Commit 7b29c57

Browse files
committed
Merge branch 'trunk' into feat/WOOMOB-611-cache-pos-eligibility
# Conflicts: # WooCommerce/WooCommerce.xcodeproj/project.pbxproj
2 parents f652b50 + b6c2f01 commit 7b29c57

File tree

75 files changed

+1680
-2984
lines changed

Some content is hidden

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

75 files changed

+1680
-2984
lines changed

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
9797
return true
9898
case .searchProductsInPOSPt2PopularProducts:
9999
return true
100-
case .searchCouponsInPOS:
101-
return true
102100
case .inventoryProductLabelsInPOS:
103101
return false
104102
case .pointOfSaleReceipts:

Modules/Sources/Experiments/FeatureFlag.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ public enum FeatureFlag: Int {
209209
///
210210
case searchProductsInPOSPt2PopularProducts
211211

212-
/// Allows searching coupons in POS
213-
///
214-
case searchCouponsInPOS
215-
216212
/// Enables optimized handling of product images
217213
///
218214
case productImageOptimizedHandling

Modules/Sources/XcodeSupport/XcodeTarget_Experiments/Empty.swift

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

Modules/Sources/XcodeSupport/XcodeTarget_ExperimentsTests/Empty.swift

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

Networking/NetworkingTests/Extensions/URLRequestConvertible+PathTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ final class URLRequestConvertible_PathTests: XCTestCase {
1212
// MARK: - `pathForAnalytics`
1313

1414
// Example from `ProductsRemote.loadAllProducts`.
15-
func test_pathForAnalytics_returns_path_of_JetpackRequest() throws {
15+
func test_pathForAnalytics_returns_path_of_JetpackRequest() async throws {
1616
// Given
1717
let productsRemote = ProductsRemote(network: network)
18-
productsRemote.loadAllProducts(for: 134, completion: { _ in })
18+
_ = try? await productsRemote.loadAllProducts(for: 134)
1919

2020
// When
2121
let request = try XCTUnwrap(network.requestsForResponseData.first)

Networking/NetworkingTests/Remote/ProductsRemoteTests.swift

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -256,39 +256,28 @@ final class ProductsRemoteTests: XCTestCase {
256256

257257
/// Verifies that loadAllProducts properly parses the `products-load-all` sample response.
258258
///
259-
func testLoadAllProductsProperlyReturnsParsedProducts() {
259+
func test_loadAllProducts_properly_returns_parsed_products() async throws {
260+
// Given
260261
let remote = ProductsRemote(network: network)
261-
let expectation = self.expectation(description: "Load All Products")
262-
263262
network.simulateResponse(requestUrlSuffix: "products", filename: "products-load-all")
264263

265-
remote.loadAllProducts(for: sampleSiteID) { result in
266-
switch result {
267-
case .success(let products):
268-
XCTAssertEqual(products.count, 10)
269-
default:
270-
XCTFail("Unexpected result: \(result)")
271-
}
272-
expectation.fulfill()
273-
}
264+
// When
265+
let products = try await remote.loadAllProducts(for: sampleSiteID)
274266

275-
wait(for: [expectation], timeout: Constants.expectationTimeout)
267+
// Then
268+
XCTAssertEqual(products.count, 10)
276269
}
277270

278271
/// Verifies that loadAllProducts with `excludedProductIDs` makes a network request with the corresponding parameter.
279272
///
280-
func testLoadAllProductsWithExcludedIDsIncludesAnExcludeParamInNetworkRequest() throws {
273+
func test_loadAllProducts_with_excluded_ids_includes_an_exclude_param_in_network_request() async throws {
281274
// Arrange
282275
let remote = ProductsRemote(network: network)
283276
network.simulateResponse(requestUrlSuffix: "products", filename: "products-load-all")
284277
let excludedProductIDs: [Int64] = [17, 671]
285278

286279
// Action
287-
waitForExpectation { expectation in
288-
remote.loadAllProducts(for: sampleSiteID, excludedProductIDs: excludedProductIDs) { result in
289-
expectation.fulfill()
290-
}
291-
}
280+
_ = try await remote.loadAllProducts(for: sampleSiteID, excludedProductIDs: excludedProductIDs)
292281

293282
// Assert
294283
let queryParameters = try XCTUnwrap(network.queryParameters)
@@ -298,18 +287,14 @@ final class ProductsRemoteTests: XCTestCase {
298287

299288
/// Verifies that loadAllProducts with `productIDs` makes a network request with the `include` parameter.
300289
///
301-
func test_loadAllProducts_with_productIDs_adds_a_include_param_in_network_request() throws {
290+
func test_loadAllProducts_with_productIDs_adds_a_include_param_in_network_request() async throws {
302291
// Given
303292
let remote = ProductsRemote(network: network)
304293
network.simulateResponse(requestUrlSuffix: "products", filename: "products-load-all")
305294
let productIDs: [Int64] = [13, 61]
306295

307296
// When
308-
waitForExpectation { expectation in
309-
remote.loadAllProducts(for: sampleSiteID, productIDs: productIDs) { result in
310-
expectation.fulfill()
311-
}
312-
}
297+
_ = try await remote.loadAllProducts(for: sampleSiteID, productIDs: productIDs)
313298

314299
// Then
315300
let queryParameters = try XCTUnwrap(network.queryParameters)
@@ -319,17 +304,13 @@ final class ProductsRemoteTests: XCTestCase {
319304

320305
/// Verifies that loadAllProducts with empty `productIDs` makes a network request without the `include` parameter.
321306
///
322-
func test_loadAllProducts_with_empty_productIDs_does_not_add_include_param_in_network_request() throws {
307+
func test_loadAllProducts_with_empty_productIDs_does_not_add_include_param_in_network_request() async throws {
323308
// Given
324309
let remote = ProductsRemote(network: network)
325310
network.simulateResponse(requestUrlSuffix: "products", filename: "products-load-all")
326311

327312
// When
328-
waitForExpectation { expectation in
329-
remote.loadAllProducts(for: sampleSiteID, productIDs: []) { result in
330-
expectation.fulfill()
331-
}
332-
}
313+
_ = try await remote.loadAllProducts(for: sampleSiteID, productIDs: [])
333314

334315
// Then
335316
let queryParameters = try XCTUnwrap(network.queryParameters)
@@ -339,21 +320,16 @@ final class ProductsRemoteTests: XCTestCase {
339320

340321
/// Verifies that loadAllProducts properly relays Networking Layer errors.
341322
///
342-
func test_loadAllProducts_properly_relays_netwoking_errors() {
323+
func test_loadAllProducts_properly_relays_netwoking_errors() async {
324+
// Given
343325
let remote = ProductsRemote(network: network)
344-
let expectation = self.expectation(description: "Load all products returns error")
345-
346-
remote.loadAllProducts(for: sampleSiteID) { result in
347-
switch result {
348-
case .failure:
349-
break
350-
default:
351-
XCTFail("Unexpected result: \(result)")
352-
}
353-
expectation.fulfill()
354-
}
355326

356-
wait(for: [expectation], timeout: Constants.expectationTimeout)
327+
do {
328+
_ = try await remote.loadAllProducts(for: sampleSiteID)
329+
XCTFail("Expected error to be thrown")
330+
} catch {
331+
XCTAssertEqual(error as? NetworkError, .notFound())
332+
}
357333
}
358334

359335

Networking/Sources/Extended/Remote/ProductsRemote.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public protocol ProductsRemoteProtocol {
2020
orderBy: ProductsRemote.OrderKey,
2121
order: ProductsRemote.Order,
2222
productIDs: [Int64],
23-
excludedProductIDs: [Int64],
24-
completion: @escaping (Result<[Product], Error>) -> Void)
23+
excludedProductIDs: [Int64]) async throws -> [Product]
2524
func searchProducts(for siteID: Int64,
2625
keyword: String,
2726
pageNumber: Int,
@@ -179,8 +178,7 @@ public final class ProductsRemote: Remote, ProductsRemoteProtocol {
179178
orderBy: OrderKey = .name,
180179
order: Order = .ascending,
181180
productIDs: [Int64] = [],
182-
excludedProductIDs: [Int64] = [],
183-
completion: @escaping (Result<[Product], Error>) -> Void) {
181+
excludedProductIDs: [Int64] = []) async throws -> [Product] {
184182
let stringOfExcludedProductIDs = excludedProductIDs.map { String($0) }
185183
.joined(separator: ",")
186184
let stringOfProductIDs: String = {
@@ -211,9 +209,9 @@ public final class ProductsRemote: Remote, ProductsRemoteProtocol {
211209

212210
let path = Path.products
213211
let request = JetpackRequest(wooApiVersion: .mark3, method: .get, siteID: siteID, path: path, parameters: parameters, availableAsRESTRequest: true)
214-
let mapper = ProductListMapper(siteID: siteID)
212+
let mapper = ListMapper<Product>(siteID: siteID)
215213

216-
enqueue(request, mapper: mapper, completion: completion)
214+
return try await enqueue(request, mapper: mapper)
217215
}
218216

219217
/// Retrieves products for the Point of Sale. Simple and variable products are loaded for WC version 9.6+, otherwise only simple products are loaded.

WooCommerce/Classes/Analytics/WooAnalyticsEvent+DomainSettings.swift

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

WooCommerce/Classes/Extensions/UIImage+Woo.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,6 @@ extension UIImage {
301301
return UIImage.gridicon(.cross, size: CGSize(width: 22, height: 22))
302302
}
303303

304-
/// Domain credit image.
305-
///
306-
static var domainCreditImage: UIImage {
307-
return UIImage(named: "domain-credit")!
308-
}
309-
310304
/// Domain purchase success image.
311305
///
312306
static var domainPurchaseSuccessImage: UIImage {

WooCommerce/Classes/POS/Presentation/ItemListView.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ struct ItemListView: View {
5454
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.searchProductsInPOS)
5555
}
5656

57-
private var isSearchCouponsFeatureEnabled: Bool {
58-
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.searchCouponsInPOS)
59-
}
60-
6157
private var isBarcodeScani1FeatureEnabled: Bool {
6258
ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi1)
6359
}
@@ -77,7 +73,7 @@ struct ItemListView: View {
7773
case .products:
7874
return isSearchProductsFeatureEnabled
7975
case .coupons:
80-
return isSearchCouponsFeatureEnabled
76+
return true
8177
}
8278
}
8379

0 commit comments

Comments
 (0)