From 8991f25b7df3093f5c0fe78f99bbb7464a711124 Mon Sep 17 00:00:00 2001 From: AllanFly120 Date: Wed, 5 Aug 2020 16:02:30 -0700 Subject: [PATCH] test: add RN E2E test based on detox framework (#1383) * test: add RN integ test app * test: add RN test cases * chore: add RN test lock file * test: add RN test cases * chore: set up detox RN test lauching script * test: add S3 test cases on RN * chore: refactor rn test script for first-time runner * test: add pod install command * test: update README to RN integ test * test: update README with guidance to install simulator and clean workspace * chore: update lock file --- package.json | 1 + scripts/verdaccio-publish/index.js | 3 +- tests/react-native/End2End/.buckconfig | 6 + tests/react-native/End2End/.detoxrc.json | 14 + tests/react-native/End2End/.env.example | 5 + tests/react-native/End2End/.eslintrc.js | 4 + tests/react-native/End2End/.gitattributes | 1 + tests/react-native/End2End/.gitignore | 65 ++ tests/react-native/End2End/.npmrc | 1 + tests/react-native/End2End/.watchmanconfig | 1 + tests/react-native/End2End/App.tsx | 185 ++++ tests/react-native/End2End/README.md | 75 ++ .../End2End/__tests__/App-test.tsx | 14 + tests/react-native/End2End/android/app/_BUCK | 55 ++ .../End2End/android/app/build.gradle | 210 ++++ .../End2End/android/app/build_defs.bzl | 19 + .../End2End/android/app/proguard-rules.pro | 10 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 26 + .../main/java/com/end2end/MainActivity.java | 15 + .../java/com/end2end/MainApplication.java | 49 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/styles.xml | 9 + .../react-native/End2End/android/build.gradle | 38 + .../End2End/android/gradle.properties | 21 + .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55616 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + tests/react-native/End2End/android/gradlew | 188 ++++ .../react-native/End2End/android/gradlew.bat | 100 ++ .../End2End/android/settings.gradle | 3 + tests/react-native/End2End/app.json | 4 + tests/react-native/End2End/babel.config.js | 6 + .../End2End/e2e/End2EndTest.spec.js | 76 ++ tests/react-native/End2End/e2e/config.json | 7 + tests/react-native/End2End/e2e/environment.js | 23 + tests/react-native/End2End/index.js | 9 + .../End2End/ios/End2End-tvOS/Info.plist | 53 + .../End2End/ios/End2End-tvOSTests/Info.plist | 24 + .../ios/End2End.xcodeproj/project.pbxproj | 923 ++++++++++++++++++ .../xcschemes/End2End-tvOS.xcscheme | 129 +++ .../xcshareddata/xcschemes/End2End.xcscheme | 129 +++ .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../End2End/ios/End2End/AppDelegate.h | 15 + .../End2End/ios/End2End/AppDelegate.m | 42 + .../ios/End2End/Base.lproj/LaunchScreen.xib | 42 + .../AppIcon.appiconset/Contents.json | 38 + .../ios/End2End/Images.xcassets/Contents.json | 6 + .../End2End/ios/End2End/Info.plist | 57 ++ tests/react-native/End2End/ios/End2End/main.m | 16 + .../End2End/ios/End2EndTests/End2EndTests.m | 68 ++ .../End2End/ios/End2EndTests/Info.plist | 24 + tests/react-native/End2End/ios/Podfile | 47 + tests/react-native/End2End/ios/Podfile.lock | 187 ++++ tests/react-native/End2End/launch-app.js | 62 ++ tests/react-native/End2End/metro.config.js | 17 + tests/react-native/End2End/package.json | 48 + yarn.lock | 5 + 68 files changed, 3208 insertions(+), 1 deletion(-) create mode 100755 tests/react-native/End2End/.buckconfig create mode 100644 tests/react-native/End2End/.detoxrc.json create mode 100644 tests/react-native/End2End/.env.example create mode 100755 tests/react-native/End2End/.eslintrc.js create mode 100755 tests/react-native/End2End/.gitattributes create mode 100755 tests/react-native/End2End/.gitignore create mode 100644 tests/react-native/End2End/.npmrc create mode 100755 tests/react-native/End2End/.watchmanconfig create mode 100755 tests/react-native/End2End/App.tsx create mode 100644 tests/react-native/End2End/README.md create mode 100755 tests/react-native/End2End/__tests__/App-test.tsx create mode 100755 tests/react-native/End2End/android/app/_BUCK create mode 100755 tests/react-native/End2End/android/app/build.gradle create mode 100755 tests/react-native/End2End/android/app/build_defs.bzl create mode 100755 tests/react-native/End2End/android/app/proguard-rules.pro create mode 100755 tests/react-native/End2End/android/app/src/debug/AndroidManifest.xml create mode 100755 tests/react-native/End2End/android/app/src/main/AndroidManifest.xml create mode 100755 tests/react-native/End2End/android/app/src/main/java/com/end2end/MainActivity.java create mode 100755 tests/react-native/End2End/android/app/src/main/java/com/end2end/MainApplication.java create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100755 tests/react-native/End2End/android/app/src/main/res/values/strings.xml create mode 100755 tests/react-native/End2End/android/app/src/main/res/values/styles.xml create mode 100755 tests/react-native/End2End/android/build.gradle create mode 100755 tests/react-native/End2End/android/gradle.properties create mode 100755 tests/react-native/End2End/android/gradle/wrapper/gradle-wrapper.jar create mode 100755 tests/react-native/End2End/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 tests/react-native/End2End/android/gradlew create mode 100755 tests/react-native/End2End/android/gradlew.bat create mode 100755 tests/react-native/End2End/android/settings.gradle create mode 100755 tests/react-native/End2End/app.json create mode 100755 tests/react-native/End2End/babel.config.js create mode 100644 tests/react-native/End2End/e2e/End2EndTest.spec.js create mode 100644 tests/react-native/End2End/e2e/config.json create mode 100644 tests/react-native/End2End/e2e/environment.js create mode 100755 tests/react-native/End2End/index.js create mode 100755 tests/react-native/End2End/ios/End2End-tvOS/Info.plist create mode 100755 tests/react-native/End2End/ios/End2End-tvOSTests/Info.plist create mode 100644 tests/react-native/End2End/ios/End2End.xcodeproj/project.pbxproj create mode 100755 tests/react-native/End2End/ios/End2End.xcodeproj/xcshareddata/xcschemes/End2End-tvOS.xcscheme create mode 100755 tests/react-native/End2End/ios/End2End.xcodeproj/xcshareddata/xcschemes/End2End.xcscheme create mode 100644 tests/react-native/End2End/ios/End2End.xcworkspace/contents.xcworkspacedata create mode 100644 tests/react-native/End2End/ios/End2End.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100755 tests/react-native/End2End/ios/End2End/AppDelegate.h create mode 100755 tests/react-native/End2End/ios/End2End/AppDelegate.m create mode 100755 tests/react-native/End2End/ios/End2End/Base.lproj/LaunchScreen.xib create mode 100755 tests/react-native/End2End/ios/End2End/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100755 tests/react-native/End2End/ios/End2End/Images.xcassets/Contents.json create mode 100755 tests/react-native/End2End/ios/End2End/Info.plist create mode 100755 tests/react-native/End2End/ios/End2End/main.m create mode 100755 tests/react-native/End2End/ios/End2EndTests/End2EndTests.m create mode 100755 tests/react-native/End2End/ios/End2EndTests/Info.plist create mode 100755 tests/react-native/End2End/ios/Podfile create mode 100644 tests/react-native/End2End/ios/Podfile.lock create mode 100644 tests/react-native/End2End/launch-app.js create mode 100755 tests/react-native/End2End/metro.config.js create mode 100755 tests/react-native/End2End/package.json diff --git a/package.json b/package.json index 91ae1d990807..e52d3ae4058a 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "eslint-config-prettier": "6.11.0", "eslint-plugin-prettier": "3.1.4", "eslint-plugin-simple-import-sort": "5.0.3", + "figlet": "^1.5.0", "fs-extra": "^9.0.0", "generate-changelog": "^1.7.1", "husky": "^4.2.3", diff --git a/scripts/verdaccio-publish/index.js b/scripts/verdaccio-publish/index.js index 551108db0de9..1c3f561b098d 100644 --- a/scripts/verdaccio-publish/index.js +++ b/scripts/verdaccio-publish/index.js @@ -8,7 +8,7 @@ const { spawn, execSync } = require("child_process"); const pipeStdIo = { stdio: [process.stdin, process.stdout, process.stderr] }; -execSync("rm -rf verdaccio/storage/@aws-sdk"); +execSync("rm -rf verdaccio/storage"); // Start verdaccio in the background const verdaccio = spawn("npx", ["verdaccio", "-c", "verdaccio/config.yaml"], pipeStdIo).on("error", (e) => { @@ -21,6 +21,7 @@ const args = [ "lerna", "publish", "prerelease", + "--force-publish", "--preid", "ci", "--exact", diff --git a/tests/react-native/End2End/.buckconfig b/tests/react-native/End2End/.buckconfig new file mode 100755 index 000000000000..934256cb29d4 --- /dev/null +++ b/tests/react-native/End2End/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/tests/react-native/End2End/.detoxrc.json b/tests/react-native/End2End/.detoxrc.json new file mode 100644 index 000000000000..9ab7721f4d72 --- /dev/null +++ b/tests/react-native/End2End/.detoxrc.json @@ -0,0 +1,14 @@ +{ + "testRunner": "jest", + "runnerConfig": "e2e/config.json", + "configurations": { + "ios": { + "type": "ios.simulator", + "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/End2End.app", + "build": "xcodebuild -workspace ios/End2End.xcworkspace -scheme End2End -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", + "device": { + "type": "iPhone X" + } + } + } +} diff --git a/tests/react-native/End2End/.env.example b/tests/react-native/End2End/.env.example new file mode 100644 index 000000000000..73c4910e9679 --- /dev/null +++ b/tests/react-native/End2End/.env.example @@ -0,0 +1,5 @@ +# When building and testing the app, please rename this file to .env and replace the +# keys with proper resources +AWS_SMOKE_TEST_IDENTITY_POOL_ID=[identity-pool-id] +AWS_SMOKE_TEST_BUCKET=[bucket-name] +AWS_SMOKE_TEST_REGION=[region] \ No newline at end of file diff --git a/tests/react-native/End2End/.eslintrc.js b/tests/react-native/End2End/.eslintrc.js new file mode 100755 index 000000000000..5006dbb4f7af --- /dev/null +++ b/tests/react-native/End2End/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: "@react-native-community" +}; diff --git a/tests/react-native/End2End/.gitattributes b/tests/react-native/End2End/.gitattributes new file mode 100755 index 000000000000..d42ff18354df --- /dev/null +++ b/tests/react-native/End2End/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/tests/react-native/End2End/.gitignore b/tests/react-native/End2End/.gitignore new file mode 100755 index 000000000000..3385ed2b2fea --- /dev/null +++ b/tests/react-native/End2End/.gitignore @@ -0,0 +1,65 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots + +# Bundle artifact +*.jsbundle + +# CocoaPods +/ios/Pods/ + +.env +junit.xml + +# No need to track package SHA because of the testing local packages +yarn.lock \ No newline at end of file diff --git a/tests/react-native/End2End/.npmrc b/tests/react-native/End2End/.npmrc new file mode 100644 index 000000000000..c70e5286c8b3 --- /dev/null +++ b/tests/react-native/End2End/.npmrc @@ -0,0 +1 @@ +@aws-sdk:registry=http://localhost:4873/ \ No newline at end of file diff --git a/tests/react-native/End2End/.watchmanconfig b/tests/react-native/End2End/.watchmanconfig new file mode 100755 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/tests/react-native/End2End/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/react-native/End2End/App.tsx b/tests/react-native/End2End/App.tsx new file mode 100755 index 000000000000..d402deb7bd5f --- /dev/null +++ b/tests/react-native/End2End/App.tsx @@ -0,0 +1,185 @@ +/** + * Sample React Native App + * https://github.com/facebook/react-native + * + * Generated with the TypeScript template + * https://github.com/emin93/react-native-template-typescript + * + * @format + */ + +import React, { Fragment, useState } from "react"; +import { SafeAreaView, StyleSheet, ScrollView, StatusBar, Button, Text } from "react-native"; +import { S3 } from "@aws-sdk/client-s3"; +import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity"; +import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity"; +import { + //@ts-ignore imported ENVs are injected by Babel at compile time + AWS_SMOKE_TEST_IDENTITY_POOL_ID, + //@ts-ignore + AWS_SMOKE_TEST_REGION, + //@ts-ignore + AWS_SMOKE_TEST_BUCKET, +} from "react-native-dotenv"; + +const App = () => { + const [responseContent, setResponseContent] = useState(""); + const [uploadId, setUploadId] = useState(""); + const [uploadParts, setUploadParts] = useState>([]); + const s3 = new S3({ + credentials: fromCognitoIdentityPool({ + identityPoolId: AWS_SMOKE_TEST_IDENTITY_POOL_ID, + client: new CognitoIdentityClient({ + region: AWS_SMOKE_TEST_REGION, + }), + }), + region: AWS_SMOKE_TEST_REGION, + }); + const Key = `smoke-test-rn`; + + return ( + <> + + + + +