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

Add bookmarks search UI tests #3161

Merged
merged 3 commits into from
Sep 3, 2024
Merged

Conversation

jotaemepereira
Copy link
Collaborator

@jotaemepereira jotaemepereira commented Aug 27, 2024

Task/Issue URL: https://app.asana.com/0/1204006570077678/1208027756712863/f
Tech Design URL:
CC:

Description

Adds the following UI tests:

  • Test 'No results' empty state is shown when searching and no results (both panel and manager)
  • Test that searching filter the correct results (both panel and manager)
  • Test 'Show in Folder' menu item action is shown on items when searching (both panel and manager)
  • Test search actions should be hidden when the user has no bookmarks (panel)

Steps to test

  1. Selec the UI Tests target
  2. Run the tests inside BookmarkSearchTests

Definition of Done:

Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Copy link
Contributor

github-actions bot commented Aug 27, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 33357fe

bookmarksMenuToggleBookmarksBarMenuItem
NSMenuItem.separator()
NSMenuItem(title: UserText.bookmarks)
.withAccessibilityIdentifier("MainMenu.bookmarks")
Copy link
Collaborator Author

@jotaemepereira jotaemepereira Aug 27, 2024

Choose a reason for hiding this comment

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

ℹ️ This the only change to this class. I added an accessibility identifier, but I had to fix the indentation.

@jotaemepereira jotaemepereira force-pushed the juan/ui-testing-bookmarks-search branch from f8834ba to 131b5dd Compare August 27, 2024 15:44
@@ -797,6 +797,10 @@ extension MainViewController {
@objc func resetBookmarks(_ sender: Any?) {
LocalBookmarkManager.shared.resetBookmarks()
UserDefaults.standard.set(false, forKey: UserDefaultsWrapper<Bool>.Key.homePageContinueSetUpImport.rawValue)


UserDefaults.standard.set(false, forKey: UserDefaultsWrapper<Bool>.Key.bookmarksBarPromptShown.rawValue)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ I had to to add this to be consistent between new tests. When we reset bookmarks, I want to reset the show bookmarks bar prompt dialog, so it’s shown.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That makes perfect sense 👍 but why are you adjusting onboardingFinished in the line below? It feels to me like a side effect (one wouldn't normally expect onboarding flag to be adjusted when you reset bookmarks, and especially not to have that flag set to true).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought it was needed for the show bookmarks bar dialog to appear, but that is not the case. I removed it

@jotaemepereira jotaemepereira force-pushed the juan/ui-testing-bookmarks-search branch 3 times, most recently from 74ef78a to fd58733 Compare August 27, 2024 15:50

import XCTest

class BookmarkUtilities {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

💡 'I’m having second thoughts about this class. I think another approach is to have an extension of XCUIApplication and define those methods there. Thoughts?

Then it’s easier to read in the tests:

app.openBookmarksManager(..)
app.openSiteToBookmark()
app.dismissPopover()
// etc ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I second your idea 👍 would much better prefer to have an extension on XCUIApplication than standalone utility classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great. I’ve done that ✅

Comment on lines 42 to 47
/// Open the initial site to be bookmarked, bookmarking it and/or escaping out of the dialog only if needed
/// - Parameter url: The URL we will use to load the bookmark
/// - Parameter pageTitle: The page title that would become the bookmark name
/// - Parameter bookmarkingViaDialog: open bookmark dialog, adding bookmark
/// - Parameter escapingDialog: `esc` key to leave dialog
/// - Parameter folderName: The name of the folder where you want to save the bookmark. If the folder does not exist, it fails.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot for taking time to document the code, especially for these utility APIs 🙏

Copy link
Collaborator

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

This looks great @jotaemepereira, thanks!
I've run UI Tests in CI for your branch and it's green: https://github.com/duckduckgo/macos-browser/actions/runs/10613949826

Left a few comments. I'm mostly interested about adjusting onboardingFinished flag from "Reset Bookmarks" menu option.

BookmarksUtilities can be rewritten as XCUIApplication extension now, or after you merge this 👍

@jotaemepereira jotaemepereira force-pushed the juan/ui-testing-bookmarks-search branch from 805c2d1 to 7f19b10 Compare September 2, 2024 19:21
@jotaemepereira
Copy link
Collaborator Author

The feedback was addressed, but I’m waiting for #3188 to be merged, given that a bug introduced by #3138 makes this test fail.

@jotaemepereira jotaemepereira force-pushed the juan/ui-testing-bookmarks-search branch from 7f19b10 to 33357fe Compare September 3, 2024 13:37
@jotaemepereira jotaemepereira merged commit 8561bd2 into main Sep 3, 2024
18 checks passed
@jotaemepereira jotaemepereira deleted the juan/ui-testing-bookmarks-search branch September 3, 2024 13:59
samsymons added a commit that referenced this pull request Sep 6, 2024
* main: (28 commits)
  Fix bookmark sort UI tests failure (#3219)
  Add tests for DuckPlayer pixel calculation (#3216)
  Implement checkbox VPN exclusions UI (#3207)
  fix zoom updated (#3140)
  Bump version to 1.105.0 (255)
  Add DuckPlayer enrollment pixels (#3190)
  Update PeopleFinders to address broker changes (#3208)
  Bump BSK with C-S-S to 6.14.0 (#3209)
  Zoom PDF controls (#3204)
  Fix exception on Copy in Save dialog (#3205)
  Remove DuckPlayer onboarding animation (#3198)
  Fix wrong URL displayed for auth dialog (#3191)
  Bump version to 1.105.0 (254)
  UI Ship review feedback for Duck Player onboarding (#3186)
  Implement bookmarks sort UI tests (#3162)
  Add bookmarks search UI tests (#3161)
  Bug: Disable boomark reordering when searching (#3188)
  Bump version to 1.105.0 (253)
  Remote feature flag for New Tab Page Improvements (#3176)
  Fix bookmarks bar issues (#3187)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants