forked from agentic-review-benchmarks/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA11yOnboardingTests.swift
More file actions
114 lines (101 loc) · 4.59 KB
/
A11yOnboardingTests.swift
File metadata and controls
114 lines (101 loc) · 4.59 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
// 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
class A11yOnboardingTests: BaseTestCase {
var currentScreen = 0
var rootA11yId: String {
return "\(AccessibilityIdentifiers.Onboarding.onboarding)\(currentScreen)"
}
override func setUp() async throws {
launchArguments = [LaunchArguments.ClearProfile,
LaunchArguments.DisableAnimations,
LaunchArguments.SkipSplashScreenExperiment]
currentScreen = 0
try await super.setUp()
}
override func tearDown() async throws {
app.terminate()
try await super.tearDown()
}
func testA11yFirstRunTour() throws {
let sanitizedTestName = self.name.replacingOccurrences(of: "()", with: "").replacingOccurrences(of: ".", with: "_")
// swiftlint:disable large_tuple
var missingLabels: [A11yUtils.MissingAccessibilityElement] = []
// swiftlint:enable large_tuple
guard #available(iOS 17.0, *), !skipPlatform else { return }
// Complete the First run from first screen to the latest one
// Check that the first's tour screen is shown as well as all the elements in there
waitForElementsToExist(
[
app.images["\(rootA11yId)ImageView"],
app.staticTexts["\(rootA11yId)TitleLabel"],
app.staticTexts["\(rootA11yId)DescriptionLabel"],
app.buttons["\(rootA11yId)PrimaryButton"],
app.buttons["\(rootA11yId)SecondaryButton"],
app.buttons["\(AccessibilityIdentifiers.Onboarding.closeButton)"],
app.pageIndicators["\(AccessibilityIdentifiers.Onboarding.pageControl)"]
]
)
try app.performAccessibilityAudit()
checkMissingLabels(missingLabels: &missingLabels)
// Swipe to the second screen
app.buttons["\(rootA11yId)SecondaryButton"].tap()
currentScreen += 1
waitForElementsToExist(
[
app.images["\(rootA11yId)ImageView"],
app.staticTexts["\(rootA11yId)TitleLabel"],
app.staticTexts["\(rootA11yId)DescriptionLabel"],
app.buttons["\(rootA11yId)PrimaryButton"],
]
)
try app.performAccessibilityAudit()
checkMissingLabels(missingLabels: &missingLabels)
// Swipe to the third screen
app.buttons["\(rootA11yId)SecondaryButton"].waitAndTap()
currentScreen += 1
mozWaitForElementToExist(app.images["\(rootA11yId)ImageView"])
try app.performAccessibilityAudit()
checkMissingLabels(missingLabels: &missingLabels)
// Swipe to the fourth screen
app.buttons["\(rootA11yId)SecondaryButton"].tap()
currentScreen += 1
mozWaitForElementToExist(app.images["\(rootA11yId)ImageView"], timeout: TIMEOUT)
try app.performAccessibilityAudit()
checkMissingLabels(missingLabels: &missingLabels)
// Swipe to the fifth screen
app.buttons["\(rootA11yId)PrimaryButton"].tap()
currentScreen += 1
mozWaitForElementToExist(app.images["\(rootA11yId)ImageView"], timeout: TIMEOUT)
try app.performAccessibilityAudit()
checkMissingLabels(missingLabels: &missingLabels)
// Finish onboarding
app.buttons["\(rootA11yId)PrimaryButton"].tap()
let topSites = app.collectionViews.links[AccessibilityIdentifiers.FirefoxHomepage.TopSites.itemCell]
mozWaitForElementToExist(topSites)
// Generate Report
A11yUtils.generateAndAttachReport(missingLabels: missingLabels, testName: sanitizedTestName, generateCsv: false)
}
private func checkMissingLabels(missingLabels: inout [A11yUtils.MissingAccessibilityElement]) {
A11yUtils.checkMissingLabels(
in: app.buttons.allElementsBoundByIndex,
screenName: "Onboarding \(rootA11yId) Screen",
missingLabels: &missingLabels,
elementType: "Button"
)
A11yUtils.checkMissingLabels(
in: app.images.allElementsBoundByIndex,
screenName: "Onboarding \(rootA11yId) Screen",
missingLabels: &missingLabels,
elementType: "Image"
)
A11yUtils.checkMissingLabels(
in: app.staticTexts.allElementsBoundByIndex,
screenName: "Onboarding \(rootA11yId) Screen",
missingLabels: &missingLabels,
elementType: "StaticText"
)
}
}