Skip to content

Commit a24e749

Browse files
Wiktor Jaszczukmateusz1913
authored andcommitted
test: e2e tests for bare-example app, wired with GH Actions
1 parent 3ebc1bf commit a24e749

12 files changed

Lines changed: 385 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Install Maestro
2+
description: Install Maestro
3+
4+
inputs:
5+
target-platform:
6+
description: 'Target platform like ios or android'
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Install Maestro CLI
13+
shell: bash
14+
run: |
15+
export MAESTRO_VERSION=1.40.3
16+
curl -Ls "https://get.maestro.mobile.dev" | bash
17+
18+
- name: Conditionally install brew packages for iOS
19+
shell: bash
20+
run: |
21+
if [[ "${{ inputs.target-platform }}" == "ios" ]]; then
22+
echo "Installing brew packages for iOS..."
23+
brew tap facebook/fb
24+
brew install facebook/fb/idb-companion
25+
else
26+
echo "Skipping brew install because target platform is ${{ inputs.target-platform }}"
27+
fi
28+
29+
- name: Add Maestro to path
30+
shell: bash
31+
run: echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Upload Maestro test results
2+
description: Upload Maestro test results as artifacts
3+
4+
inputs:
5+
id:
6+
description: 'artifact ID'
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Test Report
13+
uses: dorny/test-reporter@v2
14+
continue-on-error: true
15+
with:
16+
name: Maestro E2E test report ${{ inputs.id }}
17+
path: ${{ github.workspace }}/examples/bare-example/e2e_results/report.xml
18+
reporter: java-junit
19+
20+
- name: Upload report
21+
uses: actions/upload-artifact@v4
22+
continue-on-error: true
23+
with:
24+
name: Maestro E2E recordings and screenshots ${{ inputs.id }}
25+
path: |
26+
${{ github.workspace }}/examples/bare-example/e2e_results/*.mp4
27+
${{ github.workspace }}/examples/bare-example/e2e_results/*.png
28+
29+
- name: Upload report
30+
uses: actions/upload-artifact@v4
31+
continue-on-error: true
32+
with:
33+
name: Maestro E2E test logs API ${{ inputs.id }}
34+
path: |
35+
~/.maestro/tests/**
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: E2E tests - Android
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '.github/workflows/test-e2e-android.yaml'
9+
- 'packages/react-native-legal/**/*.[tj]sx?'
10+
- 'packages/react-native-legal/android/**'
11+
- 'examples/bare-example/**/*.[tj]sx?'
12+
- 'examples/bare-example/android/**'
13+
14+
push:
15+
branches:
16+
- main
17+
18+
workflow_dispatch:
19+
20+
concurrency:
21+
group: e2e_tests-android-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
env:
25+
MAESTRO_CLI_NO_ANALYTICS: true
26+
MAESTRO_CLI_ANALYSIS_NOTIFICATION_DISABLED: true
27+
MAESTRO_DISABLE_UPDATE_CHECK: true
28+
29+
jobs:
30+
e2e-android:
31+
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
api-level: [ 30, 34, 35 ]
36+
steps:
37+
- name: Enable KVM group perms
38+
run: |
39+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
40+
sudo udevadm control --reload-rules
41+
sudo udevadm trigger --name-match=kvm
42+
43+
- name: Checkout Repo
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup
49+
uses: ./.github/actions/setup
50+
51+
- name: Install Maestro
52+
uses: ./.github/actions/installMaestro
53+
with:
54+
target-platform: android
55+
56+
- name: Cache Build
57+
id: cache-build
58+
uses: actions/cache@v4
59+
env:
60+
cache-name: cached-android-build
61+
with:
62+
path: |
63+
examples/bare-example/android/build
64+
examples/bare-example/android/app/build
65+
examples/bare-example/android/app/.cxx
66+
key: bare-example-android-build
67+
68+
- uses: actions/setup-java@v4
69+
with:
70+
distribution: 'zulu'
71+
java-version: '17'
72+
cache: 'gradle'
73+
74+
- name: Gradle cache
75+
uses: gradle/actions/setup-gradle@v3
76+
77+
- name: Install example dependencies
78+
run: yarn workspace react-native-legal-bare-example install --frozen-lockfile --immutable
79+
80+
- name: Bundle app
81+
run: yarn workspace react-native-legal-bare-example build:android
82+
83+
- name: Create AVD and generate snapshot for caching
84+
uses: reactivecircus/android-emulator-runner@v2
85+
with:
86+
api-level: ${{ matrix.api-level }}
87+
arch: 'x86_64'
88+
target: 'google_apis'
89+
force-avd-creation: true
90+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
91+
disable-animations: false
92+
script: ./scripts/e2e_android_emulator_build_and_test.sh
93+
94+
- name: Upload report
95+
if: always()
96+
continue-on-error: true
97+
uses: ./.github/actions/uploadMaestroTestResults
98+
with:
99+
id: API ${{ matrix.api-level }}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: E2E tests - iOS
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '.github/workflows/test-e2e-ios.yaml'
9+
- 'packages/react-native-legal/**/*.[tj]sx?'
10+
- 'packages/react-native-legal/ios/**'
11+
- 'examples/bare-example/**/*.[tj]sx?'
12+
- 'examples/bare-example/ios/**'
13+
14+
push:
15+
branches:
16+
- main
17+
18+
workflow_dispatch:
19+
20+
env:
21+
MAESTRO_CLI_NO_ANALYTICS: true
22+
MAESTRO_CLI_ANALYSIS_NOTIFICATION_DISABLED: true
23+
MAESTRO_DISABLE_UPDATE_CHECK: true
24+
25+
concurrency:
26+
group: e2e_tests-ios-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
e2e-ios:
31+
runs-on: macos-15
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
simulator: [ 'iPhone 16 Pro (18.5)', 'iPhone SE (3rd generation) (18.0)' ]
36+
steps:
37+
- name: Checkout Repo
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Setup
43+
uses: ./.github/actions/setup
44+
45+
- name: Install Maestro
46+
uses: ./.github/actions/installMaestro
47+
with:
48+
target-platform: ios
49+
50+
- name: Install example dependencies
51+
run: yarn workspace react-native-legal-bare-example install --frozen-lockfile --immutable
52+
53+
- name: Cache Pods
54+
id: cache-pods
55+
uses: actions/cache@v4
56+
env:
57+
cache-name: cached-ios-pods-deps
58+
with:
59+
path: examples/bare-example/ios/Pods
60+
key: bare-example-pods
61+
62+
- name: Cache Build
63+
id: cache-build
64+
uses: actions/cache@v4
65+
env:
66+
cache-name: cached-ios-build
67+
with:
68+
path: examples/bare-example/ios/build
69+
key: bare-example-ios-build
70+
71+
- name: Install example Pods
72+
run: yarn workspace react-native-legal-bare-example pods
73+
74+
- name: Bundle app
75+
run: yarn workspace react-native-legal-bare-example build:ios
76+
77+
- name: List simulators
78+
run: xcrun simctl list
79+
80+
- name: Build iOS App
81+
run: yarn workspace react-native-legal-bare-example ios:release --simulator="${{ matrix.simulator }}"
82+
83+
- name: Run tests
84+
run: yarn workspace react-native-legal-bare-example e2e:ios
85+
86+
- name: Upload report
87+
if: always()
88+
continue-on-error: true
89+
uses: ./.github/actions/uploadMaestroTestResults
90+
with:
91+
id: ${{ matrix.simulator }}

