Skip to content

Commit 0c988ad

Browse files
committed
refactor(ci): testing app with new Jet (#7874)
1 parent a752075 commit 0c988ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3742
-3651
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22
echo "Running $1 on all running emulators..."
3-
devices=`adb devices`
3+
devices=`$ANDROID_HOME/platform-tools/adb devices`
44

55
for device in $devices; do
66
if [[ "$device" =~ "emulator-" ]]; then
7-
adb -s $device $1
7+
$ANDROID_HOME/platform-tools/adb -s $device $1
88
fi
99
done
1010
echo "All Done."

.github/workflows/tests_e2e_android.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ concurrency:
2828
jobs:
2929
android:
3030
name: Android
31-
runs-on: ubuntu-latest
31+
runs-on: ubuntu-latest-l
3232
timeout-minutes: 90
3333
strategy:
3434
fail-fast: false
@@ -46,7 +46,7 @@ jobs:
4646
iteration: [0]
4747
env:
4848
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49-
EMULATOR_COMMAND: "-avd TestingAVD -noaudio -gpu swiftshader_indirect -camera-back none -no-snapshot -no-window -no-boot-anim -nojni -memory 2048 -timezone 'Europe/London' -cores 2"
49+
EMULATOR_COMMAND: "-avd TestingAVD -noaudio -gpu swiftshader_indirect -camera-back none -no-snapshot -no-window -no-boot-anim -nojni -memory 4096 -timezone 'Europe/London' -cores 4"
5050
EMULATOR_EXECUTABLE: qemu-system-x86_64-headless
5151
steps:
5252
- name: Liberate disk space

.github/workflows/tests_e2e_ios.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ concurrency:
2727
jobs:
2828
ios:
2929
name: iOS
30-
runs-on: macos-14
30+
runs-on: macos-14-xlarge
3131
# TODO matrix across APIs, at least 11 and 15 (lowest to highest)
3232
timeout-minutes: 100
3333
env:
@@ -78,7 +78,7 @@ jobs:
7878
- uses: hendrikmuhs/ccache-action@v1
7979
name: Xcode Compile Cache
8080
with:
81-
key: ${{ runner.os }}-v2 # makes a unique key w/related restore key internally
81+
key: ${{ runner.os }}-v3 # makes a unique key w/related restore key internally
8282
create-symlink: true
8383
max-size: 1500M
8484

@@ -108,8 +108,8 @@ jobs:
108108
id: pods-cache
109109
with:
110110
path: tests/ios/Pods
111-
key: ${{ runner.os }}-pods-v2-${{ hashFiles('tests/ios/Podfile.lock') }}
112-
restore-keys: ${{ runner.os }}-pods-v2
111+
key: ${{ runner.os }}-pods-v3-${{ hashFiles('tests/ios/Podfile.lock') }}
112+
restore-keys: ${{ runner.os }}-pods-v3
113113

114114
- name: Pod Install
115115
uses: nick-fields/retry@v3

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"scripts": {
55
"version": "node ./scripts/version.js",
6+
"prepare": "patch-package",
67
"lerna:prepare": "lerna run prepare",
78
"lerna:clean": "lerna clean",
89
"build:all:clean": "lerna run build:clean",
@@ -32,15 +33,13 @@
3233
"tests:android:build:windows": "cd tests && yarn detox build --configuration android.emu.debug.windows",
3334
"tests:android:build-release": "cd tests && yarn detox build --configuration android.emu.release",
3435
"tests:android:test": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug",
35-
"tests:android:test-no-compat": "yarn tests:android:emulator:forward && cd tests && SKIP_COMPAT_TESTS=true yarn detox test --configuration android.emu.debug",
3636
"tests:android:test:windows": "cd tests && yarn detox test --configuration android.emu.debug",
3737
"tests:android:test:debug": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --inspect",
3838
"tests:android:test-reuse": "yarn tests:android:emulator:forward && cd tests && yarn detox test --configuration android.emu.debug --reuse",
39-
"tests:android:test-reuse-no-compat": "yarn tests:android:emulator:forward && cd tests && SKIP_COMPAT_TESTS=true yarn detox test --configuration android.emu.debug --reuse",
4039
"tests:android:test-cover": "yarn tests:android:emulator:forward && cd tests && ./node_modules/.bin/nyc yarn detox test --configuration android.emu.debug",
4140
"tests:android:test-cover-reuse": "yarn tests:android:emulator:forward && cd tests && ./node_modules/.bin/nyc yarn detox test --configuration android.emu.debug --reuse",
4241
"tests:android:test:jacoco-report": "cd tests/android && ./gradlew jacocoAndroidTestReport",
43-
"tests:android:emulator:forward": ".github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8081 tcp:8081'",
42+
"tests:android:emulator:forward": ".github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8081 tcp:8081' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8090 tcp:8090' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:8080 tcp:8080' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:9099 tcp:9099' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:9000 tcp:9000' && .github/workflows/scripts/adb_all_emulators.sh 'reverse tcp:9199 tcp:9199'",
4443
"tests:ios:build": "cd tests && yarn detox build --configuration ios.sim.debug",
4544
"tests:ios:build-release": "cd tests && yarn detox build --configuration ios.sim.release",
4645
"tests:ios:test": "cd tests && SIMCTL_CHILD_GULGeneratedClassDisposeDisabled=1 yarn detox test --configuration ios.sim.debug --loglevel warn",
@@ -81,6 +80,7 @@
8180
"inquirer": "^8.2.6",
8281
"jest": "^29.7.0",
8382
"lerna": "^8.1.4",
83+
"patch-package": "^8.0.0",
8484
"prettier": "^3.3.2",
8585
"regenerator-transform": "^0.15.2",
8686
"rimraf": "^5.0.7",

packages/app-check/e2e/appcheck.e2e.js

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,45 @@
1515
*
1616
*/
1717

18-
const jwt = require('jsonwebtoken');
18+
function decodeJWT(token) {
19+
// Split the token into its parts
20+
const parts = token.split('.');
21+
22+
if (parts.length !== 3) {
23+
throw new Error('Invalid token format');
24+
}
25+
26+
// Decode the base64 URL parts
27+
const base64UrlDecode = str => {
28+
let base64 = str.replace(/-/g, '+').replace(/_/g, '/');
29+
switch (base64.length % 4) {
30+
case 0:
31+
break;
32+
case 2:
33+
base64 += '==';
34+
break;
35+
case 3:
36+
base64 += '=';
37+
break;
38+
default:
39+
throw new Error('Invalid base64 string');
40+
}
41+
42+
return decodeURIComponent(
43+
atob(base64)
44+
.split('')
45+
.map(function (c) {
46+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
47+
})
48+
.join(''),
49+
);
50+
};
51+
52+
// Decode the payload
53+
const payload = JSON.parse(base64UrlDecode(parts[1]));
54+
55+
return payload;
56+
}
1957

2058
describe('appCheck() modular', function () {
2159
describe('firebase v8 compatibility', function () {
@@ -48,7 +86,7 @@ describe('appCheck() modular', function () {
4886
// it relies on token auto refresh being left false for local tests where the app is reused, since it is persistent
4987
// but in CI it's fresh every time and would be true if not overridden in Info.plist
5088
it('should configure token auto refresh in Info.plist on ios', async function () {
51-
if (device.getPlatform() === 'ios') {
89+
if (Platform.ios) {
5290
const tokenRefresh =
5391
await NativeModules.RNFBAppCheckModule.isTokenAutoRefreshEnabled('[DEFAULT]');
5492
tokenRefresh.should.equal(false);
@@ -63,14 +101,14 @@ describe('appCheck() modular', function () {
63101
firebase.appCheck().setTokenAutoRefreshEnabled(false);
64102

65103
// Only iOS lets us assert on this unfortunately, other platforms have no accessor
66-
if (device.getPlatform() === 'ios') {
104+
if (Platform.ios) {
67105
let tokenRefresh =
68106
await NativeModules.RNFBAppCheckModule.isTokenAutoRefreshEnabled('[DEFAULT]');
69107
tokenRefresh.should.equal(false);
70108
}
71109
firebase.appCheck().setTokenAutoRefreshEnabled(true);
72110
// Only iOS lets us assert on this unfortunately, other platforms have no accessor
73-
if (device.getPlatform() === 'ios') {
111+
if (Platform.ios) {
74112
tokenRefresh =
75113
await NativeModules.RNFBAppCheckModule.isTokenAutoRefreshEnabled('[DEFAULT]');
76114
tokenRefresh.should.equal(true);
@@ -82,7 +120,7 @@ describe('appCheck() modular', function () {
82120
it('token fetch attempt with configured debug token should work', async function () {
83121
const { token } = await firebase.appCheck().getToken(true);
84122
token.should.not.equal('');
85-
const decodedToken = jwt.decode(token);
123+
const decodedToken = decodeJWT(token);
86124
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
87125
if (decodedToken.exp * 1000 < Date.now()) {
88126
return Promise.reject(
@@ -97,7 +135,7 @@ describe('appCheck() modular', function () {
97135
// TODO sometimes fails on android https://github.com/firebase/firebase-android-sdk/issues/2954
98136
const { token: token2 } = await firebase.appCheck().getToken(true);
99137
token2.should.not.equal('');
100-
const decodedToken2 = jwt.decode(token2);
138+
const decodedToken2 = decodeJWT(token2);
101139
decodedToken2.aud[1].should.equal('projects/react-native-firebase-testing');
102140
if (decodedToken2.exp * 1000 < Date.now()) {
103141
return Promise.reject(
@@ -152,7 +190,7 @@ describe('appCheck() modular', function () {
152190

153191
const { token } = await firebase.appCheck().getToken(true);
154192
token.should.not.equal('');
155-
const decodedToken = jwt.decode(token);
193+
const decodedToken = decodeJWT(token);
156194
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
157195
if (decodedToken.exp * 1000 < Date.now()) {
158196
return Promise.reject(
@@ -166,7 +204,7 @@ describe('appCheck() modular', function () {
166204
it('limited use token fetch attempt with configured debug token should work', async function () {
167205
const { token } = await firebase.appCheck().getLimitedUseToken();
168206
token.should.not.equal('');
169-
const decodedToken = jwt.decode(token);
207+
const decodedToken = decodeJWT(token);
170208
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
171209
if (decodedToken.exp * 1000 < Date.now()) {
172210
return Promise.reject(
@@ -240,14 +278,14 @@ describe('appCheck() modular', function () {
240278

241279
setTokenAutoRefreshEnabled(appCheckInstance, false);
242280
// Only iOS lets us assert on this unfortunately, other platforms have no accessor
243-
if (device.getPlatform() === 'ios') {
281+
if (Platform.ios) {
244282
let tokenRefresh =
245283
await NativeModules.RNFBAppCheckModule.isTokenAutoRefreshEnabled('[DEFAULT]');
246284
tokenRefresh.should.equal(false);
247285
}
248286
setTokenAutoRefreshEnabled(appCheckInstance, true);
249287
// Only iOS lets us assert on this unfortunately, other platforms have no accessor
250-
if (device.getPlatform() === 'ios') {
288+
if (Platform.ios) {
251289
tokenRefresh =
252290
await NativeModules.RNFBAppCheckModule.isTokenAutoRefreshEnabled('[DEFAULT]');
253291
tokenRefresh.should.equal(true);
@@ -261,7 +299,7 @@ describe('appCheck() modular', function () {
261299

262300
const { token } = await getToken(appCheckInstance, true);
263301
token.should.not.equal('');
264-
const decodedToken = jwt.decode(token);
302+
const decodedToken = decodeJWT(token);
265303
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
266304
if (decodedToken.exp * 1000 < Date.now()) {
267305
return Promise.reject(
@@ -276,7 +314,7 @@ describe('appCheck() modular', function () {
276314
// TODO sometimes fails on android https://github.com/firebase/firebase-android-sdk/issues/2954
277315
const { token: token2 } = await getToken(appCheckInstance, true);
278316
token2.should.not.equal('');
279-
const decodedToken2 = jwt.decode(token2);
317+
const decodedToken2 = decodeJWT(token2);
280318
decodedToken2.aud[1].should.equal('projects/react-native-firebase-testing');
281319
if (decodedToken2.exp * 1000 < Date.now()) {
282320
return Promise.reject(
@@ -335,7 +373,7 @@ describe('appCheck() modular', function () {
335373

336374
const { token } = await getToken(instance2, true);
337375
token.should.not.equal('');
338-
const decodedToken = jwt.decode(token);
376+
const decodedToken = decodeJWT(token);
339377
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
340378
if (decodedToken.exp * 1000 < Date.now()) {
341379
return Promise.reject(
@@ -371,7 +409,7 @@ describe('appCheck() modular', function () {
371409

372410
const { token } = await getLimitedUseToken(appCheckInstance);
373411
token.should.not.equal('');
374-
const decodedToken = jwt.decode(token);
412+
const decodedToken = decodeJWT(token);
375413
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
376414
if (decodedToken.exp * 1000 < Date.now()) {
377415
return Promise.reject(

packages/app-distribution/e2e/app-distribution.e2e.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('appDistribution()', function () {
2525

2626
describe('isTesterSignedIn()', function () {
2727
it('checks if a tester is signed in', async function () {
28-
if (device.getPlatform() === 'ios') {
28+
if (Platform.ios) {
2929
await firebase.appDistribution().isTesterSignedIn();
3030
} else {
3131
this.skip();
@@ -35,7 +35,7 @@ describe('appDistribution()', function () {
3535
// Requires a valid google account logged in on device and associated with iOS testing app
3636
xdescribe('signInTester()', function () {
3737
it('signs a tester in', async function () {
38-
if (device.getPlatform() === 'ios') {
38+
if (Platform.ios) {
3939
await firebase.appDistribution().signInTester();
4040
} else {
4141
this.skip();
@@ -45,7 +45,7 @@ describe('appDistribution()', function () {
4545

4646
describe('signOutTester()', function () {
4747
it('signs out a tester', async function () {
48-
if (device.getPlatform() === 'ios') {
48+
if (Platform.ios) {
4949
await firebase.appDistribution().signOutTester();
5050
} else {
5151
this.skip();
@@ -56,7 +56,7 @@ describe('appDistribution()', function () {
5656
// plus a new IPA file uploaded
5757
xdescribe('checkForUpdate()', function () {
5858
it('checks for an update', async function () {
59-
if (device.getPlatform() === 'ios') {
59+
if (Platform.ios) {
6060
await firebase.appDistribution().checkForUpdate();
6161
} else {
6262
this.skip();
@@ -78,7 +78,7 @@ describe('appDistribution()', function () {
7878
it('checks if a tester is signed in', async function () {
7979
const { getAppDistribution, isTesterSignedIn } = appDistributionModular;
8080
const appDistribution = getAppDistribution();
81-
if (device.getPlatform() === 'ios') {
81+
if (Platform.ios) {
8282
await isTesterSignedIn(appDistribution);
8383
} else {
8484
this.skip();
@@ -90,7 +90,7 @@ describe('appDistribution()', function () {
9090
it('signs a tester in', async function () {
9191
const { getAppDistribution, signInTester } = appDistributionModular;
9292
const appDistribution = getAppDistribution();
93-
if (device.getPlatform() === 'ios') {
93+
if (Platform.ios) {
9494
await signInTester(appDistribution);
9595
} else {
9696
this.skip();
@@ -102,7 +102,7 @@ describe('appDistribution()', function () {
102102
it('signs out a tester', async function () {
103103
const { getAppDistribution, signOutTester } = appDistributionModular;
104104
const appDistribution = getAppDistribution();
105-
if (device.getPlatform() === 'ios') {
105+
if (Platform.ios) {
106106
await signOutTester(appDistribution);
107107
} else {
108108
this.skip();
@@ -115,7 +115,7 @@ describe('appDistribution()', function () {
115115
it('checks for an update', async function () {
116116
const { getAppDistribution, checkForUpdate } = appDistributionModular;
117117
const appDistribution = getAppDistribution();
118-
if (device.getPlatform() === 'ios') {
118+
if (Platform.ios) {
119119
await checkForUpdate(appDistribution);
120120
} else {
121121
this.skip();

packages/app/e2e/helpers.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ exports.getE2eTestProject = function getE2eTestProject() {
33
};
44

55
exports.getE2eEmulatorHost = function getE2eEmulatorHost() {
6-
// Note that in most package implementations involving the emulator, we re-write
7-
// localhost and 127.0.0.1 on Android to 10.0.2.2 (the Android emulator host interface)
8-
// But this specific code is executing in the host context even during E2E test.
9-
// So no re-write is necessary here.
6+
if (Platform.android) {
7+
return '10.0.2.2';
8+
}
109
return '127.0.0.1';
1110
};

packages/app/e2e/utilsStatics.e2e.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('utils()', function () {
2121
describe('statics', function () {
2222
it('provides native path strings', function () {
2323
firebase.utils.FilePath.should.be.an.Object();
24-
if (device.getPlatform() === 'ios') {
24+
if (Platform.ios) {
2525
firebase.utils.FilePath.MAIN_BUNDLE.should.be.a.String();
2626
} else {
2727
should.equal(firebase.utils.FilePath.MAIN_BUNDLE, null);
@@ -31,20 +31,14 @@ describe('utils()', function () {
3131
firebase.utils.FilePath.DOCUMENT_DIRECTORY.should.be.a.String();
3232

3333
// Even on android it may be null, skip if so
34-
if (
35-
device.getPlatform() === 'android' &&
36-
firebase.utils.FilePath.EXTERNAL_DIRECTORY !== null
37-
) {
34+
if (Platform.android && firebase.utils.FilePath.EXTERNAL_DIRECTORY !== null) {
3835
firebase.utils.FilePath.EXTERNAL_DIRECTORY.should.be.a.String();
3936
} else {
4037
should.equal(firebase.utils.FilePath.EXTERNAL_DIRECTORY, null);
4138
}
4239

4340
// Even on android it may be null, skip if so
44-
if (
45-
device.getPlatform() === 'android' &&
46-
firebase.utils.FilePath.EXTERNAL_STORAGE_DIRECTORY !== null
47-
) {
41+
if (Platform.android && firebase.utils.FilePath.EXTERNAL_STORAGE_DIRECTORY !== null) {
4842
firebase.utils.FilePath.EXTERNAL_STORAGE_DIRECTORY.should.be.a.String();
4943
} else {
5044
should.equal(firebase.utils.FilePath.EXTERNAL_STORAGE_DIRECTORY, null);

0 commit comments

Comments
 (0)