Skip to content

Commit db5a6ec

Browse files
authored
Merge pull request #5583 from woocommerce/update-mocks-ui-test-prep
Updating mocks for Orders, Products and Reviews screens as preparation for UI tests
2 parents 39d7fdd + d0ec286 commit db5a6ec

35 files changed

+3175
-1693
lines changed

WooCommerce/UITestsFoundation/Screens/Orders/OrdersScreen.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import ScreenObject
22
import XCTest
33

4+
private struct ElementStringIDs {
5+
static let searchButton = "order-search-button"
6+
static let filterButton = "Filter"
7+
}
8+
49
public final class OrdersScreen: ScreenObject {
510

611
// TODO: Remove force `try` once `ScreenObject` migration is completed
712
public let tabBar = try! TabNavComponent()
813

914
private let searchButtonGetter: (XCUIApplication) -> XCUIElement = {
10-
$0.buttons["order-search-button"]
15+
$0.buttons[ElementStringIDs.searchButton]
16+
}
17+
18+
private let filterButtonGetter: (XCUIApplication) -> XCUIElement = {
19+
$0.buttons[ElementStringIDs.filterButton]
1120
}
1221

1322
private var searchButton: XCUIElement { searchButtonGetter(app) }
@@ -17,12 +26,11 @@ public final class OrdersScreen: ScreenObject {
1726
(try? OrdersScreen().isLoaded) ?? false
1827
}
1928

20-
init(app: XCUIApplication = XCUIApplication()) throws {
29+
public init(app: XCUIApplication = XCUIApplication()) throws {
2130
try super.init(
2231
expectedElementGetters: [
2332
searchButtonGetter,
24-
// swiftlint:disable:next opening_braces
25-
{ $0.buttons["order-filter-button"] }
33+
filterButtonGetter
2634
],
2735
app: app
2836
)

WooCommerce/UITestsFoundation/Screens/TabNavComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public final class TabNavComponent: ScreenObject {
2424
private var reviewsTabButton: XCUIElement { reviewsTabButtonGetter(app) }
2525
var productsTabButton: XCUIElement { productsTabButtonGetter(app) }
2626

27-
init(app: XCUIApplication = XCUIApplication()) throws {
27+
public init(app: XCUIApplication = XCUIApplication()) throws {
2828
try super.init(
2929
expectedElementGetters: [
3030
myStoreTabButtonGetter,

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 148 additions & 28 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import UITestsFoundation
2+
import XCTest
3+
4+
class LoginFlow {
5+
6+
// Login with WordPress.com account flow
7+
@discardableResult
8+
static func logInWithWPcom() throws -> MyStoreScreen {
9+
return try PrologueScreen().selectContinueWithWordPress()
10+
.proceedWith(email: TestCredentials.emailAddress)
11+
.proceedWith(password: TestCredentials.password)
12+
.verifyEpilogueDisplays(displayName: TestCredentials.displayName, siteUrl: TestCredentials.siteUrl)
13+
.continueWithSelectedSite()
14+
}
15+
}
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{
2+
"request": {
3+
"method": "GET",
4+
"urlPath": "/rest/v1.1/jetpack-blogs/161477129/rest-api/",
5+
"queryParameters": {
6+
"json": {
7+
"equalTo": "true"
8+
},
9+
"path": {
10+
"matches": "/wc-analytics/reports/revenue/stats/(.*)"
11+
},
12+
"query": {
13+
"matches": "(.*)interval\":\"day(.*)"
14+
}
15+
}
16+
},
17+
"response": {
18+
"status": 200,
19+
"jsonBody": {
20+
"data": {
21+
"totals": {
22+
"orders_count": 16,
23+
"num_items_sold": 0,
24+
"gross_sales": 0,
25+
"total_sales": 6470,
26+
"coupons": 0,
27+
"coupons_count": 0,
28+
"refunds": 0,
29+
"taxes": 0,
30+
"shipping": 0,
31+
"net_revenue": 0,
32+
"avg_items_per_order": 0,
33+
"avg_order_value": 0,
34+
"num_returning_customers": 0,
35+
"num_new_customers": 0,
36+
"products": 0,
37+
"segments": []
38+
},
39+
"intervals": [{
40+
"interval": "{{#assign 'customformat'}}yyyy-MM-dd{{/assign}}{{now format=customformat}}",
41+
"date_start": "{{now format=customformat}} 00:00:00",
42+
"date_start_gmt": "{{now format=customformat}} 00:00:00",
43+
"date_end": "{{now format=customformat}} 23:59:59",
44+
"date_end_gmt": "{{now format=customformat}} 23:59:59",
45+
"subtotals": {
46+
"orders_count": 1,
47+
"num_items_sold": 0,
48+
"gross_sales": 0,
49+
"total_sales": 23,
50+
"coupons": 0,
51+
"coupons_count": 0,
52+
"refunds": 0,
53+
"taxes": 0,
54+
"shipping": 0,
55+
"net_revenue": 0,
56+
"avg_items_per_order": 0,
57+
"avg_order_value": 0,
58+
"total_customers": 0,
59+
"segments": []
60+
}
61+
}, {
62+
"interval": "{{fnow offset='1 days' format=customformat}}",
63+
"date_start": "{{fnow offset='1 days' format=customformat}} 00:00:00",
64+
"date_start_gmt": "{{fnow offset='1 days' format=customformat}} 00:00:00",
65+
"date_end": "{{fnow offset='1 days' format=customformat}} 23:59:59",
66+
"date_end_gmt": "{{fnow offset='1 days' format=customformat}} 23:59:59",
67+
"subtotals": {
68+
"orders_count": 2,
69+
"num_items_sold": 0,
70+
"gross_sales": 0,
71+
"total_sales": 43,
72+
"coupons": 0,
73+
"coupons_count": 0,
74+
"refunds": 0,
75+
"taxes": 0,
76+
"shipping": 0,
77+
"net_revenue": 0,
78+
"avg_items_per_order": 0,
79+
"avg_order_value": 0,
80+
"total_customers": 0,
81+
"segments": []
82+
}
83+
}, {
84+
"interval": "{{fnow offset='2 days' format=customformat}}",
85+
"date_start": "{{fnow offset='2 days' format=customformat}} 00:00:00",
86+
"date_start_gmt": "{{fnow offset='2 days' format=customformat}} 00:00:00",
87+
"date_end": "{{fnow offset='2 days' format=customformat}} 23:59:59",
88+
"date_end_gmt": "{{fnow offset='2 days' format=customformat}} 23:59:59",
89+
"subtotals": {
90+
"orders_count": 4,
91+
"num_items_sold": 0,
92+
"gross_sales": 0,
93+
"total_sales": 55,
94+
"coupons": 0,
95+
"coupons_count": 0,
96+
"refunds": 0,
97+
"taxes": 0,
98+
"shipping": 0,
99+
"net_revenue": 0,
100+
"avg_items_per_order": 0,
101+
"avg_order_value": 0,
102+
"total_customers": 0,
103+
"segments": []
104+
}
105+
}, {
106+
"interval": "{{fnow offset='3 days' format=customformat}}",
107+
"date_start": "{{fnow offset='3 days' format=customformat}} 00:00:00",
108+
"date_start_gmt": "{{fnow offset='3 days' format=customformat}} 00:00:00",
109+
"date_end": "{{fnow offset='3 days' format=customformat}} 23:59:59",
110+
"date_end_gmt": "{{fnow offset='3 days' format=customformat}} 23:59:59",
111+
"subtotals": {
112+
"orders_count": 1,
113+
"num_items_sold": 0,
114+
"gross_sales": 0,
115+
"total_sales": 5,
116+
"coupons": 0,
117+
"coupons_count": 0,
118+
"refunds": 0,
119+
"taxes": 0,
120+
"shipping": 0,
121+
"net_revenue": 0,
122+
"avg_items_per_order": 0,
123+
"avg_order_value": 0,
124+
"total_customers": 0,
125+
"segments": []
126+
}
127+
}, {
128+
"interval": "{{fnow offset='4 days' format=customformat}}",
129+
"date_start": "{{fnow offset='4 days' format=customformat}} 00:00:00",
130+
"date_start_gmt": "{{fnow offset='4 days' format=customformat}} 00:00:00",
131+
"date_end": "{{fnow offset='4 days' format=customformat}} 23:59:59",
132+
"date_end_gmt": "{{fnow offset='4 days' format=customformat}} 23:59:59",
133+
"subtotals": {
134+
"orders_count": 4,
135+
"num_items_sold": 0,
136+
"gross_sales": 0,
137+
"total_sales": 121,
138+
"coupons": 0,
139+
"coupons_count": 0,
140+
"refunds": 0,
141+
"taxes": 0,
142+
"shipping": 0,
143+
"net_revenue": 0,
144+
"avg_items_per_order": 0,
145+
"avg_order_value": 0,
146+
"total_customers": 0,
147+
"segments": []
148+
}
149+
}, {
150+
"interval": "{{fnow offset='5 days' format=customformat}}",
151+
"date_start": "{{fnow offset='5 days' format=customformat}} 00:00:00",
152+
"date_start_gmt": "{{fnow offset='5 days' format=customformat}} 00:00:00",
153+
"date_end": "{{fnow offset='5 days' format=customformat}} 23:59:59",
154+
"date_end_gmt": "{{fnow offset='5 days' format=customformat}} 23:59:59",
155+
"subtotals": {
156+
"orders_count": 0,
157+
"num_items_sold": 0,
158+
"gross_sales": 0,
159+
"total_sales": 0,
160+
"coupons": 0,
161+
"coupons_count": 0,
162+
"refunds": 0,
163+
"taxes": 0,
164+
"shipping": 0,
165+
"net_revenue": 0,
166+
"avg_items_per_order": 0,
167+
"avg_order_value": 0,
168+
"total_customers": 0,
169+
"segments": []
170+
}
171+
}, {
172+
"interval": "{{fnow offset='6 days' format=customformat}}",
173+
"date_start": "{{fnow offset='6 days' format=customformat}} 00:00:00",
174+
"date_start_gmt": "{{fnow offset='6 days' format=customformat}} 00:00:00",
175+
"date_end": "{{fnow offset='6 days' format=customformat}} 23:59:59",
176+
"date_end_gmt": "{{fnow offset='6 days' format=customformat}} 23:59:59",
177+
"subtotals": {
178+
"orders_count": 0,
179+
"num_items_sold": 0,
180+
"gross_sales": 0,
181+
"total_sales": 0,
182+
"coupons": 0,
183+
"coupons_count": 0,
184+
"refunds": 0,
185+
"taxes": 0,
186+
"shipping": 0,
187+
"net_revenue": 0,
188+
"avg_items_per_order": 0,
189+
"avg_order_value": 0,
190+
"total_customers": 0,
191+
"segments": []
192+
}
193+
}]
194+
}
195+
},
196+
"headers": {
197+
"Content-Type": "application/json",
198+
"Connection": "keep-alive"
199+
}
200+
}
201+
}

0 commit comments

Comments
 (0)