-
Notifications
You must be signed in to change notification settings - Fork 384
ci(repo): mock firebase for e2e tests #2821
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9d80c9
ci(repo): mock firebase for e2e tests
testableapple 373de71
ci(e2e): add compilation-cache diagnostics (remarks + verbose dispatc…
testableapple 36b29c7
ci(e2e): remove xcode compilation cache (works, but ~no benefit on CI…
testableapple 325b532
Fix format
testableapple 924f27e
Rename e2e workflow
testableapple 530a25b
Merge branch 'master' into ci/e2e-mock-firebase
testableapple abb2100
Merge branch 'master' into ci/e2e-mock-firebase
testableapple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /// No-op stand-in for `firebase_core`, swapped in via `pubspec_overrides.e2e.yaml`. | ||
| /// | ||
| /// Being a pure-Dart package (no `flutter.plugin` section), it removes the Firebase | ||
| /// pods / Gradle dependencies from e2e builds entirely: nothing is downloaded, | ||
| /// compiled, or initialized. Only the API surface used by `sample_app` is stubbed. | ||
| library; | ||
|
|
||
| /// No-op replacement for the Firebase entry point. | ||
| class Firebase { | ||
| /// Does nothing and returns a dummy [FirebaseApp]. | ||
| static Future<FirebaseApp> initializeApp({String? name, FirebaseOptions? options}) async => const FirebaseApp(); | ||
| } | ||
|
|
||
| /// Inert replacement for a configured Firebase app. | ||
| class FirebaseApp { | ||
| /// Creates the inert app handle. | ||
| const FirebaseApp(); | ||
| } | ||
|
|
||
| /// Plain data holder matching the real `FirebaseOptions` constructor, so the | ||
| /// FlutterFire-generated `firebase_options.dart` compiles unchanged. | ||
| class FirebaseOptions { | ||
| /// Mirrors the real constructor's signature; values are never read. | ||
| const FirebaseOptions({ | ||
| required this.apiKey, | ||
| required this.appId, | ||
| required this.messagingSenderId, | ||
| required this.projectId, | ||
| this.authDomain, | ||
| this.databaseURL, | ||
| this.storageBucket, | ||
| this.measurementId, | ||
| this.trackingId, | ||
| this.deepLinkURLScheme, | ||
| this.androidClientId, | ||
| this.iosClientId, | ||
| this.iosBundleId, | ||
| this.appGroupId, | ||
| }); | ||
|
|
||
| /// See the real `firebase_core` for field semantics; all unused here. | ||
| final String apiKey, appId, messagingSenderId, projectId; | ||
|
|
||
| /// Optional platform-specific fields accepted for constructor compatibility. | ||
| final String? authDomain, | ||
| databaseURL, | ||
| storageBucket, | ||
| measurementId, | ||
| trackingId, | ||
| deepLinkURLScheme, | ||
| androidClientId, | ||
| iosClientId, | ||
| iosBundleId, | ||
| appGroupId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: firebase_core | ||
| description: No-op pure-Dart stand-in for firebase_core, swapped in by e2e builds to keep the native Firebase SDK out of the app. | ||
| version: 0.0.1 | ||
| publish_to: none | ||
|
|
||
| environment: | ||
| sdk: ^3.0.0 |
32 changes: 32 additions & 0 deletions
32
sample_app/e2e_stubs/firebase_crashlytics/lib/firebase_crashlytics.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /// No-op stand-in for `firebase_crashlytics`, swapped in via `pubspec_overrides.e2e.yaml`. | ||
| /// | ||
| /// See the `firebase_core` stub for the rationale. Only the API surface used by | ||
| /// `sample_app` is stubbed; every call silently does nothing. | ||
| library; | ||
|
|
||
| import 'package:flutter/foundation.dart'; | ||
|
|
||
| /// No-op replacement for the Crashlytics reporter. | ||
| class FirebaseCrashlytics { | ||
| FirebaseCrashlytics._(); | ||
|
|
||
| /// The shared no-op instance. | ||
| static final FirebaseCrashlytics instance = FirebaseCrashlytics._(); | ||
|
|
||
| /// Does nothing. The positional bool must match the real API's signature. | ||
| // ignore: avoid_positional_boolean_parameters | ||
| Future<void> setCrashlyticsCollectionEnabled(bool enabled) async {} | ||
|
|
||
| /// Does nothing. | ||
| Future<void> recordError( | ||
| dynamic exception, | ||
| StackTrace? stack, { | ||
| dynamic reason, | ||
| Iterable<Object> information = const [], | ||
| bool? printDetails, | ||
| bool fatal = false, | ||
| }) async {} | ||
|
|
||
| /// Does nothing. | ||
| Future<void> recordFlutterFatalError(FlutterErrorDetails flutterErrorDetails) async {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| name: firebase_crashlytics | ||
| description: No-op pure-Dart stand-in for firebase_crashlytics, swapped in by e2e builds to keep the native Firebase SDK out of the app. | ||
| version: 0.0.1 | ||
| publish_to: none | ||
|
|
||
| environment: | ||
| sdk: ^3.0.0 | ||
|
|
||
| dependencies: | ||
| flutter: | ||
| sdk: flutter |
90 changes: 90 additions & 0 deletions
90
sample_app/e2e_stubs/firebase_messaging/lib/firebase_messaging.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /// No-op stand-in for `firebase_messaging`, swapped in via `pubspec_overrides.e2e.yaml`. | ||
| /// | ||
| /// See the `firebase_core` stub for the rationale. Only the API surface used by | ||
| /// `sample_app` is stubbed: permission requests report denied, token getters | ||
| /// return null, and the message streams never emit. | ||
| library; | ||
|
|
||
| /// Signature of the top-level FCM background handler. | ||
| typedef BackgroundMessageHandler = Future<void> Function(RemoteMessage message); | ||
|
|
||
| /// No-op replacement for the FCM entry point. | ||
| class FirebaseMessaging { | ||
| FirebaseMessaging._(); | ||
|
|
||
| /// The shared no-op instance. | ||
| static final FirebaseMessaging instance = FirebaseMessaging._(); | ||
|
|
||
| /// Never emits. | ||
| static Stream<RemoteMessage> get onMessage => const Stream.empty(); | ||
|
|
||
| /// Never emits. | ||
| static Stream<RemoteMessage> get onMessageOpenedApp => const Stream.empty(); | ||
|
|
||
| /// Does nothing; [handler] is never invoked. | ||
| static void onBackgroundMessage(BackgroundMessageHandler handler) {} | ||
|
|
||
| /// Never emits. | ||
| Stream<String> get onTokenRefresh => const Stream.empty(); | ||
|
|
||
| /// Always resolves to null. | ||
| Future<String?> getToken({String? vapidKey}) async => null; | ||
|
|
||
| /// Always resolves to null. | ||
| Future<String?> getAPNSToken() async => null; | ||
|
|
||
| /// Always resolves to null. | ||
| Future<RemoteMessage?> getInitialMessage() async => null; | ||
|
|
||
| /// Always reports [AuthorizationStatus.denied]. | ||
| Future<NotificationSettings> requestPermission({ | ||
| bool alert = true, | ||
| bool announcement = false, | ||
| bool badge = true, | ||
| bool carPlay = false, | ||
| bool criticalAlert = false, | ||
| bool provisional = false, | ||
| bool providesAppNotificationSettings = false, | ||
| bool sound = true, | ||
| }) async => const NotificationSettings(authorizationStatus: AuthorizationStatus.denied); | ||
|
|
||
| /// Does nothing. | ||
| Future<void> setForegroundNotificationPresentationOptions({ | ||
| bool alert = false, | ||
| bool badge = false, | ||
| bool sound = false, | ||
| }) async {} | ||
| } | ||
|
|
||
| /// Mirrors the real enum values. | ||
| enum AuthorizationStatus { | ||
| /// Permission granted. | ||
| authorized, | ||
|
|
||
| /// Permission denied — the stub's fixed answer. | ||
| denied, | ||
|
|
||
| /// Permission not requested yet. | ||
| notDetermined, | ||
|
|
||
| /// Provisional (quiet) permission. | ||
| provisional, | ||
| } | ||
|
|
||
| /// Minimal result type for [FirebaseMessaging.requestPermission]. | ||
| class NotificationSettings { | ||
| /// Creates settings with the given [authorizationStatus]. | ||
| const NotificationSettings({required this.authorizationStatus}); | ||
|
|
||
| /// The reported permission state. | ||
| final AuthorizationStatus authorizationStatus; | ||
| } | ||
|
|
||
| /// Minimal FCM message: only [data] is read by `sample_app`. | ||
| class RemoteMessage { | ||
| /// Creates a message carrying [data]. | ||
| const RemoteMessage({this.data = const {}}); | ||
|
|
||
| /// The message payload. | ||
| final Map<String, dynamic> data; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: firebase_messaging | ||
| description: No-op pure-Dart stand-in for firebase_messaging, swapped in by e2e builds to keep the native Firebase SDK out of the app. | ||
| version: 0.0.1 | ||
| publish_to: none | ||
|
|
||
| environment: | ||
| sdk: ^3.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copied over pubspec_overrides.yaml by the e2e CI jobs BEFORE `melos bootstrap` | ||
| # (melos merges its own managed overrides into the existing file, preserving these | ||
| # entries). Swaps the Firebase plugins for the pure-Dart no-op stubs in | ||
| # e2e_stubs/ so no native Firebase SDK is downloaded, compiled, or | ||
| # initialized during e2e runs. | ||
| dependency_overrides: | ||
| firebase_core: | ||
| path: e2e_stubs/firebase_core | ||
| firebase_crashlytics: | ||
| path: e2e_stubs/firebase_crashlytics | ||
| firebase_messaging: | ||
| path: e2e_stubs/firebase_messaging |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we already do this for android as well? Currently only applied for iOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android is much faster and the benefit of mocking it there is very low. But this way we at least can receive crash reports from Android as far as i understood.