auth_test.dart 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import 'package:appflowy/generated/locale_keys.g.dart';
  2. import 'package:appflowy/workspace/application/settings/prelude.dart';
  3. import 'package:appflowy/workspace/presentation/settings/widgets/settings_user_view.dart';
  4. import 'package:easy_localization/easy_localization.dart';
  5. import 'package:flutter_test/flutter_test.dart';
  6. import 'package:integration_test/integration_test.dart';
  7. import '../util/util.dart';
  8. void main() {
  9. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  10. group('auth', () {
  11. testWidgets('sign in with supabase', (tester) async {
  12. await tester.initializeAppFlowy();
  13. await tester.tapGoogleLoginInButton();
  14. tester.expectToSeeHomePage();
  15. });
  16. testWidgets('sign out with supabase', (tester) async {
  17. await tester.initializeAppFlowy();
  18. await tester.tapGoogleLoginInButton();
  19. // Open the setting page and sign out
  20. await tester.openSettings();
  21. await tester.openSettingsPage(SettingsPage.user);
  22. await tester.tapButton(find.byType(SettingLogoutButton));
  23. tester.expectToSeeText(LocaleKeys.button_OK.tr());
  24. await tester.tapButtonWithName(LocaleKeys.button_OK.tr());
  25. // Go to the sign in page again
  26. await tester.pumpAndSettle(const Duration(seconds: 1));
  27. tester.expectToSeeGoogleLoginButton();
  28. });
  29. testWidgets('sign in as annoymous', (tester) async {
  30. await tester.initializeAppFlowy();
  31. await tester.tapSignInAsGuest();
  32. // should not see the sync setting page when sign in as annoymous
  33. await tester.openSettings();
  34. await tester.expectNoSettingsPage(SettingsPage.syncSetting);
  35. });
  36. testWidgets('enable encryption', (tester) async {
  37. await tester.initializeAppFlowy();
  38. await tester.tapGoogleLoginInButton();
  39. // Open the setting page and sign out
  40. await tester.openSettings();
  41. await tester.openSettingsPage(SettingsPage.syncSetting);
  42. // the switch should be off by default
  43. tester.assertEnableEncryptSwitchValue(false);
  44. await tester.toggleEnableEncrypt();
  45. // the switch should be on after toggling
  46. tester.assertEnableEncryptSwitchValue(true);
  47. // the switch can not be toggled back to off
  48. await tester.toggleEnableEncrypt();
  49. tester.assertEnableEncryptSwitchValue(true);
  50. });
  51. testWidgets('enable sync', (tester) async {
  52. await tester.initializeAppFlowy();
  53. await tester.tapGoogleLoginInButton();
  54. // Open the setting page and sign out
  55. await tester.openSettings();
  56. await tester.openSettingsPage(SettingsPage.syncSetting);
  57. // the switch should be on by default
  58. tester.assertEnableSyncSwitchValue(true);
  59. await tester.toggleEnableSync();
  60. // the switch should be off
  61. tester.assertEnableSyncSwitchValue(false);
  62. // the switch should be on after toggling
  63. await tester.toggleEnableSync();
  64. tester.assertEnableSyncSwitchValue(true);
  65. });
  66. });
  67. }