Skip to content

Commit 16ca782

Browse files
committed
Merge branch 'develop' into issue/250-tracking-ui
2 parents 6bc85df + ccf9aad commit 16ca782

File tree

64 files changed

+1046
-326
lines changed

Some content is hidden

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

64 files changed

+1046
-326
lines changed

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
B5A2417D217F9ECC00595DEF /* MetaContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A2417C217F9ECC00595DEF /* MetaContainer.swift */; };
167167
B5BB1D0C20A2050300112D92 /* DateFormatter+Woo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BB1D0B20A2050300112D92 /* DateFormatter+Woo.swift */; };
168168
B5BB1D1020A237FB00112D92 /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BB1D0F20A237FB00112D92 /* Address.swift */; };
169-
B5BB1D1220A255EC00112D92 /* OrderStatusKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BB1D1120A255EC00112D92 /* OrderStatusKey.swift */; };
169+
B5BB1D1220A255EC00112D92 /* OrderStatusEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5BB1D1120A255EC00112D92 /* OrderStatusEnum.swift */; };
170170
B5C151BB217EC34100C7BDC1 /* KeyedDecodingContainer+Woo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C151BA217EC34100C7BDC1 /* KeyedDecodingContainer+Woo.swift */; };
171171
B5C151C0217EE3FB00C7BDC1 /* NoteListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C151BF217EE3FB00C7BDC1 /* NoteListMapperTests.swift */; };
172172
B5C6FCC820A32E4800A4F8E4 /* DateFormatterWooTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6FCC720A32E4800A4F8E4 /* DateFormatterWooTests.swift */; };
@@ -357,7 +357,7 @@
357357
B5A2417C217F9ECC00595DEF /* MetaContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaContainer.swift; sourceTree = "<group>"; };
358358
B5BB1D0B20A2050300112D92 /* DateFormatter+Woo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Woo.swift"; sourceTree = "<group>"; };
359359
B5BB1D0F20A237FB00112D92 /* Address.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Address.swift; sourceTree = "<group>"; };
360-
B5BB1D1120A255EC00112D92 /* OrderStatusKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderStatusKey.swift; sourceTree = "<group>"; };
360+
B5BB1D1120A255EC00112D92 /* OrderStatusEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderStatusEnum.swift; sourceTree = "<group>"; };
361361
B5C151BA217EC34100C7BDC1 /* KeyedDecodingContainer+Woo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KeyedDecodingContainer+Woo.swift"; sourceTree = "<group>"; };
362362
B5C151BF217EE3FB00C7BDC1 /* NoteListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteListMapperTests.swift; sourceTree = "<group>"; };
363363
B5C6FCC720A32E4800A4F8E4 /* DateFormatterWooTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateFormatterWooTests.swift; sourceTree = "<group>"; };
@@ -617,7 +617,7 @@
617617
B5C6FCCE20A3592900A4F8E4 /* OrderItem.swift */,
618618
74C8F06320EEB44800B6EDC9 /* OrderNote.swift */,
619619
CE12FBD8221F3A6F00C59248 /* OrderStatus.swift */,
620-
B5BB1D1120A255EC00112D92 /* OrderStatusKey.swift */,
620+
B5BB1D1120A255EC00112D92 /* OrderStatusEnum.swift */,
621621
743E84EB22171F4600FAC9D7 /* ShipmentTracking.swift */,
622622
B56C1EB720EA76F500D749F9 /* Site.swift */,
623623
7426CA0E21AF2C90004E9FFC /* SiteAPI.swift */,
@@ -1079,7 +1079,7 @@
10791079
74A1D26B21189B8100931DFA /* SiteVisitStatsItem.swift in Sources */,
10801080
B505F6EC20BEFDC200BB1B69 /* Loader.swift in Sources */,
10811081
74D3BD142114FE6900A6E85E /* MIContainer.swift in Sources */,
1082-
B5BB1D1220A255EC00112D92 /* OrderStatusKey.swift in Sources */,
1082+
B5BB1D1220A255EC00112D92 /* OrderStatusEnum.swift in Sources */,
10831083
B5DAEFF02180DD5A0002356A /* NotificationsRemote.swift in Sources */,
10841084
74C8F06820EEB7BD00B6EDC9 /* OrderNotesMapper.swift in Sources */,
10851085
B53EF5342180F646003E146F /* DotcomValidator.swift in Sources */,

