import_files_test.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'dart:io';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_test/flutter_test.dart';
  4. import 'package:integration_test/integration_test.dart';
  5. import 'util/mock/mock_file_picker.dart';
  6. import 'util/util.dart';
  7. import 'package:path/path.dart' as p;
  8. void main() {
  9. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  10. group('import files', () {
  11. const location = 'import_files';
  12. setUp(() async {
  13. await TestFolder.cleanTestLocation(location);
  14. await TestFolder.setTestLocation(location);
  15. });
  16. tearDown(() async {
  17. await TestFolder.cleanTestLocation(location);
  18. });
  19. tearDownAll(() async {
  20. await TestFolder.cleanTestLocation(null);
  21. });
  22. testWidgets('import multiple markdown files', (tester) async {
  23. await tester.initializeAppFlowy();
  24. await tester.tapGoButton();
  25. // expect to see a readme page
  26. tester.expectToSeePageName(readme);
  27. await tester.tapAddButton();
  28. await tester.tapImportButton();
  29. final testFileNames = ['test1.md', 'test2.md'];
  30. final fileLocation = await tester.currentFileLocation();
  31. for (final fileName in testFileNames) {
  32. final str = await rootBundle.loadString(
  33. p.join(
  34. 'assets/test/workspaces/markdowns',
  35. fileName,
  36. ),
  37. );
  38. File(p.join(fileLocation, fileName)).writeAsStringSync(str);
  39. }
  40. // mock get files
  41. await mockPickFilePaths(testFileNames, name: location);
  42. await tester.tapTextAndMarkdownButton();
  43. tester.expectToSeePageName('test1');
  44. tester.expectToSeePageName('test2');
  45. });
  46. });
  47. }