@@ -42,11 +42,6 @@ void main() {
42
42
await store.addUsers ([eg.selfUser, ...users]);
43
43
connection = store.connection as FakeApiConnection ;
44
44
45
- if (narrow is ChannelNarrow ) {
46
- // Ensure topics are loaded before testing actual logic.
47
- connection.prepare (body:
48
- jsonEncode (GetStreamTopicsResult (topics: [eg.getStreamTopicsEntry ()]).toJson ()));
49
- }
50
45
final controllerKey = GlobalKey <ComposeBoxController >();
51
46
await tester.pumpWidget (TestZulipApp (accountId: eg.selfAccount.id,
52
47
child: ComposeBox (controllerKey: controllerKey, narrow: narrow)));
@@ -55,6 +50,21 @@ void main() {
55
50
return controllerKey;
56
51
}
57
52
53
+ Future <void > enterTopic (WidgetTester tester, {
54
+ required ChannelNarrow narrow,
55
+ required String topic,
56
+ }) async {
57
+ final topicInputFinder = find.byWidgetPredicate (
58
+ (widget) => widget is TextField && widget.controller is ComposeTopicController );
59
+
60
+ connection.prepare (body:
61
+ jsonEncode (GetStreamTopicsResult (topics: [eg.getStreamTopicsEntry ()]).toJson ()));
62
+ await tester.enterText (topicInputFinder, topic);
63
+ check (connection.takeRequests ()).single
64
+ ..method.equals ('GET' )
65
+ ..url.path.equals ('/api/v1/users/me/${narrow .streamId }/topics' );
66
+ }
67
+
58
68
group ('ComposeContentController' , () {
59
69
group ('insertPadded' , () {
60
70
// Like `parseMarkedText` in test/model/autocomplete_test.dart,
@@ -271,12 +281,13 @@ void main() {
271
281
TypingNotifier .debugEnable = false ;
272
282
addTearDown (TypingNotifier .debugReset);
273
283
274
- final controllerKey = await prepareComposeBox (tester, narrow: ChannelNarrow (eg.stream ().streamId));
284
+ final narrow = ChannelNarrow (eg.stream ().streamId);
285
+ final controllerKey = await prepareComposeBox (tester, narrow: narrow);
275
286
final composeBoxController = controllerKey.currentState! ;
276
287
277
288
// (When we check that the send button looks disabled, it should be because
278
289
// the file is uploading, not a pre-existing reason.)
279
- composeBoxController.topicController ! .value = const TextEditingValue (text : 'some topic' );
290
+ await enterTopic (tester, narrow : narrow, topic : 'some topic' );
280
291
composeBoxController.contentController.value = const TextEditingValue (text: 'see image: ' );
281
292
await tester.pump ();
282
293
checkAppearsLoading (tester, false );
@@ -330,12 +341,13 @@ void main() {
330
341
TypingNotifier .debugEnable = false ;
331
342
addTearDown (TypingNotifier .debugReset);
332
343
333
- final controllerKey = await prepareComposeBox (tester, narrow: ChannelNarrow (eg.stream ().streamId));
344
+ final narrow = ChannelNarrow (eg.stream ().streamId);
345
+ final controllerKey = await prepareComposeBox (tester, narrow: narrow);
334
346
final composeBoxController = controllerKey.currentState! ;
335
347
336
348
// (When we check that the send button looks disabled, it should be because
337
349
// the file is uploading, not a pre-existing reason.)
338
- composeBoxController.topicController ! .value = const TextEditingValue (text : 'some topic' );
350
+ await enterTopic (tester, narrow : narrow, topic : 'some topic' );
339
351
composeBoxController.contentController.value = const TextEditingValue (text: 'see image: ' );
340
352
await tester.pump ();
341
353
checkAppearsLoading (tester, false );
0 commit comments