Networking/Networking/Model/Order.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct Order: Decodable {
1010
public let customerID: Int
1111

1212
public let number: String
13-
public let statusKey: OrderStatusKey
13+
public let statusKey: String
1414
public let currency: String
1515
public let customerNote: String?
1616

@@ -38,7 +38,7 @@ public struct Order: Decodable {
3838
parentID: Int,
3939
customerID: Int,
4040
number: String,
41-
statusKey: OrderStatusKey,
41+
statusKey: String,
4242
currency: String,
4343
customerNote: String?,
4444
dateCreated: Date,
@@ -99,7 +99,7 @@ public struct Order: Decodable {
9999
let customerID = try container.decode(Int.self, forKey: .customerID)
100100

101101
let number = try container.decode(String.self, forKey: .number)
102-
let statusKey = try container.decode(OrderStatusKey.self, forKey: .status)
102+
let statusKey = try container.decode(String.self, forKey: .status)
103103

104104
let currency = try container.decode(String.self, forKey: .currency)
105105
let customerNote = try container.decode(String.self, forKey: .customerNote)

Networking/Networking/Model/OrderStatus.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public struct OrderStatus: Decodable {
99
public let slug: String
1010
public let total: Int
1111

12-
public var status: OrderStatusKey {
13-
return OrderStatusKey(rawValue: slug)
12+
public var status: OrderStatusEnum {
13+
return OrderStatusEnum(rawValue: slug)
1414
}
1515

1616
/// OrderStatus struct initializer.

Networking/Networking/Model/OrderStatusKey.swift renamed to Networking/Networking/Model/OrderStatusEnum.swift

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Foundation
22

33

4-
/// Represents all of the possible Order Statuses
4+
/// Represents all of the possible Order Statuses in enum form
55
///
6-
public enum OrderStatusKey: Decodable, Hashable {
6+
public enum OrderStatusEnum: Decodable, Hashable {
77
case pending
88
case processing
99
case onHold
@@ -17,7 +17,7 @@ public enum OrderStatusKey: Decodable, Hashable {
1717

1818
/// RawRepresentable Conformance
1919
///
20-
extension OrderStatusKey: RawRepresentable {
20+
extension OrderStatusEnum: RawRepresentable {
2121

2222
/// Designated Initializer.
2323
///
@@ -42,7 +42,7 @@ extension OrderStatusKey: RawRepresentable {
4242
}
4343
}
4444

45-
/// Returns the current Enum Case's Raw Value
45+
/// Returns the current Enum Case's Raw Value, also known as the `slug`
4646
///
4747
public var rawValue: String {
4848
switch self {
@@ -59,31 +59,6 @@ extension OrderStatusKey: RawRepresentable {
5959
}
6060

6161

62-
/// StringConvertible Conformance
63-
///
64-
extension OrderStatusKey: CustomStringConvertible {
65-
66-
/// Returns a string describing the current OrderStatus Instance
67-
/// Custom doesn't return a localized string because the payload arrives at runtime, not buildtime.
68-
///
69-
public var description: String {
70-
switch self {
71-
case .pending: return NSLocalizedString("Pending", comment: "Pending Order Status")
72-
case .processing: return NSLocalizedString("Processing", comment: "Processing Order Status")
73-
case .onHold: return NSLocalizedString("On Hold", comment: "On Hold Order Status")
74-
case .failed: return NSLocalizedString("Failed", comment: "Failed Order Status")
75-
case .cancelled: return NSLocalizedString("Canceled", comment: "Cancelled Order Status")
76-
case .completed: return NSLocalizedString("Completed", comment: "Completed Order Status")
77-
case .refunded: return NSLocalizedString("Refunded", comment: "Refunded Order Status")
78-
case .custom(let payload):
79-
return payload
80-
.replacingOccurrences(of: "-", with: " ")
81-
.capitalized
82-
}
83-
}
84-
}
85-
86-
8762
/// Enum containing the 'Known' OrderStatus Keys
8863
///
8964
private enum Keys {

Networking/Networking/Remote/ReportRemote.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public class ReportRemote: Remote {
1515
/// - siteID: Site for which we'll fetch the order totals.
1616
/// - completion: Closure to be executed upon completion.
1717
///
18-
public func loadOrderTotals(for siteID: Int, completion: @escaping ([OrderStatusKey: Int]?, Error?) -> Void) {
18+
public func loadOrderTotals(for siteID: Int, completion: @escaping ([OrderStatusEnum: Int]?, Error?) -> Void) {
1919
loadReportOrderTotals(for: siteID) { (orderStatuses, error) in
20-
var returnDict = [OrderStatusKey: Int]()
20+
var returnDict = [OrderStatusEnum: Int]()
2121
orderStatuses?.forEach({ (orderStatus) in
22-
let status = OrderStatusKey(rawValue: orderStatus.slug)
22+
let status = OrderStatusEnum(rawValue: orderStatus.slug)
2323
returnDict[status] = orderStatus.total
2424
})
2525
completion(returnDict, error)

Networking/NetworkingTests/Mapper/OrderListMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class OrderListMapperTests: XCTestCase {
2626
XCTAssertEqual(firstOrder.parentID, 0)
2727
XCTAssertEqual(firstOrder.customerID, 11)
2828
XCTAssertEqual(firstOrder.number, "963")
29-
XCTAssert(firstOrder.statusKey == .processing)
29+
XCTAssert(firstOrder.statusKey == "processing")
3030
XCTAssertEqual(firstOrder.currency, "USD")
3131
XCTAssertEqual(firstOrder.customerNote, "")
3232
XCTAssertEqual(firstOrder.dateCreated, dateCreated)

Networking/NetworkingTests/Mapper/OrderMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class OrderMapperTests: XCTestCase {
2828
XCTAssertEqual(order.parentID, 0)
2929
XCTAssertEqual(order.customerID, 11)
3030
XCTAssertEqual(order.number, "963")
31-
XCTAssert(order.statusKey == .processing)
31+
XCTAssert(order.statusKey == "processing")
3232
XCTAssertEqual(order.currency, "USD")
3333
XCTAssertEqual(order.customerNote, "")
3434
XCTAssertEqual(order.dateCreated, dateCreated)

Networking/NetworkingTests/Mapper/ReportOrderMapperTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class ReportOrderMapperTests: XCTestCase {
2525
return
2626
}
2727

28-
var reportTotals = [OrderStatusKey: Int]()
28+
var reportTotals = [OrderStatusEnum: Int]()
2929
results.forEach({ (orderStatus) in
30-
let status = OrderStatusKey(rawValue: orderStatus.slug)
30+
let status = OrderStatusEnum(rawValue: orderStatus.slug)
3131
reportTotals[status] = orderStatus.total
3232
})
3333
let orderStatuses = results
@@ -41,8 +41,8 @@ class ReportOrderMapperTests: XCTestCase {
4141
XCTAssertEqual(reportTotals[.cancelled], 7)
4242
XCTAssertEqual(reportTotals[.refunded], 8)
4343
XCTAssertEqual(reportTotals[.failed], 9)
44-
XCTAssertEqual(reportTotals[OrderStatusKey(rawValue: "cia-investigation")], 10)
45-
XCTAssertEqual(reportTotals[OrderStatusKey(rawValue: "pre-ordered")], 1)
44+
XCTAssertEqual(reportTotals[OrderStatusEnum(rawValue: "cia-investigation")], 10)
45+
XCTAssertEqual(reportTotals[OrderStatusEnum(rawValue: "pre-ordered")], 1)
4646

4747
XCTAssertNotNil(orderStatuses)
4848
XCTAssertEqual(orderStatuses.count, 9)

Networking/NetworkingTests/Remote/ReportRemoteTests.swift

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class ReportRemoteTests: XCTestCase {
2121
network.removeAllSimulatedResponses()
2222
}
2323

24+
// MARK: - loadOrderTotals
25+
2426
/// Verifies that 'loadOrderTotals' properly parses the successful response
2527
///
2628
func testOrderTotalsReturnsSuccess() {
@@ -39,7 +41,7 @@ class ReportRemoteTests: XCTestCase {
3941
XCTAssertEqual(reportTotals?[.cancelled], 7)
4042
XCTAssertEqual(reportTotals?[.refunded], 8)
4143
XCTAssertEqual(reportTotals?[.failed], 9)
42-
XCTAssertEqual(reportTotals?[OrderStatusKey(rawValue: "cia-investigation")], 10)
44+
XCTAssertEqual(reportTotals?[OrderStatusEnum(rawValue: "cia-investigation")], 10)
4345
expectation.fulfill()
4446
}
4547
wait(for: [expectation], timeout: Constants.expectationTimeout)
@@ -65,4 +67,43 @@ class ReportRemoteTests: XCTestCase {
6567
}
6668
wait(for: [expectation], timeout: Constants.expectationTimeout)
6769
}
70+
71+
// MARK: - loadOrderStatuses
72+
73+
/// Verifies that 'loadOrderStatuses' properly parses the successful response
74+
///
75+
func testLoadOrderStatusesReturnsSuccess() {
76+
let expectation = self.expectation(description: "Load order statuses")
77+
let remote = ReportRemote(network: network)
78+
79+
network.simulateResponse(requestUrlSuffix: "reports/orders/totals", filename: "report-orders")
80+
remote.loadOrderStatuses(for: sampleSiteID) { (orderStatuses, error) in
81+
XCTAssertNil(error)
82+
XCTAssertNotNil(orderStatuses)
83+
XCTAssertEqual(orderStatuses?.count, 9)
84+
expectation.fulfill()
85+
}
86+
wait(for: [expectation], timeout: Constants.expectationTimeout)
87+
}
88+
89+
/// Verifies that `loadOrderStatuses` correctly returns a Dotcom Error, whenever the request failed.
90+
///
91+
func testLoadOrderStatusesProperlyParsesErrorResponses() {
92+
let expectation = self.expectation(description: "Error Handling")
93+
let remote = ReportRemote(network: network)
94+
95+
network.simulateResponse(requestUrlSuffix: "reports/orders/totals", filename: "generic_error")
96+
remote.loadOrderTotals(for: sampleSiteID) { (reportTotals, error) in
97+
guard let error = error as? DotcomError else {
98+
XCTFail()
99+
return
100+
}
101+
102+
XCTAssert(error == .unauthorized)
103+
XCTAssertEqual(reportTotals?.isEmpty, true)
104+
105+
expectation.fulfill()
106+
}
107+
wait(for: [expectation], timeout: Constants.expectationTimeout)
108+
}
68109
}

RELEASE-NOTES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
1.4
22
-----
33
- improvement: Add shipment tracking to Order Details screen
4+
- improvement: The store switcher now allows you to go back to the previous screen without logging you out
5+
- improvement: Custom order status labels are now supported! Instead of just displaying the order status slug and capitalizing the slug, the custom order status label will now be fetched from the server and properly displayed.
6+
- improvement: Filtering by custom order status now supported!
47
- bugfix: correctly flips chevron on Dashboard > New Orders, to support RTL languages.
58

69
1.3

0 commit comments

Comments
 (0)