Skip to content

Commit

Permalink
Refactor MTE-3854 Integrate menu refactor work and xcode 16 (#23381)
Browse files Browse the repository at this point in the history
* Integrate menu refactor work and xcode 16

* Disable testTelemetryForSiteMenu for now

* No more "Copy Link" from the browser tab menu (known as Action.CopyAddressPAM in the screen graph)

* Document what's working on new BrowserTabMenu and what's not

* Fix some XCUITEsts with menu redisign experiment On

* Fix linter issue

* Fix SyncFAUITests XCUITest

* Fix SearchTest and SettingsTests

* Fix linter issues on  SettingsTests

* Fix Whats new XCUI Test

* Fixed Report Site XCUITests

* Fix Find in page and shortcut tests

* Renamed private tab selector

* Fix night mode tests

* Removed commented lines

* Fix Login test

* Revert indentation change

---------

Co-authored-by: mbarone <[email protected]>
  • Loading branch information
clarmso and mdotb-moz authored Dec 2, 2024
1 parent f5130b0 commit c8680a6
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 161 deletions.
1 change: 1 addition & 0 deletions firefox-ios/firefox-ios-tests/Tests/UnitTest.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"ShortcutRouteTests\/testOpenLastBookmarkShortcutWithInvalidUrl()",
"TabManagerTests\/testDeleteSelectedTab()",
"TabManagerTests\/testPrivatePreference_togglePBMDeletesPrivate()",
"TabToolbarHelperTests\/testTelemetryForSiteMenu()",
"TestFavicons\/testFaviconFetcherParse()",
"VersionSettingTests",
"VersionSettingTests\/testCopyAppVersion()"
Expand Down
12 changes: 4 additions & 8 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,13 @@ class BaseTestCase: XCTestCase {
timeout: TIMEOUT
)
navigator.goto(BrowserTabMenu)
mozWaitForElementToExist(
app.tables.otherElements[StandardImageIdentifiers.Large.bookmark],
timeout: TIMEOUT_LONG
)
app.tables.otherElements[StandardImageIdentifiers.Large.bookmark].tap()
navigator.nowAt(BrowserTab)
navigator.goto(SaveBrowserTabMenu)
navigator.performAction(Action.Bookmark)
}

func unbookmark() {
navigator.goto(BrowserTabMenu)
app.otherElements[StandardImageIdentifiers.Large.bookmarkSlash].waitAndTap()
bookmark()
app.buttons["Delete Bookmark"].waitAndTap()
navigator.nowAt(BrowserTab)
}

Expand Down
35 changes: 14 additions & 21 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/BookmarksTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,23 @@ let url_3 = "localhost:\(serverPort)/test-fixture/test-example.html"

