@@ -170,6 +170,31 @@ void main() {
170170 await tester.pump (const Duration (milliseconds: 250 ));
171171 }
172172
173+ Future <void > showFromAppBar (WidgetTester tester, {
174+ ZulipStream ? channel,
175+ String topic = someTopic,
176+ StreamMessage ? message,
177+ }) async {
178+ final effectiveChannel = channel ?? someChannel;
179+ final effectiveMessage = message ?? someMessage;
180+ assert (effectiveMessage.topic.apiName == topic);
181+
182+ connection.prepare (json: eg.newestGetMessagesResult (
183+ foundOldest: true , messages: [effectiveMessage]).toJson ());
184+ await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
185+ child: MessageListPage (
186+ initNarrow: eg.topicNarrow (effectiveChannel.streamId, topic))));
187+ // global store, per-account store, and message list get loaded
188+ await tester.pumpAndSettle ();
189+
190+ final topicRow = find.descendant (
191+ of: find.byType (ZulipAppBar ),
192+ matching: find.text (topic));
193+ await tester.longPress (topicRow);
194+ // sheet appears onscreen; default duration of bottom-sheet enter animation
195+ await tester.pump (const Duration (milliseconds: 250 ));
196+ }
197+
173198 group ('showTopicActionSheet' , () {
174199 void checkButtons () {
175200 final actionSheetFinder = find.byType (BottomSheet );
@@ -197,20 +222,7 @@ void main() {
197222
198223 testWidgets ('show from app bar' , (tester) async {
199224 await prepare ();
200- connection.prepare (json: eg.newestGetMessagesResult (
201- foundOldest: true , messages: [someMessage]).toJson ());
202- await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
203- child: MessageListPage (
204- initNarrow: eg.topicNarrow (someChannel.streamId, someTopic))));
205- // global store, per-account store, and message list get loaded
206- await tester.pumpAndSettle ();
207-
208- final topicRow = find.descendant (
209- of: find.byType (ZulipAppBar ),
210- matching: find.text (someTopic));
211- await tester.longPress (topicRow);
212- // sheet appears onscreen; default duration of bottom-sheet enter animation
213- await tester.pump (const Duration (milliseconds: 250 ));
225+ await showFromAppBar (tester);
214226 checkButtons ();
215227 });
216228
0 commit comments