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';
							 | 
						
					
						
							
								
									
										
										
										
											2024-09-03 16:58:38 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:appflowy/workspace/presentation/settings/pages/account/account.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:appflowy/workspace/presentation/settings/widgets/setting_appflowy_cloud.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:easy_localization/easy_localization.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-25 12:02:18 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:flutter/material.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:flutter_test/flutter_test.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'util.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extension AppFlowyAuthTest on WidgetTester {
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-06 20:08:17 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Future<void> tapGoogleLoginInButton({bool pumpAndSettle = true}) async {
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-15 15:23:23 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await tapButton(
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-27 10:49:31 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      find.byKey(signInWithGoogleButtonKey),
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-06 20:08:17 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      pumpAndSettle: pumpAndSettle,
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-15 15:23:23 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    );
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  /// Requires being on the SettingsPage.account of the SettingsDialog
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  Future<void> logout() async {
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    final scrollable = find.findSettingsScrollable();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await scrollUntilVisible(
							 | 
						
					
						
							
								
									
										
										
										
											2024-09-03 16:58:38 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      find.byType(AccountSignInOutButton),
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      100,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      scrollable: scrollable,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    );
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-09-03 16:58:38 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await tapButton(find.byType(AccountSignInOutButton));
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-25 12:02:18 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expectToSeeText(LocaleKeys.button_ok.tr());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await tapButtonWithName(LocaleKeys.button_ok.tr());
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  Future<void> tapSignInAsGuest() async {
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-11 20:15:40 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await tapButton(find.byType(SignInAnonymousButtonV2));
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  void expectToSeeGoogleLoginButton() {
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-27 10:49:31 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(find.byKey(signInWithGoogleButtonKey), 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);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  void assertToggleValue(Finder finder, bool value) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    final Toggle switchWidget = widget(finder);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    final isSwitched = switchWidget.value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    assert(isSwitched == value);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  void assertAppFlowyCloudEnableSyncSwitchValue(bool value) {
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    assertToggleValue(
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      find.descendant(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        of: find.byType(AppFlowyCloudEnableSync),
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        matching: find.byWidgetPredicate((widget) => widget is Toggle),
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      ),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      value,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    );
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  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),
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      matching: find.byWidgetPredicate((widget) => widget is Toggle),
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    );
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await tapButton(finder);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |