Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start on getting a test harness in place #25

Merged
merged 10 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import { ThirdwebProvider } from "@thirdweb-dev/react-native";
import React, { useState } from "react";
import { SafeAreaView, StyleSheet } from "react-native";
import { Button, SafeAreaView, StyleSheet, View } from "react-native";
import * as XMTP from "xmtp-react-native-sdk";

import AuthView from "./src/AuthView";
import HomeView from "./src/HomeView";
import TestsView from "./src/TestsView";

export default function App() {
const [client, setClient] = useState<XMTP.Client | null>(null);
const [isTesting, setIsTesting] = useState<boolean>(false);

return (
return isTesting ? (
<SafeAreaView style={{ flexGrow: 1 }}>
<TestsView />
</SafeAreaView>
) : (
<ThirdwebProvider activeChain="mainnet">
<SafeAreaView style={{ flexGrow: 1 }}>
{client != null ? (
<HomeView client={client} />
) : (
<AuthView setClient={setClient} />
<View>
<AuthView setClient={setClient} />
<Button onPress={() => setIsTesting(true)} title="Unit tests" />
</View>
)}
</SafeAreaView>
</ThirdwebProvider>
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ SPEC CHECKSUMS:
SwiftProtobuf: afced68785854575756db965e9da52bbf3dc45e7
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: b2286639f0cff509e909eed5b0ce2aed7eea3e77
XMTPReactNative: 30c5c76129cf24a1d4474effcd2a9b4237714b68
XMTPReactNative: bdd05452ff13f1276f13ca3d1034535c40bf5970
XMTPRust: 2c356f57f034d771717933a6127a7d51667f9843
Yoga: ba09b6b11e6139e3df8229238aa794205ca6a02a

Expand Down
149 changes: 149 additions & 0 deletions example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
3E461D99554A48A4959DE609 /* SplashScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */; };
A6A5DB882A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6A5DB872A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.swift */; };
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
C90474A97E544153BED95C2A /* noop-file.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF0078FD601458DA88B0565 /* noop-file.swift */; };
FD38E403931970F81205A40A /* libPods-xmtpreactnativesdkexample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78B76F8B6347E6AE6088DF9B /* libPods-xmtpreactnativesdkexample.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
A6A5DB8B2A00551E001DF8C2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
remoteInfo = xmtpreactnativesdkexample;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* xmtpreactnativesdkexample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = xmtpreactnativesdkexample.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -28,6 +39,8 @@
6AF9BAAAC2041F823F5E5BC1 /* Pods-xmtpreactnativesdkexample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xmtpreactnativesdkexample.release.xcconfig"; path = "Target Support Files/Pods-xmtpreactnativesdkexample/Pods-xmtpreactnativesdkexample.release.xcconfig"; sourceTree = "<group>"; };
78B76F8B6347E6AE6088DF9B /* libPods-xmtpreactnativesdkexample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-xmtpreactnativesdkexample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
80323D3D45487AD85F64F249 /* Pods-xmtpreactnativesdkexample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xmtpreactnativesdkexample.debug.xcconfig"; path = "Target Support Files/Pods-xmtpreactnativesdkexample/Pods-xmtpreactnativesdkexample.debug.xcconfig"; sourceTree = "<group>"; };
A6A5DB852A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = xmtpreactnativesdkexampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A6A5DB872A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = xmtpreactnativesdkexampleUITests.swift; sourceTree = "<group>"; };
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SplashScreen.storyboard; path = xmtpreactnativesdkexample/SplashScreen.storyboard; sourceTree = "<group>"; };
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
Expand All @@ -44,6 +57,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A6A5DB822A00551E001DF8C2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -84,6 +104,7 @@
children = (
13B07FAE1A68108700A75B9A /* xmtpreactnativesdkexample */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
A6A5DB862A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests */,
83CBBA001A601CBA00E9B192 /* Products */,
2D16E6871FA4F8E400B85C8A /* Frameworks */,
D65327D7A22EEC0BE12398D9 /* Pods */,
Expand All @@ -98,6 +119,7 @@
isa = PBXGroup;
children = (
13B07F961A680F5B00A75B9A /* xmtpreactnativesdkexample.app */,
A6A5DB852A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -110,6 +132,14 @@
name = xmtpreactnativesdkexample;
sourceTree = "<group>";
};
A6A5DB862A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests */ = {
isa = PBXGroup;
children = (
A6A5DB872A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.swift */,
);
path = xmtpreactnativesdkexampleUITests;
sourceTree = "<group>";
};
BB2F792B24A3F905000567C9 /* Supporting */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -161,18 +191,43 @@
productReference = 13B07F961A680F5B00A75B9A /* xmtpreactnativesdkexample.app */;
productType = "com.apple.product-type.application";
};
A6A5DB842A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = A6A5DB8F2A00551E001DF8C2 /* Build configuration list for PBXNativeTarget "xmtpreactnativesdkexampleUITests" */;
buildPhases = (
A6A5DB812A00551E001DF8C2 /* Sources */,
A6A5DB822A00551E001DF8C2 /* Frameworks */,
A6A5DB832A00551E001DF8C2 /* Resources */,
);
buildRules = (
);
dependencies = (
A6A5DB8C2A00551E001DF8C2 /* PBXTargetDependency */,
);
name = xmtpreactnativesdkexampleUITests;
productName = xmtpreactnativesdkexampleUITests;
productReference = A6A5DB852A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1430;
LastUpgradeCheck = 1130;
TargetAttributes = {
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = FY4NZR34Z3;
LastSwiftMigration = 1250;
};
A6A5DB842A00551E001DF8C2 = {
CreatedOnToolsVersion = 14.3;
DevelopmentTeam = FY4NZR34Z3;
ProvisioningStyle = Automatic;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "xmtpreactnativesdkexample" */;
Expand All @@ -189,6 +244,7 @@
projectRoot = "";
targets = (
13B07F861A680F5B00A75B9A /* xmtpreactnativesdkexample */,
A6A5DB842A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests */,
);
};
/* End PBXProject section */
Expand All @@ -204,6 +260,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A6A5DB832A00551E001DF8C2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -314,8 +377,24 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
A6A5DB812A00551E001DF8C2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A6A5DB882A00551E001DF8C2 /* xmtpreactnativesdkexampleUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
A6A5DB8C2A00551E001DF8C2 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 13B07F861A680F5B00A75B9A /* xmtpreactnativesdkexample */;
targetProxy = A6A5DB8B2A00551E001DF8C2 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -486,6 +565,67 @@
};
name = Release;
};
A6A5DB8D2A00551E001DF8C2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = FY4NZR34Z3;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.xmtp.xmtpreactnativesdkexampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = xmtpreactnativesdkexample;
};
name = Debug;
};
A6A5DB8E2A00551E001DF8C2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = FY4NZR34Z3;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
MARKETING_VERSION = 1.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.xmtp.xmtpreactnativesdkexampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = xmtpreactnativesdkexample;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand All @@ -507,6 +647,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A6A5DB8F2A00551E001DF8C2 /* Build configuration list for PBXNativeTarget "xmtpreactnativesdkexampleUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A6A5DB8D2A00551E001DF8C2 /* Debug */,
A6A5DB8E2A00551E001DF8C2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@
ReferencedContainer = "container:xmtpreactnativesdkexample.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A6A5DB842A00551E001DF8C2"
BuildableName = "xmtpreactnativesdkexampleUITests.xctest"
BlueprintName = "xmtpreactnativesdkexampleUITests"
ReferencedContainer = "container:xmtpreactnativesdkexample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// xmtpreactnativesdkexampleUITests.swift
// xmtpreactnativesdkexampleUITests
//
// Created by Pat Nakajima on 5/1/23.
//

import XCTest

final class xmtpreactnativesdkexampleUITests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}

func testRunTests() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Go to unit tests page
let button = app.buttons["Unit tests"]
XCTAssert(button.waitForExistence(timeout: 3))
button.tap()

// Make sure we're there
let view = app.staticTexts["Test View"]
XCTAssert(view.waitForExistence(timeout: 3))

// Wait for tests to complete
let complete = app.staticTexts["tests-complete"]
XCTAssert(complete.waitForExistence(timeout: 5))

// See if we have any failures
if app.staticTexts["FAIL"].waitForExistence(timeout: 3) {
// Take a screenshot so we can see what failed in the UI
let screenshot = app.windows.firstMatch.screenshot()
let attachment = XCTAttachment(screenshot: screenshot)
attachment.lifetime = .keepAlways
add(attachment)

XCTFail("Tests failed.")
}
}
Comment on lines +21 to +49
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where we run the tests in Xcode, it's what should be run by xcode cloud when we set up CI.


}
7 changes: 4 additions & 3 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading