appearance_settings_test.dart 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import 'package:appflowy/workspace/application/appearance_defaults.dart';
  2. import 'package:appflowy/workspace/application/settings/prelude.dart';
  3. import 'package:appflowy/workspace/presentation/settings/widgets/settings_appearance/settings_appearance.dart';
  4. import 'package:flutter/material.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('appearance settings tests', () {
  11. testWidgets('after editing text field, button should be able to be clicked',
  12. (tester) async {
  13. await tester.initializeAppFlowy();
  14. await tester.tapGoButton();
  15. tester.expectToSeeHomePage();
  16. await tester.openSettings();
  17. await tester.openSettingsPage(SettingsPage.appearance);
  18. final dropDown = find.byKey(ThemeFontFamilySetting.popoverKey);
  19. await tester.tap(dropDown);
  20. await tester.pumpAndSettle();
  21. final textField = find.byKey(ThemeFontFamilySetting.textFieldKey);
  22. await tester.tap(textField);
  23. await tester.pumpAndSettle();
  24. await tester.enterText(textField, 'Abel');
  25. await tester.pumpAndSettle();
  26. final fontFamilyButton = find.byKey(const Key('Abel'));
  27. expect(fontFamilyButton, findsOneWidget);
  28. await tester.tap(fontFamilyButton);
  29. await tester.pumpAndSettle();
  30. // just switch the page and verify that the font family was set after that
  31. await tester.openSettingsPage(SettingsPage.files);
  32. await tester.openSettingsPage(SettingsPage.appearance);
  33. expect(find.textContaining('Abel'), findsOneWidget);
  34. });
  35. testWidgets('reset the font family', (tester) async {
  36. await tester.initializeAppFlowy();
  37. await tester.tapGoButton();
  38. tester.expectToSeeHomePage();
  39. await tester.openSettings();
  40. await tester.openSettingsPage(SettingsPage.appearance);
  41. final dropDown = find.byKey(ThemeFontFamilySetting.popoverKey);
  42. await tester.tap(dropDown);
  43. await tester.pumpAndSettle();
  44. final textField = find.byKey(ThemeFontFamilySetting.textFieldKey);
  45. await tester.tap(textField);
  46. await tester.pumpAndSettle();
  47. await tester.enterText(textField, 'Abel');
  48. await tester.pumpAndSettle();
  49. final fontFamilyButton = find.byKey(const Key('Abel'));
  50. expect(fontFamilyButton, findsOneWidget);
  51. await tester.tap(fontFamilyButton);
  52. await tester.pumpAndSettle();
  53. // just switch the page and verify that the font family was set after that
  54. await tester.openSettingsPage(SettingsPage.files);
  55. await tester.openSettingsPage(SettingsPage.appearance);
  56. final resetButton = find.byKey(ThemeFontFamilySetting.resetButtonkey);
  57. await tester.tap(resetButton);
  58. await tester.pumpAndSettle();
  59. // just switch the page and verify that the font family was set after that
  60. await tester.openSettingsPage(SettingsPage.files);
  61. await tester.openSettingsPage(SettingsPage.appearance);
  62. expect(find.textContaining(DefaultAppearanceSettings.kDefaultFontFamily),
  63. findsOneWidget,
  64. );
  65. });
  66. });
  67. }