Skip to content

Commit 78c1ba9

Browse files
authored
fix(ui_auth): use capitalized cancel label on dialogs (#134)
* fix(ui_auth): use captialized Cancel label on dialogs * chore: add tests * chore: add license header * fix analyzer * fix test * use safeSetState
1 parent 3063f3e commit 78c1ba9

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

packages/firebase_ui_auth/lib/src/navigation/authentication.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Future<void> showDifferentMethodSignInDialog({
6565
await showGeneralDialog(
6666
context: context,
6767
barrierDismissible: true,
68-
barrierLabel: l.cancelLabel,
68+
barrierLabel: l.cancelButtonLabel,
6969
pageBuilder: (context, _, __) => DifferentMethodSignInDialog(
7070
availableProviders: availableProviders,
7171
providers: providers,

packages/firebase_ui_auth/lib/src/widgets/reauthenticate_dialog.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ReauthenticateDialog extends StatelessWidget {
8787
top: verticalPadding.top,
8888
),
8989
child: UniversalButton(
90-
text: l.cancelLabel,
90+
text: l.cancelButtonLabel,
9191
variant: ButtonVariant.text,
9292
onPressed: () => Navigator.of(context).pop(),
9393
),

packages/firebase_ui_auth/test/test_utils.dart

+12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ class TestMaterialApp extends StatelessWidget {
2525

2626
class MockCredential extends Mock implements UserCredential {}
2727

28+
class MockUserInfo extends Mock implements UserInfo {
29+
@override
30+
final String providerId;
31+
32+
MockUserInfo({required this.providerId});
33+
}
34+
2835
class MockUser extends Mock implements User {
36+
@override
37+
final List<UserInfo> providerData;
38+
39+
MockUser({this.providerData = const []});
40+
2941
@override
3042
Future<UserCredential> linkWithCredential(AuthCredential? credential) async {
3143
return super.noSuchMethod(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2023, the Chromium project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
6+
import 'package:flutter_test/flutter_test.dart';
7+
8+
import '../test_utils.dart';
9+
10+
void main() {
11+
final auth = MockAuth();
12+
auth.user = MockUser(providerData: [
13+
MockUserInfo(providerId: 'email'),
14+
MockUserInfo(providerId: 'phone'),
15+
]);
16+
17+
group('$ReauthenticateDialog', () {
18+
testWidgets('has capitalized Cancel label', (tester) async {
19+
await tester.pumpWidget(
20+
TestMaterialApp(
21+
child: ReauthenticateDialog(
22+
auth: auth,
23+
providers: [
24+
EmailAuthProvider(),
25+
PhoneAuthProvider(),
26+
],
27+
),
28+
),
29+
);
30+
31+
expect(find.text('Cancel'), findsOneWidget);
32+
});
33+
});
34+
35+
group('$DifferentMethodSignInDialog', () {
36+
testWidgets('has capitalized Cancel label', (tester) async {
37+
await tester.pumpWidget(
38+
TestMaterialApp(
39+
child: DifferentMethodSignInDialog(
40+
auth: auth,
41+
availableProviders: const ['email', 'phone'],
42+
providers: [
43+
EmailAuthProvider(),
44+
PhoneAuthProvider(),
45+
],
46+
),
47+
),
48+
);
49+
50+
expect(find.text('Cancel'), findsOneWidget);
51+
});
52+
});
53+
}

packages/firebase_ui_oauth/lib/src/oauth_provider_button_base.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class _OAuthProviderButtonBaseState extends State<OAuthProviderButtonBase>
345345

346346
@override
347347
void onError(Object error) {
348-
setState(() {
348+
safeSetState(() {
349349
isLoading = false;
350350
});
351351

tests/integration_test/firebase_ui_auth/layout_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void main() {
4242
// Test will fail if there is an overflow.
4343
// This is a built-in flutter functionality
4444

45-
await tester.tap(find.text('cancel'));
45+
await tester.tap(find.text('Cancel'));
4646
await tester.pumpAndSettle();
4747
},
4848
);

0 commit comments

Comments
 (0)