forked from agentic-review-benchmarks/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngagementNotificationTests.swift
More file actions
49 lines (46 loc) · 2.26 KB
/
EngagementNotificationTests.swift
File metadata and controls
49 lines (46 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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 XCTest
class EngagementNotificationTests: BaseTestCase {
override func setUp() async throws {
// Fresh install the app
// removeApp() does not work on iOS 15 and 16 intermittently
if #available(iOS 17, *) {
removeApp()
}
// The app is correctly installed
try await super.setUp()
}
// https://mozilla.testrail.io/index.php?/cases/view/2307101
func testDontAllowNotifications() throws {
if #unavailable(iOS 17) {
throw XCTSkip("setUp() fails to remove app intermittently")
}
// Skip login
navigator.nowAt(BrowserTab)
waitForTabsButton()
// Navigate to "Tips and Features"
// Toggle on switch position
navigator.goto(NotificationsSettings)
let tipsSwitch = app.switches["TipsAndFeaturesNotificationsUserPrefsKey"]
mozWaitForElementToExist(tipsSwitch)
app.switches["TipsAndFeaturesNotificationsUserPrefsKey"].waitAndTap()
let springBoard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let popUpTitle = "Would Like to Send You Notifications"
// Validate pop-up
mozWaitForElementToExist(springBoard.alerts.elementContainingText(popUpTitle))
// Choose "Don't allow"
springBoard.buttons["Don’t Allow"].waitAndTap()
// Toggle moves back to the "Off" position
mozWaitForValueContains(tipsSwitch, value: "0")
// Validate You turned off all Firefox notifications message
let notificationMessage1 = "You turned off all Firefox notifications. "
let notificationMessage2 = "Turn them on by going to device Settings > Notifications > Firefox"
// Workaround to validate message due to https://github.com/mozilla-mobile/firefox-ios/issues/13790
mozWaitForElementToNotExist(app.staticTexts[notificationMessage1 + notificationMessage2])
navigator.goto(SettingsScreen)
navigator.goto(NotificationsSettings)
mozWaitForElementToExist(app.staticTexts[notificationMessage1 + notificationMessage2])
}
}