| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							|  |  |  | import 'package:flutter_test/flutter_test.dart'; | 
					
						
							|  |  |  | import 'package:integration_test/integration_test.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'util/mock/mock_file_picker.dart'; | 
					
						
							|  |  |  | import 'util/util.dart'; | 
					
						
							|  |  |  | import 'package:path/path.dart' as p; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void main() { | 
					
						
							|  |  |  |   IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   group('import files', () { | 
					
						
							|  |  |  |     testWidgets('import multiple markdown files', (tester) async { | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       final context = await tester.initializeAppFlowy(); | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |       await tester.tapGoButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-31 19:06:01 +07:00
										 |  |  |       // expect to see a getting started page
 | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |       tester.expectToSeePageName(gettingStarted); | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-31 19:06:01 +07:00
										 |  |  |       await tester.tapAddViewButton(); | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |       await tester.tapImportButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       final testFileNames = ['test1.md', 'test2.md']; | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       final paths = <String>[]; | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |       for (final fileName in testFileNames) { | 
					
						
							|  |  |  |         final str = await rootBundle.loadString( | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |           'assets/test/workspaces/markdowns/$fileName', | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |         final path = p.join(context.applicationDataDirectory, fileName); | 
					
						
							|  |  |  |         paths.add(path); | 
					
						
							|  |  |  |         File(path).writeAsStringSync(str); | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |       } | 
					
						
							|  |  |  |       // mock get files
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       await mockPickFilePaths( | 
					
						
							|  |  |  |         paths: testFileNames | 
					
						
							|  |  |  |             .map((e) => p.join(context.applicationDataDirectory, e)) | 
					
						
							|  |  |  |             .toList(), | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       await tester.tapTextAndMarkdownButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       tester.expectToSeePageName('test1'); | 
					
						
							|  |  |  |       tester.expectToSeePageName('test2'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |