-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(flutter_desktop): document search (#6669)
* fix: double dispose on find menu * fix: empty query not resetting search service * fix: input focus getting lost after clicking button or pressing enter * chore: remove unused focus node and text controller * chore: bump appflowy editor * chore: code cleanup * chore: fix focus getting lost on submission * fix: next match focuses on title after jumping * chore: bump appflowy editor * revert: unnecessary changes to FlowyFormTextInput * fix: title requesting focus unexpectedly * Update frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/cover_title.dart Co-authored-by: Mathias Mogensen <[email protected]> * chore: merge conflicts * chore: code cleanup * test: add integration test * fix: show replace menu icon color in dark mode --------- Co-authored-by: Mathias Mogensen <[email protected]>
- Loading branch information
1 parent
1952ef0
commit 941b7cf
Showing
9 changed files
with
315 additions
and
154 deletions.
There are no files selected for viewing
144 changes: 144 additions & 0 deletions
144
frontend/appflowy_flutter/integration_test/desktop/document/document_find_menu_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:appflowy/generated/flowy_svgs.g.dart'; | ||
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart'; | ||
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart'; | ||
import 'package:appflowy/startup/startup.dart'; | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:universal_platform/universal_platform.dart'; | ||
|
||
import '../../shared/util.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
String generateRandomString(int len) { | ||
final r = Random(); | ||
return String.fromCharCodes( | ||
List.generate(len, (index) => r.nextInt(33) + 89), | ||
); | ||
} | ||
|
||
testWidgets( | ||
'document find menu test', | ||
(tester) async { | ||
await tester.initializeAppFlowy(); | ||
await tester.tapAnonymousSignInButton(); | ||
|
||
// create a new document | ||
await tester.createNewPageWithNameUnderParent(); | ||
|
||
// tap editor to get focus | ||
await tester.tapButton(find.byType(AppFlowyEditor)); | ||
|
||
// set clipboard data | ||
final data = [ | ||
"123456\n", | ||
...List.generate(100, (_) => "${generateRandomString(50)}\n"), | ||
"1234567\n", | ||
...List.generate(100, (_) => "${generateRandomString(50)}\n"), | ||
"12345678\n", | ||
...List.generate(100, (_) => "${generateRandomString(50)}\n"), | ||
].join(); | ||
await getIt<ClipboardService>().setData( | ||
ClipboardServiceData( | ||
plainText: data, | ||
), | ||
); | ||
|
||
// paste | ||
await tester.simulateKeyEvent( | ||
LogicalKeyboardKey.keyV, | ||
isControlPressed: | ||
UniversalPlatform.isLinux || UniversalPlatform.isWindows, | ||
isMetaPressed: UniversalPlatform.isMacOS, | ||
); | ||
await tester.pumpAndSettle(); | ||
|
||
// go back to beginning of document | ||
// FIXME: Cannot run Ctrl+F unless selection is on screen | ||
await tester.editor | ||
.updateSelection(Selection.collapsed(Position(path: [0]))); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(FindAndReplaceMenuWidget), findsNothing); | ||
|
||
// press cmd/ctrl+F to display the find menu | ||
await tester.simulateKeyEvent( | ||
LogicalKeyboardKey.keyF, | ||
isControlPressed: | ||
UniversalPlatform.isLinux || UniversalPlatform.isWindows, | ||
isMetaPressed: UniversalPlatform.isMacOS, | ||
); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(FindAndReplaceMenuWidget), findsOneWidget); | ||
|
||
final textField = find.descendant( | ||
of: find.byType(FindAndReplaceMenuWidget), | ||
matching: find.byType(TextField), | ||
); | ||
|
||
await tester.enterText( | ||
textField, | ||
"123456", | ||
); | ||
await tester.pumpAndSettle(); | ||
await tester.pumpAndSettle(); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(AppFlowyEditor), | ||
matching: find.text("123456", findRichText: true), | ||
), | ||
findsOneWidget, | ||
); | ||
|
||
await tester.testTextInput.receiveAction(TextInputAction.done); | ||
await tester.pumpAndSettle(); | ||
await tester.pumpAndSettle(); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(AppFlowyEditor), | ||
matching: find.text("1234567", findRichText: true), | ||
), | ||
findsOneWidget, | ||
); | ||
|
||
await tester.showKeyboard(textField); | ||
await tester.idle(); | ||
await tester.testTextInput.receiveAction(TextInputAction.done); | ||
await tester.pumpAndSettle(); | ||
await tester.pumpAndSettle(); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(AppFlowyEditor), | ||
matching: find.text("12345678", findRichText: true), | ||
), | ||
findsOneWidget, | ||
); | ||
|
||
// tap next button, go back to beginning of document | ||
await tester.tapButton( | ||
find.descendant( | ||
of: find.byType(FindMenu), | ||
matching: find.byFlowySvg(FlowySvgs.arrow_down_s), | ||
), | ||
); | ||
|
||
expect( | ||
find.descendant( | ||
of: find.byType(AppFlowyEditor), | ||
matching: find.text("123456", findRichText: true), | ||
), | ||
findsOneWidget, | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.