Skip to content

Commit

Permalink
UI tests (#242)
Browse files Browse the repository at this point in the history
* Pairing testcase

* Ping testcase

* ApproveSessionExistingPairing test case

* Unused extensions deleted

* Renamed to RegressionTests

* UITests step on CI

* CleanLaunch instead of deleting app

* Fix test on Real device

* Launch App fix
  • Loading branch information
flypaper0 authored Jun 3, 2022
1 parent 49e22f2 commit 84307e0
Show file tree
Hide file tree
Showing 17 changed files with 567 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ jobs:
with:
xcode-version: '13.2'

# Package builds
# Package builds
- name: Build Package
run: swift build -v
- name: Run tests
run: swift test -v

# Example app builds
# Example app builds
- name: Build Example Wallet
run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme Wallet -sdk iphonesimulator
- name: Build Example Dapp
run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme DApp -sdk iphonesimulator

# UI tests
- name: UI Tests
run: xcodebuild -project Example/ExampleApp.xcodeproj -scheme UITests -destination 'platform=iOS Simulator,name=iPhone 13' test
continue-on-error: true
5 changes: 5 additions & 0 deletions Example/DApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
url: "wallet.connect",
icons: ["https://avatars.githubusercontent.com/u/37784886"])
Sign.configure(Sign.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a"))

if CommandLine.arguments.contains("-cleanInstall") {
try? Sign.instance.cleanup()
}

Sign.instance.sessionDeletePublisher
.receive(on: DispatchQueue.main)
.sink { [unowned self] _ in
Expand Down
183 changes: 182 additions & 1 deletion Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
A5A4FC5A283CC08600BBEC1E /* SessionNamespaceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC59283CC08600BBEC1E /* SessionNamespaceViewModel.swift */; };
A5A4FC5C283D1F6700BBEC1E /* SessionDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC5B283D1F6700BBEC1E /* SessionDetailViewController.swift */; };
A5A4FC5E283D23CA00BBEC1E /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC5D283D23CA00BBEC1E /* Array.swift */; };
A5A4FC772840C12C00BBEC1E /* RegressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A4FC762840C12C00BBEC1E /* RegressionTests.swift */; };
A5E22D1A2840C62A00E36487 /* Engine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D192840C62A00E36487 /* Engine.swift */; };
A5E22D1C2840C85D00E36487 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1B2840C85D00E36487 /* App.swift */; };
A5E22D1E2840C8BF00E36487 /* RoutingEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1D2840C8BF00E36487 /* RoutingEngine.swift */; };
A5E22D202840C8C700E36487 /* DAppEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D1F2840C8C700E36487 /* DAppEngine.swift */; };
A5E22D222840C8D300E36487 /* WalletEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D212840C8D300E36487 /* WalletEngine.swift */; };
A5E22D242840C8DB00E36487 /* SafariEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D232840C8DB00E36487 /* SafariEngine.swift */; };
A5E22D2C2840EAC300E36487 /* XCUIElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E22D2B2840EAC300E36487 /* XCUIElement.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -76,6 +84,20 @@
remoteGlobalIDString = 764E1D3B26F8D3FC00A1FB15;
remoteInfo = Wallet;
};
A5A4FC7D2840C5D400BBEC1E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 764E1D3426F8D3FC00A1FB15 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 84CE641B27981DED00142511;
remoteInfo = DApp;
};
A5A4FC7F2840C5D400BBEC1E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 764E1D3426F8D3FC00A1FB15 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 764E1D3B26F8D3FC00A1FB15;
remoteInfo = Wallet;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -130,6 +152,15 @@
A5A4FC59283CC08600BBEC1E /* SessionNamespaceViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionNamespaceViewModel.swift; sourceTree = "<group>"; };
A5A4FC5B283D1F6700BBEC1E /* SessionDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionDetailViewController.swift; sourceTree = "<group>"; };
A5A4FC5D283D23CA00BBEC1E /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
A5A4FC722840C12C00BBEC1E /* UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A5A4FC762840C12C00BBEC1E /* RegressionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegressionTests.swift; sourceTree = "<group>"; };
A5E22D192840C62A00E36487 /* Engine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Engine.swift; sourceTree = "<group>"; };
A5E22D1B2840C85D00E36487 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
A5E22D1D2840C8BF00E36487 /* RoutingEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoutingEngine.swift; sourceTree = "<group>"; };
A5E22D1F2840C8C700E36487 /* DAppEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DAppEngine.swift; sourceTree = "<group>"; };
A5E22D212840C8D300E36487 /* WalletEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletEngine.swift; sourceTree = "<group>"; };
A5E22D232840C8DB00E36487 /* SafariEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariEngine.swift; sourceTree = "<group>"; };
A5E22D2B2840EAC300E36487 /* XCUIElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCUIElement.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -165,6 +196,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A5A4FC6F2840C12C00BBEC1E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -213,6 +251,7 @@
84CE641D27981DED00142511 /* DApp */,
84CE645F27A2C85B00142511 /* DappTests */,
84CE646E27A2CD6B00142511 /* WalletTests */,
A5A4FC732840C12C00BBEC1E /* UITests */,
764E1D3D26F8D3FC00A1FB15 /* Products */,
764E1D5326F8DAC800A1FB15 /* Frameworks */,
764E1D5626F8DB6000A1FB15 /* WalletConnectSwiftV2 */,
Expand All @@ -226,6 +265,7 @@
84CE641C27981DED00142511 /* DApp.app */,
84CE645E27A2C85B00142511 /* DappTests.xctest */,
84CE646D27A2CD6B00142511 /* WalletTests.xctest */,
A5A4FC722840C12C00BBEC1E /* UITests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -345,6 +385,45 @@
path = WalletTests;
sourceTree = "<group>";
};
A5A4FC732840C12C00BBEC1E /* UITests */ = {
isa = PBXGroup;
children = (
A5E22D2A2840EAB600E36487 /* Extensions */,
A5E22D252840D08B00E36487 /* Regression */,
A5A4FC812840C60100BBEC1E /* Engine */,
);
path = UITests;
sourceTree = "<group>";
};
A5A4FC812840C60100BBEC1E /* Engine */ = {
isa = PBXGroup;
children = (
A5E22D192840C62A00E36487 /* Engine.swift */,
A5E22D1D2840C8BF00E36487 /* RoutingEngine.swift */,
A5E22D1F2840C8C700E36487 /* DAppEngine.swift */,
A5E22D212840C8D300E36487 /* WalletEngine.swift */,
A5E22D232840C8DB00E36487 /* SafariEngine.swift */,
A5E22D1B2840C85D00E36487 /* App.swift */,
);
path = Engine;
sourceTree = "<group>";
};
A5E22D252840D08B00E36487 /* Regression */ = {
isa = PBXGroup;
children = (
A5A4FC762840C12C00BBEC1E /* RegressionTests.swift */,
);
path = Regression;
sourceTree = "<group>";
};
A5E22D2A2840EAB600E36487 /* Extensions */ = {
isa = PBXGroup;
children = (
A5E22D2B2840EAC300E36487 /* XCUIElement.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -427,13 +506,32 @@
productReference = 84CE646D27A2CD6B00142511 /* WalletTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
A5A4FC712840C12C00BBEC1E /* UITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = A5A4FC7A2840C12C00BBEC1E /* Build configuration list for PBXNativeTarget "UITests" */;
buildPhases = (
A5A4FC6E2840C12C00BBEC1E /* Sources */,
A5A4FC6F2840C12C00BBEC1E /* Frameworks */,
A5A4FC702840C12C00BBEC1E /* Resources */,
);
buildRules = (
);
dependencies = (
A5A4FC7E2840C5D400BBEC1E /* PBXTargetDependency */,
A5A4FC802840C5D400BBEC1E /* PBXTargetDependency */,
);
name = UITests;
productName = UITests;
productReference = A5A4FC722840C12C00BBEC1E /* UITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
764E1D3426F8D3FC00A1FB15 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1320;
LastSwiftUpdateCheck = 1330;
LastUpgradeCheck = 1250;
TargetAttributes = {
764E1D3B26F8D3FC00A1FB15 = {
Expand All @@ -450,6 +548,9 @@
CreatedOnToolsVersion = 13.2;
TestTargetID = 764E1D3B26F8D3FC00A1FB15;
};
A5A4FC712840C12C00BBEC1E = {
CreatedOnToolsVersion = 13.3;
};
};
};
buildConfigurationList = 764E1D3726F8D3FC00A1FB15 /* Build configuration list for PBXProject "ExampleApp" */;
Expand All @@ -472,6 +573,7 @@
84CE641B27981DED00142511 /* DApp */,
84CE645D27A2C85B00142511 /* DappTests */,
84CE646C27A2CD6B00142511 /* WalletTests */,
A5A4FC712840C12C00BBEC1E /* UITests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -509,6 +611,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A5A4FC702840C12C00BBEC1E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -577,6 +686,21 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A5A4FC6E2840C12C00BBEC1E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A5E22D202840C8C700E36487 /* DAppEngine.swift in Sources */,
A5E22D1E2840C8BF00E36487 /* RoutingEngine.swift in Sources */,
A5E22D222840C8D300E36487 /* WalletEngine.swift in Sources */,
A5E22D1C2840C85D00E36487 /* App.swift in Sources */,
A5A4FC772840C12C00BBEC1E /* RegressionTests.swift in Sources */,
A5E22D242840C8DB00E36487 /* SafariEngine.swift in Sources */,
A5E22D1A2840C62A00E36487 /* Engine.swift in Sources */,
A5E22D2C2840EAC300E36487 /* XCUIElement.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand All @@ -595,6 +719,16 @@
target = 764E1D3B26F8D3FC00A1FB15 /* Wallet */;
targetProxy = 84CE647127A2CD6B00142511 /* PBXContainerItemProxy */;
};
A5A4FC7E2840C5D400BBEC1E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 84CE641B27981DED00142511 /* DApp */;
targetProxy = A5A4FC7D2840C5D400BBEC1E /* PBXContainerItemProxy */;
};
A5A4FC802840C5D400BBEC1E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 764E1D3B26F8D3FC00A1FB15 /* Wallet */;
targetProxy = A5A4FC7F2840C5D400BBEC1E /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down Expand Up @@ -931,6 +1065,44 @@
};
name = Release;
};
A5A4FC782840C12C00BBEC1E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = W5R8AG9K22;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.UITests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
A5A4FC792840C12C00BBEC1E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = W5R8AG9K22;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.walletconnect.UITests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -979,6 +1151,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A5A4FC7A2840C12C00BBEC1E /* Build configuration list for PBXNativeTarget "UITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A5A4FC782840C12C00BBEC1E /* Debug */,
A5A4FC792840C12C00BBEC1E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A5A4FC712840C12C00BBEC1E"
BuildableName = "UITests.xctest"
BlueprintName = "UITests"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 4 additions & 0 deletions Example/ExampleApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
icons: ["https://avatars.githubusercontent.com/u/37784886"])
Sign.configure(Sign.Config(metadata: metadata, projectId: "8ba9ee138960775e5231b70cc5ef1c3a"))

if CommandLine.arguments.contains("-cleanInstall") {
try? Sign.instance.cleanup()
}

guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = UITabBarController.createExampleApp()
Expand Down
Loading

0 comments on commit 84307e0

Please sign in to comment.