Skip to content

Commit

Permalink
Fix fingerprinting UI tests (#2252)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1206085950214556/f
Tech Design URL:
CC:

Description:

This PR fixes fingerprinting UI tests.
  • Loading branch information
samsymons authored Dec 13, 2023
1 parent 8697128 commit 5909aab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
9 changes: 5 additions & 4 deletions DuckDuckGo/BookmarksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ extension BookmarksViewController: AddOrEditBookmarkViewControllerDelegate {
func showBookmarkDeletedMessage(_ bookmark: BookmarkEntity) {
guard let parent = bookmark.parent,
let index = parent.childrenArray.firstIndex(of: bookmark),
let domain = bookmark.urlObject?.host,
let title = bookmark.title,
let url = bookmark.url else {
assertionFailure()
Expand All @@ -962,9 +961,11 @@ extension BookmarksViewController: AddOrEditBookmarkViewControllerDelegate {
self?.tableView.reloadData()
self?.refreshAll()
} onDidDismiss: {
NotificationCenter.default.post(name: FireproofFaviconUpdater.deleteFireproofFaviconNotification,
object: nil,
userInfo: [FireproofFaviconUpdater.UserInfoKeys.faviconDomain: domain])
if let domain = bookmark.urlObject?.host {
NotificationCenter.default.post(name: FireproofFaviconUpdater.deleteFireproofFaviconNotification,
object: nil,
userInfo: [FireproofFaviconUpdater.UserInfoKeys.faviconDomain: domain])
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion DuckDuckGo/ForgetDataAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ class ForgetDataAlert {
let forgetTabsAndDataAction = UIAlertAction(title: UserText.actionForgetAll, style: .destructive) { _ in
forgetTabsAndDataHandler()
}


forgetTabsAndDataAction.accessibilityIdentifier = "alert.forget-data.confirm"

let cancelAction = UIAlertAction(title: UserText.actionCancel, style: .cancel) { _ in
cancelHandler?()
}

cancelAction.accessibilityIdentifier = "alert.forget-data.cancel"

alert.addAction(forgetTabsAndDataAction)
alert.addAction(cancelAction)

return alert
}

Expand Down
10 changes: 7 additions & 3 deletions FingerprintingUITests/FingerprintUITest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class FingerprintUITest: XCTestCase {
app.navigationBars.buttons["Done"].tap()

// Clear all tabs and data
app.toolbars["Toolbar"].buttons["Fire"].tap()
app.buttons["Close Tabs and Clear Data"].tap()
app.toolbars["Toolbar"].buttons["Close Tabs and Clear Data"].tap()
app.buttons["alert.forget-data.confirm"].tap()

sleep(2)

Expand All @@ -148,7 +148,11 @@ class FingerprintUITest: XCTestCase {
} else {
XCTFail("Bookmarks button missing")
}
app.tables.staticTexts["DuckDuckGo — Privacy, simplified."].tap()
if app.tables.staticTexts["DuckDuckGo — Privacy, simplified."].waitForExistence(timeout: 25) {
app.staticTexts["DuckDuckGo — Privacy, simplified."].tap()
} else {
XCTFail("Could not find bookmark")
}

// Verify the test passed
XCTAssertTrue(webview.staticTexts["TEST PASSED"].waitForExistence(timeout: 25), "Test not run")
Expand Down

0 comments on commit 5909aab

Please sign in to comment.