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

Refactor MTE-3854 Integrate menu refactor work and xcode 16 #23381

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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()",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test fails with the menu refactor turned on. 😞

"TestFavicons\/testFaviconFetcherParse()",
"VersionSettingTests",
"VersionSettingTests\/testCopyAppVersion()"
Expand Down
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
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 @@ -451,7 +451,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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LoginTest: BaseTestCase {
private func openLoginsSettingsFromBrowserTab() {
waitForExistence(app.buttons["TabToolbar.menuButton"])
navigator.goto(BrowserTabMenu)
waitForExistence(app.tables.otherElements[StandardImageIdentifiers.Large.login])
waitForExistence(app.buttons[AccessibilityIdentifiers.MainMenu.HeaderView.mainButton])
navigator.goto(LoginsSettings)

unlockLoginsView()
Expand Down Expand Up @@ -201,8 +201,7 @@ class LoginTest: BaseTestCase {
app.menuItems["Select All"].tap()
app.menuItems["Cut"].waitAndTap()
enterTextInField(typedText: "foo")
waitForExistence(app.buttons["Done"])
app.buttons["Done"].tap()
app.buttons["Done"].waitAndTap()
// The username is correctly changed
mozWaitForElementToExist(app.tables["Login Detail List"])
mozWaitForElementToExist(app.tables.cells[loginsListURLLabel])
Expand Down
Loading