diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..0ee3cf612ef70c517cec058d38f12cfb66846ef8 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,26 @@ + +version: 2 +jobs: + build: + macos: + xcode: "10.2.1" + steps: + - checkout + - run: + name: Install Dependencies + command: scripts/install.ios.sh + - run: + name: Install Android + command: scripts/install.android.sh + - run: + name: npm install + command: npm install + - run: + name: iOS unit tests + command: 'npm run test-unit-ios' + - run: + name: Android unit tests + command: 'npm run test-unit-android' + - run: + name: Detox iOS e2e tests + command: 'npm run test-e2e-ios-release' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 45555037ee11931d2b338a3f2d39649732c224a8..6fb4c82d243c9d3f55efc591c427c37e187ea14d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: node_js +osx_image: xcode10.1 node_js: - "10" diff --git a/README.md b/README.md index 173f7a61af8d01e4884eaba6373ef8ee671eecf9..21eeeb1906f3656d9dae657a9833b5716460c6ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# React Native Notifications [![Build Status](https://travis-ci.org/wix/react-native-notifications.svg)](https://travis-ci.org/wix/react-native-notifications) +# React Native Notifications [![CircleCI](https://circleci.com/gh/wix/react-native-notifications/tree/master.svg?style=svg)](https://circleci.com/gh/wix/react-native-notifications/tree/master) Handle all the aspects of push notifications for your app, including remote and local notifications, interactive notifications, silent notifications, and more. diff --git a/e2e/Notifications.test.js b/e2e/Notifications.test.js index fd39b4e20ceb7d3b332ac9b9a3713c44e4f9f048..d6ede1100e04d84eff2674f7388cc1dd4f099751 100644 --- a/e2e/Notifications.test.js +++ b/e2e/Notifications.test.js @@ -1,38 +1,34 @@ const Utils = require('./Utils'); -const { elementByLabel } = Utils; +const {elementByLabel} = Utils; describe('Notifications', () => { - describe('Foreground', () => { - beforeEach(async () => { - await device.relaunchApp({permissions: {notifications: 'YES'}}); - }); + beforeEach(async () => { + await device.relaunchApp({delete: true, permissions: {notifications: 'YES'}}); + }); - it('Receive notification', async () => { + describe('Foreground', () => { + it('Should receive notification', async () => { await device.sendUserNotification(createNotification({link: 'foreground/notification'})); await expect(elementByLabel('foreground/notification')).toBeVisible(); }); - it('Click notification', async () => { + it('Should open notification', async () => { await device.sendUserNotification(createNotification({link: 'foreground/notification/click', showAlert: true})); await expect(elementByLabel('Notification Clicked: foreground/notification/click')).toBeVisible(); }); }); describe('Background', () => { - beforeEach(async () => { - await device.launchApp({newInstance: true, permissions: {notifications: 'YES'}}); - }); - - it('Receive notification', async () => { - device.sendToHome(); - await expect(elementByLabel('background/notification')).toBeNotVisible(); - device.launchApp({newInstance: false, userNotification: createNotification({link: 'background/notification'})}); - await expect(elementByLabel('background/notification')).toBeVisible(); + it('Should open notification', async () => { + await device.sendToHome(); + await expect(elementByLabel('Notification Clicked: background/notification')).toBeNotVisible(); + await device.launchApp({newInstance: false, userNotification: createNotification({link: 'background/notification'})}); + await expect(elementByLabel('Notification Clicked: background/notification')).toBeVisible(); }); }); describe('Dead state', () => { - it('Receive notification', async () => { + it('Should receive notification', async () => { await device.launchApp({newInstance: true, userNotification: createNotification({link: 'deadState/notification'})}); await expect(elementByLabel('deadState/notification')).toBeVisible(); }); diff --git a/example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp_release.xcscheme b/example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp_release.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..10ca932eac0762b2b5426a6ced5067a2b26dcf39 --- /dev/null +++ b/example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp_release.xcscheme @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json index cbf8e0452d309b36907019a5e948e88a5ecf40af..3abce21519e51ad245be980228e9c1d28296572c 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,10 @@ "main": "lib/src/index", "scripts": { "pretest": "./node_modules/.bin/eslint *.js test", - "test": "jest", + "test": "node scripts/test", "start": "node ./scripts/start", "test-e2e-ios": "node ./scripts/test-e2e --ios", + "test-e2e-ios-release": "node ./scripts/test-e2e --ios --release", "test-unit-ios": "node ./scripts/test-unit --ios", "test-unit-android": "node ./scripts/test-unit --android", "test-js": "node ./scripts/test-js" @@ -92,8 +93,8 @@ "name": "iPhone X" }, "ios.sim.release": { - "binaryPath": "playground/ios/DerivedData/playground/Build/Products/Release-iphonesimulator/playground.app", - "build": "RCT_NO_LAUNCH_PACKAGER=true xcodebuild build -scheme playground_release -project playground/ios/playground.xcodeproj -sdk iphonesimulator -configuration Release -derivedDataPath playground/ios/DerivedData/playground ONLY_ACTIVE_ARCH=YES -quiet -UseModernBuildSystem=NO", + "binaryPath": "example/ios/DerivedData/NotificationsExampleApp/Build/Products/Release-iphonesimulator/NotificationsExampleApp.app", + "build": "RCT_NO_LAUNCH_PACKAGER=true xcodebuild build -scheme NotificationsExampleApp_release -project example/ios/NotificationsExampleApp.xcodeproj -sdk iphonesimulator -configuration Release -derivedDataPath example/ios/DerivedData/NotificationsExampleApp ONLY_ACTIVE_ARCH=YES -quiet -UseModernBuildSystem=NO", "type": "ios.simulator", "name": "iPhone X" } diff --git a/scripts/install.android.sh b/scripts/install.android.sh new file mode 100755 index 0000000000000000000000000000000000000000..321a015f73cc9d2e9c6be9ab76c04473b0e28676 --- /dev/null +++ b/scripts/install.android.sh @@ -0,0 +1,40 @@ +#!/bin/bash -e +echo node -v $(node -v) + +$(dirname "$0")/install.sh + +if [ -z "$ZZ_BITRISE" ]; then +ANDROID_API=28 +ANDROID_HOME="/usr/local/share/android-sdk" +echo "export ANDROID_API=${ANDROID_API}" >> $BASH_ENV +echo "export ANDROID_HOME=${ANDROID_HOME}" >> $BASH_ENV + +cat $BASH_ENV + +# jdk +HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew untap adoptopenjdk/openjdk +HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew cask install adoptopenjdk8 + +export PATH="$PATH:$ANDROID_HOME/tools/bin" + +# set variables +ANDROID_SDK_URL="https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip" +TMP_DIR=$(mktemp -d) + +# download and install sdk +cd "$TMP_DIR" +curl "$ANDROID_SDK_URL" > "sdk.zip" +unzip "sdk.zip" -d "$ANDROID_HOME" + +# install what you need +yes | sdkmanager --licenses || : +echo y | sdkmanager "platforms;android-${ANDROID_API}" +echo y | sdkmanager "platform-tools" +echo y | sdkmanager "build-tools;28.0.3" +echo y | sdkmanager "extras;android;m2repository" +echo y | sdkmanager "extras;google;m2repository" +echo y | sdkmanager "system-images;android-${ANDROID_API};google_apis;x86_64" +echo y | sdkmanager "extras;intel;Hardware_Accelerated_Execution_Manager" +echo y | sdkmanager "extras;google;google_play_services" +echo no | avdmanager create avd --force --name Nexus_5X_API_${ANDROID_API} --abi x86_64 --device "Nexus 5X" -k "system-images;android-${ANDROID_API};google_apis;x86_64" +fi \ No newline at end of file diff --git a/scripts/install.ios.sh b/scripts/install.ios.sh new file mode 100755 index 0000000000000000000000000000000000000000..5fac98ed379db41aa78d82b5732f4432e472d8ee --- /dev/null +++ b/scripts/install.ios.sh @@ -0,0 +1,12 @@ +#!/bin/bash -e + +$(dirname "$0")/install.sh + +HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install ruby +export PATH="/usr/local/opt/ruby/bin:$PATH" +gem install xcpretty +export CODE_SIGNING_REQUIRED=NO +HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew +HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils + +echo 'export PATH=$PATH' >> $BASH_ENV \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..9b65356b0c15e137d346b3276133c94827098e64 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +npm install -g react-native-cli +npm install -g detox-cli +git submodule update --init --recursive diff --git a/scripts/test.js b/scripts/test.js new file mode 100644 index 0000000000000000000000000000000000000000..2f4ad9f637c40be3c3a9edab9e838c00e3bacb82 --- /dev/null +++ b/scripts/test.js @@ -0,0 +1,9 @@ +const exec = require('shell-utils').exec; + +run(); + +function run() { + exec.execSync(`jest`); + exec.execSync(`npm run test-unit-ios`); + exec.execSync(`npm run test-unit-android`); +}