class BookmarksTests: BaseTestCase {
private func checkBookmarked() {
navigator.goto(BrowserTabMenu)
mozWaitForElementToExist(app.tables.otherElements[StandardImageIdentifiers.Large.bookmarkSlash])
if iPad() {
app.otherElements["PopoverDismissRegion"].tap()
navigator.nowAt(BrowserTab)
} else {
navigator.goto(BrowserTab)
}
navigator.goto(LibraryPanel_Bookmarks)
app.buttons["Done"].waitAndTap()
navigator.nowAt(BrowserTab)
}

private func undoBookmarkRemoval() {
navigator.goto(BrowserTabMenu)
app.otherElements[StandardImageIdentifiers.Large.bookmarkSlash].waitAndTap()
navigator.nowAt(BrowserTab)
navigator.goto(SaveBrowserTabMenu)
app.tables.cells[AccessibilityIdentifiers.MainMenu.bookmarkThisPage].waitAndTap()
app.staticTexts["Delete Bookmark"].waitAndTap()
app.buttons["Undo"].waitAndTap()
navigator.nowAt(BrowserTab)
}

private func checkUnbookmarked() {
navigator.goto(BrowserTabMenu)
mozWaitForElementToExist(app.tables.otherElements[StandardImageIdentifiers.Large.bookmark])
if iPad() {
app.otherElements["PopoverDismissRegion"].tap()
navigator.nowAt(BrowserTab)
} else {
navigator.goto(BrowserTab)
}
navigator.goto(LibraryPanel_Bookmarks)
app.buttons["Done"].waitAndTap()
navigator.nowAt(BrowserTab)
}

// https://mozilla.testrail.io/index.php?/cases/view/2306905
Expand Down Expand Up @@ -354,9 +345,11 @@ class BookmarksTests: BaseTestCase {
bookmarkPageAndTapEdit()
app.buttons["crossLarge"].tap()
waitForTabsButton()
navigator.nowAt(BrowserTab)
unbookmark()
bookmarkPageAndTapEdit()
app.buttons["Save"].tap()
navigator.nowAt(BrowserTab)
navigator.goto(LibraryPanel_Bookmarks)
checkItemInBookmarkList(oneItemBookmarked: true)
}
Expand Down Expand Up @@ -394,8 +387,8 @@ class BookmarksTests: BaseTestCase {
}

private func bookmarkPageAndTapEdit() {
bookmark()
app.buttons["Edit"].waitAndTap()
bookmark() // Bookmark the page
bookmark() // Open the "Edit Bookmark" page
mozWaitForElementToExist(app.navigationBars["Edit Bookmark"])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class ClipBoardTests: BaseTestCase {
// Tap on "Copy Link
navigator.openURL(url_3)
waitForTabsButton()
// Menu Refactor: No "Copy Link" from browser tab menu
/*
navigator.performAction(Action.CopyAddressPAM)
// The Link is copied to clipboard
mozWaitForElementToExist(app.staticTexts["URL Copied To Clipboard"])
Expand All @@ -86,6 +88,7 @@ class ClipBoardTests: BaseTestCase {
mozWaitForElementToExist(urlBar)
waitForValueContains(urlBar, value: "localhost")
mozWaitForElementToExist(app.staticTexts["Example Domain"])
*/
}

// https://mozilla.testrail.io/index.php?/cases/view/2325691
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ class DesktopModeTestsIphone: IphoneOnlyTestCase {
XCTAssert(app.webViews.staticTexts.matching(identifier: "MOBILE_UA").count > 0)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton])
navigator.goto(BrowserTabMenu)
mozWaitForElementToExist(app.tables["Context Menu"].otherElements[StandardImageIdentifiers.Large.deviceDesktop])
mozWaitForElementToExist(app.tables.cells[AccessibilityIdentifiers.MainMenu.switchToDesktopSite])
navigator.goto(RequestDesktopSite)
waitUntilPageLoad()
XCTAssert(app.webViews.staticTexts.matching(identifier: "DESKTOP_UA").count > 0)

navigator.nowAt(BrowserTab)
navigator.goto(BrowserTabMenu)
mozWaitForElementToExist(app.tables["Context Menu"].otherElements[StandardImageIdentifiers.Large.deviceMobile])
mozWaitForElementToExist(app.tables.cells.staticTexts["Switch to Mobile Site"])
// Select Mobile site here, the identifier is the same but the Text is not
navigator.goto(RequestMobileSite)
waitUntilPageLoad()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FindInPageTests: BaseTestCase {

mozWaitForElementToNotExist(app.staticTexts["Fennec pasted from XCUITests-Runner"])
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].waitAndTap()
app.tables["Context Menu"].otherElements[StandardImageIdentifiers.Large.search].waitAndTap()
app.otherElements.images[StandardImageIdentifiers.Large.search].waitAndTap()

// Enter some text to start finding
if #available(iOS 16, *) {
Expand Down Expand Up @@ -125,7 +125,7 @@ class FindInPageTests: BaseTestCase {
navigator.nowAt(BrowserTab)
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].waitAndTap()
// Enter some text to start finding
app.tables["Context Menu"].otherElements[StandardImageIdentifiers.Large.search].tap()
app.otherElements.images[StandardImageIdentifiers.Large.search].tap()
if #available(iOS 16, *) {
app.searchFields["find.searchField"].typeText("The Book of")
mozWaitForElementToExist(app.searchFields["The Book of"])
Expand Down
153 changes: 78 additions & 75 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/FxScreenGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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/

// swiftlint:disable all

import Common
import Foundation
import MappaMundi
Expand Down Expand Up @@ -59,6 +61,8 @@ let CreditCardsSettings = "AutofillCreditCard"
let PageZoom = "PageZoom"
let NotificationsSettings = "NotificationsSetting"
let AddressesSettings = "AutofillAddress"
let ToolsBrowserTabMenu = "ToolsBrowserTabMenu"
let SaveBrowserTabMenu = "SaveBrowserTabMenu"

// These are in the exact order they appear in the settings
// screen. XCUIApplication loses them on small screens.
Expand Down Expand Up @@ -571,6 +575,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.gesture(forAction: Action.CloseDownloadsPanel, transitionTo: HomePanelsScreen) { userState in
app.buttons["Done"].tap()
}
screenState.tap(app.buttons["readingListLarge"], to: LibraryPanel_ReadingList)
}