examples/bare-example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ yarn-error.log
6464

6565
# testing
6666
/coverage
67+
68+
/e2e_results
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
appId: com.reactnativelegalbareexample
2+
name: "[Android] Check React Native entry in OSS libraries list"
3+
tags:
4+
- pull-request
5+
- android
6+
---
7+
- launchApp:
8+
clearState: true
9+
stopApp: true
10+
- startRecording: 'e2e_results/checkLicenses'
11+
- tapOn: 'Tap to see list of OSS libraries'
12+
- assertVisible: 'OSS Notice'
13+
- scrollUntilVisible:
14+
element:
15+
containsChild: 'react-native'
16+
index: 0
17+
direction: 'DOWN'
18+
timeout: 120000
19+
centerElement: true
20+
speed: 70
21+
- takeScreenshot: 'e2e_results/react-native_list_element'
22+
- assertVisible:
23+
text: 'Facebook'
24+
index: 0
25+
- assertVisible:
26+
text: '\d+\.\d+\.\d+'
27+
index: 0
28+
- assertVisible:
29+
text: 'MIT License'
30+
index: 0
31+
- tapOn:
32+
text: 'MIT License'
33+
index: 0
34+
- takeScreenshot: 'e2e_results/license_modal'
35+
- assertVisible: '.*MIT License.*'
36+
- assertVisible: '.*Copyright \(c\).*'
37+
- assertVisible: '.*Permission is hereby granted, free of charge.*'
38+
- back
39+
- tapOn:
40+
containsChild: 'react-native'
41+
waitToSettleTimeoutMs: 3500
42+
index: 0
43+
44+
- runFlow:
45+
when:
46+
visible:
47+
text: 'Use without an account'
48+
file: '../common/acceptChromeTerms-UseWithoutAnAccountVariant.yaml'
49+
50+
- runFlow:
51+
when:
52+
visible:
53+
text: 'Accept & continue'
54+
file: '../common/acceptChromeTerms-AcceptContinueVariant.yaml'
55+
56+
- assertVisible: A framework for building native applications using React
57+
- takeScreenshot: 'e2e_results/github_page'
58+
- back
59+
- stopRecording
60+
- killApp
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
appId: org.reactjs.native.example.ReactNativeLegalBareExample
2+
name: '[iOS] Check React Native entry in OSS libraries list'
3+
tags:
4+
- pull-request
5+
- ios
6+
---
7+
- launchApp:
8+
clearState: true
9+
stopApp: true
10+
- startRecording: 'e2e_results/checkLicenses'
11+
- tapOn: 'Tap to see list of OSS libraries'
12+
- assertVisible: 'OSS Notice'
13+
- scrollUntilVisible:
14+
label: Scroll to React Native library
15+
element: "react-native"
16+
direction: 'DOWN'
17+
timeout: 60000
18+
speed: 80
19+
- takeScreenshot: 'e2e_results/react-native_list_element'
20+
- tapOn: "react-native"
21+
- takeScreenshot: 'e2e_results/react-native_entry'
22+
- assertVisible: "react-native"
23+
- assertVisible: "MIT License"
24+
- assertVisible: "OSS Notice"
25+
- tapOn: "OSS Notice"
26+
- takeScreenshot: 'e2e_results/react-native_back_to_list'
27+
- stopRecording
28+
- killApp
29+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: "[Android] Accept Chrome T & C - Use without an account variant"
2+
appId: com.android.chrome
3+
---
4+
- tapOn:
5+
label: Accept Chrome T & C
6+
text: "Accept & continue"
7+
- tapOn:
8+
label: "Turn off Chrome sync"
9+
text: "No thanks"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: "[Android] Accept Chrome T & C - Accept and Continue variant"
2+
appId: com.android.chrome
3+
---
4+
- tapOn:
5+
label: Dismiss Chrome sign in
6+
text: "Use without an account"
7+
- tapOn:
8+
label: "Dismiss Chrome notifications"
9+
id: "com.android.chrome:id/negative_button"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flows:
2+
- checkLicenses/*

0 commit comments

Comments
 (0)