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 MTE-4138 - long press share actions tests #24242

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -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"])
Original file line number Diff line number Diff line change
@@ -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, *) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, feel free to run the tests only on more recent versions of iOS.

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()
}
}
}
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
@@ -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) {
@@ -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) {
@@ -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