-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathScreenshots.swift
511 lines (448 loc) · 24.1 KB
/
Screenshots.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
/*
* Backpack - Skyscanner's Design System
*
* Copyright 2018 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import XCTest
// swiftlint:disable type_body_length
// swiftlint:disable function_body_length
// swiftlint:disable file_length
class Screenshots: BackpackSnapshotTestCase {
func createApp() -> XCUIApplication {
let app = XCUIApplication()
app.launchArguments.append("UITests")
return app
}
override func setUp() {
super.setUp()
continueAfterFailure = true
}
func tapDialogScrimView () {
let dialogScrimViewCoordinate: XCUICoordinate =
app.otherElements["dialogScrimView"].coordinate(withNormalizedOffset: CGVector(dx: 10.0, dy: 10.0))
dialogScrimViewCoordinate.tap()
}
@MainActor
func testLightModeScreenshots() async {
app = createApp()
app.launchArguments.append("FORCE_LIGHT_MODE")
setupSnapshot(app)
app.launch()
await captureAllScreenshots()
}
@MainActor
func testDarkModeScreenshots() async {
app = createApp()
app.launchArguments.append("FORCE_DARK_MODE")
setupSnapshot(app)
app.launch()
await captureAllScreenshots(userInterfaceStyle: .dark)
}
@MainActor
func captureAllScreenshots(userInterfaceStyle: UIUserInterfaceStyle = .light) async {
await navigate(title: "Badges") {
saveScreenshot(component: "badge", scenario: "all", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Bar charts") {
app.cells.element(boundBy: 3).tap()
saveScreenshot(component: "bar-chart", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Bottom sheet") {
app.tables.staticTexts["Bottom Sheet with a bottom section"].tap()
saveScreenshot(component: "bottom-sheet", scenario: "with-bottom-section",
userInterfaceStyle: userInterfaceStyle)
app.buttons["Dismiss"].tap()
}
await navigate(title: "Buttons") {
switchTab(title: "UIKit")
app.tables.staticTexts["Primary"].tap()
saveScreenshot(component: "button", scenario: "primary", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Secondary"].tap()
saveScreenshot(component: "button", scenario: "secondary", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Secondary On Dark"].tap()
saveScreenshot(component: "button", scenario: "secondaryOnDark", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Destructive"].tap()
saveScreenshot(component: "button", scenario: "destructive", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Featured"].tap()
saveScreenshot(component: "button", scenario: "featured", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Link"].tap()
saveScreenshot(component: "button", scenario: "link", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Link On Dark"].tap()
saveScreenshot(component: "button", scenario: "linkOnDark", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Primary On Dark"].tap()
saveScreenshot(component: "button", scenario: "primaryOnDark", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Primary On Light"].tap()
saveScreenshot(component: "button", scenario: "primaryOnLight", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Calendar") {
app.tables.staticTexts["Default"].tap()
app.swipeUp()
app.cells.element(boundBy: 25).tap()
saveScreenshot(component: "calendar", scenario: "single", userInterfaceStyle: userInterfaceStyle)
app.buttons["Range"].tap()
app.cells.element(boundBy: 25).tap()
app.cells.element(boundBy: 30).tap()
saveScreenshot(component: "calendar", scenario: "range", userInterfaceStyle: userInterfaceStyle)
app.buttons["Multiple"].tap()
app.cells.element(boundBy: 25).tap()
app.cells.element(boundBy: 27).tap()
app.cells.element(boundBy: 32).tap()
saveScreenshot(component: "calendar", scenario: "multiple", userInterfaceStyle: userInterfaceStyle)
app.swipeUp()
app.swipeUp()
app.swipeUp()
app.swipeUp()
app.swipeUp()
saveScreenshot(component: "calendar", scenario: "pill", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Custom styles for specific dates"].tap()
saveScreenshot(component: "calendar", scenario: "custom-style", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With prices"].tap()
saveScreenshot(component: "calendar", scenario: "with-prices", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Cards") {
switchTab(title: "UIKit")
app.tables.staticTexts["Default"].tap()
saveScreenshot(component: "card", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Without padding"].tap()
saveScreenshot(component: "card", scenario: "without-padding", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Selected"].tap()
saveScreenshot(component: "card", scenario: "selected", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Corner style large"].tap()
saveScreenshot(component: "card", scenario: "corner-style-large", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Background color"].tap()
saveScreenshot(component: "card", scenario: "background-color", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With divider"].tap()
saveScreenshot(component: "card", scenario: "with-divider", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With divider arranged vertically"].tap()
saveScreenshot(component: "card", scenario: "with-divider-arranged-vertically",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With divider without padding"].tap()
saveScreenshot(component: "card", scenario: "with-divider-without-padding",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With divider and corner style large"].tap()
saveScreenshot(component: "card", scenario: "with-divider-and-corner-style-large",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With solid divider with padding"].tap()
saveScreenshot(component: "card", scenario: "with-solid-divider-with-padding",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With solid divider without padding"].tap()
saveScreenshot(component: "card", scenario: "with-solid-divider-without-padding",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Wrapper default"].tap()
saveScreenshot(component: "card-wrapper", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Card Button") {
saveScreenshot(component: "card-button", scenario: "all", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Chips") {
app.tables.staticTexts["Default"].tap()
saveScreenshot(component: "chip", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["On Dark"].tap()
saveScreenshot(component: "chip", scenario: "on-dark", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["On Image"].tap()
saveScreenshot(component: "chip", scenario: "on-image", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Dialogs") {
let showButtonText = "Show dialog"
app.tables.staticTexts["Success"].tap()
app.buttons[showButtonText].tap()
saveScreenshot(component: "dialog", scenario: "success", userInterfaceStyle: userInterfaceStyle)
tapDialogScrimView()
tapBackButton()
app.tables.staticTexts["Warning"].tap()
app.buttons[showButtonText].tap()
saveScreenshot(component: "dialog", scenario: "warning", userInterfaceStyle: userInterfaceStyle)
tapDialogScrimView()
tapBackButton()
app.tables.staticTexts["Destructive"].tap()
app.buttons[showButtonText].tap()
saveScreenshot(component: "dialog", scenario: "destructive", userInterfaceStyle: userInterfaceStyle)
app.buttons["Delete"].tap()
tapBackButton()
app.tables.staticTexts["Flare"].tap()
app.buttons[showButtonText].tap()
saveScreenshot(component: "dialog", scenario: "flare", userInterfaceStyle: userInterfaceStyle)
tapDialogScrimView()
tapBackButton()
app.tables.staticTexts["Image"].tap()
app.buttons[showButtonText].tap()
saveScreenshot(component: "dialog", scenario: "image", userInterfaceStyle: userInterfaceStyle)
tapDialogScrimView()
tapBackButton()
}
await navigate(title: "Flare views") {
app.tables.staticTexts["Default"].tap()
saveScreenshot(component: "flare-view", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Background image"].tap()
saveScreenshot(component: "flare-view", scenario: "background-image", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Flare at top"].tap()
saveScreenshot(component: "flare-view", scenario: "flare-at-top", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Rounded"].tap()
saveScreenshot(component: "flare-view", scenario: "rounded", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Horizontal navigation") {
app.tables.staticTexts["Default"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Small"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "small", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Without underline"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "without-underline",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With icons"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "with-icons",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Small with icons"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "small-with-icons",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Wide"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "wide",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Alternate"].tap()
saveScreenshot(component: "horizontal-navigation", scenario: "alternate",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Icons") {
switchTab(title: "UIKit")
saveScreenshot(component: "icon", scenario: "all", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Labels") {
switchTab(title: "UIKit")
app.tables.staticTexts["Body"].tap()
saveScreenshot(component: "label", scenario: "body", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Heading"].tap()
saveScreenshot(component: "label", scenario: "heading", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Hero"].tap()
saveScreenshot(component: "label", scenario: "hero", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Map") {
app.tables.staticTexts["Default"].tap()
app.otherElements["Manchester airport"].tap()
app.otherElements["London"].tap()
app.maps.otherElements["London"].tap()
saveScreenshot(component: "map", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Navigation bars") {
app.tables.staticTexts["Large - no back button"].tap()
saveScreenshot(component: "navigation-bar", scenario: "large-simple",
userInterfaceStyle: userInterfaceStyle)
app.buttons["NavigateBack"].tap()
app.tables.staticTexts["Large - with back button"].tap()
saveScreenshot(component: "navigation-bar", scenario: "large-back-button",
userInterfaceStyle: userInterfaceStyle)
app.buttons["NavigateBack"].tap()
app.tables.staticTexts["Collapsed - simple"].tap()
saveScreenshot(component: "navigation-bar", scenario: "collapsed-simple",
userInterfaceStyle: userInterfaceStyle)
app.buttons["NavigateBack"].tap()
app.tables.staticTexts["Large - onImage"].tap()
saveScreenshot(component: "navigation-bar", scenario: "large-onImage",
userInterfaceStyle: userInterfaceStyle)
app.buttons["NavigateBack"].tap()
app.tables.staticTexts["Collapsed - onImage"].tap()
saveScreenshot(component: "navigation-bar", scenario: "collapsed-onImage",
userInterfaceStyle: userInterfaceStyle)
app.buttons["NavigateBack"].tap()
}
await navigate(title: "Nudger") {
saveScreenshot(component: "nudger", scenario: "default",
userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Overlay") {
switchTab(title: "UIKit")
app.tables.staticTexts["Solid"].tap()
saveScreenshot(component: "overlay", scenario: "solid", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Top"].tap()
saveScreenshot(component: "overlay", scenario: "top", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Bottom"].tap()
saveScreenshot(component: "overlay", scenario: "bottom", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Left"].tap()
saveScreenshot(component: "overlay", scenario: "left", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Right"].tap()
saveScreenshot(component: "overlay", scenario: "right", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Vignette"].tap()
saveScreenshot(component: "overlay", scenario: "vignette", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Panels") {
app.tables.staticTexts["Default"].tap()
saveScreenshot(component: "panel", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Without padding"].tap()
saveScreenshot(component: "panel", scenario: "without-padding", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Elevated"].tap()
saveScreenshot(component: "panel", scenario: "elevated", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Progress bar") {
app.buttons["Increase"].tap()
app.buttons["Increase"].tap()
saveScreenshot(component: "progress-bar", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Rating") {
app.tables.staticTexts["BPKRating: title text"].tap()
saveScreenshot(component: "rating", scenario: "with-title-text", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["BPKRating: titleView - BPKStarRating"].tap()
saveScreenshot(component: "rating", scenario: "with-custom-title-view-star-rating", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["BPKRating: titleView - ImageView"].tap()
saveScreenshot(component: "rating", scenario: "with-custom-title-view-image-view", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Snackbar") {
app.tables.staticTexts["With text"].tap()
saveScreenshot(component: "snack-bar", scenario: "with-text", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With text and button"].tap()
saveScreenshot(component: "snack-bar", scenario: "with-text-and-button",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["With text and icon only button"].tap()
saveScreenshot(component: "snack-bar", scenario: "with-text-and-icon-only-button",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Spinners") {
saveScreenshot(component: "spinner", scenario: "all", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Star ratings") {
app.tables.staticTexts["Docs"].tap()
saveScreenshot(component: "star-rating", scenario: "docs", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Skeleton") {
switchTab(title: "UIKit")
saveScreenshot(component: "skeleton", scenario: "all", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Switches") {
switchTab(title: "UIKit")
saveScreenshot(component: "switch", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Tab bar controller") {
saveScreenshot(component: "tab-bar-controller", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Tappable link labels") {
app.tables.staticTexts["Text with single link"].tap()
saveScreenshot(component: "tappable-link-label", scenario: "single", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Text with multiple links"].tap()
saveScreenshot(component: "tappable-link-label", scenario: "multiple", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Alternate style"].tap()
saveScreenshot(component: "tappable-link-label", scenario: "alternate-style",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Link with custom color"].tap()
saveScreenshot(component: "tappable-link-label", scenario: "custom-color",
userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Text fields") {
saveScreenshot(component: "text-field", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Text views") {
saveScreenshot(component: "text-view", scenario: "default", userInterfaceStyle: userInterfaceStyle)
}
await navigate(title: "Toasts") {
app.tables.staticTexts["Docs"].tap()
app.buttons["Show Toast"].tap()
saveScreenshot(component: "toast", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Page indicators") {
saveScreenshot(component: "page-indicator", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Price") {
app.tables.staticTexts["ExtraSmall"].tap()
saveScreenshot(component: "price", scenario: "extraSmall", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Small"].tap()
saveScreenshot(component: "price", scenario: "small", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
app.tables.staticTexts["Large"].tap()
saveScreenshot(component: "price", scenario: "large", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Floating notification") {
app.buttons["With icon and action"].tap()
saveScreenshot(component: "floating-notification", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Flight Leg") {
saveScreenshot(component: "flight-leg", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Carousel") {
saveScreenshot(component: "carousel", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Carousel Card") {
saveScreenshot(component: "carousel-card", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
await navigate(title: "Card Carousel") {
saveScreenshot(component: "card-carousel", scenario: "default", userInterfaceStyle: userInterfaceStyle)
tapBackButton()
}
}
}