Skip to content

Commit ef39897

Browse files
authored
Merge branch 'trunk' into task/remove-minimum-barcode-length
2 parents e9faa1d + 96b814d commit ef39897

25 files changed

+925
-477
lines changed

Modules/Sources/Networking/Mapper/ProductListMapper.swift

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

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")

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [*] Shipping Labels: Fixed issue displaying fulfilled shipment after purchasing a label and quickly navigating back to the purchase form. [https://github.com/woocommerce/woocommerce-ios/pull/15790]
1313
- [*] Shipping Labels: Fixed mismatched indices of purchased labels on the order details screen. [https://github.com/woocommerce/woocommerce-ios/pull/15800]
1414
- [*] POS: Prevent card reader connection success alert flashing when connecting during a payment [https://github.com/woocommerce/woocommerce-ios/pull/15784]
15+
- [internal] POS: Improved scrolling and animation performance by refactoring the shadow implementation and updating the cart and checkout views. [https://github.com/woocommerce/woocommerce-ios/pull/15817]
1516

1617
22.6
1718
-----

WooCommerce/Classes/POS/Models/Cart+BarcodeScanError.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ extension Cart {
2424
title: title(for: error),
2525
subtitle: subtitle(for: error),
2626
quantity: 1,
27-
state: .error
27+
state: .error,
28+
accessibilityLabel: accessibilityLabel(for: error)
2829
)
2930
}
3031

@@ -50,6 +51,12 @@ extension Cart {
5051
private func subtitle(for error: PointOfSaleBarcodeScanError) -> String {
5152
return error.localizedDescription
5253
}
54+
55+
private func accessibilityLabel(for error: PointOfSaleBarcodeScanError) -> String {
56+
let errorDescription = error.localizedDescription
57+
let scannedValue = title(for: error)
58+
return "\(errorDescription). \(scannedValue)"
59+
}
5360
}
5461

5562
extension PointOfSaleBarcodeScanError {

WooCommerce/Classes/POS/Models/Cart.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import enum Yosemite.PointOfSaleBarcodeScanError
66
struct Cart {
77
var purchasableItems: [Cart.PurchasableItem] = []
88
var coupons: [Cart.CouponItem] = []
9+
10+
var accessibilityFocusedItemID: UUID? = nil
911
}
1012

1113
protocol CartItem {
@@ -26,6 +28,7 @@ extension Cart {
2628
let quantity: Int
2729
let type: CartItemType = .purchasableItem
2830
let state: ItemState
31+
let accessibilityLabel: String?
2932

3033
enum ItemState {
3134
case loaded(POSOrderableItem)
@@ -42,12 +45,22 @@ extension Cart {
4245
}
4346
}
4447

45-
init(id: UUID, title: String, subtitle: String?, quantity: Int, state: ItemState) {
48+
var formattedPrice: String? {
49+
switch state {
50+
case .loaded(let item):
51+
return item.formattedPrice
52+
case .loading, .error:
53+
return nil
54+
}
55+
}
56+
57+
init(id: UUID, title: String, subtitle: String?, quantity: Int, state: ItemState, accessibilityLabel: String? = nil) {
4658
self.id = id
4759
self.title = title
4860
self.subtitle = subtitle
4961
self.quantity = quantity
5062
self.state = state
63+
self.accessibilityLabel = accessibilityLabel
5164
}
5265

5366
init(id: UUID, item: POSOrderableItem, title: String, subtitle: String?, quantity: Int) {
@@ -56,6 +69,7 @@ extension Cart {
5669
self.subtitle = subtitle
5770
self.quantity = quantity
5871
self.state = .loaded(item)
72+
self.accessibilityLabel = nil
5973
}
6074

6175
static func loading(id: UUID) -> PurchasableItem {

WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ extension PointOfSaleAggregateModel {
218218
productType: .init(cartItem: cartItem)
219219
)
220220
)
221+
222+
cart.accessibilityFocusedItemID = cartItem.id
221223
}
222224
} catch {
223225
DDLogInfo("Failed to find item by barcode: \(error)")

0 commit comments

Comments
 (0)