Skip to content

Commit

Permalink
Add MTE-4138 - long press share actions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 committed Jan 21, 2025
1 parent db33295 commit a87ee6b
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class BaseTestCase: XCTestCase {
if #available(iOS 17, *) {
app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField].press(forDuration: 1.5)
} else {
navigator.performAction(Action.CloseURLBarOpen)
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].waitAndTap()
app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField].press(forDuration: 2)
}
mozWaitForElementToExist(app.tables["Context Menu"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,176 @@ class ShareLongPressTests: BaseTestCase {
openNewTabAndValidateURLisPaste(url: "https://www")
}

// https://mozilla.testrail.io/index.php?/cases/view/2864380
func testBookmarksShareNormalWebsiteReminders() {
if #available(iOS 17, *) {
longPressBookmarkAndReachShareOptions(option: "Reminders")
// The URL of the website is added in a new reminder
waitForElementsToExist(
[
app.navigationBars["Reminders"],
app.links.elementContainingText(url_1)
]
)
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864387
func testBookmarksShareNormalWebsiteSendLinkDevice() {
longPressBookmarkAndReachShareOptions(option: "Send Link to Device")
// If not signed in, the browser prompts you to sign in
waitForElementsToExist(
[
app.staticTexts[sendLinkMsg1],
app.staticTexts[sendLinkMsg2]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864386
func testBookmarksShareNormalWebsiteCopyURL() {
longPressBookmarkAndReachShareOptions(option: "Copy")
app.buttons["Done"].waitAndTap()
openNewTabAndValidateURLisPaste(url: url_1)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864396
func testHistoryShareNormalWebsiteReminders() {
if #available(iOS 17, *) {
longPressHistoryAndReachShareOptions(option: "Reminders")
// The URL of the website is added in a new reminder
waitForElementsToExist(
[
app.navigationBars["Reminders"],
app.links.elementContainingText("https://www.mozilla.org/")
]
)
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864403
func testHistoryShareNormalWebsiteSendLinkDevice() {
longPressHistoryAndReachShareOptions(option: "Send Link to Device")
// If not signed in, the browser prompts you to sign in
waitForElementsToExist(
[
app.staticTexts[sendLinkMsg1],
app.staticTexts[sendLinkMsg2]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864402
func testHistoryShareNormalWebsiteCopyURL() {
longPressHistoryAndReachShareOptions(option: "Copy")
app.buttons["Done"].waitAndTap()
openNewTabAndValidateURLisPaste(url: "https://www.mozilla.org/")
}

// https://mozilla.testrail.io/index.php?/cases/view/2864412
func testReaderModeShareNormalWebsiteReminders() {
if #available(iOS 17, *) {
longPressReadingListAndReachShareOptions(option: "Reminders")
// The URL of the website is added in a new reminder
waitForElementsToExist(
[
app.navigationBars["Reminders"],
app.links.elementContainingText("test-mozilla-book.html")
]
)
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864419
func testReaderModeShareNormalWebsiteSendLinkDevice() {
longPressReadingListAndReachShareOptions(option: "Send Link to Device")
// If not signed in, the browser prompts you to sign in
waitForElementsToExist(
[
app.staticTexts[sendLinkMsg1],
app.staticTexts[sendLinkMsg2]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864418
func testReaderModeShareNormalWebsiteCopy() {
longPressReadingListAndReachShareOptions(option: "Copy")
app.buttons["Done"].waitAndTap()
openNewTabAndValidateURLisPaste(url: "test-mozilla-book.html")
}

private func longPressReadingListAndReachShareOptions(option: String) {
navigator.openURL(path(forTestPage: "test-mozilla-book.html"))
waitUntilPageLoad()
navigator.nowAt(BrowserTab)
mozWaitForElementToNotExist(app.staticTexts["Fennec pasted from XCUITests-Runner"])
app.buttons["Reader View"].waitAndTap()
waitUntilPageLoad()
app.buttons["Add to Reading List"].waitAndTap()
navigator.goto(LibraryPanel_ReadingList)
// Long-press on a website
app.tables.cells.staticTexts.firstMatch.press(forDuration: 1.0)
// Tap the Share button in the context menu
app.tables["Context Menu"].cells.otherElements["shareLarge"].waitAndTap()
// Tap the Reminders button in the menu
if #available(iOS 16, *) {
app.collectionViews.cells[option].waitAndTap()
} else {
app.buttons[option].waitAndTap()
}
}

private func longPressHistoryAndReachShareOptions(option: String) {
// Go to a webpage and navigate to history
navigator.nowAt(NewTabScreen)
navigator.openURL("mozilla.org")
waitForTabsButton()
navigator.goto(HistoryRecentlyClosed)
// Long-press on a website
app.tables.cells.staticTexts.element(boundBy: 1).press(forDuration: 1.0)
// Tap the Share button in the context menu
app.tables["Context Menu"].cells.otherElements["shareLarge"].waitAndTap()
// Tap the Reminders button in the menu
if #available(iOS 16, *) {
app.collectionViews.cells[option].waitAndTap()
} else {
app.buttons[option].waitAndTap()
}
}

private func longPressBookmarkAndReachShareOptions(option: String) {
// Go to a webpage, and add to bookmarks
navigator.nowAt(NewTabScreen)
navigator.openURL(path(forTestPage: url_1))
navigator.nowAt(BrowserTab)
waitForTabsButton()
bookmark()
waitForTabsButton()
navigator.goto(LibraryPanel_Bookmarks)
// Long-press on a bookmarked website
app.tables.cells.staticTexts["Example Domain"].press(forDuration: 1.0)
// Tap the Share button in the context menu
app.tables["Context Menu"].cells.otherElements["shareLarge"].waitAndTap()
// Tap the Reminders button in the menu
if #available(iOS 16, *) {
app.collectionViews.cells[option].waitAndTap()
} else {
app.buttons[option].waitAndTap()
}
}

private func longPressPocketAndReachShareOptions(option: String) {
navigator.goto(NewTabScreen)
// Long tap on the first Pocket element
app.collectionViews
.cells.matching(identifier: AccessibilityIdentifiers.FirefoxHomepage.Pocket.itemCell)
.staticTexts.firstMatch.press(forDuration: 1.5)
app.tables["Context Menu"].cells.otherElements["shareLarge"].waitAndTap()
app.collectionViews.cells[option].waitAndTap()
if #available(iOS 16, *) {
app.collectionViews.cells[option].waitAndTap()
} else {
app.buttons[option].waitAndTap()
}
}
}
66 changes: 48 additions & 18 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareMenuTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ class ShareMenuTests: BaseTestCase {
waitForElementsToExist(
[
app.staticTexts["Printer"],
app.staticTexts["Copies"],
app.staticTexts["Paper Size"],
app.staticTexts["Letter"],
app.staticTexts["Orientation"],
app.staticTexts["Layout"]
app.staticTexts["Orientation"]
]
)
if #available(iOS 16, *) {
mozWaitForElementToExist(app.staticTexts["Layout"])
}
if #available(iOS 17, *) {
mozWaitForElementToExist(app.staticTexts["Options"])
} else {
mozWaitForElementToExist(app.staticTexts["Print Options"])
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864047
Expand All @@ -55,12 +60,18 @@ class ShareMenuTests: BaseTestCase {
waitForElementsToExist(
[
app.buttons["Undo"],
app.buttons["Redo"],
app.buttons["autofill"],
app.buttons["Done"],
app.buttons["Color picker"]
app.buttons["Redo"]
]
)
if #available(iOS 17, *) {
mozWaitForElementToExist(app.buttons["PKPalette-Multicolor-Swatch"])
}
if #available(iOS 16, *) {
mozWaitForElementToExist(app.buttons["autofill"])
mozWaitForElementToExist(app.buttons["Done"])
} else {
mozWaitForElementToExist(app.buttons["Colour picker"])
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864046
Expand Down Expand Up @@ -90,13 +101,18 @@ class ShareMenuTests: BaseTestCase {
waitForElementsToExist(
[
app.staticTexts["Printer"],
app.staticTexts["Copies"],
app.staticTexts["Paper Size"],
app.staticTexts["Letter"],
app.staticTexts["Orientation"],
app.staticTexts["Layout"]
app.staticTexts["Orientation"]
]
)
if #available(iOS 16, *) {
mozWaitForElementToExist(app.staticTexts["Layout"])
}
if #available(iOS 17, *) {
mozWaitForElementToExist(app.staticTexts["Options"])
} else {
mozWaitForElementToExist(app.staticTexts["Print Options"])
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864079
Expand Down Expand Up @@ -124,12 +140,18 @@ class ShareMenuTests: BaseTestCase {
waitForElementsToExist(
[
app.buttons["Undo"],
app.buttons["Redo"],
app.buttons["autofill"],
app.buttons["Done"],
app.buttons["Color picker"]
app.buttons["Redo"]
]
)
if #available(iOS 17, *) {
mozWaitForElementToExist(app.buttons["PKPalette-Multicolor-Swatch"])
}
if #available(iOS 16, *) {
mozWaitForElementToExist(app.buttons["autofill"])
mozWaitForElementToExist(app.buttons["Done"])
} else {
mozWaitForElementToExist(app.buttons["Colour picker"])
}
}

private func reachReaderModeShareMenuLayoutAndSelectOption(option: String) {
Expand All @@ -141,7 +163,11 @@ class ShareMenuTests: BaseTestCase {
navigator.goto(ToolsBrowserTabMenu)
// Tap the Share button in the menu
navigator.performAction(Action.ShareBrowserTabMenuOption)
app.collectionViews.cells[option].waitAndTap()
if #available(iOS 16, *) {
app.collectionViews.cells[option].waitAndTap()
} else {
app.buttons[option].waitAndTap()
}
}

private func reachShareMenuLayoutAndSelectOption(option: String) {
Expand All @@ -151,6 +177,10 @@ class ShareMenuTests: BaseTestCase {
navigator.goto(ToolsBrowserTabMenu)
// Tap the Share button in the menu
navigator.performAction(Action.ShareBrowserTabMenuOption)
app.collectionViews.cells[option].waitAndTap()
if #available(iOS 16, *) {
app.collectionViews.cells[option].waitAndTap()
} else {
app.buttons[option].waitAndTap()
}
}
}
Loading

0 comments on commit a87ee6b

Please sign in to comment.