Skip to content

Commit

Permalink
Bookmark all tabs - Context menu (#2599)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1207032400501906/f 

**Description**:
Add the new “Bookmark All Tabs…” menu item to:
1. Main application Menu -> Bookmarks menu.
2. The more options menu, the menu shown from the “…” button.
3. The contextual menu of a single Tab.
  • Loading branch information
alessandroboron authored Apr 14, 2024
1 parent d0fb45d commit dd83ac7
Show file tree
Hide file tree
Showing 17 changed files with 326 additions and 18 deletions.
6 changes: 6 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,8 @@
9F982F0F2B8224BF00231028 /* AddEditBookmarkFolderDialogViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F982F0C2B8224BE00231028 /* AddEditBookmarkFolderDialogViewModel.swift */; };
9F982F132B822B7B00231028 /* AddEditBookmarkFolderDialogViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F982F112B82268F00231028 /* AddEditBookmarkFolderDialogViewModelTests.swift */; };
9F982F142B822C7400231028 /* AddEditBookmarkFolderDialogViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F982F112B82268F00231028 /* AddEditBookmarkFolderDialogViewModelTests.swift */; };
9F9C49F62BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F9C49F52BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift */; };
9F9C49F72BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F9C49F52BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift */; };
9FA173DA2B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FA173D92B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift */; };
9FA173DB2B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FA173D92B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift */; };
9FA173DC2B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FA173D92B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift */; };
Expand Down Expand Up @@ -4246,6 +4248,7 @@
9F872DA22B90920F00138637 /* BookmarkFolderInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkFolderInfo.swift; sourceTree = "<group>"; };
9F982F0C2B8224BE00231028 /* AddEditBookmarkFolderDialogViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditBookmarkFolderDialogViewModel.swift; sourceTree = "<group>"; };
9F982F112B82268F00231028 /* AddEditBookmarkFolderDialogViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditBookmarkFolderDialogViewModelTests.swift; sourceTree = "<group>"; };
9F9C49F52BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MoreOptionsMenu+BookmarksTests.swift"; sourceTree = "<group>"; };
9FA173D92B79BD8A00EE4E6E /* BookmarkDialogContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkDialogContainerView.swift; sourceTree = "<group>"; };
9FA173DE2B7A0EFE00EE4E6E /* BookmarkDialogButtonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkDialogButtonsView.swift; sourceTree = "<group>"; };
9FA173E22B7A12B600EE4E6E /* BookmarkDialogFolderManagementView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkDialogFolderManagementView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5439,6 +5442,7 @@
566B195F29CDB7A9007E38F4 /* Mocks */,
378205FA283C277800D1D4AA /* MainMenuTests.swift */,
566B195C29CDB692007E38F4 /* MoreOptionsMenuTests.swift */,
9F9C49F52BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift */,
);
path = Menus;
sourceTree = "<group>";
Expand Down Expand Up @@ -11206,6 +11210,7 @@
566B196429CDB824007E38F4 /* MoreOptionsMenuTests.swift in Sources */,
9F0A2CF92B96A58600C5B8C0 /* BaseBookmarkEntityTests.swift in Sources */,
3706FE56293F661700E42796 /* FaviconManagerMock.swift in Sources */,
9F9C49F72BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift in Sources */,
3706FE57293F661700E42796 /* LocalPinningManagerTests.swift in Sources */,
3706FE58293F661700E42796 /* HistoryStoreTests.swift in Sources */,
3706FE59293F661700E42796 /* EncryptionKeyGeneratorTests.swift in Sources */,
Expand Down Expand Up @@ -13185,6 +13190,7 @@
85AC3B4925DAC9BD00C7D2AA /* ConfigurationStorageTests.swift in Sources */,
9F180D122B69C665000D695F /* DownloadsTabExtensionMock.swift in Sources */,
AA91F83927076F1900771A0D /* PrivacyIconViewModelTests.swift in Sources */,
9F9C49F62BC786790099738D /* MoreOptionsMenu+BookmarksTests.swift in Sources */,
4B723E0726B0003E00E14D75 /* CSVImporterTests.swift in Sources */,
4BCF15EC2ABB9AF80083F6DF /* NetworkProtectionRemoteMessageTests.swift in Sources */,
B62EB47C25BAD3BB005745C6 /* WKWebViewPrivateMethodsAvailabilityTests.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ struct UserText {
static let editFavorite = NSLocalizedString("edit.favorite", value: "Edit Favorite", comment: "Header of the view that edits a favorite bookmark")
static let removeFromFavorites = NSLocalizedString("remove.from.favorites", value: "Remove from Favorites", comment: "Button for removing bookmarks from favorites")
static let bookmarkThisPage = NSLocalizedString("bookmark.this.page", value: "Bookmark This Page", comment: "Menu item for bookmarking current page")
static let bookmarkAllTabs = NSLocalizedString("bookmark.all.tabs", value: "Bookmark All Tabs…", comment: "Menu item for bookmarking all the open tabs")
static let bookmarksShowToolbarPanel = NSLocalizedString("bookmarks.show-toolbar-panel", value: "Open Bookmarks Panel", comment: "Menu item for opening the bookmarks panel")
static let bookmarksManageBookmarks = NSLocalizedString("bookmarks.manage-bookmarks", value: "Manage Bookmarks", comment: "Menu item for opening the bookmarks management interface")
static let bookmarkImportedFromFolder = NSLocalizedString("bookmarks.imported.from.folder", value: "Imported from", comment: "Name of the folder the imported bookmarks are saved into")
Expand Down
12 changes: 12 additions & 0 deletions DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -7429,6 +7429,18 @@
}
}
},
"bookmark.all.tabs" : {
"comment" : "Menu item for bookmarking all the open tabs",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Bookmark All Tabs…"
}
}
}
},
"bookmark.dialog.add" : {
"comment" : "Button to confim a bookmark creation",
"extractionState" : "extracted_with_value",
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ import SubscriptionUI
func buildBookmarksMenu() -> NSMenuItem {
NSMenuItem(title: UserText.bookmarks).submenu(bookmarksMenu.buildItems {
NSMenuItem(title: UserText.bookmarkThisPage, action: #selector(MainViewController.bookmarkThisPage), keyEquivalent: "d")
NSMenuItem(title: UserText.bookmarkAllTabs, action: #selector(MainViewController.bookmarkAllOpenTabs), keyEquivalent: [.command, .shift, "d"])
manageBookmarksMenuItem
bookmarksMenuToggleBookmarksBarMenuItem
NSMenuItem.separator()
Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ extension MainViewController {
.openBookmarkPopover(setFavorite: false, accessPoint: .init(sender: sender, default: .moreMenu))
}

@objc func bookmarkAllOpenTabs(_ sender: Any) {
// TODO: https://app.asana.com/0/0/1207032400501907/f
print(#function)
}

@objc func favoriteThisPage(_ sender: Any) {
guard let tabIndex = getActiveTabAndIndex()?.index else { return }
if tabCollectionViewModel.selectedTabIndex != tabIndex {
Expand Down Expand Up @@ -947,6 +952,8 @@ extension MainViewController: NSMenuItemValidation {
case #selector(MainViewController.bookmarkThisPage(_:)),
#selector(MainViewController.favoriteThisPage(_:)):
return activeTabViewModel?.canBeBookmarked == true
case #selector(MainViewController.bookmarkAllOpenTabs(_:)):
return tabCollectionViewModel.canBookmarkAllOpenTabs()
case #selector(MainViewController.openBookmark(_:)),
#selector(MainViewController.showManageBookmarks(_:)):
return true
Expand Down
11 changes: 11 additions & 0 deletions DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Subscription
protocol OptionsButtonMenuDelegate: AnyObject {

func optionsButtonMenuRequestedBookmarkThisPage(_ sender: NSMenuItem)
func optionsButtonMenuRequestedBookmarkAllOpenTabs(_ sender: NSMenuItem)
func optionsButtonMenuRequestedBookmarkPopover(_ menu: NSMenu)
func optionsButtonMenuRequestedBookmarkManagementInterface(_ menu: NSMenu)
func optionsButtonMenuRequestedBookmarkImportInterface(_ menu: NSMenu)
Expand Down Expand Up @@ -174,6 +175,10 @@ final class MoreOptionsMenu: NSMenu {
actionDelegate?.optionsButtonMenuRequestedBookmarkThisPage(sender)
}

@objc func bookmarkAllOpenTabs(_ sender: NSMenuItem) {
actionDelegate?.optionsButtonMenuRequestedBookmarkAllOpenTabs(sender)
}

@objc func openBookmarks(_ sender: NSMenuItem) {
actionDelegate?.optionsButtonMenuRequestedBookmarkPopover(self)
}
Expand Down Expand Up @@ -644,6 +649,12 @@ final class BookmarksSubMenu: NSMenu {

bookmarkPageItem.isEnabled = tabCollectionViewModel.selectedTabViewModel?.canBeBookmarked == true

let bookmarkAllTabsItem = addItem(withTitle: UserText.bookmarkAllTabs, action: #selector(MoreOptionsMenu.bookmarkAllOpenTabs(_:)), keyEquivalent: "d")
.withModifierMask([.command, .shift])
.targetting(target)

bookmarkAllTabsItem.isEnabled = tabCollectionViewModel.canBookmarkAllOpenTabs()

addItem(NSMenuItem.separator())

addItem(withTitle: UserText.bookmarksShowToolbarPanel, action: #selector(MoreOptionsMenu.openBookmarks(_:)), keyEquivalent: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,11 @@ extension NavigationBarViewController: OptionsButtonMenuDelegate {
.openBookmarkPopover(setFavorite: false, accessPoint: .init(sender: sender, default: .moreMenu))
}

func optionsButtonMenuRequestedBookmarkAllOpenTabs(_ sender: NSMenuItem) {
// TODO: https://app.asana.com/0/0/1207032400501907/f
print(#function)
}

func optionsButtonMenuRequestedBookmarkPopover(_ menu: NSMenu) {
popovers.showBookmarkListPopover(usingView: bookmarkListButton,
withDelegate: self,
Expand Down
9 changes: 9 additions & 0 deletions DuckDuckGo/TabBar/View/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,15 @@ extension TabBarViewController: TabBarViewItemDelegate {
bookmarkTab(with: url, title: tabViewModel.title)
}

func tabBarViewAllItemsCanBeBookmarked(_ tabBarViewItem: TabBarViewItem) -> Bool {
tabCollectionViewModel.canBookmarkAllOpenTabs()
}

func tabBarViewItemBookmarkAllOpenTabsAction(_ tabBarViewItem: TabBarViewItem) {
// TODO: https://app.asana.com/0/0/1207032400501907/f
print(#function)
}

func tabBarViewItemCloseAction(_ tabBarViewItem: TabBarViewItem) {
guard let indexPath = collectionView.indexPath(for: tabBarViewItem) else {
assertionFailure("TabBarViewController: Failed to get index path of tab bar view item")
Expand Down
27 changes: 21 additions & 6 deletions DuckDuckGo/TabBar/View/TabBarViewItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protocol TabBarViewItemDelegate: AnyObject {
func tabBarViewItemCanBeDuplicated(_ tabBarViewItem: TabBarViewItem) -> Bool
func tabBarViewItemCanBePinned(_ tabBarViewItem: TabBarViewItem) -> Bool
func tabBarViewItemCanBeBookmarked(_ tabBarViewItem: TabBarViewItem) -> Bool
func tabBarViewAllItemsCanBeBookmarked(_ tabBarViewItem: TabBarViewItem) -> Bool

func tabBarViewItemCloseAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemTogglePermissionAction(_ tabBarViewItem: TabBarViewItem)
Expand All @@ -41,6 +42,7 @@ protocol TabBarViewItemDelegate: AnyObject {
func tabBarViewItemDuplicateAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemPinAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemBookmarkThisPageAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemBookmarkAllOpenTabsAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemMoveToNewWindowAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemMoveToNewBurnerWindowAction(_ tabBarViewItem: TabBarViewItem)
func tabBarViewItemFireproofSite(_ tabBarViewItem: TabBarViewItem)
Expand Down Expand Up @@ -196,6 +198,10 @@ final class TabBarViewItem: NSCollectionViewItem {
delegate?.tabBarViewItemBookmarkThisPageAction(self)
}

@objc func bookmarkAllOpenTabsAction(_ sender: Any) {
delegate?.tabBarViewItemBookmarkAllOpenTabsAction(self)
}

private var lastKnownIndexPath: IndexPath?

@IBAction func closeButtonAction(_ sender: Any) {
Expand Down Expand Up @@ -486,16 +492,19 @@ extension TabBarViewItem: NSMenuDelegate {
// Section 1
addDuplicateMenuItem(to: menu)
addPinMenuItem(to: menu)
menu.addItem(NSMenuItem.separator())
addMuteUnmuteMenuItem(to: menu)
menu.addItem(.separator())

// Section 2
addBookmarkMenuItem(to: menu)
addFireproofMenuItem(to: menu)

addMuteUnmuteMenuItem(to: menu)
menu.addItem(NSMenuItem.separator())
addBookmarkMenuItem(to: menu)
menu.addItem(.separator())

// Section 3
addBookmarkAllTabsMenuItem(to: menu)
menu.addItem(.separator())

// Section 4
addCloseMenuItem(to: menu)
addCloseOtherMenuItem(to: menu, areThereOtherTabs: areThereOtherTabs)
addCloseTabsToTheRightMenuItem(to: menu, areThereTabsToTheRight: otherItemsState.hasItemsToTheRight)
Expand Down Expand Up @@ -525,6 +534,13 @@ extension TabBarViewItem: NSMenuDelegate {
menu.addItem(bookmarkMenuItem)
}

private func addBookmarkAllTabsMenuItem(to menu: NSMenu) {
let bookmarkMenuItem = NSMenuItem(title: UserText.bookmarkAllTabs, action: #selector(bookmarkAllOpenTabsAction(_:)), keyEquivalent: "")
bookmarkMenuItem.target = self
bookmarkMenuItem.isEnabled = delegate?.tabBarViewAllItemsCanBeBookmarked(self) ?? false
menu.addItem(bookmarkMenuItem)
}

private func addFireproofMenuItem(to menu: NSMenu) {
var menuItem = NSMenuItem(title: UserText.fireproofSite, action: #selector(fireproofSiteAction(_:)), keyEquivalent: "")
menuItem.isEnabled = false
Expand All @@ -543,7 +559,6 @@ extension TabBarViewItem: NSMenuDelegate {
let audioState = delegate?.tabBarViewItemAudioState(self) ?? .notSupported

if audioState != .notSupported {
menu.addItem(NSMenuItem.separator())
let menuItemTitle = audioState == .muted ? UserText.unmuteTab : UserText.muteTab
let muteUnmuteMenuItem = NSMenuItem(title: menuItemTitle, action: #selector(muteUnmuteSiteAction(_:)), keyEquivalent: "")
muteUnmuteMenuItem.target = self
Expand Down
11 changes: 11 additions & 0 deletions DuckDuckGo/TabBar/ViewModel/TabCollectionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -762,3 +762,14 @@ extension TabCollectionViewModel {
}

}

// MARK: - Bookmark All Open Tabs

extension TabCollectionViewModel {

func canBookmarkAllOpenTabs() -> Bool {
// At least two non pinned, non empty (URL only), and not showing an error tabs.
tabViewModels.values.filter(\.canBeBookmarked).count >= 2
}

}
23 changes: 23 additions & 0 deletions UnitTests/Menus/MainMenuTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import XCTest
import Combine
import BrowserServicesKit
@testable import DuckDuckGo_Privacy_Browser

class MainMenuTests: XCTestCase {
Expand Down Expand Up @@ -87,4 +88,26 @@ class MainMenuTests: XCTestCase {
XCTAssertEqual(manager.reopenLastClosedMenuItem?.keyEquivalent, ReopenMenuItemKeyEquivalentManager.Const.keyEquivalent)
XCTAssertEqual(manager.reopenLastClosedMenuItem?.keyEquivalentModifierMask, ReopenMenuItemKeyEquivalentManager.Const.modifierMask)
}

// MARK: - Bookmarks

@MainActor
func testWhenBookmarksMenuIsInitialized_ThenSecondItemIsBookmarkAllTabs() throws {
// GIVEN
let sut = MainMenu(featureFlagger: DummyFeatureFlagger(), bookmarkManager: MockBookmarkManager(), faviconManager: FaviconManagerMock(), copyHandler: CopyHandler())
let bookmarksMenu = try XCTUnwrap(sut.item(withTitle: UserText.bookmarks))

// WHEN
let result = try XCTUnwrap(bookmarksMenu.submenu?.item(withTitle: UserText.bookmarkAllTabs))

// THEN
XCTAssertEqual(result.keyEquivalent, "d")
XCTAssertEqual(result.keyEquivalentModifierMask, [.command, .shift])
}
}

private class DummyFeatureFlagger: FeatureFlagger {
func isFeatureOn<F: BrowserServicesKit.FeatureFlagSourceProviding>(forProvider: F) -> Bool {
false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CapturingOptionsButtonMenuDelegate: OptionsButtonMenuDelegate {

var optionsButtonMenuRequestedPreferencesCalled = false
var optionsButtonMenuRequestedAppearancePreferencesCalled = false
var optionsButtonMenuRequestedBookmarkAllOpenTabsCalled = false

func optionsButtonMenuRequestedDataBrokerProtection(_ menu: NSMenu) {

Expand All @@ -36,6 +37,10 @@ class CapturingOptionsButtonMenuDelegate: OptionsButtonMenuDelegate {

}

func optionsButtonMenuRequestedBookmarkAllOpenTabs(_ sender: NSMenuItem) {
optionsButtonMenuRequestedBookmarkAllOpenTabsCalled = true
}

func optionsButtonMenuRequestedBookmarkPopover(_ menu: NSMenu) {

}
Expand Down
61 changes: 61 additions & 0 deletions UnitTests/Menus/MoreOptionsMenu+BookmarksTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// MoreOptionsMenu+BookmarksTests.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import XCTest
@testable import DuckDuckGo_Privacy_Browser

@MainActor
final class MoreOptionsMenu_BookmarksTests: XCTestCase {

func testWhenBookmarkSubmenuIsInitThenBookmarkAllTabsKeyIsCmdShiftD() throws {
// GIVEN
let sut = BookmarksSubMenu(targetting: self, tabCollectionViewModel: .init())

// WHEN
let result = try XCTUnwrap(sut.item(withTitle: UserText.bookmarkAllTabs))

// THEN
XCTAssertEqual(result.keyEquivalent, "d")
XCTAssertEqual(result.keyEquivalentModifierMask, [.command, .shift])
}

func testWhenTabCollectionCanBookmarkAllTabsThenBookmarkAllTabsMenuItemIsEnabled() throws {
// GIVEN
let tab1 = Tab(content: .url(.duckDuckGo, credential: nil, source: .ui))
let tab2 = Tab(content: .url(.duckDuckGoEmail, credential: nil, source: .ui))
let sut = BookmarksSubMenu(targetting: self, tabCollectionViewModel: .init(tabCollection: .init(tabs: [tab1, tab2])))

// WHEN
let result = try XCTUnwrap(sut.item(withTitle: UserText.bookmarkAllTabs))

// THEN
XCTAssertTrue(result.isEnabled)
}

func testWhenTabCollectionCannotBookmarkAllTabsThenBookmarkAllTabsMenuItemIsDisabled() throws {
// GIVEN
let sut = BookmarksSubMenu(targetting: self, tabCollectionViewModel: .init(tabCollection: .init(tabs: [])))

// WHEN
let result = try XCTUnwrap(sut.item(withTitle: UserText.bookmarkAllTabs))

// THEN
XCTAssertFalse(result.isEnabled)
}

}
17 changes: 17 additions & 0 deletions UnitTests/Menus/MoreOptionsMenuTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ final class MoreOptionsMenuTests: XCTestCase {
XCTAssertTrue(capturingActionDelegate.optionsButtonMenuRequestedPreferencesCalled)
}

// MARK: - Bookmarks

@MainActor
func testWhenClickingOnBookmarkAllTabsMenuItemThenTheActionDelegateIsAlerted() throws {
// GIVEN
let bookmarksMenu = try XCTUnwrap(moreOptionMenu.item(at: 8)?.submenu)
let bookmarkAllTabsIndex = try XCTUnwrap(bookmarksMenu.indexOfItem(withTitle: UserText.bookmarkAllTabs))
let bookmarkAllTabsMenuItem = try XCTUnwrap(bookmarksMenu.items[bookmarkAllTabsIndex])
bookmarkAllTabsMenuItem.isEnabled = true

// WHEN
bookmarksMenu.performActionForItem(at: bookmarkAllTabsIndex)

// THEN
XCTAssertTrue(capturingActionDelegate.optionsButtonMenuRequestedBookmarkAllOpenTabsCalled)
}

}

final class NetworkProtectionVisibilityMock: NetworkProtectionFeatureVisibility {
Expand Down
Loading

0 comments on commit dd83ac7

Please sign in to comment.