Skip to content

Commit 6b2b657

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

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
@@ -715,20 +715,24 @@ void main() {
715715
.isA<Icon>().color.isNotNull().isSameColorAs(expectedIconColor);
716716
}
717717

718-
group('attach from media library', () {
719-
testWidgets('success', (tester) async {
720-
TypingNotifier.debugEnable = false;
721-
addTearDown(TypingNotifier.debugReset);
718+
Future<void> prepare(WidgetTester tester) async {
719+
TypingNotifier.debugEnable = false;
720+
addTearDown(TypingNotifier.debugReset);
722721

723-
final channel = eg.stream();
724-
final narrow = ChannelNarrow(channel.streamId);
725-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
722+
final channel = eg.stream();
723+
final narrow = ChannelNarrow(channel.streamId);
724+
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
726725

727-
// (When we check that the send button looks disabled, it should be because
728-
// the file is uploading, not a pre-existing reason.)
729-
await enterTopic(tester, narrow: narrow, topic: 'some topic');
730-
controller!.content.value = const TextEditingValue(text: 'see image: ');
731-
await tester.pump();
726+
// (When we check that the send button looks disabled, it should be because
727+
// the file is uploading, not a pre-existing reason.)
728+
await enterTopic(tester, narrow: narrow, topic: 'some topic');
729+
controller!.content.value = const TextEditingValue(text: 'see image: ');
730+
await tester.pump();
731+
}
732+
733+
group('attach from media library', () {
734+
testWidgets('success', (tester) async {
735+
await prepare(tester);
732736
checkAppearsLoading(tester, false);
733737

734738
testBinding.pickFilesResult = FilePickerResult([PlatformFile(
@@ -776,18 +780,7 @@ void main() {
776780

777781
group('attach from camera', () {
778782
testWidgets('success', (tester) async {
779-
TypingNotifier.debugEnable = false;
780-
addTearDown(TypingNotifier.debugReset);
781-
782-
final channel = eg.stream();
783-
final narrow = ChannelNarrow(channel.streamId);
784-
await prepareComposeBox(tester, narrow: narrow, streams: [channel]);
785-
786-
// (When we check that the send button looks disabled, it should be because
787-
// the file is uploading, not a pre-existing reason.)
788-
await enterTopic(tester, narrow: narrow, topic: 'some topic');
789-
controller!.content.value = const TextEditingValue(text: 'see image: ');
790-
await tester.pump();
783+
await prepare(tester);
791784
checkAppearsLoading(tester, false);
792785

793786
testBinding.pickImageResult = XFile.fromData(

0 commit comments

Comments
 (0)