From 4c866b54b3e54987301dc8160e2389f01a3e1bf2 Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Wed, 11 Oct 2023 13:17:04 +0200 Subject: [PATCH 1/6] fix(ui_auth): use captialized Cancel label on dialogs --- .../firebase_ui_auth/lib/src/navigation/authentication.dart | 2 +- .../firebase_ui_auth/lib/src/widgets/reauthenticate_dialog.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firebase_ui_auth/lib/src/navigation/authentication.dart b/packages/firebase_ui_auth/lib/src/navigation/authentication.dart index 8303b7b9..70f723b5 100644 --- a/packages/firebase_ui_auth/lib/src/navigation/authentication.dart +++ b/packages/firebase_ui_auth/lib/src/navigation/authentication.dart @@ -65,7 +65,7 @@ Future showDifferentMethodSignInDialog({ await showGeneralDialog( context: context, barrierDismissible: true, - barrierLabel: l.cancelLabel, + barrierLabel: l.cancelButtonLabel, pageBuilder: (context, _, __) => DifferentMethodSignInDialog( availableProviders: availableProviders, providers: providers, diff --git a/packages/firebase_ui_auth/lib/src/widgets/reauthenticate_dialog.dart b/packages/firebase_ui_auth/lib/src/widgets/reauthenticate_dialog.dart index c6871c85..7280b238 100644 --- a/packages/firebase_ui_auth/lib/src/widgets/reauthenticate_dialog.dart +++ b/packages/firebase_ui_auth/lib/src/widgets/reauthenticate_dialog.dart @@ -87,7 +87,7 @@ class ReauthenticateDialog extends StatelessWidget { top: verticalPadding.top, ), child: UniversalButton( - text: l.cancelLabel, + text: l.cancelButtonLabel, variant: ButtonVariant.text, onPressed: () => Navigator.of(context).pop(), ), From 984187b4acfcf82019ec8f6970220b991240ebaa Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Wed, 11 Oct 2023 13:25:30 +0200 Subject: [PATCH 2/6] chore: add tests --- .../firebase_ui_auth/test/test_utils.dart | 12 +++++ .../test/widgets/dialogs_test.dart | 50 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 packages/firebase_ui_auth/test/widgets/dialogs_test.dart diff --git a/packages/firebase_ui_auth/test/test_utils.dart b/packages/firebase_ui_auth/test/test_utils.dart index 283c9d7e..15aad549 100644 --- a/packages/firebase_ui_auth/test/test_utils.dart +++ b/packages/firebase_ui_auth/test/test_utils.dart @@ -25,7 +25,19 @@ class TestMaterialApp extends StatelessWidget { class MockCredential extends Mock implements UserCredential {} +class MockUserInfo extends Mock implements UserInfo { + @override + final String providerId; + + MockUserInfo({required this.providerId}); +} + class MockUser extends Mock implements User { + @override + final List providerData; + + MockUser({this.providerData = const []}); + @override Future linkWithCredential(AuthCredential? credential) async { return super.noSuchMethod( diff --git a/packages/firebase_ui_auth/test/widgets/dialogs_test.dart b/packages/firebase_ui_auth/test/widgets/dialogs_test.dart new file mode 100644 index 00000000..c0c83db7 --- /dev/null +++ b/packages/firebase_ui_auth/test/widgets/dialogs_test.dart @@ -0,0 +1,50 @@ +import 'package:firebase_ui_auth/firebase_ui_auth.dart'; +import 'package:firebase_ui_auth/src/widgets/reauthenticate_dialog.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import '../test_utils.dart'; + +void main() { + final auth = MockAuth(); + auth.user = MockUser(providerData: [ + MockUserInfo(providerId: 'email'), + MockUserInfo(providerId: 'phone'), + ]); + + group('$ReauthenticateDialog', () { + testWidgets('has capitalized Cancel label', (tester) async { + await tester.pumpWidget( + TestMaterialApp( + child: ReauthenticateDialog( + auth: auth, + providers: [ + EmailAuthProvider(), + PhoneAuthProvider(), + ], + ), + ), + ); + + expect(find.text('Cancel'), findsOneWidget); + }); + }); + + group('$DifferentMethodSignInDialog', () { + testWidgets('has capitalized Cancel label', (tester) async { + await tester.pumpWidget( + TestMaterialApp( + child: DifferentMethodSignInDialog( + auth: auth, + availableProviders: const ['email', 'phone'], + providers: [ + EmailAuthProvider(), + PhoneAuthProvider(), + ], + ), + ), + ); + + expect(find.text('Cancel'), findsOneWidget); + }); + }); +} From 9044ba2759036e1ae61a91fc2f7a4b164da88a74 Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Wed, 11 Oct 2023 15:01:15 +0200 Subject: [PATCH 3/6] chore: add license header --- packages/firebase_ui_auth/test/widgets/dialogs_test.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/firebase_ui_auth/test/widgets/dialogs_test.dart b/packages/firebase_ui_auth/test/widgets/dialogs_test.dart index c0c83db7..087b58cd 100644 --- a/packages/firebase_ui_auth/test/widgets/dialogs_test.dart +++ b/packages/firebase_ui_auth/test/widgets/dialogs_test.dart @@ -1,3 +1,7 @@ +// Copyright 2023, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:firebase_ui_auth/firebase_ui_auth.dart'; import 'package:firebase_ui_auth/src/widgets/reauthenticate_dialog.dart'; import 'package:flutter_test/flutter_test.dart'; From 9083a4cbe7cf9b8eb938e23db0abc124e407b55a Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Wed, 11 Oct 2023 16:46:00 +0200 Subject: [PATCH 4/6] fix analyzer --- packages/firebase_ui_auth/test/widgets/dialogs_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/firebase_ui_auth/test/widgets/dialogs_test.dart b/packages/firebase_ui_auth/test/widgets/dialogs_test.dart index 087b58cd..5186d71c 100644 --- a/packages/firebase_ui_auth/test/widgets/dialogs_test.dart +++ b/packages/firebase_ui_auth/test/widgets/dialogs_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'package:firebase_ui_auth/firebase_ui_auth.dart'; -import 'package:firebase_ui_auth/src/widgets/reauthenticate_dialog.dart'; import 'package:flutter_test/flutter_test.dart'; import '../test_utils.dart'; From d2b61de6852cb9eaeb31fc56a2341638b19597c3 Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Thu, 12 Oct 2023 15:15:40 +0200 Subject: [PATCH 5/6] fix test --- tests/integration_test/firebase_ui_auth/layout_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_test/firebase_ui_auth/layout_test.dart b/tests/integration_test/firebase_ui_auth/layout_test.dart index a8edaba6..8532d852 100644 --- a/tests/integration_test/firebase_ui_auth/layout_test.dart +++ b/tests/integration_test/firebase_ui_auth/layout_test.dart @@ -42,7 +42,7 @@ void main() { // Test will fail if there is an overflow. // This is a built-in flutter functionality - await tester.tap(find.text('cancel')); + await tester.tap(find.text('Cancel')); await tester.pumpAndSettle(); }, ); From 290616e687a1d733b6b2dae1f802a94389763c01 Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Thu, 12 Oct 2023 15:45:47 +0200 Subject: [PATCH 6/6] use safeSetState --- .../firebase_ui_oauth/lib/src/oauth_provider_button_base.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart b/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart index a04f76fb..e0ea4fab 100644 --- a/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart +++ b/packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart @@ -345,7 +345,7 @@ class _OAuthProviderButtonBaseState extends State @override void onError(Object error) { - setState(() { + safeSetState(() { isLoading = false; });