mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 10:03:18 +00:00 
			
		
		
		
	 f0d5f51703
			
		
	
	
		f0d5f51703
		
			
		
	
	
	
	
		
			
			* fix:windows integration test * fix: load asset * fix: windows test * fix: test * test: refactor the folder test --------- Co-authored-by: vedon <vedon.fu@gmail.com> Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
		
			
				
	
	
		
			131 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			131 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:io';
 | |
| 
 | |
| import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
 | |
| import 'package:appflowy_editor/appflowy_editor.dart';
 | |
| import 'package:flutter/services.dart';
 | |
| import 'package:flutter_test/flutter_test.dart';
 | |
| import 'package:integration_test/integration_test.dart';
 | |
| 
 | |
| import '../util/ime.dart';
 | |
| import '../util/util.dart';
 | |
| 
 | |
| void main() {
 | |
|   IntegrationTestWidgetsFlutterBinding.ensureInitialized();
 | |
| 
 | |
|   group('edit document', () {
 | |
|     testWidgets('redo & undo', (tester) async {
 | |
|       await tester.initializeAppFlowy();
 | |
|       await tester.tapGoButton();
 | |
| 
 | |
|       // create a new document called Sample
 | |
|       const pageName = 'Sample';
 | |
|       await tester.createNewPageWithName(ViewLayoutPB.Document, pageName);
 | |
| 
 | |
|       // focus on the editor
 | |
|       await tester.editor.tapLineOfEditorAt(0);
 | |
| 
 | |
|       // insert 1. to trigger it to be a numbered list
 | |
|       await tester.ime.insertText('1. ');
 | |
|       expect(find.text('1.', findRichText: true), findsOneWidget);
 | |
|       expect(
 | |
|         tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type,
 | |
|         NumberedListBlockKeys.type,
 | |
|       );
 | |
| 
 | |
|       // undo
 | |
|       // numbered list will be reverted to paragraph
 | |
|       await tester.simulateKeyEvent(
 | |
|         LogicalKeyboardKey.keyZ,
 | |
|         isControlPressed: Platform.isWindows || Platform.isLinux,
 | |
|         isMetaPressed: Platform.isMacOS,
 | |
|       );
 | |
|       expect(
 | |
|         tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type,
 | |
|         ParagraphBlockKeys.type,
 | |
|       );
 | |
| 
 | |
|       // redo
 | |
|       await tester.simulateKeyEvent(
 | |
|         LogicalKeyboardKey.keyZ,
 | |
|         isControlPressed: Platform.isWindows || Platform.isLinux,
 | |
|         isMetaPressed: Platform.isMacOS,
 | |
|         isShiftPressed: true,
 | |
|       );
 | |
|       expect(
 | |
|         tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type,
 | |
|         NumberedListBlockKeys.type,
 | |
|       );
 | |
| 
 | |
|       // switch to other page and switch back
 | |
|       await tester.openPage(readme);
 | |
|       await tester.openPage(pageName);
 | |
| 
 | |
|       // the numbered list should be kept
 | |
|       expect(
 | |
|         tester.editor.getCurrentEditorState().getNodeAtPath([0])!.type,
 | |
|         NumberedListBlockKeys.type,
 | |
|       );
 | |
|     });
 | |
| 
 | |
|     testWidgets('write a readme document', (tester) async {
 | |
|       await tester.initializeAppFlowy();
 | |
|       await tester.tapGoButton();
 | |
| 
 | |
|       // create a new document called Sample
 | |
|       const pageName = 'Sample';
 | |
|       await tester.createNewPageWithName(ViewLayoutPB.Document, pageName);
 | |
| 
 | |
|       // focus on the editor
 | |
|       await tester.editor.tapLineOfEditorAt(0);
 | |
| 
 | |
|       // mock inputting the sample
 | |
|       final lines = _sample.split('\n');
 | |
|       for (final line in lines) {
 | |
|         await tester.ime.insertText(line);
 | |
|         await tester.ime.insertCharacter('\n');
 | |
|       }
 | |
| 
 | |
|       // switch to other page and switch back
 | |
|       await tester.openPage(readme);
 | |
|       await tester.openPage(pageName);
 | |
| 
 | |
|       // this screenshots are different on different platform, so comment it out temporarily.
 | |
|       // check the document
 | |
|       // await expectLater(
 | |
|       //   find.byType(AppFlowyEditor),
 | |
|       //   matchesGoldenFile('document/edit_document_test.png'),
 | |
|       // );
 | |
|     });
 | |
|   });
 | |
| }
 | |
| 
 | |
| // TODO(Lucas.Xu): there're no shorctcuts for underline, format code yet.
 | |
| const _sample = r'''
 | |
| # Heading 1
 | |
| ## Heading 2
 | |
| ### Heading 3
 | |
| ---
 | |
| [] Highlight any text, and use the editing menu to _style_ **your** writing `however` you ~~like.~~
 | |
| 
 | |
| [] Type followed by bullet or num to create a list.
 | |
| 
 | |
| [x] Click `+ New Page` button at the bottom of your sidebar to add a new page.
 | |
| 
 | |
| [] Click `+` next to any page title in the sidebar to quickly add a new subpage, `Document`, `Grid`, or `Kanban Board`.
 | |
| ---
 | |
| * bulleted list 1
 | |
| 
 | |
| * bulleted list 2
 | |
| 
 | |
| * bulleted list 3
 | |
| bulleted list 4
 | |
| ---
 | |
| 1. numbered list 1
 | |
| 
 | |
| 2. numbered list 2
 | |
| 
 | |
| 3. numbered list 3
 | |
| numbered list 4
 | |
| ---
 | |
| " quote''';
 |