Skip to content

Commit 0a2fd7b

Browse files
committed
Enter customer note from mock data instead of random note
1 parent 21b8bed commit 0a2fd7b

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

WooCommerce/UITestsFoundation/OrderDataStructs.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1+
/// Mock for a list of Orders
2+
public struct OrdersMock: Codable {
3+
public let response: OrdersResponseData
4+
}
5+
6+
/// Mocks for a single Order
17
public struct OrderMock: Codable {
28
public let response: OrderResponseData
39
}
410

11+
public struct OrdersResponseData: Codable {
12+
public let status: Int
13+
public let jsonBody: OrdersBodyData
14+
}
15+
516
public struct OrderResponseData: Codable {
617
public let status: Int
718
public let jsonBody: OrderBodyData
819
}
920

10-
public struct OrderBodyData: Codable {
21+
public struct OrdersBodyData: Codable {
1122
public let data: [OrderData]
1223
}
1324

25+
public struct OrderBodyData: Codable {
26+
public let data: OrderData
27+
}
28+
1429
public struct OrderData: Codable {
1530
public let id: Int
1631
public let number: String
1732
public let status: String
1833
public var total: String
1934
public let line_items: [LineItems]
2035
public let billing: BillingInformation
36+
public let customer_note: String
2137
}
2238

2339
public struct LineItems: Codable {

WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class GetMocks {
5353
}
5454

5555
static func readOrdersData() throws -> [OrderData] {
56-
let originalData = try JSONDecoder().decode(OrderMock.self, from: self.getMockData(test: OrdersTests.self, filename: "orders_any"))
56+
let originalData = try JSONDecoder().decode(OrdersMock.self, from: self.getMockData(test: OrdersTests.self, filename: "orders_any"))
5757
var updatedData = originalData.response.jsonBody.data
5858

5959
for index in 0..<updatedData.count {
@@ -66,5 +66,10 @@ class GetMocks {
6666
}
6767

6868
return updatedData
69-
}
69+
}
70+
71+
static func readNewOrderData() throws -> OrderData {
72+
let originalData = try JSONDecoder().decode(OrderMock.self, from: self.getMockData(test: OrdersTests.self, filename: "orders_3337"))
73+
return try XCTUnwrap(originalData.response.jsonBody.data)
74+
}
7075
}

WooCommerce/WooCommerceUITests/Tests/OrdersTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ final class OrdersTests: XCTestCase {
2727

2828
func test_create_new_order() throws {
2929
let products = try GetMocks.readProductsData()
30+
let order = try GetMocks.readNewOrderData()
3031

3132
try TabNavComponent().goToOrdersScreen()
3233
.startOrderCreation()
@@ -35,7 +36,7 @@ final class OrdersTests: XCTestCase {
3536
.addCustomerDetails(name: "Mira")
3637
.addShipping(amount: "1.25", name: "Flat Rate")
3738
.addFee(amount: "2.34")
38-
.addCustomerNote(getRandomPhrase())
39+
.addCustomerNote(order.customer_note)
3940
.createOrder()
4041
}
4142

0 commit comments

Comments
 (0)