Add tests to validate fixes for #1189
parent
a9d5631f27
commit
f3e20df96c
1 changed files with 60 additions and 0 deletions
@ -0,0 +1,60 @@ |
|||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:flutter_quill/flutter_quill.dart' hide Text; |
||||||
|
import 'package:flutter_test/flutter_test.dart'; |
||||||
|
import 'widget_tester_extension.dart'; |
||||||
|
|
||||||
|
void main() { |
||||||
|
group('Bug fix', () { |
||||||
|
group('1189 - The provided text position is not in the current node', () { |
||||||
|
late QuillController controller; |
||||||
|
late QuillEditor editor; |
||||||
|
|
||||||
|
setUp(() { |
||||||
|
controller = QuillController.basic(); |
||||||
|
editor = QuillEditor.basic(controller: controller, readOnly: false); |
||||||
|
}); |
||||||
|
|
||||||
|
tearDown(() { |
||||||
|
controller.dispose(); |
||||||
|
}); |
||||||
|
|
||||||
|
testWidgets('Refocus editor after controller clears document', |
||||||
|
(tester) async { |
||||||
|
await tester.pumpWidget(MaterialApp(home: Column(children: [editor]))); |
||||||
|
await tester.quillEnterText(find.byType(QuillEditor), 'test\n'); |
||||||
|
|
||||||
|
editor.focusNode.unfocus(); |
||||||
|
await tester.pump(); |
||||||
|
controller.clear(); |
||||||
|
editor.focusNode.requestFocus(); |
||||||
|
await tester.pump(); |
||||||
|
expect(tester.takeException(), isNull); |
||||||
|
}); |
||||||
|
|
||||||
|
testWidgets('Refocus editor after removing block attribute', |
||||||
|
(tester) async { |
||||||
|
await tester.pumpWidget(MaterialApp(home: Column(children: [editor]))); |
||||||
|
await tester.quillEnterText(find.byType(QuillEditor), 'test\n'); |
||||||
|
|
||||||
|
controller.formatSelection(Attribute.ul); |
||||||
|
editor.focusNode.unfocus(); |
||||||
|
await tester.pump(); |
||||||
|
controller.formatSelection(const ListAttribute(null)); |
||||||
|
editor.focusNode.requestFocus(); |
||||||
|
await tester.pump(); |
||||||
|
expect(tester.takeException(), isNull); |
||||||
|
}); |
||||||
|
|
||||||
|
testWidgets('Tap checkbox in unfocused editor', (tester) async { |
||||||
|
await tester.pumpWidget(MaterialApp(home: Column(children: [editor]))); |
||||||
|
await tester.quillEnterText(find.byType(QuillEditor), 'test\n'); |
||||||
|
|
||||||
|
controller.formatSelection(Attribute.unchecked); |
||||||
|
editor.focusNode.unfocus(); |
||||||
|
await tester.pump(); |
||||||
|
await tester.tap(find.byType(CheckboxPoint)); |
||||||
|
expect(tester.takeException(), isNull); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
Loading…
Reference in new issue