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

chore: implem new e2e tests #4504

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: e2e-tests
on:
push:
tags:
- v*
branches:
- master
paths:
- "go/**"
- "!go/**.md"
- "go.*"
- "**.go"
- "js/**"
- ".github/workflows/ios.yml"
pull_request:
paths:
- "go/**"
- "!go/**.md"
- "go.*"
- "**.go"
- "js/**"
- "!js/packages/i18n/locale/*/*.json"
- ".github/workflows/ios.yml"
workflow_run:
workflows: [Android]
types:
- completed
jobs:
mac_runner_matrix_builder:
name: macOS matrix builder
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Generate runner matrix (optimized)
id: set-matrix
run: |
# usage: node .github/workflows/mac-runner-matrix-builder.js STRATEGY
#
# STRATEGY
# self-hosted pick the self-hosted runner configuration
# github pick the github runner configuration
# optimized pick a dc4 runner if available or fallback on github one
#
node .github/workflows/utils/mac-runner-matrix-builder.js optimized
build:
needs: mac_runner_matrix_builder
name: e2e-tests
runs-on: ${{ matrix.runner }}
env:
E2E_TESTING_IOS_DEVICE: iPhone 11
E2E_TESTING_IOS_VERSION: 15.5
CACHE_DIRS: js/android/.gomobile-cache; js/ios/.gomobile-cache; js/ios/.xcodegen-cache
strategy:
fail-fast: false
matrix: ${{fromJson(needs.mac_runner_matrix_builder.outputs.matrix)}}
steps:
- name: Run e2e-tests
working-directory: js
run: |
make e2e-tests.ci-flow
7 changes: 1 addition & 6 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,11 @@ jobs:
working-directory: js
run: GOMOBILE_IOS_TARGET=iossimulator make ios.gomobile

- name: Build the app for e2e testing
- name: Build iOS app for e2e testing
working-directory: js/ios
run: |
xcodebuild \
-workspace Berty.xcworkspace \
-configuration "AppStore Release" \
-scheme "Berty AppStore" \
-destination "name=$E2E_TESTING_IOS_DEVICE"
- name: Run e2e-tests
working-directory: js
run: |
make e2e-tests.ci-flow
7 changes: 4 additions & 3 deletions js/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ YOLO_SUFFIX ?= Yolo
E2E_TESTING_IOS_DEVICE ?= iPhone 11
E2E_TESTING_IOS_VERSION ?= 15.5
E2E_GET_IOS_APP ?= $(shell ls -ladt1 "$(HOME)/Library/Developer/Xcode/DerivedData/"*"/Build/Products/AppStore Release-iphonesimulator/Berty.app" | head -n 1)

E2E_GET_ANDROID_APP ?= $(shell ls -ladt1 "$(HOME)/.android/app/build/outputs/apk/debug/app-x86-debug.apk")
## Internal variables

rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
Expand Down Expand Up @@ -92,15 +92,16 @@ e2e-tests.tests:
IOS_DEVICE="$(E2E_TESTING_IOS_DEVICE)" \
IOS_APP="$(if $(IOS_APP),$(IOS_APP),$(E2E_GET_IOS_APP))" \
IOS_VERSION="$(E2E_TESTING_IOS_VERSION)" \
node ./e2e-tests/src/tests/2-simulators/joinGroupAndSendMessage.js
ANDROID_APP="$(if $(ANDROID_APP),$(ANDROID_APP),$(E2E_GET_ANDROID_APP))" \
cd e2e-tests && npm test

.PHONY: e2e-tests.ci-flow
e2e-tests.ci-flow: e2e-tests/node_modules
$(call check-program, npx)
npx concurrently --kill-others -n server,tests -s 'command-tests' 'make e2e-tests.server' 'sleep 10; make e2e-tests.tests'

.PHONY: test
test: node_modules
test: node_modules e2e-tests/node_modules
$(call check-program, yarn)
yarn test --coverage

Expand Down
5 changes: 5 additions & 0 deletions js/e2e-tests/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"jest": true
}
}
40 changes: 25 additions & 15 deletions js/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,52 @@ cd ..
### Start appium

```sh
npx appium
make e2e-tests.server
```

### Environment

Example

```js
MAX_TYPING_FREQUENCY = 20 // Maximum frequency of keystrokes for typing and clear. Defaults to 60 keystrokes per minute
IOS_APP =
'/Users/norman/Library/Developer/Xcode/DerivedData/Berty-fhgkrmolfophlogtwrazqwhipyex/Build/Products/AppStore Release-iphonesimulator/Berty.app' // Full path to the application to be tested
ANDROID_APP =
'/Users/lucasdecurtis/berty_fork/js/android/app/build/outputs/apk/debug/app-x86-debug.apk' // Full path to the apk to be tested
IOS_VERSION = '15.5' // The platform version of an emulator or a real device
IOS_DEVICE = 'iPhone 11' // The name of the device under test
DEBUG_MODE = 'true' // Tell appium to handle the SelectNode screen that will show up when app is in debug mode
```

### Build the app

#### For IOS

```sh
make ios.release
```

You can close the simulator that started since we only want to build the app

Then grab the app path from the `info Installing` line in the command output, for example:
Then grab the app path from the `info Installing` line in the command output and add it in the .env file, for example:

```
info Installing "/Users/norman/Library/Developer/Xcode/DerivedData/Berty-fhgkrmolfophlogtwrazqwhipyex/Build/Products/AppStore Release-iphonesimulator/Berty.app"
```

### Run the test script
#### For Android

```sh
IOS_APP=<path-to-the-app> node e2e-tests/src/tests/testName.js
make android.release
```

#### Environment

Instead of passing variables, you can either create a .env file and set variables in it
You then need to get the path to apk which can be found in folder "js/android/app/build/outputs/apk" and add it in the .env file

Example
### Run the test script

```js
MAX_TYPING_FREQUENCY = 20 // Maximum frequency of keystrokes for typing and clear. Defaults to 60 keystrokes per minute
IOS_APP =
'/Users/norman/Library/Developer/Xcode/DerivedData/Berty-fhgkrmolfophlogtwrazqwhipyex/Build/Products/AppStore Release-iphonesimulator/Berty.app' // Full path to the application to be tested
ANDROID_APP = '' // Full path to the application to be tested
IOS_VERSION = '15.5' // The platform version of an emulator or a real device
IOS_DEVICE = 'iPhone 11' // The name of the device under test
```sh
make e2e-tests.tests
```

## Known errors
Expand Down