Skip to content

Commit c5b47b3

Browse files
committed
compose test [nfc]: Extract prepare helper
Signed-off-by: Zixuan James Li <[email protected]>
1 parent ae7939a commit c5b47b3

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

test/widgets/compose_box_test.dart

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -574,20 +574,24 @@ void main() {
574574
.isA<Icon>().color.isNotNull().isSameColorAs(expectedIconColor);
575575
}
576576

577-
group('attach from media library', () {
578-
testWidgets('success', (tester) async {
579-
TypingNotifier.debugEnable = false;
580-
addTearDown(TypingNotifier.debugReset);
577+
Future<void> prepare(WidgetTester tester) async {
578+
TypingNotifier.debugEnable = false;
579+
addTearDown(TypingNotifier.debugReset);
581580

582-
final channel = eg.stream();
583-
final narrow = ChannelNarrow(channel.streamId);
584-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
581+
final channel = eg.stream();
582+
final narrow = ChannelNarrow(channel.streamId);
583+
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
585584

586-
// (When we check that the send button looks disabled, it should be because
587-
// the file is uploading, not a pre-existing reason.)
588-
await enterTopic(tester, narrow: narrow, topic: 'some topic');
589-
controller!.content.value = const TextEditingValue(text: 'see image: ');
590-
await tester.pump();
585+
// (When we check that the send button looks disabled, it should be because
586+
// the file is uploading, not a pre-existing reason.)
587+
await enterTopic(tester, narrow: narrow, topic: 'some topic');
588+
controller!.content.value = const TextEditingValue(text: 'see image: ');
589+
await tester.pump();
590+
}
591+
592+
group('attach from media library', () {
593+
testWidgets('success', (tester) async {
594+
await prepare(tester);
591595
checkAppearsLoading(tester, false);
592596

593597
testBinding.pickFilesResult = FilePickerResult([PlatformFile(
@@ -635,18 +639,7 @@ void main() {
635639

636640
group('attach from camera', () {
637641
testWidgets('success', (tester) async {
638-
TypingNotifier.debugEnable = false;
639-
addTearDown(TypingNotifier.debugReset);
640-
641-
final channel = eg.stream();
642-
final narrow = ChannelNarrow(channel.streamId);
643-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
644-
645-
// (When we check that the send button looks disabled, it should be because
646-
// the file is uploading, not a pre-existing reason.)
647-
await enterTopic(tester, narrow: narrow, topic: 'some topic');
648-
controller!.content.value = const TextEditingValue(text: 'see image: ');
649-
await tester.pump();
642+
await prepare(tester);
650643
checkAppearsLoading(tester, false);
651644

652645
testBinding.pickImageResult = XFile.fromData(

0 commit comments

Comments
 (0)