1
1
import 'dart:convert' ;
2
2
3
3
import 'package:checks/checks.dart' ;
4
+ import 'package:collection/collection.dart' ;
4
5
import 'package:flutter/material.dart' ;
5
6
import 'package:flutter/services.dart' ;
6
7
import 'package:flutter_checks/flutter_checks.dart' ;
@@ -143,6 +144,35 @@ void main() {
143
144
connection = store.connection as FakeApiConnection ;
144
145
}
145
146
147
+ Future <void > showFromInbox (WidgetTester tester, {
148
+ String topic = someTopic,
149
+ }) async {
150
+ assert (() {
151
+ final channelIdsWithUnreads = store.unreads.streams.keys;
152
+ final topicWithUnreads = channelIdsWithUnreads.firstWhereOrNull ((streamId) =>
153
+ store.unreads.countInTopicNarrow (streamId, TopicName (topic)) > 0 );
154
+ if (topicWithUnreads == null ) {
155
+ throw FlutterError .fromParts ([
156
+ ErrorSummary ('showFromInbox called without an unread message' ),
157
+ ErrorHint (
158
+ 'Before calling showFromInbox, ensure that [Unreads] '
159
+ 'has an unread message in the relevant topic. ' ,
160
+ ),
161
+ ]);
162
+ }
163
+ return true ;
164
+ }());
165
+
166
+ await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
167
+ child: const HomePage ()));
168
+ await tester.pump ();
169
+ check (find.byType (InboxPageBody )).findsOne ();
170
+
171
+ await tester.longPress (find.text (topic));
172
+ // sheet appears onscreen; default duration of bottom-sheet enter animation
173
+ await tester.pump (const Duration (milliseconds: 250 ));
174
+ }
175
+
146
176
group ('showTopicActionSheet' , () {
147
177
void checkButtons () {
148
178
final actionSheetFinder = find.byType (BottomSheet );
@@ -164,14 +194,7 @@ void main() {
164
194
topic: someTopic,
165
195
unreadMessageIds: [someMessage.id],
166
196
)]));
167
- await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
168
- child: const HomePage ()));
169
- await tester.pump ();
170
- check (find.byType (InboxPageBody )).findsOne ();
171
-
172
- await tester.longPress (find.text (someTopic));
173
- // sheet appears onscreen; default duration of bottom-sheet enter animation
174
- await tester.pump (const Duration (milliseconds: 250 ));
197
+ await showFromInbox (tester);
175
198
checkButtons ();
176
199
});
177
200
0 commit comments