map.addScreenState(HistoryRecentlyClosed) { screenState in
Expand Down Expand Up @@ -1086,108 +1091,104 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.backAction = navigationControllerBackAction
}

map.addScreenState(BrowserTabMenu) { screenState in
sleep(1)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.settings],
to: SettingsScreen
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.sync],
to: Intro_FxASignin,
if: "fxaUsername == nil"
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.login],
to: LoginsSettings
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.bookmarkTrayFill],
to: LibraryPanel_Bookmarks
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.history],
to: LibraryPanel_History
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.download],
to: LibraryPanel_Downloads
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.readingList],
to: LibraryPanel_ReadingList
)
map.addScreenState(ToolsBrowserTabMenu) { screenState in
// Zoom
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.avatarCircle],
to: FxAccountManagementPage
)

app.tables.cells[AccessibilityIdentifiers.MainMenu.zoom],
to: PageZoom)
// Turn on night mode
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.nightMode],
app.otherElements.images[StandardImageIdentifiers.Large.nightMode],
forAction: Action.ToggleNightMode,
transitionTo: BrowserTabMenu
transitionTo: BrowserTab
) { userState in
userState.nightMode = !userState.nightMode
}

screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.whatsNew],
forAction: Action.OpenWhatsNewPage
) { userState in
}
// Report broken site (TODO)
// Share
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.deviceDesktopSend],
forAction: Action.SentToDevice
) { userState in
}

screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.share],
app.tables.cells[AccessibilityIdentifiers.MainMenu.share],
forAction: Action.ShareBrowserTabMenuOption
) { userState in
}

screenState.dismissOnUse = true
screenState.backAction = cancelBackAction
}

map.addScreenState(SaveBrowserTabMenu) { screenState in
// Bookmark this page
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.deviceDesktop],
to: RequestDesktopSite
app.tables.cells[AccessibilityIdentifiers.MainMenu.bookmarkThisPage],
forAction: Action.BookmarkThreeDots
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.deviceMobile],
to: RequestMobileSite
app.tables.cells[AccessibilityIdentifiers.MainMenu.bookmarkThisPage],
forAction: Action.Bookmark
)
// Add to shortcuts
// No Copy link available (Action.CopyAddressPAM)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.search],
to: FindInPage
app.tables.cells[AccessibilityIdentifiers.MainMenu.addToShortcuts],
forAction: Action.PinToTopSitesPAM
)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.pageZoom],
to: PageZoom
app.tables.cells[AccessibilityIdentifiers.MainMenu.saveToReadingList],
forAction: Action.AddToReadingListBrowserTabMenu
)
// TODO: Add new state
// screenState.tap(
// app.tables["Context Menu"].otherElements[StandardImageIdentifiers.Large.lightbulb],
// to: ReportSiteIssue
// )

