tabs_test.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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(
  27. name: _calendarName,
  28. layout: ViewLayoutPB.Calendar,
  29. );
  30. await tester.createNewPageWithName(
  31. name: _documentName,
  32. layout: ViewLayoutPB.Document,
  33. );
  34. // Navigate current view to "Read me" document again
  35. await tester.tapButtonWithName(_readmeName);
  36. /// Open second menu item in a new tab
  37. await tester.openAppInNewTab(_calendarName);
  38. /// Open third menu item in a new tab
  39. await tester.openAppInNewTab(_documentName);
  40. expect(
  41. find.descendant(
  42. of: find.byType(TabsManager),
  43. matching: find.byType(TabBar),
  44. ),
  45. findsOneWidget,
  46. );
  47. expect(
  48. find.descendant(
  49. of: find.byType(TabBar),
  50. matching: find.byType(FlowyTab),
  51. ),
  52. findsNWidgets(3),
  53. );
  54. /// Navigate to the first tab
  55. await tester.tap(
  56. find.descendant(
  57. of: find.byType(FlowyTab),
  58. matching: find.text(_readmeName),
  59. ),
  60. );
  61. });
  62. });
  63. }