Skip to content

Commit

Permalink
Add MTE-4097 - tests for share from toolbar (#24147)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 authored Jan 15, 2025
1 parent 476a828 commit b37ab18
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 8 deletions.
4 changes: 4 additions & 0 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,7 @@
B12DDFED2A8DE825008CE9CF /* ToolbarMenuTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B12DDFEC2A8DE825008CE9CF /* ToolbarMenuTests.swift */; };
B15058812AA0A878008B7382 /* OpeningScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B15058802AA0A878008B7382 /* OpeningScreenTests.swift */; };
B1664E9E2B163B7A005D4C71 /* CreditCardsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1664E9D2B163B7A005D4C71 /* CreditCardsTests.swift */; };
B1B95C622D3680DB00FD1337 /* ShareToolbarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1B95C612D3680DB00FD1337 /* ShareToolbarTests.swift */; };
B1CA62822C0DB43600D31625 /* MultiWindowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1CA62812C0DB43600D31625 /* MultiWindowTests.swift */; };
B1E156A62CD5080E009DF9E5 /* AddressesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1E156A52CD5080E009DF9E5 /* AddressesTests.swift */; };
B1F90EC12BB3F6B600A4D431 /* ZoomingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1F90EC02BB3F6B600A4D431 /* ZoomingTests.swift */; };
Expand Down Expand Up @@ -8337,6 +8338,7 @@
B1864C62B7F68815AA1FE0C2 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/HistoryPanel.strings; sourceTree = "<group>"; };
B18D4F2291BA5459431EDCA9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Shared.strings"; sourceTree = "<group>"; };
B19648D5B3667FE0CB25D069 /* my */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = my; path = my.lproj/Menu.strings; sourceTree = "<group>"; };
B1B95C612D3680DB00FD1337 /* ShareToolbarTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareToolbarTests.swift; sourceTree = "<group>"; };
B1C044CA95EB3F5258D2EC51 /* bg */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bg; path = bg.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B1CA62812C0DB43600D31625 /* MultiWindowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiWindowTests.swift; sourceTree = "<group>"; };
B1D14C77AD55FE126B7904D8 /* oc */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = oc; path = oc.lproj/PrivateBrowsing.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10868,6 +10870,7 @@
B1CA62812C0DB43600D31625 /* MultiWindowTests.swift */,
78F28FBF2CB81FDF00DA862E /* InactiveTabsTest.swift */,
B126B8A92D2FFD93002F4EFC /* ShareMenuTests.swift */,
B1B95C612D3680DB00FD1337 /* ShareToolbarTests.swift */,
);
path = XCUITests;
sourceTree = "<group>";
Expand Down Expand Up @@ -16127,6 +16130,7 @@
39C261CC2018DE21009D97BD /* FxScreenGraphTests.swift in Sources */,
787EDD852943EE75002B93AE /* JumpBackInTests.swift in Sources */,
B15058812AA0A878008B7382 /* OpeningScreenTests.swift in Sources */,
B1B95C622D3680DB00FD1337 /* ShareToolbarTests.swift in Sources */,
B1F90EC12BB3F6B600A4D431 /* ZoomingTests.swift in Sources */,
8AEAD9F92C3DB0CD001A2C5A /* MicrosurveyTests.swift in Sources */,
E143BF652CE36FFD00A1D2D9 /* TabTrayTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"ScreenGraphTest",
"SearchSettingsUITests",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"ThirdPartySearchTest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"SearchTests",
"SettingsTests",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"TabCounterTests",
Expand Down
1 change: 1 addition & 0 deletions firefox-ios/firefox-ios-tests/Tests/Smoketest1.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
"SearchTests\/testSearchWithFirefoxOption()",
"SettingsTests",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"SyncUITests\/testCreateAnAccountLink()",
Expand Down
1 change: 1 addition & 0 deletions firefox-ios/firefox-ios-tests/Tests/Smoketest2.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"SettingsTests\/testOpenMailAppSettings()",
"SettingsTests\/testOpenSiriOption()",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"TabCounterTests",
Expand Down
1 change: 1 addition & 0 deletions firefox-ios/firefox-ios-tests/Tests/Smoketest3.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"SettingsTests\/testOpenSiriOption()",
"SettingsTests\/testSettingsOptionSubtitles()",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"TabCounterTests",
Expand Down
1 change: 1 addition & 0 deletions firefox-ios/firefox-ios-tests/Tests/Smoketest4.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"SearchTests\/testSearchWithFirefoxOption()",
"SettingsTests",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"TabCounterTests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"SearchTests",
"SettingsTests",
"ShareMenuTests",
"ShareToolbarTests",
"SiteLoadTest",
"SyncUITests",
"TabCounterTests",
Expand Down
18 changes: 10 additions & 8 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareMenuTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ class ShareMenuTests: BaseTestCase {

// https://mozilla.testrail.io/index.php?/cases/view/2864073
func testShareWebsiteReaderModeReminders() {
reachReaderModeShareMenuLayoutAndSelectOption(option: "Reminders")
// The URL of the website is added in a new reminder
waitForElementsToExist(
[
app.navigationBars["Reminders"],
app.links.elementContainingText("test-mozilla-book.html")
]
)
if #available(iOS 17, *) {
reachReaderModeShareMenuLayoutAndSelectOption(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/2864082
Expand Down
164 changes: 164 additions & 0 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareToolbarTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// 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/

import Foundation

class ShareToolbarTests: BaseTestCase {
// https://mozilla.testrail.io/index.php?/cases/view/2864270
func testShareNormalWebsiteTabReminders() {
if #available(iOS 17, *) {
tapToolbarShareButtonAndSelectOption(option: "Reminders")
// The URL of the website is added in a new reminder
waitForElementsToExist(
[
app.navigationBars["Reminders"],
app.links["http://" + url_3]
]
)
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2864279
func testShareNormalWebsitePrint() {
tapToolbarShareButtonAndSelectOption(option: "Print")
// The Print dialog appears
waitForElementsToExist(
[
app.staticTexts["Printer"],
app.staticTexts["Copies"],
app.staticTexts["Paper Size"],
app.staticTexts["Letter"],
app.staticTexts["Orientation"],
app.staticTexts["Layout"]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864277
func testShareNormalWebsiteSendLinkToDevice() {
tapToolbarShareButtonAndSelectOption(option: "Send Link to Device")
// If not signed in, the browser prompts you to sign in
waitForElementsToExist(
[
app.staticTexts["You are not signed in to your account."],
app.staticTexts["Please open Firefox, go to Settings and sign in to continue."]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864278
func testShareNormalWebsiteMarkup() {
tapToolbarShareButtonAndSelectOption(option: "Markup")
// The Markup tool opens
waitForElementsToExist(
[
app.buttons["Undo"],
app.buttons["Redo"],
app.buttons["autofill"],
app.buttons["Done"],
app.buttons["Color picker"]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864276
func testShareNormalWebsiteCopyUrl() {
tapToolbarShareButtonAndSelectOption(option: "Copy")
openNewTabAndValidateURLisPaste(url: url_3)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864301
func testShareWebsiteReaderModeReminders() {
if #available(iOS 17, *) {
reachReaderModeShareMenuLayoutAndSelectOption(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/2864310
func testShareWebsiteReaderModePrint() {
reachReaderModeShareMenuLayoutAndSelectOption(option: "Print")
// The Print dialog appears
waitForElementsToExist(
[
app.staticTexts["Printer"],
app.staticTexts["Copies"],
app.staticTexts["Paper Size"],
app.staticTexts["Letter"],
app.staticTexts["Orientation"],
app.staticTexts["Layout"]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864307
func testShareWebsiteReaderModeCopy() {
reachReaderModeShareMenuLayoutAndSelectOption(option: "Copy")
openNewTabAndValidateURLisPaste(url: "test-mozilla-book.html")
}

// https://mozilla.testrail.io/index.php?/cases/view/2864308
func testShareWebsiteReaderModeSendLink() {
reachReaderModeShareMenuLayoutAndSelectOption(option: "Send Link to Device")
// If not signed in, the browser prompts you to sign in
waitForElementsToExist(
[
app.staticTexts["You are not signed in to your account."],
app.staticTexts["Please open Firefox, go to Settings and sign in to continue."]
]
)
}

// https://mozilla.testrail.io/index.php?/cases/view/2864309
func testShareWebsiteReaderModeMarkup() {
reachReaderModeShareMenuLayoutAndSelectOption(option: "Markup")
// The Markup tool opens
waitForElementsToExist(
[
app.buttons["Undo"],
app.buttons["Redo"],
app.buttons["autofill"],
app.buttons["Done"],
app.buttons["Color picker"]
]
)
}

private func reachReaderModeShareMenuLayoutAndSelectOption(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()
app.buttons[AccessibilityIdentifiers.Toolbar.shareButton].waitAndTap()
app.collectionViews.cells[option].waitAndTap()
}

private func tapToolbarShareButtonAndSelectOption(option: String) {
navigator.openURL(url_3)
waitUntilPageLoad()
app.buttons[AccessibilityIdentifiers.Toolbar.shareButton].waitAndTap()
app.collectionViews.cells[option].waitAndTap()
}

private func openNewTabAndValidateURLisPaste(url: String) {
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].waitAndTap()
if #available(iOS 17, *) {
app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField].press(forDuration: 1.5)
} else {
navigator.performAction(Action.CloseURLBarOpen)
app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField].press(forDuration: 2)
}
mozWaitForElementToExist(app.tables["Context Menu"])
app.tables.otherElements[AccessibilityIdentifiers.Photon.pasteAction].waitAndTap()
let urlBar = app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField]
mozWaitForValueContains(urlBar, value: url)
}
}

0 comments on commit b37ab18

Please sign in to comment.