diff --git a/.circleci/config.yml b/.circleci/config.yml index 827b9e29b..248747b3a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,127 @@ defaults: &defaults working_directory: ~/repo -version: 2 +macos: &macos + macos: + xcode: "11.2.1" + +bash-env: &bash-env + BASH_ENV: "~/.nvm/nvm.sh" + +install-npm-modules: &install-npm-modules + name: Install NPM modules + command: yarn + +restore-npm-cache-linux: &restore-npm-cache-linux + name: Restore NPM cache + key: node-modules-{{ checksum "yarn.lock" }} + +save-npm-cache-linux: &save-npm-cache-linux + key: node-modules-{{ checksum "yarn.lock" }} + name: Save NPM cache + paths: + - ./node_modules + +restore-npm-cache-mac: &restore-npm-cache-mac + name: Restore NPM cache + key: node-v1-mac-{{ checksum "yarn.lock" }} + +save-npm-cache-mac: &save-npm-cache-mac + key: node-v1-mac-{{ checksum "yarn.lock" }} + name: Save NPM cache + paths: + - ./node_modules + +install-node: &install-node + name: Install Node 10 + command: | + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash + source ~/.nvm/nvm.sh + # https://github.com/creationix/nvm/issues/1394 + set +e + nvm install 10 + echo 'export PATH="/home/circleci/.nvm/versions/node/v10.20.1/bin:$PATH"' >> ~/.bash_profile + source ~/.bash_profile + +restore-gems-cache: &restore-gems-cache + name: Restore gems cache + key: bundle-v1-{{ checksum "ios/Gemfile.lock" }} + +save-gems-cache: &save-gems-cache + name: Save gems cache + key: bundle-v1-{{ checksum "ios/Gemfile.lock" }} + paths: + - vendor/bundle + +update-fastlane: &update-fastlane + name: Update Fastlane + command: | + echo "ruby-2.6.4" > ~/.ruby-version + bundle install + working_directory: ios + +restore-brew-cache: &restore-brew-cache + name: Restore Brew cache + key: brew-{{ checksum "yarn.lock" }}-{{ checksum ".circleci/config.yml" }} + +save-brew-cache: &save-brew-cache + name: Save brew cache + key: brew-{{ checksum "yarn.lock" }}-{{ checksum ".circleci/config.yml" }} + paths: + - /usr/local/Homebrew + +install-apple-sim-utils: &install-apple-sim-utils + name: Install appleSimUtils + command: | + brew update + brew tap wix/brew + brew install wix/brew/applesimutils + +rebuild-detox: &rebuild-detox + name: Rebuild Detox framework cache + command: | + npx detox clean-framework-cache + npx detox build-framework-cache + +version: 2.1 + +# EXECUTORS +executors: + mac-env: + <<: *macos + environment: + <<: *bash-env + +# COMMANDS +commands: + detox-test: + parameters: + folder: + type: string + steps: + - checkout + + - attach_workspace: + at: . + + - restore_cache: *restore-npm-cache-mac + + - restore_cache: *restore-brew-cache + + - run: *install-node + + - run: *install-apple-sim-utils + + - run: *install-npm-modules + + - run: *rebuild-detox + + - run: + name: Test + command: | + npx detox test << parameters.folder >> --configuration ios.sim.release --cleanup + +# JOBS jobs: lint-testunit: <<: *defaults @@ -14,14 +134,9 @@ jobs: steps: - checkout - - restore_cache: - name: Restore NPM cache - key: node-modules-{{ checksum "yarn.lock" }} + - restore_cache: *restore-npm-cache-linux - - run: - name: Install NPM modules - command: | - yarn + - run: *install-npm-modules - run: name: Lint @@ -38,162 +153,79 @@ jobs: command: | yarn codecov - - save_cache: - key: node-modules-{{ checksum "yarn.lock" }} - name: Save NPM cache - paths: - - ./node_modules + - save_cache: *save-npm-cache-linux + # E2E e2e-build: - macos: - xcode: "11.2.1" - - environment: - BASH_ENV: "~/.nvm/nvm.sh" + executor: mac-env steps: - checkout - - restore_cache: - name: Restore NPM cache - key: node-v1-mac-{{ checksum "yarn.lock" }} + - restore_cache: *restore-npm-cache-mac - - run: - name: Install Node 10 - command: | - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash - source ~/.nvm/nvm.sh - # https://github.com/creationix/nvm/issues/1394 - set +e - nvm install 10 + - restore_cache: *restore-brew-cache - - run: - name: Install appleSimUtils - command: | - brew update - brew tap wix/brew - brew install wix/brew/applesimutils + - run: *install-node - - run: - name: Install NPM modules - command: | - yarn global add detox-cli - yarn + - run: *install-apple-sim-utils - - run: - name: Rebuild Detox framework cache - command: | - detox clean-framework-cache - detox build-framework-cache + - run: *install-npm-modules + + - run: *rebuild-detox - run: name: Build command: | - detox build --configuration ios.sim.release + npx detox build --configuration ios.sim.release - persist_to_workspace: root: . paths: - ios/build/Build/Products/Release-iphonesimulator/RocketChatRN.app - - save_cache: - name: Save NPM cache - key: node-v1-mac-{{ checksum "yarn.lock" }} - paths: - - node_modules + - save_cache: *save-npm-cache-mac - e2e-test: - macos: - xcode: "11.2.1" - - environment: - BASH_ENV: "~/.nvm/nvm.sh" + - save_cache: *save-brew-cache + e2e-test-onboarding: + executor: mac-env steps: - - checkout + - detox-test: + folder: "./e2e/tests/onboarding" - - attach_workspace: - at: . + e2e-test-room: + executor: mac-env + steps: + - detox-test: + folder: "./e2e/tests/room" - - restore_cache: - name: Restore NPM cache - key: node-v1-mac-{{ checksum "yarn.lock" }} - - - run: - name: Install Node 10 - command: | - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash - source ~/.nvm/nvm.sh - # https://github.com/creationix/nvm/issues/1394 - set +e - nvm install 10 - - - run: - name: Install appleSimUtils - command: | - brew update - brew tap wix/brew - brew install wix/brew/applesimutils - - - run: - name: Install NPM modules - command: | - yarn global add detox-cli - yarn - - - run: - name: Rebuild Detox framework cache - command: | - detox clean-framework-cache - detox build-framework-cache - - - run: - name: Test - command: | - detox test --configuration ios.sim.release --cleanup - - - save_cache: - name: Save NPM cache - key: node-v1-mac-{{ checksum "yarn.lock" }} - paths: - - node_modules + e2e-test-assorted: + executor: mac-env + steps: + - detox-test: + folder: "./e2e/tests/assorted" + # Android builds android-build: <<: *defaults docker: - image: circleci/android:api-28-node environment: - # GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError" - # GRADLE_OPTS: -Xmx2048m -Dorg.gradle.daemon=false - # JVM_OPTS: -Xmx4096m JAVA_OPTS: '-Xms512m -Xmx2g' GRADLE_OPTS: '-Xmx3g -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx2g -XX:+HeapDumpOnOutOfMemoryError"' TERM: dumb - BASH_ENV: "~/.nvm/nvm.sh" + <<: *bash-env steps: - checkout - - run: - name: Install Node 10 - command: | - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash - source ~/.nvm/nvm.sh - # https://github.com/creationix/nvm/issues/1394 - set +e - nvm install 10 - echo 'export PATH="/home/circleci/.nvm/versions/node/v10.20.1/bin:$PATH"' >> ~/.bash_profile - source ~/.bash_profile + - run: *install-node - - restore_cache: - name: Restore NPM cache - key: node-modules-{{ checksum "yarn.lock" }} + - restore_cache: *restore-npm-cache-linux - - run: - name: Install NPM modules - command: | - yarn + - run: *install-npm-modules - restore_cache: name: Restore gradle cache @@ -261,11 +293,7 @@ jobs: - store_artifacts: path: /tmp/build/outputs - - save_cache: - name: Save NPM cache - key: node-modules-{{ checksum "yarn.lock" }} - paths: - - ./node_modules + - save_cache: *save-npm-cache-linux - save_cache: name: Save gradle cache @@ -273,44 +301,22 @@ jobs: paths: - ~/.gradle + # iOS builds ios-build: - macos: - xcode: "11.2.1" - - environment: - BASH_ENV: "~/.nvm/nvm.sh" + executor: mac-env steps: - checkout - - restore_cache: - name: Restore gems cache - key: bundle-v1-{{ checksum "ios/Gemfile.lock" }} + - restore_cache: *restore-gems-cache - - restore_cache: - name: Restore NPM cache - key: node-v1-mac-{{ checksum "yarn.lock" }} + - restore_cache: *restore-npm-cache-mac - - run: - name: Install Node 10 - command: | - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash - source ~/.nvm/nvm.sh - # https://github.com/creationix/nvm/issues/1394 - set +e - nvm install 10 + - run: *install-node - - run: - name: Install NPM modules - command: | - yarn + - run: *install-npm-modules - - run: - name: Update Fastlane - command: | - echo "ruby-2.6.4" > ~/.ruby-version - bundle install - working_directory: ios + - run: *update-fastlane - run: name: Set Google Services @@ -348,17 +354,9 @@ jobs: fi working_directory: ios - - save_cache: - name: Save NPM cache - key: node-v1-mac-{{ checksum "yarn.lock" }} - paths: - - node_modules + - save_cache: *save-npm-cache-mac - - save_cache: - name: Save gems cache - key: bundle-v1-{{ checksum "ios/Gemfile.lock" }} - paths: - - vendor/bundle + - save_cache: *save-gems-cache - store_artifacts: path: ios/RocketChatRN.ipa @@ -370,8 +368,7 @@ jobs: - ios/fastlane/report.xml ios-testflight: - macos: - xcode: "11.2.1" + executor: mac-env steps: - checkout @@ -379,16 +376,9 @@ jobs: - attach_workspace: at: ios - - restore_cache: - name: Restore gems cache - key: bundle-v1-{{ checksum "ios/Gemfile.lock" }} + - restore_cache: *restore-gems-cache - - run: - name: Update Fastlane - command: | - echo "ruby-2.4" > ~/.ruby-version - bundle install - working_directory: ios + - run: *update-fastlane - run: name: Fastlane Tesflight Upload @@ -396,14 +386,9 @@ jobs: bundle exec fastlane ios beta working_directory: ios - - save_cache: - name: Save gems cache - key: bundle-v1-{{ checksum "ios/Gemfile.lock" }} - paths: - - vendor/bundle + - save_cache: *save-gems-cache workflows: - version: 2 build-and-test: jobs: - lint-testunit @@ -415,7 +400,13 @@ workflows: - e2e-build: requires: - e2e-hold - - e2e-test: + - e2e-test-onboarding: + requires: + - e2e-build + - e2e-test-room: + requires: + - e2e-build + - e2e-test-assorted: requires: - e2e-build diff --git a/README.md b/README.md index bcae9f99d..1f0c5deea 100644 --- a/README.md +++ b/README.md @@ -208,13 +208,15 @@ Readme will guide you on how to config. - Build your app ```bash -$ detox build --configuration ios.sim.release +$ npx detox build --configuration ios.sim.release ``` - Run tests ```bash -$ detox test --configuration ios.sim.release +$ npx detox test ./e2e/tests/onboarding --configuration ios.sim.release +$ npx detox test ./e2e/tests/room --configuration ios.sim.release +$ npx detox test ./e2e/tests/assorted --configuration ios.sim.release ``` ## Storybook diff --git a/app/containers/FormContainer.js b/app/containers/FormContainer.js index fda039765..763e98df6 100644 --- a/app/containers/FormContainer.js +++ b/app/containers/FormContainer.js @@ -23,7 +23,7 @@ export const FormContainerInner = ({ children }) => ( ); -const FormContainer = ({ children, theme }) => ( +const FormContainer = ({ children, theme, testID }) => ( ( > - + {children} @@ -41,6 +41,7 @@ const FormContainer = ({ children, theme }) => ( FormContainer.propTypes = { theme: PropTypes.string, + testID: PropTypes.string, children: PropTypes.element }; diff --git a/app/containers/TwoFactor/index.js b/app/containers/TwoFactor/index.js index 3d1c9fe6d..0f32d2e2d 100644 --- a/app/containers/TwoFactor/index.js +++ b/app/containers/TwoFactor/index.js @@ -92,7 +92,7 @@ const TwoFactor = React.memo(({ theme, split }) => { isVisible={visible} hideModalContentWhileAnimating > - + {I18n.t(method?.title || 'Two_Factor_Authentication')} {method?.text ? {I18n.t(method.text)} : null} @@ -106,6 +106,7 @@ const TwoFactor = React.memo(({ theme, split }) => { keyboardType={method?.keyboardType} secureTextEntry={method?.secureTextEntry} error={data.invalid && { error: 'totp-invalid', reason: I18n.t('Code_or_password_invalid') }} + testID='two-factor-input' /> {isEmail && {I18n.t('Send_me_the_code_again')}} @@ -123,6 +124,7 @@ const TwoFactor = React.memo(({ theme, split }) => { style={styles.button} onPress={onSubmit} theme={theme} + testID='two-factor-send' /> diff --git a/app/sagas/messages.js b/app/sagas/messages.js index 75ba17069..1b815fd5f 100644 --- a/app/sagas/messages.js +++ b/app/sagas/messages.js @@ -27,10 +27,12 @@ const handleReplyBroadcast = function* handleReplyBroadcast({ message }) { rid: subscriptions[0].rid, name: username, fname: name, message }); } else { - const room = yield RocketChat.createDirectMessage(username); - yield goRoom({ - rid: room.rid, name: username, fname: name, message - }); + const result = yield RocketChat.createDirectMessage(username); + if (result?.success) { + yield goRoom({ + rid: result?.room.rid, t: 'd', name: username, fname: name, message + }); + } } } catch (e) { log(e); diff --git a/app/views/ForgotPasswordView.js b/app/views/ForgotPasswordView.js index 698d1c7f1..d767afab6 100644 --- a/app/views/ForgotPasswordView.js +++ b/app/views/ForgotPasswordView.js @@ -85,7 +85,7 @@ class ForgotPasswordView extends React.Component { const { theme } = this.props; return ( - + {I18n.t('Forgot_password')} + {this.renderUserForm()} diff --git a/app/views/NewServerView.js b/app/views/NewServerView.js index efea48c1d..cb82c58df 100644 --- a/app/views/NewServerView.js +++ b/app/views/NewServerView.js @@ -69,7 +69,7 @@ class NewServerView extends React.Component { const previousServer = navigation.getParam('previousServer', null); const close = navigation.getParam('close', () => {}); return { - headerLeft: previousServer ? : undefined, + headerLeft: previousServer ? : undefined, title: I18n.t('Workspaces'), ...themedHeader(screenProps.theme) }; @@ -297,7 +297,7 @@ class NewServerView extends React.Component { const { connecting, theme } = this.props; const { text, connectingOpen } = this.state; return ( - + {I18n.t('Join_your_workspace')} {I18n.t('Onboarding_join_open_description')} @@ -334,6 +334,7 @@ class NewServerView extends React.Component { disabled={connecting} loading={connectingOpen && connecting} theme={theme} + testID='new-server-view-open' /> { isIOS ? this.renderCertificatePicker() : null } diff --git a/app/views/OnboardingView/index.js b/app/views/OnboardingView/index.js index 921efd9db..3db267505 100644 --- a/app/views/OnboardingView/index.js +++ b/app/views/OnboardingView/index.js @@ -68,7 +68,7 @@ class OnboardingView extends React.Component { render() { const { theme } = this.props; return ( - + {I18n.t('Onboarding_title')} @@ -80,6 +80,7 @@ class OnboardingView extends React.Component { type='primary' onPress={this.connectServer} theme={theme} + testID='join-workspace' />