| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  | import 'package:appflowy/generated/locale_keys.g.dart'; | 
					
						
							| 
									
										
										
										
											2023-09-11 21:32:26 -05:00
										 |  |  | import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/widgets.dart'; | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  | import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart'; | 
					
						
							| 
									
										
										
										
											2023-11-24 11:54:47 +08:00
										 |  |  | import 'package:appflowy/workspace/presentation/settings/widgets/setting_supabase_cloud.dart'; | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  | import 'package:appflowy/workspace/presentation/settings/widgets/settings_user_view.dart'; | 
					
						
							|  |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter_test/flutter_test.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'base.dart'; | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  | import 'expectation.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | extension AppFlowyAuthTest on WidgetTester { | 
					
						
							|  |  |  |   Future<void> tapGoogleLoginInButton() async { | 
					
						
							| 
									
										
										
										
											2023-09-11 21:32:26 -05:00
										 |  |  |     await tapButton(find.byKey(const Key('signInWithGoogleButton'))); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |   Future<void> logout() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(SettingLogoutButton)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expectToSeeText(LocaleKeys.button_ok.tr()); | 
					
						
							|  |  |  |     await tapButtonWithName(LocaleKeys.button_ok.tr()); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |   Future<void> tapSignInAsGuest() async { | 
					
						
							| 
									
										
										
										
											2023-09-11 21:32:26 -05:00
										 |  |  |     await tapButton(find.byType(SignInAnonymousButton)); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void expectToSeeGoogleLoginButton() { | 
					
						
							| 
									
										
										
										
											2023-09-11 21:32:26 -05:00
										 |  |  |     expect(find.byKey(const Key('signInWithGoogleButton')), findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertSwitchValue(Finder finder, bool value) { | 
					
						
							|  |  |  |     final Switch switchWidget = widget(finder); | 
					
						
							|  |  |  |     final isSwitched = switchWidget.value; | 
					
						
							|  |  |  |     assert(isSwitched == value); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertEnableEncryptSwitchValue(bool value) { | 
					
						
							|  |  |  |     assertSwitchValue( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: find.byType(EnableEncrypt), | 
					
						
							|  |  |  |         matching: find.byWidgetPredicate((widget) => widget is Switch), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       value, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |   void assertSupabaseEnableSyncSwitchValue(bool value) { | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |     assertSwitchValue( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							| 
									
										
										
										
											2023-11-24 11:54:47 +08:00
										 |  |  |         of: find.byType(SupabaseEnableSync), | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |         matching: find.byWidgetPredicate((widget) => widget is Switch), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       value, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |   void assertAppFlowyCloudEnableSyncSwitchValue(bool value) { | 
					
						
							|  |  |  |     assertSwitchValue( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: find.byType(AppFlowyCloudEnableSync), | 
					
						
							|  |  |  |         matching: find.byWidgetPredicate((widget) => widget is Switch), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       value, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |   Future<void> toggleEnableEncrypt() async { | 
					
						
							|  |  |  |     final finder = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(EnableEncrypt), | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate((widget) => widget is Switch), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |   Future<void> toggleEnableSync(Type syncButton) async { | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |     final finder = find.descendant( | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       of: find.byType(syncButton), | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |       matching: find.byWidgetPredicate((widget) => widget is Switch), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |