tabs_test.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import 'dart:io';
  2. import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart';
  3. import 'package:appflowy/workspace/presentation/home/tabs/tabs_manager.dart';
  4. import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter/services.dart';
  7. import 'package:flutter_test/flutter_test.dart';
  8. import 'package:integration_test/integration_test.dart';
  9. import 'util/base.dart';
  10. import 'util/common_operations.dart';
  11. import 'util/expectation.dart';
  12. import 'util/keyboard.dart';
  13. const _documentName = 'First Doc';
  14. const _documentTwoName = 'Second Doc';
  15. void main() {
  16. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  17. group('Tabs', () {
  18. testWidgets('Open AppFlowy and open/navigate/close tabs', (tester) async {
  19. await tester.initializeAppFlowy();
  20. await tester.tapGoButton();
  21. expect(
  22. find.descendant(
  23. of: find.byType(TabsManager),
  24. matching: find.byType(TabBar),
  25. ),
  26. findsNothing,
  27. );
  28. await tester.createNewPageWithName(
  29. name: _documentName,
  30. layout: ViewLayoutPB.Document,
  31. );
  32. await tester.createNewPageWithName(
  33. name: _documentTwoName,
  34. layout: ViewLayoutPB.Document,
  35. );
  36. /// Open second menu item in a new tab
  37. await tester.openAppInNewTab(gettingStarted, ViewLayoutPB.Document);
  38. /// Open third menu item in a new tab
  39. await tester.openAppInNewTab(_documentName, ViewLayoutPB.Document);
  40. expect(
  41. find.descendant(
  42. of: find.byType(TabBar),
  43. matching: find.byType(FlowyTab),
  44. ),
  45. findsNWidgets(3),
  46. );
  47. /// Navigate to the second tab
  48. await tester.tap(
  49. find.descendant(
  50. of: find.byType(FlowyTab),
  51. matching: find.text(gettingStarted),
  52. ),
  53. );
  54. /// Close tab by shortcut
  55. await FlowyTestKeyboard.simulateKeyDownEvent(
  56. [
  57. Platform.isMacOS
  58. ? LogicalKeyboardKey.meta
  59. : LogicalKeyboardKey.control,
  60. LogicalKeyboardKey.keyW,
  61. ],
  62. tester: tester,
  63. );
  64. expect(
  65. find.descendant(
  66. of: find.byType(TabBar),
  67. matching: find.byType(FlowyTab),
  68. ),
  69. findsNWidgets(2),
  70. );
  71. });
  72. });
  73. }