tabs_test.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart';
  2. import 'package:appflowy/workspace/presentation/home/tabs/tabs_manager.dart';
  3. import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.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/base.dart';
  8. import 'util/common_operations.dart';
  9. const _readmeName = 'Read me';
  10. const _documentName = 'Document';
  11. const _calendarName = 'Calendar';
  12. void main() {
  13. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  14. group('Tabs', () {
  15. testWidgets('Open AppFlowy and open/navigate multiple tabs',
  16. (tester) async {
  17. await tester.initializeAppFlowy();
  18. await tester.tapGoButton();
  19. expect(
  20. find.descendant(
  21. of: find.byType(TabsManager),
  22. matching: find.byType(TabBar),
  23. ),
  24. findsNothing,
  25. );
  26. await tester.createNewPageWithName(ViewLayoutPB.Calendar, _calendarName);
  27. await tester.createNewPageWithName(ViewLayoutPB.Document, _documentName);
  28. // Navigate current view to "Read me" document again
  29. await tester.tapButtonWithName(_readmeName);
  30. /// Open second menu item in a new tab
  31. await tester.openAppInNewTab(_calendarName);
  32. /// Open third menu item in a new tab
  33. await tester.openAppInNewTab(_documentName);
  34. expect(
  35. find.descendant(
  36. of: find.byType(TabsManager),
  37. matching: find.byType(TabBar),
  38. ),
  39. findsOneWidget,
  40. );
  41. expect(
  42. find.descendant(
  43. of: find.byType(TabBar),
  44. matching: find.byType(FlowyTab),
  45. ),
  46. findsNWidgets(3),
  47. );
  48. /// Navigate to the first tab
  49. await tester.tap(
  50. find.descendant(
  51. of: find.byType(FlowyTab),
  52. matching: find.text(_readmeName),
  53. ),
  54. );
  55. });
  56. });
  57. }