screenState.dismissOnUse = true
screenState.backAction = navigationControllerBackAction
}

map.addScreenState(BrowserTabMenu) { screenState in
sleep(1)

// Sign In (if unauthenticated)
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.pin],
forAction: Action.PinToTopSitesPAM
)
app.buttons[AccessibilityIdentifiers.MainMenu.HeaderView.mainButton],
to: Intro_FxASignin,
if: "fxaUsername == nil")
// Signed in (TODO)
// New tab
screenState.tap(app.tables.cells[AccessibilityIdentifiers.MainMenu.newTab], to: NewTabScreen)
// New private tab (TODO: Action.OpenPrivateTabLongPressTabsButton
// Switch to Desktop/Mobile Site
// The cell's identifier is the same for desktop and mobile, so I use static
// texts for the RequestMobileSite case
screenState.tap(app.tables.cells[AccessibilityIdentifiers.MainMenu.switchToDesktopSite], to: RequestDesktopSite)
screenState.tap(app.tables.cells.staticTexts["Switch to Mobile Site"], to: RequestMobileSite)
// Find in Page...
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.link],
forAction: Action.CopyAddressPAM
)

app.tables.cells[AccessibilityIdentifiers.MainMenu.findInPage],
to: FindInPage)
// Tools (Zoom, NightMode, Report, Share)
screenState.tap(app.tables.cells[AccessibilityIdentifiers.MainMenu.tools], to: ToolsBrowserTabMenu)
// Save (Add Bookmark, Shortcut)
screenState.tap(app.tables.cells[AccessibilityIdentifiers.MainMenu.save], to: SaveBrowserTabMenu)
// Bookmarks
screenState.tap(app.tables.cells[AccessibilityIdentifiers.MainMenu.bookmarks], to: LibraryPanel_Bookmarks)
// History
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.bookmark],
forAction: Action.BookmarkThreeDots,
Action.Bookmark
app.tables.cells[AccessibilityIdentifiers.MainMenu.history],
to: LibraryPanel_History)
// Downloads
screenState.tap(
app.tables.cells[AccessibilityIdentifiers.MainMenu.downloads],
to: LibraryPanel_Downloads
)
// Passwords (TODO)
// Customize Homepage (TODO)
// New in Firefox
screenState.tap(
app.tables.otherElements[StandardImageIdentifiers.Large.readingListAdd],
forAction: Action.AddToReadingListBrowserTabMenu
app.otherElements.cells["MainMenu.WhatsNew"],
forAction: Action.OpenWhatsNewPage
)
// Get Help (TODO: Actions to open support.mozilla.org)
// SettingsScreen
screenState.tap(app.tables.cells[AccessibilityIdentifiers.MainMenu.settings], to: SettingsScreen)

// "x" for close the menu and go back
screenState.dismissOnUse = true
screenState.backAction = cancelBackAction
}
Expand Down Expand Up @@ -1311,3 +1312,5 @@ extension XCUIElement {
}
}
}

// swiftlint:enable all
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,10 @@ class HomePageSettingsUITests: BaseTestCase {
navigator.openURL(website)
waitUntilPageLoad()
navigator.goto(BrowserTabMenu)
app.tables.otherElements[StandardImageIdentifiers.Large.pin].waitAndTap()
// Tap on Save item
app.otherElements.images[StandardImageIdentifiers.Large.save].waitAndTap()
// Tap on Add to Shortcuts
app.otherElements.images[StandardImageIdentifiers.Large.pin].waitAndTap()
navigator.nowAt(BrowserTab)
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.performAction(Action.CloseURLBarOpen)
Expand Down
Loading

0 comments on commit c8680a6

Please sign in to comment.