forked from qodo-benchmark/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureFlaggedTestBase.swift
More file actions
59 lines (52 loc) · 2.34 KB
/
Copy pathFeatureFlaggedTestBase.swift
File metadata and controls
59 lines (52 loc) · 2.34 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
50
51
52
53
54
55
56
57
58
59
// 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 Common
/// Provides utilities to enable experiments and feature flags for specific test cases within a test class.
///
/// See also:
/// https://github.com/mozilla-mobile/firefox-ios/wiki/Automated-UI-Tests#experiments--feature-flags
class FeatureFlaggedTestBase: BaseTestCase {
override func setUpApp() {
// Important: `app.launch()` must be called explicitly in each test case.
setUpLaunchArguments()
}
/// Adds experiment data and feature flag information to the app's launch arguments.
///
/// - Parameters:
/// - jsonFileName: The name of the JSON file containing experiment configurations.
/// - featureName: The feature name as defined in the Nimbus feature YAML file,
/// written in kebab-case under the `features:` section.
func addLaunchArgument(jsonFileName: String, featureName: String) {
var launchArgs = app.launchArguments
launchArgs.append("\(LaunchArguments.LoadExperiment)\(jsonFileName)")
launchArgs.append("\(LaunchArguments.ExperimentFeatureName)\(featureName)")
app.launchArguments = launchArgs
launchArguments = launchArgs + launchArguments
}
}
/// Provides utilities to enable experiments and feature flags for an entire test class.
/// Use this when *all* tests in the class require the same experiment and feature flag.
///
/// See also:
/// https://github.com/mozilla-mobile/firefox-ios/wiki/Automated-UI-Tests#experiments--feature-flags
class FeatureFlaggedTestSuite: FeatureFlaggedTestBase {
/// Set these variables inside the `setUpExperimentVariables()` method.
var jsonFileName: String!
var featureName: String!
override func setUpApp() {
addLaunchArgument(jsonFileName: jsonFileName, featureName: featureName)
}
override func setUp() async throws {
continueAfterFailure = false
setUpApp()
setUpExperimentVariables()
setUpLaunchArguments()
setUpScreenGraph()
}
// Important: `launchApp` must be called explicitly in each test case.
func launchApp() {
app.launch()
mozWaitForElementToExist(app.windows.otherElements.firstMatch)
}
}