share_markdown_test.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'dart:io';
  2. import 'package:flutter_test/flutter_test.dart';
  3. import 'package:integration_test/integration_test.dart';
  4. import 'util/mock/mock_file_picker.dart';
  5. import 'util/util.dart';
  6. void main() {
  7. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  8. group('share markdown in document page', () {
  9. const location = 'markdown';
  10. setUp(() async {
  11. await TestFolder.cleanTestLocation(location);
  12. await TestFolder.setTestLocation(location);
  13. });
  14. tearDown(() async {
  15. await TestFolder.cleanTestLocation(location);
  16. });
  17. tearDownAll(() async {
  18. await TestFolder.cleanTestLocation(null);
  19. });
  20. testWidgets('click the share button in document page', (tester) async {
  21. await tester.initializeAppFlowy();
  22. await tester.tapGoButton();
  23. // expect to see a readme page
  24. tester.expectToSeePageName(readme);
  25. // mock the file picker
  26. final path = await mockSaveFilePath(location, 'test.md');
  27. // click the share button and select markdown
  28. await tester.tapShareButton();
  29. await tester.tapMarkdownButton();
  30. // expect to see the success dialog
  31. tester.expectToExportSuccess();
  32. final file = File(path);
  33. final isExist = file.existsSync();
  34. expect(isExist, true);
  35. final markdown = file.readAsStringSync();
  36. expect(markdown, expectedMarkdown);
  37. });
  38. });
  39. }
  40. const expectedMarkdown = r'''
  41. # Welcome to AppFlowy!
  42. ## Here are the basics
  43. - [ ] Click anywhere and just start typing.
  44. - [ ] Highlight any text, and use the editing menu to _style_ **your** <u>writing</u> `however` you ~~like.~~
  45. - [ ] As soon as you type `/` a menu will pop up. Select different types of content blocks you can add.
  46. - [ ] Type `/` followed by `/bullet` or `/num` to create a list.
  47. - [x] Click `+ New Page `button at the bottom of your sidebar to add a new page.
  48. - [ ] Click `+` next to any page title in the sidebar to quickly add a new subpage, `Document`, `Grid`, or `Kanban Board`.
  49. ---
  50. ## Keyboard shortcuts, markdown, and code block
  51. 1. Keyboard shortcuts [guide](https://appflowy.gitbook.io/docs/essential-documentation/shortcuts)
  52. 1. Markdown [reference](https://appflowy.gitbook.io/docs/essential-documentation/markdown)
  53. 1. Type `/code` to insert a code block
  54. ## Have a question❓
  55. > Click `?` at the bottom right for help and support.
  56. ''';