forked from qodo-benchmark/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistoryTests.swift
More file actions
665 lines (597 loc) · 27.9 KB
/
HistoryTests.swift
File metadata and controls
665 lines (597 loc) · 27.9 KB
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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import Common
import XCTest
import Shared
let webpage = [
"url": "www.mozilla.org",
"label": "Internet for people, not profit — Mozilla",
"value": "mozilla.org"
]
let oldHistoryEntries: [String] = [
"Internet for people, not profit — Mozilla (US)",
"Explore / Twitter",
"Example Domain"
]
let emptyRecentlyClosedMesg = "Websites you’ve visited recently will show up here."
// This is part of the info the user will see in recent closed tabs once the default
// visited website (https://www.mozilla.org/en-US/book/) is closed
let bookOfMozilla = [
"file": "test-mozilla-book.html",
"title": "The Book of Mozilla",
"label": "localhost:\(serverPort)/test-fixture/test-mozilla-book.html"
]
class HistoryTests: BaseTestCase {
typealias HistoryPanelA11y = AccessibilityIdentifiers.LibraryPanels.HistoryPanel
let testWithDB = [
"testOpenHistoryFromBrowserContextMenuOptions",
"testClearHistoryFromSettings",
"testClearRecentHistory",
"testClearRecentHistory_TAE"
]
// This DDBB contains those 4 websites listed in the name
let historyDB = "browserYoutubeTwitterMozillaExample-places.db"
var toolbarScreen: ToolbarScreen!
var settingScreen: SettingScreen!
var browserScreen: BrowserScreen!
var historyScreen: HistoryScreen!
override func setUp() async throws {
// Test name looks like: "[Class testFunc]", parse out the function name
let parts = name.replacingOccurrences(of: "]", with: "").split(separator: " ")
let key = String(parts[1])
if testWithDB.contains(key) {
// for the current test name, add the db fixture used
launchArguments = [LaunchArguments.SkipIntro,
LaunchArguments.SkipWhatsNew,
LaunchArguments.SkipETPCoverSheet,
LaunchArguments.SkipDefaultBrowserOnboarding,
LaunchArguments.LoadDatabasePrefix + historyDB,
LaunchArguments.SkipContextualHints,
LaunchArguments.DisableAnimations]
}
try await super.setUp()
toolbarScreen = ToolbarScreen(app: app)
settingScreen = SettingScreen(app: app)
browserScreen = BrowserScreen(app: app)
historyScreen = HistoryScreen(app: app)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307300
func testEmptyHistoryListFirstTime() {
navigator.nowAt(NewTabScreen)
// Go to History List from Top Sites and check it is empty
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
app.tables.cells[HistoryPanelA11y.recentlyClosedCell],
app.tables.cells[HistoryPanelA11y.recentlyClosedCell].staticTexts["Recently Closed"],
app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg]
]
)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307301
func testOpenSyncDevices() {
// Firefox sync page should be available
navigator.nowAt(NewTabScreen)
navigator.goto(TabTray)
navigator.performAction(Action.ToggleExperimentSyncMode)
waitForElementsToExist(
[
app.otherElements.staticTexts["Firefox Sync"],
app.otherElements.buttons["Sync and Save Data"]
]
)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307487
func testClearHistoryFromSettings() throws {
XCTExpectFailure("The app was not launched", strict: false) {
navigator.nowAt(NewTabScreen)
// Browse to have an item in history list
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
app.tables.cells[HistoryPanelA11y.recentlyClosedCell],
app.tables.cells.staticTexts[oldHistoryEntries[0]]
]
)
mozWaitForElementToNotExist(app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg])
// Clear all private data via the settings
navigator.goto(HomePanelsScreen)
navigator.nowAt(NewTabScreen)
navigator.goto(ClearPrivateDataSettings)
app.tables.cells["ClearPrivateData"].waitAndTap()
app.alerts.buttons["OK"].waitAndTap()
// Back on History panel view check that there is not any item
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
app.tables[HistoryPanelA11y.tableView],
app.tables.cells[HistoryPanelA11y.recentlyClosedCell]
]
)
mozWaitForElementToNotExist(app.tables.cells.staticTexts[oldHistoryEntries[0]])
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg])
}
}
// https://mozilla.testrail.io/index.php?/cases/view/2307014
// Smoketest
func testClearPrivateData() throws {
XCTExpectFailure("The app was not launched", strict: false) {
navigator.nowAt(NewTabScreen)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton])
// Clear private data from settings and confirm
navigator.goto(ClearPrivateDataSettings)
app.tables.cells["ClearPrivateData"].waitAndTap()
mozWaitForElementToExist(app.tables.cells["ClearPrivateData"])
app.alerts.buttons["OK"].waitAndTap()
// Wait for OK pop-up to disappear after confirming
mozWaitForElementToNotExist(app.alerts.buttons["OK"])
// Try to tap on the disabled Clear Private Data button
app.tables.cells["ClearPrivateData"].waitAndTap()
// If the button is disabled, the confirmation pop-up should not exist
// Disabling assertion due to https://mozilla-hub.atlassian.net/browse/FXIOS-7494 issue
// After this issue is clarified the assertion will be re-enabled or changed.
// XCTAssertEqual(app.alerts.buttons["OK"].exists, false)
}
}
// https://mozilla.testrail.io/index.php?/cases/view/2307014
// Smoketest TAE
func testClearPrivateData_TAE() throws {
XCTExpectFailure("The app was not launched", strict: false) {
navigator.nowAt(NewTabScreen)
toolbarScreen.assertSettingsButtonExists()
// Clear private data from settings and confirm
navigator.goto(ClearPrivateDataSettings)
settingScreen.clearPrivateDataAndConfirm()
// Wait for OK pop-up to disappear after confirming
settingScreen.assertConfirmationAlertNotPresent()
// Try to tap on the disabled Clear Private Data button
settingScreen.tryTapClearPrivateDataButton()
// If the button is disabled, the confirmation pop-up should not exist
// Disabling assertion due to https://mozilla-hub.atlassian.net/browse/FXIOS-7494 issue
// After this issue is clarified the assertion will be re-enabled or changed.
// XCTAssertEqual(app.alerts.buttons["OK"].exists, false)
}
}
// https://mozilla.testrail.io/index.php?/cases/view/2307357
func testRecentlyClosedWebsiteOpen() {
// Open "Book of Mozilla"
openBookOfMozilla()
// The tab, which is still opened, is not included in the "Recently Closed" list
navigator.goto(BrowserTabMenu)
navigator.goto(LibraryPanel_History)
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView])
mozWaitForElementToNotExist(app.tables.cells.staticTexts[bookOfMozilla["label"]!])
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg])
}
// https://mozilla.testrail.io/index.php?/cases/view/2307463
func testRecentlyClosedWebsiteClosed() {
// Open "Book of Mozilla" and close the tab
openBookOfMozilla()
closeFirstTabByX(isTabTrayOn: true)
// On regular mode, the closed tab is listed in "Recently Closed" list
navigator.nowAt(NewTabScreen)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
// On private mode, the closed tab on regular mode is listed in "Recently Closed" list as well
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307475
func testRecentlyClosedPrivateMode() {
// Open "Book of Mozilla" on private mode and close the tab
waitForTabsButton()
navigator.goto(TabTray)
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.nowAt(BrowserTab)
openBookOfMozilla()
closeFirstTabByX(isTabTrayOn: true)
// "Recently Closed Tabs List" is empty
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.nowAt(NewTabScreen)
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
app.tables[HistoryPanelA11y.tableView],
app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg]
]
)
mozWaitForElementToNotExist(app.tables.cells.staticTexts[bookOfMozilla["label"]!])
}
// https://mozilla.testrail.io/index.php?/cases/view/2307479
func testRemoveAllTabsButtonRecentlyClosedHistory() {
// Open "Book of Mozilla"
openBookOfMozilla()
// Tap "Remove All Tabs" instead of close the tab individually
waitForTabsButton()
navigator.goto(TabTray)
navigator.performAction(Action.AcceptRemovingAllTabs)
// The closed tab is listed in "Recently Closed" list
navigator.goto(HomePanelsScreen)
navigator.nowAt(NewTabScreen)
navigator.goto(LibraryPanel_History)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307482
func testClearRecentlyClosedHistory() {
// Open "Book of Mozilla" and close the tab
openBookOfMozilla()
closeFirstTabByX(isTabTrayOn: true)
// Once the website is visited and closed it will appear in Recently Closed Tabs list
navigator.nowAt(NewTabScreen)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
// Clear all private data via the settings
navigator.goto(HomePanelsScreen)
navigator.nowAt(NewTabScreen)
navigator.goto(ClearPrivateDataSettings)
app.tables.cells["ClearPrivateData"].waitAndTap()
app.alerts.buttons["OK"].waitAndTap()
// The closed tab is *not* listed in "Recently Closed Tabs List"
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
app.tables[HistoryPanelA11y.tableView],
app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg]
]
)
mozWaitForElementToNotExist(app.tables.cells.staticTexts[bookOfMozilla["label"]!])
}
// https://mozilla.testrail.io/index.php?/cases/view/2307483
func testLongTapOptionsRecentlyClosedItem_tabTrayExperimentOn() {
// Open "Book of Mozilla" and close the tab
openBookOfMozilla()
closeFirstTabByX(isTabTrayOn: true)
// Long tap a recently closed item launches a context menu
navigator.nowAt(NewTabScreen)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
app.tables.cells.staticTexts[bookOfMozilla["label"]!].press(forDuration: 1)
waitForElementsToExist(
[
app.tables["Context Menu"],
app.tables.buttons[StandardImageIdentifiers.Large.plus],
app.tables.buttons[StandardImageIdentifiers.Large.privateMode]
]
)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307484
func testOpenInNewTabRecentlyClosedItem() {
// Open "Book of Mozilla" and close the tab
openBookOfMozilla()
closeFirstTabByX(isTabTrayOn: true)
// Open the page on a new tab from History Recently Closed screen
navigator.nowAt(NewTabScreen)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
// userState.numTabs does not work on iOS 15
if #available(iOS 16, *) {
XCTAssertEqual(userState.numTabs, 1)
}
app.tables.cells.staticTexts[bookOfMozilla["label"]!].press(forDuration: 1)
mozWaitForElementToExist(app.tables["Context Menu"])
app.tables.buttons[StandardImageIdentifiers.Large.plus].waitAndTap()
// The page is opened on the new tab
navigator.nowAt(NewTabScreen)
navigator.goto(TabTray)
if isTablet {
mozWaitForElementToExist(app.navigationBars.segmentedControls["navBarTabTray"])
} else {
mozWaitForElementToExist(app.otherElements["navBarTabTray"])
}
mozWaitForElementToExist(app.staticTexts[bookOfMozilla["title"]!])
// userState.numTabs does not work on iOS 15
if #available(iOS 16, *) {
XCTAssertEqual(userState.numTabs, 2)
}
}
// https://mozilla.testrail.io/index.php?/cases/view/2307485
func testOpenInNewPrivateTabRecentlyClosedItem() {
// Open "Book of Mozilla" and close the tab
openBookOfMozilla()
closeFirstTabByX(isTabTrayOn: true)
// Open the page on a new private tab from History Recently Closed screen
navigator.nowAt(NewTabScreen)
navigator.goto(HistoryRecentlyClosed)
waitForElementsToExist(
[
app.tables["Recently Closed Tabs List"],
app.tables.cells.staticTexts[bookOfMozilla["label"]!]
]
)
app.tables.cells.staticTexts[bookOfMozilla["label"]!].press(forDuration: 1)
mozWaitForElementToExist(app.tables["Context Menu"])
app.tables.buttons[StandardImageIdentifiers.Large.privateMode].waitAndTap()
// The page is opened only on the new private tab
navigator.nowAt(NewTabScreen)
navigator.goto(TabTray)
if isTablet {
mozWaitForElementToExist(app.navigationBars.segmentedControls["navBarTabTray"])
} else {
mozWaitForElementToExist(app.otherElements["navBarTabTray"])
}
XCTAssertFalse(app.staticTexts[bookOfMozilla["title"]!].isHittable)
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
if isTablet {
XCTAssertTrue(app.segmentedControls.buttons["Private"].isSelected)
} else {
mozWaitForElementToExist(app.staticTexts["Private"])
}
mozWaitForElementToExist(app.staticTexts[bookOfMozilla["title"]!])
XCTAssertEqual(userState.numTabs, 1)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307486
func testPrivateClosedSiteDoesNotAppearOnRecentlyClosed() {
navigator.nowAt(NewTabScreen)
// Open the two tabs in private mode. It is necessary to open two sites.
// When one tab is closed private mode, the private mode still has something opened.
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.nowAt(BrowserTab)
navigator.openURL(path(forTestPage: bookOfMozilla["file"]!))
waitUntilPageLoad()
navigator.openNewURL(urlString: path(forTestPage: "test-mozilla-org.html"))
waitUntilPageLoad()
// Close the private tab "Book of Mozilla" by tapping 'x' button
waitForTabsButton()
navigator.goto(TabTray)
mozWaitForElementToExist(app.staticTexts[webpage["label"]!])
if iPad() {
app.cells.buttons[StandardImageIdentifiers.Large.cross].firstMatch.waitAndTap()
} else {
app.cells.buttons[AccessibilityIdentifiers.TabTray.closeButton].firstMatch.waitAndTap()
}
// On private mode, the "Recently Closed Tabs List" is empty
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.goto(BrowserTabMenu)
navigator.goto(LibraryPanel_History)
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView])
mozWaitForElementToNotExist(app.tables["Recently Closed Tabs List"])
XCTAssertFalse(app.cells.staticTexts["Recently Closed"].isSelected)
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg])
XCTAssertFalse(app.tables.cells.staticTexts[bookOfMozilla["label"]!].exists)
// On regular mode, the "Recently Closed Tabs List" is empty, too
navigator.toggleOff(userState.isPrivate, withAction: Action.ToggleExperimentRegularMode)
navigator.goto(NewTabScreen)
navigator.goto(LibraryPanel_History)
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView])
mozWaitForElementToNotExist(app.tables["Recently Closed Tabs List"])
XCTAssertFalse(app.cells.staticTexts["Recently Closed"].isSelected)
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg])
XCTAssertFalse(app.tables.cells.staticTexts[bookOfMozilla["label"]!].exists)
}
// https://mozilla.testrail.io/index.php?/cases/view/2307025
// Smoke
func testTabHistory() {
openBookOfMozilla()
let urlBarBackButton = app.windows.otherElements.buttons[AccessibilityIdentifiers.Toolbar.backButton]
let urlBarForwardButton = app.windows.otherElements.buttons[AccessibilityIdentifiers.Toolbar.forwardButton]
mozWaitElementHittable(element: urlBarBackButton, timeout: 2.0)
urlBarBackButton.press(forDuration: 1.5)
app.tables.staticTexts["The Book of Mozilla"].waitAndTap()
mozWaitForElementToNotExist(app.tables.staticTexts["The Book of Mozilla"])
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
navigator.performAction(Action.OpenNewTabFromTabTray)
openBookOfMozilla()
mozWaitForElementToExist(urlBarBackButton)
urlBarBackButton.press(forDuration: 1)
app.tables.staticTexts["The Book of Mozilla"].waitAndTap()
urlBarBackButton.waitAndTap()
XCTAssertFalse(urlBarBackButton.isEnabled)
urlBarForwardButton.press(forDuration: 1)
app.tables.staticTexts["The Book of Mozilla"].waitAndTap()
let url = app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField]
mozWaitForValueContains(url, value: "localhost")
}
// https://mozilla.testrail.io/index.php?/cases/view/2307025
// Smoke TAE
func testTabHistory_TAE() {
openBookOfMozilla()
toolbarScreen.waitUntilBackButtonHittable(timeout: 2.0)
toolbarScreen.pressBackButton(duration: 1.5)
browserScreen.tapOnBookOfMozilla()
browserScreen.waitForBookOfMozillaToDisappear()
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
navigator.performAction(Action.OpenNewTabFromTabTray)
openBookOfMozilla()
toolbarScreen.assertBackButtonExists()
toolbarScreen.pressBackButton(duration: 1)
browserScreen.tapOnBookOfMozilla()
toolbarScreen.tapBackButton()
toolbarScreen.assertBackButtonIsDisabled()
toolbarScreen.pressForwardButton(duration: 1)
browserScreen.tapOnBookOfMozilla()
browserScreen.addressToolbarContainValue(value: "localhost")
}
// Private function created to select desired option from the "Clear Recent History" list
// We used this approach to avoid code duplication
private func tapOnClearRecentHistoryOption(optionSelected: String) {
app.buttons[optionSelected].waitAndTap()
}
private func navigateToPage(isTabTrayOff: Bool = true) {
navigator.openURL("example.com")
waitUntilPageLoad()
navigator.goto(TabTray)
navigator.performAction(Action.OpenNewTabFromTabTray)
if isTabTrayOff {
let cancelButton = app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton]
mozWaitForElementToExist(cancelButton, timeout: TIMEOUT_LONG)
navigator.performAction(Action.CloseURLBarOpen)
}
waitForTabsButton()
navigator.nowAt(NewTabScreen)
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
app.tables[HistoryPanelA11y.tableView],
app.tables.cells.staticTexts["Example Domain"]
]
)
}
private func openBookOfMozilla() {
navigator.openURL(path(forTestPage: bookOfMozilla["file"]!))
waitUntilPageLoad()
navigator.nowAt(BrowserTab)
}
private func closeFirstTabByX(isTabTrayOn: Bool = false) {
waitForTabsButton()
navigator.goto(TabTray)
if iPad() || isTabTrayOn == false {
app.cells.buttons[StandardImageIdentifiers.Large.cross].firstMatch.waitAndTap()
} else {
app.cells.buttons[AccessibilityIdentifiers.TabTray.closeButton].firstMatch.waitAndTap()
}
}
private func closeKeyboard() {
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
navigator.nowAt(NewTabScreen)
}
private func clearRecentHistoryAndValidate(
option: String,
shouldKeepOldEntries: Bool,
oldEntries: [String]
) {
let olderText = "Older"
navigateToPage(isTabTrayOff: false)
navigator.performAction(Action.ClearRecentHistory)
historyScreen.tapOnClearRecentHistoryOption(optionSelected: option)
if shouldKeepOldEntries {
historyScreen.waitForHistoryEntries(oldEntries)
} else {
historyScreen.waitForHistoryEntriesNotExist(oldEntries)
}
historyScreen.waitForStaticText(option, shouldExist: false)
historyScreen.waitForStaticText(olderText, shouldExist: shouldKeepOldEntries)
}
// https://mozilla.testrail.io/index.php?/cases/view/2306894
// Smoke
func testClearRecentHistory() {
// Visit a page to create a recent history entry.
navigateToPage(isTabTrayOff: false)
navigator.performAction(Action.ClearRecentHistory)
// Recent data will be removed after calling tapOnClearRecentHistoryOption(optionSelected: "Last 24 Hours").
// Older data will not be removed
tapOnClearRecentHistoryOption(optionSelected: "Last 24 Hours")
for entry in oldHistoryEntries {
mozWaitForElementToExist(app.tables.cells.staticTexts.elementContainingText(entry))
}
mozWaitForElementToNotExist(app.staticTexts["Last 24 Hours"])
mozWaitForElementToExist(app.staticTexts["Older"])
// Begin Test for Last 7 Days
// Visit a page to create a recent history entry.
navigateToPage(isTabTrayOff: false)
navigator.performAction(Action.ClearRecentHistory)
// Tapping "Today and Yesterday" will remove recent data (from yesterday and today).
// Older data will not be removed
tapOnClearRecentHistoryOption(optionSelected: "Last 7 Days")
for entry in oldHistoryEntries {
mozWaitForElementToExist(app.tables.cells.staticTexts.elementContainingText(entry))
}
mozWaitForElementToNotExist(app.staticTexts["Last 7 Days"])
mozWaitForElementToExist(app.staticTexts["Older"])
// Begin Test for Last 4 Weeks
// Visit a page to create a recent history entry.
navigateToPage(isTabTrayOff: false)
navigator.performAction(Action.ClearRecentHistory)
// Tapping "Today and Yesterday" will remove recent data (from yesterday and today).
// Older data will not be removed
tapOnClearRecentHistoryOption(optionSelected: "Last 4 Weeks")
for entry in oldHistoryEntries {
mozWaitForElementToExist(app.tables.cells.staticTexts.elementContainingText(entry))
}
mozWaitForElementToNotExist(app.staticTexts["Last 4 Weeks"])
mozWaitForElementToExist(app.staticTexts["Older"])
// Begin Test for All Time
// Visit a page to create a recent history entry.
navigateToPage(isTabTrayOff: false)
navigator.performAction(Action.ClearRecentHistory)
// Tapping everything removes both current data and older data.
tapOnClearRecentHistoryOption(optionSelected: "All Time")
for entry in oldHistoryEntries {
mozWaitForElementToNotExist(app.tables.cells.staticTexts[entry])
}
mozWaitForElementToNotExist(app.staticTexts["All Time"])
mozWaitForElementToNotExist(app.staticTexts["Older"])
}
// https://mozilla.testrail.io/index.php?/cases/view/2306894
// Smoke TAE
func testClearRecentHistory_TAE() {
clearRecentHistoryAndValidate(
option: "Last 24 Hours",
shouldKeepOldEntries: true,
oldEntries: oldHistoryEntries
)
clearRecentHistoryAndValidate(
option: "Last 7 Days",
shouldKeepOldEntries: true,
oldEntries: oldHistoryEntries
)
clearRecentHistoryAndValidate(
option: "Last 4 Weeks",
shouldKeepOldEntries: true,
oldEntries: oldHistoryEntries
)
clearRecentHistoryAndValidate(
option: "All Time",
shouldKeepOldEntries: false,
oldEntries: oldHistoryEntries
)
}
// https://mozilla.testrail.io/index.php?/cases/view/2306890
// Smoketest
func testDeleteHistoryEntryBySwiping() {
navigateToPage(isTabTrayOff: false)
navigator.goto(LibraryPanel_History)
mozWaitForElementToExist(app.cells.staticTexts["http://example.com/"])
app.cells.staticTexts["http://example.com/"].firstMatch.swipeLeft()
app.buttons["Delete"].waitAndTap()
mozWaitForElementToNotExist(app.staticTexts["http://example.com"])
mozWaitForElementToExist(app.tables[HistoryPanelA11y.tableView].staticTexts[emptyRecentlyClosedMesg])
}
// https://mozilla.testrail.io/index.php?/cases/view/2306890
// Smoketest TAE
func testDeleteHistoryEntryBySwiping_TAE() {
navigateToPage(isTabTrayOff: false)
navigator.goto(LibraryPanel_History)
historyScreen.waitForExampleEntry()
historyScreen.swipeLeftOnExampleEntry()
historyScreen.tapDeleteButton()
historyScreen.assertExampleEntryRemoved()
historyScreen.assertEmptyMessageVisible()
}
}