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

test(storage, ios): enable tests after upstream bug fixes released #7361

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.appcheck.FirebaseAppCheck;
import io.invertase.firebase.common.ReactNativeFirebaseEvent;
import io.invertase.firebase.common.ReactNativeFirebaseEventEmitter;
import io.invertase.firebase.common.ReactNativeFirebaseJSON;
import io.invertase.firebase.common.ReactNativeFirebaseMeta;
import io.invertase.firebase.common.ReactNativeFirebaseModule;
import io.invertase.firebase.common.ReactNativeFirebasePreferences;
import io.invertase.firebase.common.ReactNativeFirebaseEvent;
import io.invertase.firebase.common.ReactNativeFirebaseEventEmitter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
Expand All @@ -39,7 +39,8 @@
private static final String LOGTAG = "RNFBAppCheck";
private static final String KEY_APPCHECK_TOKEN_REFRESH_ENABLED = "app_check_token_auto_refresh";

private static HashMap<String, FirebaseAppCheck.AppCheckListener> mAppCheckListeners = new HashMap<>();
private static HashMap<String, FirebaseAppCheck.AppCheckListener> mAppCheckListeners =
new HashMap<>();

ReactNativeFirebaseAppCheckProviderFactory providerFactory =
new ReactNativeFirebaseAppCheckProviderFactory();
Expand Down Expand Up @@ -110,7 +111,8 @@
String appName = (String) pair.getKey();
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance(firebaseApp);
FirebaseAppCheck.AppCheckListener mAppCheckListener = (FirebaseAppCheck.AppCheckListener) pair.getValue();
FirebaseAppCheck.AppCheckListener mAppCheckListener =
(FirebaseAppCheck.AppCheckListener) pair.getValue();

Check warning on line 115 in packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java

View check run for this annotation

Codecov / codecov/patch

packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L114-L115

Added lines #L114 - L115 were not covered by tests
firebaseAppCheck.removeAppCheckListener(mAppCheckListener);
appCheckListenerIterator.remove();
}
Expand Down Expand Up @@ -213,16 +215,19 @@
FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance(firebaseApp);

if (mAppCheckListeners.get(appName) == null) {
FirebaseAppCheck.AppCheckListener newAppCheckListener = appCheckToken -> {
WritableMap eventBody = Arguments.createMap();
eventBody.putString("appName", appName); // for js side distribution
eventBody.putString("token", appCheckToken.getToken());
eventBody.putDouble("expireTimeMillis", appCheckToken.getExpireTimeMillis());

ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
ReactNativeFirebaseEvent event = new ReactNativeFirebaseEvent("appCheck_token_changed", eventBody, appName);
emitter.sendEvent(event);
};
FirebaseAppCheck.AppCheckListener newAppCheckListener =

Check warning on line 218 in packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java

View check run for this annotation

Codecov / codecov/patch

packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L218

Added line #L218 was not covered by tests
appCheckToken -> {
WritableMap eventBody = Arguments.createMap();
eventBody.putString("appName", appName); // for js side distribution
eventBody.putString("token", appCheckToken.getToken());
eventBody.putDouble("expireTimeMillis", appCheckToken.getExpireTimeMillis());

Check warning on line 223 in packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java

View check run for this annotation

Codecov / codecov/patch

packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L220-L223

Added lines #L220 - L223 were not covered by tests

ReactNativeFirebaseEventEmitter emitter =
ReactNativeFirebaseEventEmitter.getSharedInstance();
ReactNativeFirebaseEvent event =

Check warning on line 227 in packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java

View check run for this annotation

Codecov / codecov/patch

packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L226-L227

Added lines #L226 - L227 were not covered by tests
new ReactNativeFirebaseEvent("appCheck_token_changed", eventBody, appName);
emitter.sendEvent(event);
};

Check warning on line 230 in packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java

View check run for this annotation

Codecov / codecov/patch

packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L229-L230

Added lines #L229 - L230 were not covered by tests

firebaseAppCheck.addAppCheckListener(newAppCheckListener);
mAppCheckListeners.put(appName, newAppCheckListener);
Expand Down
49 changes: 45 additions & 4 deletions packages/storage/e2e/StorageReference.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ describe('storage() -> StorageReference', function () {
describe('getDownloadURL', function () {
it('should return a download url for a file', async function () {
// This is frequently flaky in CI - but works sometimes. Skipping only in CI for now.
// Disabled for iOS pending: https://github.com/firebase/firebase-ios-sdk/pull/10370
if (!isCI && device.getPlatform() !== 'ios') {
if (!isCI) {
const storageReference = firebase.storage().ref(`${PATH}/list/file1.txt`);
const downloadUrl = await storageReference.getDownloadURL();
downloadUrl.should.be.a.String();
Expand Down Expand Up @@ -630,6 +629,26 @@ describe('storage() -> StorageReference', function () {
});
});
});

describe('put secondaryApp', function () {
it('allows valid metadata properties for upload', async function () {
const storageReference = firebase
.storage(firebase.app('secondaryFromNative'))
// .storage()
.ref(`${PATH}/metadataTest.jpeg`);
await storageReference.put(new jet.context.window.ArrayBuffer(), {
contentType: 'image/jpg',
md5hash: '123412341234',
cacheControl: 'true',
contentDisposition: 'disposed',
contentEncoding: 'application/octet-stream',
contentLanguage: 'de',
customMetadata: {
customMetadata1: 'metadata1value',
},
});
});
});
});

describe('StorageReference modular', function () {
Expand Down Expand Up @@ -777,8 +796,7 @@ describe('storage() -> StorageReference', function () {
it('should return a download url for a file', async function () {
const { getStorage, ref, getDownloadURL } = storageModular;
// This is frequently flaky in CI - but works sometimes. Skipping only in CI for now.
// Disabled for iOS pending: https://github.com/firebase/firebase-ios-sdk/pull/10370
if (!isCI && device.getPlatform() !== 'ios') {
if (!isCI) {
const storageReference = ref(getStorage(), `${PATH}/list/file1.txt`);
const downloadUrl = await getDownloadURL(storageReference);
downloadUrl.should.be.a.String();
Expand Down Expand Up @@ -1360,5 +1378,28 @@ describe('storage() -> StorageReference', function () {
});
});
});

describe('put secondaryApp', function () {
it('allows valid metadata properties for upload', async function () {
const { getStorage, ref, uploadBytesResumable } = storageModular;
const { getApp } = modular;
const storageReference = ref(
getStorage(getApp('secondaryFromNative')),
`${PATH}/metadataTest.jpeg`,
);

await uploadBytesResumable(storageReference, new jet.context.window.ArrayBuffer(), {
contentType: 'image/jpg',
md5hash: '123412341234',
cacheControl: 'true',
contentDisposition: 'disposed',
contentEncoding: 'application/octet-stream',
contentLanguage: 'de',
customMetadata: {
customMetadata1: 'metadata1value',
},
});
});
});
});
});
13 changes: 13 additions & 0 deletions tests/patches/detox+19.12.6.patch
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,16 @@ index fb4b820..d2dc87d 100644
notifyIdle()
return true
}
diff --git a/node_modules/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js b/node_modules/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js
index 585c99b..46e4b83 100644
--- a/node_modules/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js
+++ b/node_modules/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js
@@ -272,7 +272,7 @@ class AppleSimUtils {
// want to make sure it isn't now.
if (err.code === 3 &&
(err.stderr.includes(`the app is not currently running`) ||
- err.stderr.includes(`The operation couldn’t be completed. found nothing to terminate`))) {
+ err.stderr.includes(`found nothing to terminate`))) {
return;
}

Loading