document_option_action_test.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'package:flutter_test/flutter_test.dart';
  2. import 'package:integration_test/integration_test.dart';
  3. import '../util/util.dart';
  4. void main() {
  5. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  6. // +, ... button beside the block component.
  7. group('document with option action button', () {
  8. testWidgets(
  9. 'click + to add a block after current selection, and click + and option key to add a block before current selection',
  10. (tester) async {
  11. await tester.initializeAppFlowy();
  12. await tester.tapGoButton();
  13. var editorState = tester.editor.getCurrentEditorState();
  14. expect(editorState.getNodeAtPath([1])?.delta?.toPlainText(), isNotEmpty);
  15. // add a new block after the current selection
  16. await tester.editor.hoverAndClickOptionAddButton([0], false);
  17. // await tester.pumpAndSettle();
  18. expect(editorState.getNodeAtPath([1])?.delta?.toPlainText(), isEmpty);
  19. // cancel the selection menu
  20. await tester.tapAt(Offset.zero);
  21. await tester.editor.hoverAndClickOptionAddButton([0], true);
  22. await tester.pumpAndSettle();
  23. expect(editorState.getNodeAtPath([0])?.delta?.toPlainText(), isEmpty);
  24. // cancel the selection menu
  25. await tester.tapAt(Offset.zero);
  26. await tester.tapAt(Offset.zero);
  27. await tester.createNewPageWithName(name: 'test');
  28. await tester.openPage(gettingStarted);
  29. // check the status again
  30. editorState = tester.editor.getCurrentEditorState();
  31. expect(editorState.getNodeAtPath([0])?.delta?.toPlainText(), isEmpty);
  32. expect(editorState.getNodeAtPath([2])?.delta?.toPlainText(), isEmpty);
  33. });
  34. });
  35. }