document_alignment_test.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:appflowy/generated/flowy_svgs.g.dart';
  2. import 'package:appflowy_editor/appflowy_editor.dart';
  3. import 'package:flutter_test/flutter_test.dart';
  4. import 'package:integration_test/integration_test.dart';
  5. import '../util/util.dart';
  6. void main() {
  7. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  8. group('document alignment', () {
  9. testWidgets('edit alignment in toolbar', (tester) async {
  10. await tester.initializeAppFlowy();
  11. await tester.tapGoButton();
  12. final selection = Selection.single(
  13. path: [0],
  14. startOffset: 0,
  15. endOffset: 1,
  16. );
  17. // click the first line of the readme
  18. await tester.editor.tapLineOfEditorAt(0);
  19. await tester.editor.updateSelection(selection);
  20. await tester.pumpAndSettle();
  21. // click the align center
  22. await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_left_s);
  23. await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_center_s);
  24. // expect to see the align center
  25. final editorState = tester.editor.getCurrentEditorState();
  26. final first = editorState.getNodeAtPath([0])!;
  27. expect(first.attributes[blockComponentAlign], 'center');
  28. // click the align right
  29. await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_center_s);
  30. await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_right_s);
  31. expect(first.attributes[blockComponentAlign], 'right');
  32. // click the align left
  33. await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_right_s);
  34. await tester.tapButtonWithFlowySvgData(FlowySvgs.toolbar_align_left_s);
  35. expect(first.attributes[blockComponentAlign], 'left');
  36. });
  37. });
  38. }