| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | import 'package:appflowy/env/cloud_env.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | import 'package:appflowy/generated/locale_keys.g.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/workspace/application/settings/prelude.dart'; | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  | import 'package:appflowy/workspace/presentation/settings/widgets/setting_supabase_cloud.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | import 'package:appflowy/workspace/presentation/settings/widgets/settings_user_view.dart'; | 
					
						
							|  |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							|  |  |  | import 'package:flutter_test/flutter_test.dart'; | 
					
						
							|  |  |  | import 'package:integration_test/integration_test.dart'; | 
					
						
							|  |  |  | import '../util/util.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void main() { | 
					
						
							|  |  |  |   IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |   group('supabase auth', () { | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |     testWidgets('sign in with supabase', (tester) async { | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       await tester.initializeAppFlowy(cloudType: AuthenticatorType.supabase); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |       await tester.tapGoogleLoginInButton(); | 
					
						
							| 
									
										
										
										
											2023-12-27 11:42:39 +08:00
										 |  |  |       await tester.expectToSeeHomePageWithGetStartedPage(); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     testWidgets('sign out with supabase', (tester) async { | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       await tester.initializeAppFlowy(cloudType: AuthenticatorType.supabase); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |       await tester.tapGoogleLoginInButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Open the setting page and sign out
 | 
					
						
							|  |  |  |       await tester.openSettings(); | 
					
						
							|  |  |  |       await tester.openSettingsPage(SettingsPage.user); | 
					
						
							|  |  |  |       await tester.tapButton(find.byType(SettingLogoutButton)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-25 06:29:50 -07:00
										 |  |  |       tester.expectToSeeText(LocaleKeys.button_ok.tr()); | 
					
						
							|  |  |  |       await tester.tapButtonWithName(LocaleKeys.button_ok.tr()); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // Go to the sign in page again
 | 
					
						
							|  |  |  |       await tester.pumpAndSettle(const Duration(seconds: 1)); | 
					
						
							|  |  |  |       tester.expectToSeeGoogleLoginButton(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     testWidgets('sign in as annoymous', (tester) async { | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       await tester.initializeAppFlowy(cloudType: AuthenticatorType.supabase); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |       await tester.tapSignInAsGuest(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // should not see the sync setting page when sign in as annoymous
 | 
					
						
							|  |  |  |       await tester.openSettings(); | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |       await tester.openSettingsPage(SettingsPage.user); | 
					
						
							|  |  |  |       tester.expectToSeeGoogleLoginButton(); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |     // testWidgets('enable encryption', (tester) async {
 | 
					
						
							|  |  |  |     //   await tester.initializeAppFlowy(cloudType: CloudType.supabase);
 | 
					
						
							|  |  |  |     //   await tester.tapGoogleLoginInButton();
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |     //   // Open the setting page and sign out
 | 
					
						
							|  |  |  |     //   await tester.openSettings();
 | 
					
						
							|  |  |  |     //   await tester.openSettingsPage(SettingsPage.cloud);
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |     //   // the switch should be off by default
 | 
					
						
							|  |  |  |     //   tester.assertEnableEncryptSwitchValue(false);
 | 
					
						
							|  |  |  |     //   await tester.toggleEnableEncrypt();
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |     //   // the switch should be on after toggling
 | 
					
						
							|  |  |  |     //   tester.assertEnableEncryptSwitchValue(true);
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |     //   // the switch can not be toggled back to off
 | 
					
						
							|  |  |  |     //   await tester.toggleEnableEncrypt();
 | 
					
						
							|  |  |  |     //   tester.assertEnableEncryptSwitchValue(true);
 | 
					
						
							|  |  |  |     // });
 | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     testWidgets('enable sync', (tester) async { | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       await tester.initializeAppFlowy(cloudType: AuthenticatorType.supabase); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |       await tester.tapGoogleLoginInButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Open the setting page and sign out
 | 
					
						
							|  |  |  |       await tester.openSettings(); | 
					
						
							| 
									
										
										
										
											2023-11-17 15:38:56 +08:00
										 |  |  |       await tester.openSettingsPage(SettingsPage.cloud); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // the switch should be on by default
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       tester.assertSupabaseEnableSyncSwitchValue(true); | 
					
						
							|  |  |  |       await tester.toggleEnableSync(SupabaseEnableSync); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // the switch should be off
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       tester.assertSupabaseEnableSyncSwitchValue(false); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // the switch should be on after toggling
 | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       await tester.toggleEnableSync(SupabaseEnableSync); | 
					
						
							|  |  |  |       tester.assertSupabaseEnableSyncSwitchValue(true); | 
					
						
							| 
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |