Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
test: implement select all test for no-styled text
Lucas.Xuc732f4e908fe
diff --git a/frontend/app_flowy/packages/flowy_editor/test/infra/test_raw_key_event.dart b/frontend/app_flowy/packages/flowy_editor/test/infra/test_raw_key_event.dartindex 8fa0e5e4e3..78ed06383e 100644--- a/frontend/app_flowy/packages/flowy_editor/test/infra/test_raw_key_event.dart+++ b/frontend/app_flowy/packages/flowy_editor/test/infra/test_raw_key_event.dart@@ -94,6 +94,9 @@ extension on LogicalKeyboardKey {if (this == LogicalKeyboardKey.keyZ) {return PhysicalKeyboardKey.keyZ;}+ if (this == LogicalKeyboardKey.keyA) {+ return PhysicalKeyboardKey.keyA;+ }throw UnimplementedError();}}diff --git a/frontend/app_flowy/packages/flowy_editor/test/service/internal_key_event_handlers/select_all_handler_test.dart b/frontend/app_flowy/packages/flowy_editor/test/service/internal_key_event_handlers/select_all_handler_test.dartnew file mode 100644index 0000000000..53c13b7119--- /dev/null+++ b/frontend/app_flowy/packages/flowy_editor/test/service/internal_key_event_handlers/select_all_handler_test.dart@@ -0,0 +1,38 @@+import 'package:flowy_editor/flowy_editor.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import '../../infra/test_editor.dart';++void main() async {+ setUpAll(() {+ TestWidgetsFlutterBinding.ensureInitialized();+ });++ group('select_all_handler_test.dart', () {+ testWidgets('Presses Command + A in small document', (tester) async {+ await _testSelectAllHandler(tester, 10);+ });++ testWidgets('Presses Command + A in small document', (tester) async {+ await _testSelectAllHandler(tester, 1000);+ });+ });+}++Future<void> _testSelectAllHandler(WidgetTester tester, int lines) async {+ const text = 'Welcome to Appflowy 😁';+ final editor = tester.editor;+ for (var i = 0; i < lines; i++) {+ editor.insertTextNode(text);+ }+ await editor.startTesting();+ await editor.pressLogicKey(LogicalKeyboardKey.keyA, isMetaPressed: true);++ expect(+ editor.documentSelection,+ Selection(+ start: Position(path: [0], offset: 0),+ end: Position(path: [lines - 1], offset: text.length),+ ),+ );+}