Skip to content

Commit 9f652fa

Browse files
Add problem report test
1 parent da257e7 commit 9f652fa

10 files changed

+102
-10
lines changed

ios/Configurations/UITests.xcconfig.template

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ IOS_DEVICE_PIN_CODE =
77
TEST_DEVICE_IDENTIFIER_UUID =
88

99
// Mullvad accounts used by UI tests
10-
NO_TIME_ACCOUNT_NUMBER =
11-
HAS_TIME_ACCOUNT_NUMBER =
10+
NO_TIME_ACCOUNT_NUMBER[config=Debug] =
11+
NO_TIME_ACCOUNT_NUMBER[config=Staging] =
12+
HAS_TIME_ACCOUNT_NUMBER[config=Debug] =
13+
HAS_TIME_ACCOUNT_NUMBER[config=Staging] =
1214
FIVE_WIREGUARD_KEYS_ACCOUNT_NUMBER =
1315

1416
// Ad serving domain used when testing ad blocking. Note that we are assuming there's an HTTP server running on the host.

ios/MullvadVPN.xcodeproj/project.pbxproj

+32-1
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@
602602
852969362B4E9724007EAD4C /* AccessbilityIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0B311D2B303A0D004B12E0 /* AccessbilityIdentifier.swift */; };
603603
8529693A2B4F0238007EAD4C /* TermsOfServicePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 852969392B4F0238007EAD4C /* TermsOfServicePage.swift */; };
604604
8529693C2B4F0257007EAD4C /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8529693B2B4F0257007EAD4C /* Alert.swift */; };
605+
8532E6872B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8532E6862B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift */; };
605606
85557B0E2B591B2600795FE1 /* FirewallAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85557B0D2B591B2600795FE1 /* FirewallAPIClient.swift */; };
606607
85557B102B59215F00795FE1 /* FirewallRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85557B0F2B59215F00795FE1 /* FirewallRule.swift */; };
607608
85557B122B594FC900795FE1 /* ConnectivityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85557B112B594FC900795FE1 /* ConnectivityTests.swift */; };
@@ -612,6 +613,7 @@
612613
855D9F5B2B63E56B00D7C64D /* ProblemReportPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855D9F5A2B63E56B00D7C64D /* ProblemReportPage.swift */; };
613614
8590896C2B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 859089682B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift */; };
614615
8590896F2B61763B003AF5F5 /* LoggedOutUITestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */; };
616+
85C7A2E92B89024B00035D5A /* SettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85C7A2E82B89024B00035D5A /* SettingsTests.swift */; };
615617
85D2B0B12B6BD32400DF9DA7 /* BaseUITestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8590896A2B61763B003AF5F5 /* BaseUITestCase.swift */; };
616618
85E3BDE52B70E18C00FA71FD /* Networking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85E3BDE42B70E18C00FA71FD /* Networking.swift */; };
617619
A900E9B82ACC5C2B00C95F67 /* AccountsProxy+Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A900E9B72ACC5C2B00C95F67 /* AccountsProxy+Stubs.swift */; };
@@ -1824,6 +1826,7 @@
18241826
852969382B4ED818007EAD4C /* UITests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = UITests.xcconfig; sourceTree = "<group>"; };
18251827
852969392B4F0238007EAD4C /* TermsOfServicePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServicePage.swift; sourceTree = "<group>"; };
18261828
8529693B2B4F0257007EAD4C /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
1829+
8532E6862B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemReportSubmittedPage.swift; sourceTree = "<group>"; };
18271830
85557B0D2B591B2600795FE1 /* FirewallAPIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirewallAPIClient.swift; sourceTree = "<group>"; };
18281831
85557B0F2B59215F00795FE1 /* FirewallRule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirewallRule.swift; sourceTree = "<group>"; };
18291832
85557B112B594FC900795FE1 /* ConnectivityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectivityTests.swift; sourceTree = "<group>"; };
@@ -1836,6 +1839,7 @@
18361839
859089692B61763B003AF5F5 /* LoggedInWithTimeUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedInWithTimeUITestCase.swift; sourceTree = "<group>"; };
18371840
8590896A2B61763B003AF5F5 /* BaseUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseUITestCase.swift; sourceTree = "<group>"; };
18381841
8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedOutUITestCase.swift; sourceTree = "<group>"; };
1842+
85C7A2E82B89024B00035D5A /* SettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTests.swift; sourceTree = "<group>"; };
18391843
85E3BDE42B70E18C00FA71FD /* Networking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Networking.swift; sourceTree = "<group>"; };
18401844
A900E9B72ACC5C2B00C95F67 /* AccountsProxy+Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountsProxy+Stubs.swift"; sourceTree = "<group>"; };
18411845
A900E9B92ACC5D0600C95F67 /* RESTRequestExecutor+Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RESTRequestExecutor+Stubs.swift"; sourceTree = "<group>"; };
@@ -3511,6 +3515,7 @@
35113515
850201DA2B503D7700EF8C96 /* RelayTests.swift */,
35123516
8518F6392B601910009EB113 /* Test base classes */,
35133517
85557B152B5ABBBE00795FE1 /* XCUIElementQuery+Extensions.swift */,
3518+
85C7A2E82B89024B00035D5A /* SettingsTests.swift */,
35143519
);
35153520
path = MullvadVPNUITests;
35163521
sourceTree = "<group>";
@@ -3524,6 +3529,7 @@
35243529
852969342B4E9270007EAD4C /* LoginPage.swift */,
35253530
852969322B4E9232007EAD4C /* Page.swift */,
35263531
855D9F5A2B63E56B00D7C64D /* ProblemReportPage.swift */,
3532+
8532E6862B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift */,
35273533
850201DC2B503D8C00EF8C96 /* SelectLocationPage.swift */,
35283534
850201E22B51A93C00EF8C96 /* SettingsPage.swift */,
35293535
852969392B4F0238007EAD4C /* TermsOfServicePage.swift */,
@@ -5478,6 +5484,7 @@
54785484
85557B142B5983CF00795FE1 /* MullvadAPIWrapper.swift in Sources */,
54795485
852969362B4E9724007EAD4C /* AccessbilityIdentifier.swift in Sources */,
54805486
85E3BDE52B70E18C00FA71FD /* Networking.swift in Sources */,
5487+
85C7A2E92B89024B00035D5A /* SettingsTests.swift in Sources */,
54815488
8590896C2B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift in Sources */,
54825489
8590896F2B61763B003AF5F5 /* LoggedOutUITestCase.swift in Sources */,
54835490
85557B202B5FBBD700795FE1 /* AccountPage.swift in Sources */,
@@ -5489,6 +5496,7 @@
54895496
85557B162B5ABBBE00795FE1 /* XCUIElementQuery+Extensions.swift in Sources */,
54905497
855D9F5B2B63E56B00D7C64D /* ProblemReportPage.swift in Sources */,
54915498
8529693A2B4F0238007EAD4C /* TermsOfServicePage.swift in Sources */,
5499+
8532E6872B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift in Sources */,
54925500
850201DF2B5040A500EF8C96 /* TunnelControlPage.swift in Sources */,
54935501
85557B1E2B5FB8C700795FE1 /* HeaderBar.swift in Sources */,
54945502
85557B122B594FC900795FE1 /* ConnectivityTests.swift in Sources */,
@@ -6859,7 +6867,7 @@
68596867
PROVISIONING_PROFILE_SPECIFIER = "";
68606868
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "MullvadVPN app integration tests";
68616869
SECURITY_GROUP_IDENTIFIER = group.net.mullvad.MullvadVPN;
6862-
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
6870+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG MULLVAD_ENVIRONMENT_PRODUCTION $(inherited)";
68636871
SWIFT_EMIT_LOC_STRINGS = NO;
68646872
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/MullvadVPNUITests/BridgingHeader.h";
68656873
SWIFT_VERSION = 5.0;
@@ -6870,9 +6878,12 @@
68706878
};
68716879
8529692E2B4D9C1F007EAD4C /* Release */ = {
68726880
isa = XCBuildConfiguration;
6881+
baseConfigurationReference = 852969382B4ED818007EAD4C /* UITests.xcconfig */;
68736882
buildSettings = {
68746883
APPLICATION_IDENTIFIER = net.mullvad.MullvadVPN;
68756884
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
6885+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
6886+
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CKG9MXH72F;
68766887
ENABLE_USER_SCRIPT_SANDBOXING = NO;
68776888
GCC_C_LANGUAGE_STANDARD = gnu17;
68786889
GENERATE_INFOPLIST_FILE = YES;
@@ -6886,6 +6897,7 @@
68866897
MARKETING_VERSION = 1.0;
68876898
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER).MullvadVPNUITests";
68886899
PRODUCT_NAME = "$(TARGET_NAME)";
6900+
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "MullvadVPN app integration tests";
68896901
SECURITY_GROUP_IDENTIFIER = group.net.mullvad.MullvadVPN;
68906902
SWIFT_EMIT_LOC_STRINGS = NO;
68916903
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/MullvadVPNUITests/BridgingHeader.h";
@@ -7470,25 +7482,44 @@
74707482
};
74717483
A93A1D062B59145C00F7796C /* Staging */ = {
74727484
isa = XCBuildConfiguration;
7485+
baseConfigurationReference = 852969382B4ED818007EAD4C /* UITests.xcconfig */;
74737486
buildSettings = {
7487+
APPLICATION_IDENTIFIER = net.mullvad.MullvadVPN;
7488+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
7489+
CODE_SIGN_STYLE = Manual;
7490+
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CKG9MXH72F;
7491+
"DEVELOPMENT_TEAM[sdk=macosx*]" = CKG9MXH72F;
7492+
GENERATE_INFOPLIST_FILE = YES;
74747493
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../mullvad-api/include";
7494+
INFOPLIST_FILE = MullvadVPNUITests/Info.plist;
74757495
"LIBRARY_SEARCH_PATHS[sdk=iphoneos*][arch=arm64]" = "$(PROJECT_DIR)/../target/aarch64-apple-ios/debug";
74767496
"LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*][arch=arm64]" = "$(PROJECT_DIR)/../target/aarch64-apple-ios-sim/debug";
74777497
"LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*][arch=x86_64]" = "$(PROJECT_DIR)/../target/x86_64-apple-ios/debug";
7498+
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER).MullvadVPNUITests";
74787499
PRODUCT_NAME = MullvadVPNUITests;
7500+
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "MullvadVPN app integration tests";
7501+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG MULLVAD_ENVIRONMENT_STAGING";
74797502
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/MullvadVPNUITests/BridgingHeader.h";
7503+
SWIFT_VERSION = 5.0;
7504+
TEST_TARGET_NAME = MullvadVPN;
74807505
};
74817506
name = Staging;
74827507
};
74837508
A93A1D072B59145C00F7796C /* MockRelease */ = {
74847509
isa = XCBuildConfiguration;
7510+
baseConfigurationReference = 852969382B4ED818007EAD4C /* UITests.xcconfig */;
74857511
buildSettings = {
7512+
APPLICATION_IDENTIFIER = net.mullvad.MullvadVPN;
74867513
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../mullvad-api/include";
7514+
INFOPLIST_FILE = MullvadVPNUITests/Info.plist;
74877515
"LIBRARY_SEARCH_PATHS[sdk=iphoneos*][arch=arm64]" = "$(PROJECT_DIR)/../target/aarch64-apple-ios/release";
74887516
"LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*][arch=arm64]" = "$(PROJECT_DIR)/../target/aarch64-apple-ios-sim/release";
74897517
"LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*][arch=x86_64]" = "$(PROJECT_DIR)/../target/x86_64-apple-ios/release";
74907518
PRODUCT_NAME = MullvadVPNUITests;
7519+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = MULLVAD_ENVIRONMENT_PRODUCTION;
74917520
SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/MullvadVPNUITests/BridgingHeader.h";
7521+
SWIFT_VERSION = 5.0;
7522+
TEST_TARGET_NAME = MullvadVPN;
74927523
};
74937524
name = MockRelease;
74947525
};

