Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Tests: Permissions #2625

Merged
merged 158 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
fdf89c3
Add accessibiity identifiers for Find in Page controller elements
Halle Mar 14, 2024
f4270bc
Add accessibilityIdentifier to NSMenuItemExtension.swift
Halle Mar 14, 2024
55e0e42
Set accessibilityIdentifier for address bar text field
Halle Mar 14, 2024
1141095
Add accessibilityIdentifier for Find in Page menu item
Halle Mar 14, 2024
1b74f49
Add FindInPageTests.swift to project
Halle Mar 14, 2024
8566be2
Add more accessibility identifiers to menu items and fix one incorrec…
Halle Mar 14, 2024
c7163ea
Add accessibilityIdentifier to more options find in page
Halle Mar 14, 2024
6c98b35
Change in-use accessibilityIdentifier for optionsButton so it isn't a…
Halle Mar 14, 2024
d1e2190
Find in page tests
Halle Mar 14, 2024
1d36c57
Fix accessibilityIdentifiers for find in page text fields, add roles …
Halle Mar 14, 2024
5d7ff4f
Test for number of search hits in page, single window enforecement, a…
Halle Mar 14, 2024
067ea21
Only deal with the HTML once in the test case run
Halle Mar 14, 2024
4e56b98
Merge branch 'main' into halle/find-in-page-tests
Halle Mar 15, 2024
d5b4bf3
Add waitForNonExistence XCUIElement extension to UI Tests Common
Halle Mar 15, 2024
2b71d4e
Add NSImage cropping to NSImageExtensions.swift
Halle Mar 15, 2024
0599135
Add extensions to UI Tests target
Halle Mar 15, 2024
5e38ef9
Clean up tests and language
Halle Mar 15, 2024
956a6be
Adds test to detect selected find result highlight color
Halle Mar 15, 2024
21b1d23
Merge branch 'main' into halle/find-in-page-tests
Halle Mar 15, 2024
cf26a1a
Add two more accessibility identifiers to menus
Halle Mar 15, 2024
bca6b11
Tests of find next, generalize screenshot color checking
Halle Mar 15, 2024
d25a6fb
Test cleanup
Halle Mar 15, 2024
0554d06
Formatting cleanup
Halle Mar 15, 2024
3ca9266
Test cleanup
Halle Mar 18, 2024
d706994
Merge branch 'main' into halle/find-in-page-tests
Halle Mar 18, 2024
95c0651
Fix line spaces
Halle Mar 18, 2024
e1ba012
Add tests
Halle Mar 18, 2024
b971c9c
Skip failing test with some info about required fixes
Halle Mar 18, 2024
42ed55e
Bring late fix from Find in Page
Halle Mar 18, 2024
27e01c4
Bring over fix of pixel matching from find in page branch
Halle Mar 18, 2024
3a7dded
Improvements to find in page tests from parallel branch
Halle Mar 19, 2024
4cb3242
Fixes for tests-server on independent scheme
Halle Mar 19, 2024
a494a7b
Add accessibility identifiers for recently visited sites
Halle Mar 19, 2024
ba5a011
Test of whether visited site is added to recently visited
Halle Mar 19, 2024
91d7981
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 19, 2024
c4fc7f4
Set clear history accessibility identifier
Halle Mar 19, 2024
f705a9d
Set clear all history alert buttons accessibility identifiers
Halle Mar 19, 2024
fd121f4
WIP commit showing fatal error
Halle Mar 19, 2024
aee805b
WIP fatal error more cleanup
Halle Mar 19, 2024
b42661d
Fix for validateMenuItem error during burning
Halle Mar 19, 2024
f746aeb
All passing tests
Halle Mar 19, 2024
5f54cd6
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 19, 2024
906ff8d
Clean up accessibility identifier assignment
Halle Mar 20, 2024
5311891
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 20, 2024
59abc79
Fix bad pbxproj merge
Halle Mar 20, 2024
f7ce14f
Remove warnings from tab bar tests
Halle Mar 20, 2024
a9a41cb
Restore test dependencies to pbxproj bad merge fix file
Halle Mar 20, 2024
91b155d
Improvement to accessibility identifier for window and tab restoration
Halle Mar 20, 2024
4abac8b
Simplify and clarify tests
Halle Mar 20, 2024
508cebb
Linter warning fixes
Halle Mar 20, 2024
0aa615b
Add test case
Halle Mar 20, 2024
00340e3
Fix tabs in FindInPageTests
Halle Mar 20, 2024
e9f324c
Elements and access levels
Halle Mar 20, 2024
ffd104f
Sync previous test cases already in PR
Halle Mar 20, 2024
c519aeb
More of this file's tabs and spaces linter warning saga
Halle Mar 20, 2024
f7a80a6
Formatting fix
Halle Mar 20, 2024
8e95661
Update sync tests with new accessibility identifiers
Halle Mar 20, 2024
e504083
Add accessibility identifier for adding bookmarks
Halle Mar 20, 2024
961cbf2
Add accessibility identifiers for resetting data menu items
Halle Mar 20, 2024
807bf6c
Add accessibility identifier to suggestions tableView
Halle Mar 21, 2024
e316533
Passing autocomplete tests
Halle Mar 21, 2024
0197f65
Standardize test style across all three test cases
Halle Mar 21, 2024
36d2b89
Standardize test style across test cases
Halle Mar 21, 2024
1384f36
Add BookmarksBarTests
Halle Mar 21, 2024
91c6fb2
Adding accessibility identifiers
Halle Mar 21, 2024
adde31e
First working test
Halle Mar 21, 2024
5bb2b44
All tests, one failing
Halle Mar 21, 2024
14c8448
Add URL extension for UI tests
Halle Mar 22, 2024
25dd363
Add extension to project
Halle Mar 22, 2024
0a35341
Use extension for all simple locally-served pages
Halle Mar 22, 2024
7ea6aa5
Bring over find in page test name fixes
Halle Mar 22, 2024
6a57cb1
Fix test names
Halle Mar 22, 2024
a067841
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 22, 2024
675dc51
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 22, 2024
6ea92d8
Add files back into project to avoid pbxproj merge badness
Halle Mar 22, 2024
0784ee7
More clarity in makeMenuItems
Halle Mar 25, 2024
cd56bcb
Added UITEST_MODE env var
Halle Mar 25, 2024
6a8580a
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 25, 2024
5e9ac28
Don't change menu items more than needed
Halle Mar 25, 2024
4b71bc8
Remove added linebreaks
Halle Mar 25, 2024
8f007b8
Don't use utf8String in TestsURLExtension
Halle Mar 25, 2024
9e1da48
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 25, 2024
5393069
Remove unused DataExtension.swift from target
Halle Mar 25, 2024
d290ca0
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 25, 2024
d95c05e
Remove unnecessary import
Halle Mar 25, 2024
49e9fa4
Merge branch 'main' into halle/bookmarks-bar-tests
Halle Mar 26, 2024
56ef7c8
Merge branch 'main' into halle/browsing-history-tests
Halle Mar 26, 2024
62ffa72
Merge branch 'halle/browsing-history-tests' into halle/bookmarks-bar-…
Halle Mar 26, 2024
521a0f7
Re-add bookmark bar tests after safety-first pbxproj merge
Halle Mar 26, 2024
0d5ef85
Add accessibility ID for other button on bookmark dialog
Halle Mar 27, 2024
4133f39
Test improvements
Halle Mar 27, 2024
b196c11
Merge branch 'main' into halle/bookmarks-bar-tests
Halle Mar 28, 2024
ce1f842
Commit fixes for test scheme building review
Halle Mar 29, 2024
a09ef6b
Update tests to current style
Halle Mar 29, 2024
eae14a7
Add tests back in after safety-first merge
Halle Mar 29, 2024
80a3050
Make pixel matching more forgiving
Halle Mar 29, 2024
f8555d1
Merge branch 'main' into halle/bookmarks-bar-tests
Halle Mar 29, 2024
559967b
Make setup easier to follow, arrange act assert spacing
Halle Mar 29, 2024
957b281
SwiftFormat
Halle Mar 29, 2024
5fbabe1
Keeps reappearing
Halle Mar 29, 2024
af2e3d0
Better naming
Halle Mar 29, 2024
5df0aa9
Remove extraneous unwraps
Halle Mar 29, 2024
9bec32d
Standardize title string creation
Halle Mar 29, 2024
8ad4d66
Add tests
Halle Mar 29, 2024
5a7e8cd
Remove extraneous imports
Halle Mar 29, 2024
eb10b9f
Add accessibility IDs and values
Halle Mar 29, 2024
a7834fe
Add accessibiity IDs
Halle Mar 29, 2024
15b29fe
First three pasing tests
Halle Mar 29, 2024
b973769
New accessibility function on menu items
Halle Apr 3, 2024
dd47d32
Accessibility IDs and values
Halle Apr 3, 2024
dd6e0f6
Favorites tests
Halle Apr 3, 2024
c3da7ba
Merge branch 'main' into halle/bookmarks-and-favorites-tests
Halle Apr 3, 2024
d4cedbe
Set accessibility IDs
Halle Apr 3, 2024
7b6f14c
Merge branch 'main' into halle/bookmarks-and-favorites-tests
Halle Apr 5, 2024
5179582
Re-add test case after safety-first merge
Halle Apr 5, 2024
831d2f9
Add accessibility IDs and values
Halle Apr 5, 2024
5ac85d6
Remove unused id
Halle Apr 8, 2024
f37c372
Abstract click and hover after existence is proven
Halle Apr 8, 2024
430cf0d
Increase timeout
Halle Apr 8, 2024
3496bc8
Add IDs
Halle Apr 8, 2024
e78f060
Finalize tests
Halle Apr 8, 2024
f93bdb0
Merge branch 'main' into halle/bookmarks-and-favorites-tests
Halle Apr 8, 2024
aba9a99
Whitespace warnings
Halle Apr 8, 2024
faebda4
Move function to extension
Halle Apr 8, 2024
5023958
Add IDs
Halle Apr 8, 2024
2d97b50
Add state restoration tests
Halle Apr 8, 2024
d1595c3
Merge branch 'main' into halle/state-restoration-tests
Halle Apr 9, 2024
ee28e92
Re-add new tests after safety-first merge
Halle Apr 9, 2024
87bac86
Test which tests edge cases of restore
Halle Apr 9, 2024
7f0ce51
Add app termination for clarity, since we terminate and relaunch.
Halle Apr 9, 2024
dc66630
Merge branch 'main' into halle/state-restoration-tests
Halle Apr 9, 2024
931039b
Add new test case
Halle Apr 9, 2024
74df1a6
Add accessibility IDs
Halle Apr 10, 2024
cdf15af
Add a debug method and a pre-test-case method to UITests
Halle Apr 10, 2024
a496b34
First four tests
Halle Apr 10, 2024
4277590
All tests
Halle Apr 10, 2024
3e200db
Merge branch 'main' into halle/address-bar-keyboard-shortcuts
Halle Apr 10, 2024
75733d3
Re-add tests after safety-first merge
Halle Apr 10, 2024
cdc0243
Autocomplete tests need autocomplete on
Halle Apr 11, 2024
7792d8b
Add cleanup script and set defaults to not ask for app move
Halle Apr 11, 2024
73d87cc
Merge branch 'main' into halle/permissions-tests
Halle Apr 11, 2024
02385bf
Add accessibility IDs and values
Halle Apr 12, 2024
5668775
Convenience function for address bar existence and typing
Halle Apr 12, 2024
b2eefcb
Convenience function for address bar existence and typing
Halle Apr 12, 2024
3dbb405
Two convenience functions in UITests
Halle Apr 12, 2024
6170cce
Add permissions tests
Halle Apr 12, 2024
33c6a90
Merge branch 'main' into halle/permissions-tests
Halle Apr 12, 2024
c561136
Add first run class method to every test case
Halle Apr 12, 2024
5357f67
Make button label matching function variadic and improve color test a…
Halle Apr 12, 2024
03fc2e0
Working first test
Halle Apr 12, 2024
c17f10a
Standardize XCTUnwrap behavior across test helpers
Halle Apr 15, 2024
a46d036
Add camera deny test
Halle Apr 15, 2024
3829c15
Set accessibility IDs for permission button types
Halle Apr 15, 2024
f4576cd
Mic and camera permissions tests all work
Halle Apr 15, 2024
66584f9
Add location tests
Halle Apr 15, 2024
fe8696c
Update tests to include website bug information for location permissions
Halle Apr 15, 2024
445c00f
Remove unused value
Halle Apr 15, 2024
9c5ee24
More standardization of style
Halle Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3307,6 +3307,7 @@
EE339228291BDEFD009F62C1 /* JSAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE339227291BDEFD009F62C1 /* JSAlertController.swift */; };
EE3424602BA0853900173B1B /* VPNUninstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE34245D2BA0853900173B1B /* VPNUninstaller.swift */; };
EE3424612BA0853900173B1B /* VPNUninstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE34245D2BA0853900173B1B /* VPNUninstaller.swift */; };
EE42CBCC2BC8004700AD411C /* PermissionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE42CBCB2BC8004700AD411C /* PermissionsTests.swift */; };
EE54F7B32BBFEA49006218DB /* BookmarksAndFavoritesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE54F7B22BBFEA48006218DB /* BookmarksAndFavoritesTests.swift */; };
EE66418C2B9B1981005BCD17 /* NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE66418B2B9B1981005BCD17 /* NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift */; };
EE66418D2B9B1981005BCD17 /* NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE66418B2B9B1981005BCD17 /* NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift */; };
Expand Down Expand Up @@ -4795,6 +4796,7 @@
EE0429DF2BA31D2F009EB20F /* FindInPageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FindInPageTests.swift; sourceTree = "<group>"; };
EE339227291BDEFD009F62C1 /* JSAlertController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSAlertController.swift; sourceTree = "<group>"; };
EE34245D2BA0853900173B1B /* VPNUninstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNUninstaller.swift; sourceTree = "<group>"; };
EE42CBCB2BC8004700AD411C /* PermissionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionsTests.swift; sourceTree = "<group>"; };
EE54F7B22BBFEA48006218DB /* BookmarksAndFavoritesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarksAndFavoritesTests.swift; sourceTree = "<group>"; };
EE66418B2B9B1981005BCD17 /* NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift"; sourceTree = "<group>"; };
EE66666E2B56EDE4001D898D /* VPNLocationsHostingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNLocationsHostingViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6587,6 +6589,7 @@
EE7F74902BB5D76600CD9456 /* BookmarksBarTests.swift */,
EE02D41B2BB460A600DBE6B3 /* BrowsingHistoryTests.swift */,
EE0429DF2BA31D2F009EB20F /* FindInPageTests.swift */,
EE42CBCB2BC8004700AD411C /* PermissionsTests.swift */,
EE9D81C22BC57A3700338BE3 /* StateRestorationTests.swift */,
7B4CE8E626F02134009134B1 /* TabBarTests.swift */,
);
Expand Down Expand Up @@ -12324,6 +12327,7 @@
EEC7BE2E2BC6C09500F86835 /* AddressBarKeyboardShortcutsTests.swift in Sources */,
EE54F7B32BBFEA49006218DB /* BookmarksAndFavoritesTests.swift in Sources */,
EE02D4222BB4611A00DBE6B3 /* TestsURLExtension.swift in Sources */,
EE42CBCC2BC8004700AD411C /* PermissionsTests.swift in Sources */,
7B4CE8E726F02135009134B1 /* TabBarTests.swift in Sources */,
EEBCE6832BA463DD00B9DF00 /* NSImageExtensions.swift in Sources */,
EEBCE6822BA444FA00B9DF00 /* XCUIElementExtension.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ final class AddressBarButtonsViewController: NSViewController {
return permissionAuthorizationPopover ?? {
let popover = PermissionAuthorizationPopover()
self.permissionAuthorizationPopover = popover
popover.setAccessibilityIdentifier("AddressBarButtonsViewController.permissionAuthorizationPopover")
return popover
}()
}
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/NavigationBar/View/NavigationBar.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@
<userDefinedRuntimeAttribute type="image" keyPath="disabledImage" value="Geolocation-Icon"/>
<userDefinedRuntimeAttribute type="image" keyPath="mutedImage" value="Geolocation-Icon"/>
</userDefinedRuntimeAttributes>
<accessibility identifier="NavigationBarViewController.geolocationPermissionButton"/>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uao-nC-0co" userLabel="Microphone Button" customClass="PermissionButton" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="32" y="0.0" width="32" height="32"/>
Expand All @@ -747,6 +748,7 @@
<userDefinedRuntimeAttribute type="image" keyPath="disabledImage" value="Microphone-Icon"/>
<userDefinedRuntimeAttribute type="image" keyPath="mutedImage" value="Microphone-Icon"/>
</userDefinedRuntimeAttributes>
<accessibility identifier="NavigationBarViewController.microphonePermissionButton"/>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="C2L-f9-L3r" userLabel="Camera Button" customClass="PermissionButton" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="64" y="0.0" width="32" height="32"/>
Expand All @@ -770,6 +772,7 @@
<userDefinedRuntimeAttribute type="image" keyPath="disabledImage" value="Camera-Tab-Blocked"/>
<userDefinedRuntimeAttribute type="image" keyPath="mutedImage" value="Camera-Icon"/>
</userDefinedRuntimeAttributes>
<accessibility identifier="NavigationBarViewController.cameraPermissionButton"/>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qqY-h9-UQ7" userLabel="Popups Button" customClass="PermissionButton" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="96" y="0.0" width="32" height="32"/>
Expand All @@ -789,6 +792,7 @@
<color key="value" name="ButtonMouseDownColor"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<accessibility identifier="NavigationBarViewController.popupsPermissionButton"/>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gGA-Yv-pnz" userLabel="External Scheme Button" customClass="PermissionButton" customModule="DuckDuckGo_Privacy_Browser" customModuleProvider="target">
<rect key="frame" x="128" y="0.0" width="32" height="32"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ final class PermissionAuthorizationViewController: NSViewController {
} else {
denyButton.title = UserText.permissionPopoverDenyButton
}
denyButton.setAccessibilityIdentifier("PermissionAuthorizationViewController.denyButton")
}

private func updateText() {
Expand Down Expand Up @@ -116,6 +117,7 @@ final class PermissionAuthorizationViewController: NSViewController {
buttonsBottomConstraint.isActive = !learnMoreBottomConstraint.isActive
linkButton.title = UserText.permissionPopupLearnMoreLink
allowButton.title = UserText.permissionPopupAllowButton
allowButton.setAccessibilityIdentifier("PermissionAuthorizationViewController.allowButton")
}

@IBAction func alwaysAllowLabelClick(_ sender: Any) {
Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/Permissions/View/PermissionButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,23 @@ final class PermissionButton: AddressBarButton {
case .active:
self.image = activeImage ?? defaultImage
self.normalTintColor = activeTintColor
self.setAccessibilityValue("active")
case .paused:
self.image = mutedImage ?? defaultImage
self.normalTintColor = mutedTintColor
self.setAccessibilityValue("paused")
case .disabled, .denied, .revoking:
self.image = disabledImage ?? defaultImage
self.normalTintColor = disabledTintColor
self.setAccessibilityValue("disabled-denied-revoking")
case .requested:
self.image = defaultImage
self.normalTintColor = defaultTint
self.setAccessibilityValue("requested")
case .inactive:
self.image = inactiveImage ?? defaultImage
self.normalTintColor = inactiveTintColor ?? defaultTint
self.setAccessibilityValue("inactive")
}
self.isHidden = isHidden
}
Expand Down
12 changes: 11 additions & 1 deletion DuckDuckGo/Permissions/View/PermissionContextMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ final class PermissionContextMenu: NSMenu {
setupOtherPermissionMenuItems(for: remainingPermission)
setupPopupsPermissionsMenuItems()
addPersistenceItems()
self.setAccessibilityIdentifier("PermissionContextMenu")
}

private func setupCameraPermissionsMenuItems(_ permissions: Permissions) -> Permissions {
Expand Down Expand Up @@ -279,6 +280,8 @@ private extension NSMenuItem {
if isChecked {
item.state = .on
}
item.setAccessibilityIdentifier("PermissionContextMenu.alwaysAllow")
item.setAccessibilityValue(item.state == .on ? "selected" : "unselected")
return item
}

Expand All @@ -299,6 +302,8 @@ private extension NSMenuItem {
if isChecked {
item.state = .on
}
item.setAccessibilityIdentifier("PermissionContextMenu.alwaysAsk")
item.setAccessibilityValue(item.state == .on ? "selected" : "unselected")
return item
}

Expand All @@ -312,6 +317,8 @@ private extension NSMenuItem {
if isChecked {
item.state = .on
}
item.setAccessibilityIdentifier("PermissionContextMenu.alwaysDeny")
item.setAccessibilityValue(item.state == .on ? "selected" : "unselected")
return item
}

Expand All @@ -325,7 +332,10 @@ private extension NSMenuItem {
permission.localizedDescription,
Bundle.main.displayName ?? "DuckDuckGo")
}
return NSMenuItem(title: title, action: nil, keyEquivalent: "")
let item = NSMenuItem(title: title, action: nil, keyEquivalent: "")
item.setAccessibilityIdentifier("PermissionContextMenu.permissionDisabled")
item.setAccessibilityValue(item.state == .on ? "selected" : "unselected")
return item
}

static func openSystemPreferences(for permission: PermissionType, target: PermissionContextMenu) -> NSMenuItem {
Expand Down
1 change: 1 addition & 0 deletions UITests/AddressBarKeyboardShortcutsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AddressBarKeyboardShortcutsTests: XCTestCase {

private var addressBarTextField: XCUIElement!
override class func setUp() {
UITests.firstRun()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we always start tests with a fresh install, every time we start a case, we also have to quickly make sure there are no first run problems like permissions which always appear, or the onboarding page.

UITests.setAutocompleteToggleBeforeTestcaseRuns(false) // We don't want changes in the address bar that we don't create
}

Expand Down
1 change: 1 addition & 0 deletions UITests/AutocompleteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AutocompleteTests: XCTestCase {
private var siteTitleForHistorySite: String!

override class func setUp() {
UITests.firstRun()
UITests.setAutocompleteToggleBeforeTestcaseRuns(true) // These tests require autocomplete to be on
}

Expand Down
7 changes: 6 additions & 1 deletion UITests/BookmarksAndFavoritesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class BookmarksAndFavoritesTests: XCTestCase {
private var showBookmarksBarPopup: XCUIElement!
private var showFavoritesPreferenceToggle: XCUIElement!

override class func setUp() {
UITests.firstRun()
}

override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
Expand Down Expand Up @@ -595,7 +599,8 @@ class BookmarksAndFavoritesTests: XCTestCase {
// This test uses coordinates (instead of accessibility IDs) to address the elements of the right click. As the writer of this test, I see this
// as a fragile test hook. However, I think it is preferable to making changes to the UI element it tests for this test alone. The reason is
// that the bookmark item on the bookmark bar isn't yet an accessibility-enabled UI element and doesn't appear to have a natural anchor point
// from which we can set its accessibility values without redesigning it. However, redesigning a road-tested UI element for a single test isn't a
// from which we can set its accessibility values without redesigning it. However, redesigning a road-tested UI element for a single test isn't
// a
// good idea, since the road-testing is also (valuable) testing and we don't want a single test to be the driver of a possible behavioral
// change in existing interface.
//
Expand Down
4 changes: 4 additions & 0 deletions UITests/BookmarksBarTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class BookmarksBarTests: XCTestCase {
private var addressBarTextField: XCUIElement!
private let titleStringLength = 12

override class func setUp() {
UITests.firstRun()
}

override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
Expand Down
4 changes: 4 additions & 0 deletions UITests/BrowsingHistoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class BrowsingHistoryTests: XCTestCase {
private var addressBarTextField: XCUIElement!
private let lengthForRandomPageTitle = 8

override class func setUp() {
UITests.firstRun()
}

override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
Expand Down
13 changes: 13 additions & 0 deletions UITests/Common/UITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,17 @@ enum UITests {
openVanillaBrowser.clickAfterExistenceTestSucceeds()
app.typeKey("w", modifierFlags: [.command, .option])
}

/// Avoid some first-run states that we aren't testing.
static func firstRun() {
let notificationCenter = XCUIApplication(bundleIdentifier: "com.apple.UserNotificationCenter")
if notificationCenter.exists { // If tests-server is asking for network permissions, deny them.
notificationCenter.typeKey(.escape, modifierFlags: [])
}
let app = XCUIApplication()
app.launch()
app.typeKey("n", modifierFlags: .command)
app.typeKey("w", modifierFlags: [.command, .option])
app.terminate()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove fresh-install first-run startup nuisances for all test cases.

}
14 changes: 14 additions & 0 deletions UITests/Common/XCUIElementExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ extension XCUIElement {
}
}

/// Check for the existence of the address bar and type a URL into it if it passes. Although it doesn't really make sense to restrict its usage to
/// the address bar, it is only foreseen and recommended for use with the address bar.
/// - Parameters:
/// - url: The URL to be typed into the address bar (or other element, for which use with this function should be seen as experimental)
/// - pressingEnter: If the `enter` key should not be pressed after typing this URL in, set this optional parameter to `false`, otherwise it
/// will be pressed.
func typeURLAfterExistenceTestSucceeds(_ url: URL, pressingEnter: Bool = true) {
XCTAssertTrue(
self.waitForExistence(timeout: UITests.Timeouts.elementExistence),
"The element \(self.debugDescription) didn't load with the expected title in a reasonable timeframe."
)
self.typeURL(url, pressingEnter: pressingEnter)
}

func clickAfterExistenceTestSucceeds() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New convenience function.

XCTAssertTrue(
self.waitForExistence(timeout: UITests.Timeouts.elementExistence),
Expand Down
Loading
Loading