Skip to content

Commit b6a865b

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

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

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

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

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

483487
testBinding.pickFilesResult = FilePickerResult([PlatformFile(
@@ -526,18 +530,7 @@ void main() {
526530

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

543536
testBinding.pickImageResult = XFile.fromData(

0 commit comments

Comments
 (0)