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

fix(ui_auth): use capitalized cancel label on dialogs #134

Merged
merged 6 commits into from
Oct 18, 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 @@ -65,7 +65,7 @@ Future<void> showDifferentMethodSignInDialog({
await showGeneralDialog(
context: context,
barrierDismissible: true,
barrierLabel: l.cancelLabel,
barrierLabel: l.cancelButtonLabel,
pageBuilder: (context, _, __) => DifferentMethodSignInDialog(
availableProviders: availableProviders,
providers: providers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down
12 changes: 12 additions & 0 deletions packages/firebase_ui_auth/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserInfo> providerData;

MockUser({this.providerData = const []});

@override
Future<UserCredential> linkWithCredential(AuthCredential? credential) async {
return super.noSuchMethod(
Expand Down
53 changes: 53 additions & 0 deletions packages/firebase_ui_auth/test/widgets/dialogs_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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: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);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class _OAuthProviderButtonBaseState extends State<OAuthProviderButtonBase>

@override
void onError(Object error) {
setState(() {
safeSetState(() {
isLoading = false;
});

Expand Down
2 changes: 1 addition & 1 deletion tests/integration_test/firebase_ui_auth/layout_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
);
Expand Down
Loading