user_icon_test.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import 'package:appflowy/workspace/application/settings/prelude.dart';
  2. import 'package:appflowy/workspace/presentation/settings/widgets/settings_user_view.dart';
  3. import 'package:appflowy/workspace/presentation/widgets/user_avatar.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'package:integration_test/integration_test.dart';
  6. import '../util/util.dart';
  7. void main() {
  8. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  9. group('Settings: user icon tests', () {
  10. testWidgets('select icon, select default option', (tester) async {
  11. await tester.initializeAppFlowy();
  12. await tester.tapGoButton();
  13. tester.expectToSeeHomePage();
  14. await tester.openSettings();
  15. await tester.openSettingsPage(SettingsPage.user);
  16. final userAvatarFinder = find.descendant(
  17. of: find.byType(SettingsUserView),
  18. matching: find.byType(UserAvatar),
  19. );
  20. // Open icon picker dialog
  21. await tester.tap(userAvatarFinder);
  22. await tester.pumpAndSettle();
  23. // Select first option that isn't default
  24. await tester.tap(find.byType(IconOption).first);
  25. await tester.pumpAndSettle();
  26. UserAvatar userAvatar = tester.widget(userAvatarFinder) as UserAvatar;
  27. expect(userAvatar.iconUrl, isNotEmpty);
  28. // Open icon picker dialog again
  29. await tester.tap(userAvatarFinder);
  30. await tester.pumpAndSettle();
  31. // Tap the default option
  32. await tester.tap(
  33. find.descendant(
  34. of: find.byType(IconGallery),
  35. matching: find.byType(UserAvatar),
  36. ),
  37. );
  38. await tester.pumpAndSettle();
  39. userAvatar = tester.widget(userAvatarFinder) as UserAvatar;
  40. expect(userAvatar.iconUrl, isEmpty);
  41. });
  42. });
  43. }