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,32 @@ 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
+ final channelIdsWithUnreads = store.unreads.streams.keys;
151
+ final hasTopicWithUnreads = channelIdsWithUnreads.any ((streamId) =>
152
+ store.unreads.countInTopicNarrow (streamId, TopicName (topic)) > 0 );
153
+ if (! hasTopicWithUnreads) {
154
+ throw FlutterError .fromParts ([
155
+ ErrorSummary ('showFromInbox called without an unread message' ),
156
+ ErrorHint (
157
+ 'Before calling showFromInbox, ensure that [Unreads] '
158
+ 'has an unread message in the relevant topic. ' ,
159
+ ),
160
+ ]);
161
+ }
162
+
163
+ await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
164
+ child: const HomePage ()));
165
+ await tester.pump ();
166
+ check (find.byType (InboxPageBody )).findsOne ();
167
+
168
+ await tester.longPress (find.text (topic));
169
+ // sheet appears onscreen; default duration of bottom-sheet enter animation
170
+ await tester.pump (const Duration (milliseconds: 250 ));
171
+ }
172
+
146
173
group ('showTopicActionSheet' , () {
147
174
void checkButtons () {
148
175
final actionSheetFinder = find.byType (BottomSheet );
@@ -164,14 +191,7 @@ void main() {
164
191
topic: someTopic,
165
192
unreadMessageIds: [someMessage.id],
166
193
)]));
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 ));
194
+ await showFromInbox (tester);
175
195
checkButtons ();
176
196
});
177
197
0 commit comments