ios/MullvadVPN/Classes/AccessbilityIdentifier.swift

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public enum AccessibilityIdentifier: String {
6060
case settingsTableView
6161
case tunnelControlView
6262
case problemReportView
63+
case problemReportSubmittedView
6364

6465
// Other UI elements
6566
case connectionPanelInAddressRow

ios/MullvadVPN/View controllers/ProblemReport/ProblemReportSubmissionOverlayView.swift

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class ProblemReportSubmissionOverlayView: UIView {
174174
override init(frame: CGRect) {
175175
super.init(frame: frame)
176176

177+
accessibilityIdentifier = AccessibilityIdentifier.problemReportSubmittedView
178+
177179
addSubviews()
178180
transitionToState(state)
179181

ios/MullvadVPN/View controllers/ProblemReport/ProblemReportViewController+ViewManagement.swift

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ extension ProblemReportViewController {
9696

9797
func makeSendButton() -> AppButton {
9898
let button = AppButton(style: .success)
99+
button.accessibilityIdentifier = AccessibilityIdentifier.problemReportSendButton
99100
button.translatesAutoresizingMaskIntoConstraints = false
100101
button.setTitle(Self.persistentViewModel.sendLogsButtonTitle, for: .normal)
101102
button.addTarget(self, action: #selector(handleSendButtonTap), for: .touchUpInside)

ios/MullvadVPNUITests/AccountTests.swift

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
import XCTest
1010

1111
class AccountTests: LoggedOutUITestCase {
12-
override func setUpWithError() throws {
13-
continueAfterFailure = false
14-
15-
try super.setUpWithError()
16-
}
17-
1812
func testLogin() throws {
1913
LoginPage(app)
2014
.tapAccountNumberTextField()

ios/MullvadVPNUITests/Pages/ProblemReportPage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ProblemReportPage: Page {
4040
}
4141

4242
@discardableResult func tapSendButton() -> Self {
43-
app.otherElements[AccessibilityIdentifier.problemReportSendButton]
43+
app.buttons[AccessibilityIdentifier.problemReportSendButton]
4444
.tap()
4545

4646
return self
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// ProblemReportSubmittedPage.swift
3+
// MullvadVPNUITests
4+
//
5+
// Created by Niklas Berglund on 2024-02-26.
6+
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import XCTest
11+
12+
class ProblemReportSubmittedPage: Page {
13+
@discardableResult override init(_ app: XCUIApplication) {
14+
super.init(app)
15+
16+
pageAccessibilityIdentifier = .problemReportSubmittedView
17+
waitForPageToBeShown()
18+
}
19+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// SettingsTests.swift
3+
// MullvadVPNUITests
4+
//
5+
// Created by Niklas Berglund on 2024-02-23.
6+
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import XCTest
11+
12+
class SettingsTests: LoggedOutUITestCase {
13+
func testSendProblemReport() throws {
14+
#if MULLVAD_ENVIRONMENT_STAGING
15+
let shouldSkipTest = false
16+
#else
17+
let shouldSkipTest = true
18+
#endif
19+
20+
try XCTSkipIf(shouldSkipTest, "This test should only run in the staging environment")
21+
22+
HeaderBar(app)
23+
.tapSettingsButton()
24+
25+
SettingsPage(app)
26+
.tapReportAProblemCell()
27+
28+
ProblemReportPage(app)
29+
.tapEmailTextField()
30+
.enterText("cookie@mullvad.net")
31+
.tapMessageTextView()
32+
.enterText("""
33+
Dear support
34+
This is a problem report from an iOS app test.
35+
""")
36+
.tapKeyboardDoneButton()
37+
.tapSendButton()
38+
39+
ProblemReportSubmittedPage(app)
40+
}
41+
}

ios/MullvadVPNUITests/Test base classes/BaseUITestCase.swift

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class BaseUITestCase: XCTestCase {
4848

4949
/// Test level setup
5050
override func setUp() {
51+
continueAfterFailure = false
5152
app.launch()
5253
}
5354

0 commit comments

Comments
 (0)