diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index 7436f400e4d0..40fe8cfdb31a 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -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 */; }; @@ -8337,6 +8338,7 @@ B1864C62B7F68815AA1FE0C2 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/HistoryPanel.strings; sourceTree = ""; }; B18D4F2291BA5459431EDCA9 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Shared.strings"; sourceTree = ""; }; B19648D5B3667FE0CB25D069 /* my */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = my; path = my.lproj/Menu.strings; sourceTree = ""; }; + B1B95C612D3680DB00FD1337 /* ShareToolbarTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareToolbarTests.swift; sourceTree = ""; }; B1C044CA95EB3F5258D2EC51 /* bg */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bg; path = bg.lproj/InfoPlist.strings; sourceTree = ""; }; B1CA62812C0DB43600D31625 /* MultiWindowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiWindowTests.swift; sourceTree = ""; }; B1D14C77AD55FE126B7904D8 /* oc */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = oc; path = oc.lproj/PrivateBrowsing.strings; sourceTree = ""; }; @@ -10868,6 +10870,7 @@ B1CA62812C0DB43600D31625 /* MultiWindowTests.swift */, 78F28FBF2CB81FDF00DA862E /* InactiveTabsTest.swift */, B126B8A92D2FFD93002F4EFC /* ShareMenuTests.swift */, + B1B95C612D3680DB00FD1337 /* ShareToolbarTests.swift */, ); path = XCUITests; sourceTree = ""; @@ -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 */, diff --git a/firefox-ios/firefox-ios-tests/Tests/ExperimentIntegrationTests.xctestplan b/firefox-ios/firefox-ios-tests/Tests/ExperimentIntegrationTests.xctestplan index 80b7ba508d95..6f5566a844bb 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ExperimentIntegrationTests.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/ExperimentIntegrationTests.xctestplan @@ -99,6 +99,7 @@ "ScreenGraphTest", "SearchSettingsUITests", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "ThirdPartySearchTest", diff --git a/firefox-ios/firefox-ios-tests/Tests/PerformanceTestPlan.xctestplan b/firefox-ios/firefox-ios-tests/Tests/PerformanceTestPlan.xctestplan index a1656be13805..17e776398330 100644 --- a/firefox-ios/firefox-ios-tests/Tests/PerformanceTestPlan.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/PerformanceTestPlan.xctestplan @@ -81,6 +81,7 @@ "SearchTests", "SettingsTests", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "TabCounterTests", diff --git a/firefox-ios/firefox-ios-tests/Tests/Smoketest1.xctestplan b/firefox-ios/firefox-ios-tests/Tests/Smoketest1.xctestplan index e6818ebd58eb..ca7dd5b387f9 100644 --- a/firefox-ios/firefox-ios-tests/Tests/Smoketest1.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/Smoketest1.xctestplan @@ -210,6 +210,7 @@ "SearchTests\/testSearchWithFirefoxOption()", "SettingsTests", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "SyncUITests\/testCreateAnAccountLink()", diff --git a/firefox-ios/firefox-ios-tests/Tests/Smoketest2.xctestplan b/firefox-ios/firefox-ios-tests/Tests/Smoketest2.xctestplan index 3850b95c79a0..a3994a4f2281 100644 --- a/firefox-ios/firefox-ios-tests/Tests/Smoketest2.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/Smoketest2.xctestplan @@ -110,6 +110,7 @@ "SettingsTests\/testOpenMailAppSettings()", "SettingsTests\/testOpenSiriOption()", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "TabCounterTests", diff --git a/firefox-ios/firefox-ios-tests/Tests/Smoketest3.xctestplan b/firefox-ios/firefox-ios-tests/Tests/Smoketest3.xctestplan index d375172210b2..59385dbdd83e 100644 --- a/firefox-ios/firefox-ios-tests/Tests/Smoketest3.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/Smoketest3.xctestplan @@ -145,6 +145,7 @@ "SettingsTests\/testOpenSiriOption()", "SettingsTests\/testSettingsOptionSubtitles()", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "TabCounterTests", diff --git a/firefox-ios/firefox-ios-tests/Tests/Smoketest4.xctestplan b/firefox-ios/firefox-ios-tests/Tests/Smoketest4.xctestplan index 7a6298d3e000..2b332749a5f7 100644 --- a/firefox-ios/firefox-ios-tests/Tests/Smoketest4.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/Smoketest4.xctestplan @@ -150,6 +150,7 @@ "SearchTests\/testSearchWithFirefoxOption()", "SettingsTests", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "TabCounterTests", diff --git a/firefox-ios/firefox-ios-tests/Tests/SyncIntegrationTestPlan.xctestplan b/firefox-ios/firefox-ios-tests/Tests/SyncIntegrationTestPlan.xctestplan index d54a8bd78b50..701c813d6f9a 100644 --- a/firefox-ios/firefox-ios-tests/Tests/SyncIntegrationTestPlan.xctestplan +++ b/firefox-ios/firefox-ios-tests/Tests/SyncIntegrationTestPlan.xctestplan @@ -99,6 +99,7 @@ "SearchTests", "SettingsTests", "ShareMenuTests", + "ShareToolbarTests", "SiteLoadTest", "SyncUITests", "TabCounterTests", diff --git a/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareMenuTests.swift b/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareMenuTests.swift index 05a710ebcd9e..7db984f829fb 100644 --- a/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareMenuTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareMenuTests.swift @@ -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 diff --git a/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareToolbarTests.swift b/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareToolbarTests.swift new file mode 100644 index 000000000000..39b817451dab --- /dev/null +++ b/firefox-ios/firefox-ios-tests/Tests/XCUITests/ShareToolbarTests.swift @@ -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) + } +}