sidebar_expand_test.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:appflowy/generated/locale_keys.g.dart';
  2. import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart';
  3. import 'package:appflowy/workspace/presentation/home/menu/sidebar/folder/personal_folder.dart';
  4. import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart';
  5. import 'package:easy_localization/easy_localization.dart';
  6. import 'package:flutter_test/flutter_test.dart';
  7. import 'package:integration_test/integration_test.dart';
  8. import '../util/util.dart';
  9. void main() {
  10. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  11. group('sidebar expand test', () {
  12. bool isExpanded({required FolderCategoryType type}) {
  13. if (type == FolderCategoryType.personal) {
  14. return find
  15. .descendant(
  16. of: find.byType(PersonalFolder),
  17. matching: find.byType(ViewItem),
  18. )
  19. .evaluate()
  20. .isNotEmpty;
  21. }
  22. return false;
  23. }
  24. testWidgets('first time the personal folder is expanded', (tester) async {
  25. await tester.initializeAppFlowy();
  26. await tester.tapGoButton();
  27. // first time is expanded
  28. expect(isExpanded(type: FolderCategoryType.personal), true);
  29. // collapse the personal folder
  30. await tester.tapButton(
  31. find.byTooltip(LocaleKeys.sideBar_clickToHidePersonal.tr()),
  32. );
  33. expect(isExpanded(type: FolderCategoryType.personal), false);
  34. // expand the personal folder
  35. await tester.tapButton(
  36. find.byTooltip(LocaleKeys.sideBar_clickToHidePersonal.tr()),
  37. );
  38. expect(isExpanded(type: FolderCategoryType.personal), true);
  39. });
  40. });
  41. }