Skip to content

Commit 063ef6a

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

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
@@ -463,20 +463,24 @@ void main() {
463463
.isA<Icon>().color.isNotNull().isSameColorAs(expectedIconColor);
464464
}
465465

466-
group('attach from media library', () {
467-
testWidgets('success', (tester) async {
468-
TypingNotifier.debugEnable = false;
469-
addTearDown(TypingNotifier.debugReset);
466+
Future<void> prepare(WidgetTester tester) async {
467+
TypingNotifier.debugEnable = false;
468+
addTearDown(TypingNotifier.debugReset);
470469

471-
final channel = eg.stream();
472-
final narrow = ChannelNarrow(channel.streamId);
473-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
470+
final channel = eg.stream();
471+
final narrow = ChannelNarrow(channel.streamId);
472+
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
474473

475-
// (When we check that the send button looks disabled, it should be because
476-
// the file is uploading, not a pre-existing reason.)
477-
await enterTopic(tester, narrow: narrow, topic: 'some topic');
478-
controller!.content.value = const TextEditingValue(text: 'see image: ');
479-
await tester.pump();
474+
// (When we check that the send button looks disabled, it should be because
475+
// the file is uploading, not a pre-existing reason.)
476+
await enterTopic(tester, narrow: narrow, topic: 'some topic');
477+
controller!.content.value = const TextEditingValue(text: 'see image: ');
478+
await tester.pump();
479+
}
480+
481+
group('attach from media library', () {
482+
testWidgets('success', (tester) async {
483+
await prepare(tester);
480484
checkAppearsLoading(tester, false);
481485

482486
testBinding.pickFilesResult = FilePickerResult([PlatformFile(
@@ -525,18 +529,7 @@ void main() {
525529

526530
group('attach from camera', () {
527531
testWidgets('success', (tester) async {
528-
TypingNotifier.debugEnable = false;
529-
addTearDown(TypingNotifier.debugReset);
530-
531-
final channel = eg.stream();
532-
final narrow = ChannelNarrow(channel.streamId);
533-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
534-
535-
// (When we check that the send button looks disabled, it should be because
536-
// the file is uploading, not a pre-existing reason.)
537-
await enterTopic(tester, narrow: narrow, topic: 'some topic');
538-
controller!.content.value = const TextEditingValue(text: 'see image: ');
539-
await tester.pump();
532+
await prepare(tester);
540533
checkAppearsLoading(tester, false);
541534

542535
testBinding.pickImageResult = XFile.fromData(

0 commit comments

Comments
 (0)