Skip to content

Commit 131a4e9

Browse files
committed
compose_box test: Use full MessageListPage in compose box widget tests
1 parent 9689dce commit 131a4e9

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

test/widgets/compose_box_test.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import 'package:zulip/model/typing_status.dart';
2020
import 'package:zulip/widgets/app.dart';
2121
import 'package:zulip/widgets/color.dart';
2222
import 'package:zulip/widgets/compose_box.dart';
23+
import 'package:zulip/widgets/message_list.dart';
2324
import 'package:zulip/widgets/page.dart';
2425
import 'package:zulip/widgets/icons.dart';
2526
import 'package:zulip/widgets/theme.dart';
@@ -69,15 +70,12 @@ void main() {
6970

7071
connection = store.connection as FakeApiConnection;
7172

73+
connection.prepare(json:
74+
eg.newestGetMessagesResult(foundOldest: true, messages: []).toJson());
7275
await tester.pumpWidget(TestZulipApp(accountId: selfAccount.id,
73-
child: Column(
74-
// This positions the compose box at the bottom of the screen,
75-
// simulating the layout of the message list page.
76-
children: [
77-
const Expanded(child: SizedBox.expand()),
78-
ComposeBox(narrow: narrow),
79-
])));
76+
child: MessageListPage(initNarrow: narrow)));
8077
await tester.pumpAndSettle();
78+
connection.takeRequests();
8179

8280
controller = tester.state<ComposeBoxState>(find.byType(ComposeBox)).controller;
8381
}
@@ -1334,13 +1332,22 @@ void main() {
13341332
await enterContent(tester, 'some content');
13351333
checkContentInputValue(tester, 'some content');
13361334

1335+
// Encache a new connection; prepare it for the message-list fetch
1336+
final newConnection = (testBinding.globalStore
1337+
..clearCachedApiConnections()
1338+
..useCachedApiConnections = true)
1339+
.apiConnectionFromAccount(store.account) as FakeApiConnection;
1340+
newConnection.prepare(json:
1341+
eg.newestGetMessagesResult(foundOldest: true, messages: []).toJson());
1342+
13371343
store.updateMachine!
13381344
..debugPauseLoop()
13391345
..poll()
13401346
..debugPrepareLoopError(
13411347
eg.apiExceptionBadEventQueueId(queueId: store.queueId))
13421348
..debugAdvanceLoop();
13431349
await tester.pump();
1350+
await tester.pump(Duration.zero);
13441351

13451352
final newStore = testBinding.globalStore.perAccountSync(store.accountId)!;
13461353
check(newStore)

0 commit comments

Comments
 (0)