Closed niteshsh4rma closed 1 year ago
It's not that convenient yet and I think we should provide some test utilities with Fleather. Right now you can use flutter_test_robots
to make it a bit easier.
void main() {
testWidgets('test', (tester) async {
final controller = FleatherController();
final app = MaterialApp(home: FleatherEditor(controller: controller));
final editor = find.byType(RawEditor);
await tester.pumpWidget(app);
await tester.tap(editor);
await tester.ime.typeText('My Text', finder: editor);
expect(controller.document.toPlainText(), 'My Text\n');
await tester.pumpAndSettle(throttleDuration);
});
}
I'm closing it but feel free to reopen if it's not fixed. @niteshsh4rma
Thanks, @Amir-P for the workaround (& @niteshsh4rma for raising an issue). In my case, these lines were enough to make it work (w/o the "expect" from the initial post - it's failing on it probably because you need to trigger frame rendering firstly after action, and only after you can check the results of it):
final editor = find.byType(RawEditor);
await tester.tap(editor);
await tester.ime.typeText(commentText, finder: editor);
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle(throttleDuration);
Note (for others facing this issue & trying this approach): you need to install the "flutter_test_robots".
Steps to Reproduce
final editor = find.byType(RawEditor)
tester.tap(editor)
tester.enterText("Hey there")
Logs
Nothing happens after
tester.enterText
is called and test is completed, no text in the FleatherField