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/workspace/application/settings/prelude.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:appflowy/workspace/presentation/settings/pages/settings_account_view.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:flutter_test/flutter_test.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:integration_test/integration_test.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-05 17:20:27 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import '../shared/util.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								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();
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await tester.openSettingsPage(SettingsPage.account);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.logout();
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // Go to the sign in page again
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.pumpAndSettle(const Duration(seconds: 1));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.expectToSeeGoogleLoginButton();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-05 17:20:27 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    testWidgets('sign in as anonymous', (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();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-05 17:20:27 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      // should not see the sync setting page when sign in as anonymous
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-22 15:40:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.openSettings();
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await tester.openSettingsPage(SettingsPage.account);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // Scroll to sign-out
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.scrollUntilVisible(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        find.byType(SignInOutButton),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        100,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        scrollable: find.findSettingsScrollable(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      );
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapButton(find.byType(SignInOutButton));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |