Skip to content

Commit cdc6eb5

Browse files
Merge pull request #9 from synonymdev/e2e-tests
E2e iOS tests
2 parents 17c0e74 + 89cce08 commit cdc6eb5

File tree

26 files changed

+26782
-637
lines changed

26 files changed

+26782
-637
lines changed

.github/scripts/test-ios.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
#Start metro server
6+
yarn start &
7+
P1=$!
8+
#perform tests
9+
yarn e2e:ios-test &
10+
P2=$!
11+
#wait for tests to finish
12+
wait $P2
13+
#kill metro server
14+
kill $P1

.github/workflows/e2e-ios.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: e2e-ios
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
e2e-test:
10+
name: E2E iOS test
11+
runs-on: macOS-latest
12+
timeout-minutes: 35
13+
14+
steps:
15+
- name: Check out Git repository
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 14
22+
23+
- name: Cache lib node modules
24+
uses: actions/cache@v3
25+
id: lib-npmcache
26+
with:
27+
path: node_modules
28+
key: node-modules-${{ hashFiles('**/yarn.lock') }}
29+
30+
- name: Install lib dependencies
31+
if: steps.lib-npmcache.outputs.cache-hit != 'true'
32+
run: yarn install
33+
34+
- name: Build lib
35+
run: yarn build
36+
37+
- name: Cache app node modules
38+
uses: actions/cache@v3
39+
id: app-npmcache
40+
with:
41+
path: example/node_modules
42+
key: node-modules-${{ hashFiles('**/yarn.lock') }}
43+
44+
- name: Rebuild detox
45+
if: steps.app-npmcache.outputs.cache-hit == 'true'
46+
working-directory: example
47+
run: yarn detox clean-framework-cache && yarn detox build-framework-cache
48+
49+
- name: Install app dependencies
50+
if: steps.app-npmcache.outputs.cache-hit != 'true'
51+
working-directory: example
52+
run: yarn install
53+
54+
- name: Cache Pods
55+
uses: actions/cache@v3
56+
id: podcache
57+
with:
58+
path: example/ios/Pods
59+
key: pods-${{ hashFiles('**/Podfile.lock') }}
60+
61+
- name: Install pods and rn-nodify
62+
working-directory: example
63+
run: |
64+
gem update cocoapods xcodeproj
65+
yarn rn-setup
66+
67+
- name: Install brew dependencies
68+
run: brew tap wix/brew && brew install applesimutils
69+
70+
- name: Build iOS app
71+
working-directory: example
72+
run: yarn e2e:ios-build
73+
74+
- name: Test iOS app
75+
working-directory: example
76+
run: sh ../.github/scripts/test-ios.sh

.github/workflows/lint-check.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,3 @@ jobs:
2424

2525
- name: Lint check
2626
run: yarn lint:check
27-
28-
- name: Run linters
29-
uses: tinovyatkin/action-eslint@v1
30-
with:
31-
repo-token: ${{secrets.GITHUB_TOKEN}}
32-
check-name: eslint

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ android/build/
88
android/local.properties
99
android/.gradle/
1010
yarn-error.log
11+
example/.watchman*
12+
example/*.log

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def getExtOrIntegerDefault(name) {
2929
android {
3030
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
3131
defaultConfig {
32-
minSdkVersion 16
32+
minSdkVersion 21
3333
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
3434
versionCode 1
3535
versionName "1.0"

example/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module.exports = {
22
root: true,
33
extends: '@react-native-community',
44
parser: '@typescript-eslint/parser',
5+
env: {
6+
jest: true,
7+
},
58
plugins: ['@typescript-eslint'],
69
globals: {
710
localStorage: false,

example/App.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const App = (): ReactElement => {
5656
<ScrollView
5757
contentInsetAdjustmentBehavior="automatic"
5858
style={styles.scrollView}>
59+
<Text style={styles.text}>react-native-ldk</Text>
5960
<View style={styles.messageContainer}>
6061
<Text style={styles.text}>{message}</Text>
6162
</View>
@@ -264,6 +265,24 @@ const App = (): ReactElement => {
264265
setMessage(ldkVersion.value.ldk);
265266
}}
266267
/>
268+
269+
<Button
270+
title={'E2E test'}
271+
onPress={async (): Promise<void> => {
272+
//TODO add more functionality to test
273+
const ldkVersion = await ldk.version();
274+
if (ldkVersion.isErr()) {
275+
return setMessage(ldkVersion.error.message);
276+
}
277+
278+
const nodeIdRes = await ldk.nodeId();
279+
if (nodeIdRes.isErr()) {
280+
return setMessage(nodeIdRes.error.message);
281+
}
282+
283+
return setMessage('e2e success');
284+
}}
285+
/>
267286
</View>
268287
</ScrollView>
269288
</SafeAreaView>

example/android/app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ android {
143143
multiDexEnabled true
144144
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
145145

146+
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
147+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
148+
missingDimensionStrategy 'detox', 'full'
149+
146150
if (isNewArchitectureEnabled()) {
147151
// We configure the NDK build only if you decide to opt-in for the New Architecture.
148152
externalNativeBuild {
@@ -240,6 +244,7 @@ android {
240244
signingConfig signingConfigs.debug
241245
minifyEnabled enableProguardInReleaseBuilds
242246
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
247+
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" // Detox
243248
}
244249
}
245250

@@ -262,6 +267,8 @@ android {
262267

263268
dependencies {
264269
implementation files("../../node_modules/@synonymdev/react-native-ldk/android/libs/LDK-release.aar")
270+
androidTestImplementation(project(path: ":detox"))
271+
implementation 'androidx.appcompat:appcompat:1.4.2'
265272
implementation fileTree(dir: "libs", include: ["*.jar"])
266273

267274
//noinspection GradleDynamicVersion
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.example;
2+
3+
import com.wix.detox.Detox;
4+
import com.wix.detox.config.DetoxConfig;
5+
6+
import org.junit.Rule;
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import androidx.test.ext.junit.runners.AndroidJUnit4;
11+
import androidx.test.filters.LargeTest;
12+
import androidx.test.rule.ActivityTestRule;
13+
14+
@RunWith(AndroidJUnit4.class)
15+
@LargeTest
16+
public class DetoxTest {
17+
// Replace 'MainActivity' with the value of android:name entry in
18+
// <activity> in AndroidManifest.xml
19+
@Rule
20+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
21+
22+
@Test
23+
public void runDetoxTests() {
24+
// This is optional - in case you've decided to integrate TestButler
25+
// See https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#8-test-butler-support-optional
26+
// TestButlerProbe.assertReadyIfInstalled();
27+
28+
DetoxConfig detoxConfig = new DetoxConfig();
29+
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
30+
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
31+
detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60);
32+
33+
Detox.runTests(mActivityRule, detoxConfig);
34+
}
35+
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:icon="@mipmap/ic_launcher"
1010
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:allowBackup="false"
12-
android:theme="@style/AppTheme">
12+
android:theme="@style/AppTheme"
13+
android:networkSecurityConfig="@xml/network_security_config">
1314
<activity
1415
android:name=".MainActivity"
1516
android:label="@string/app_name"

0 commit comments

Comments
 (0)