Skip to content

Commit 953dece

Browse files
committed
compose_box test [nfc]: Support overriding account
This will be useful when we need to override the API feature level for example. Signed-off-by: Zixuan James Li <[email protected]>
1 parent de2bf6c commit 953dece

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/widgets/compose_box_test.dart

+10-5
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ void main() {
3232
late PerAccountStore store;
3333
late FakeApiConnection connection;
3434

35-
Future<GlobalKey<ComposeBoxController>> prepareComposeBox(WidgetTester tester,
36-
{required Narrow narrow, List<User> users = const []}) async {
35+
Future<GlobalKey<ComposeBoxController>> prepareComposeBox(WidgetTester tester, {
36+
required Narrow narrow,
37+
Account? account,
38+
List<User> users = const [],
39+
}) async {
3740
addTearDown(testBinding.reset);
38-
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
41+
account ??= eg.selfAccount;
42+
await testBinding.globalStore.add(account, eg.initialSnapshot(
43+
zulipFeatureLevel: account.zulipFeatureLevel));
3944

40-
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
45+
store = await testBinding.globalStore.perAccount(account.id);
4146

4247
await store.addUsers([eg.selfUser, ...users]);
4348
connection = store.connection as FakeApiConnection;
@@ -48,7 +53,7 @@ void main() {
4853
jsonEncode(GetStreamTopicsResult(topics: [eg.getStreamTopicsEntry()]).toJson()));
4954
}
5055
final controllerKey = GlobalKey<ComposeBoxController>();
51-
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
56+
await tester.pumpWidget(TestZulipApp(accountId: account.id,
5257
child: ComposeBox(controllerKey: controllerKey, narrow: narrow)));
5358
await tester.pumpAndSettle();
5459

0 commit comments

Comments
 (0)