Skip to content

Commit fa3f012

Browse files
committed
emoji_reaction test: Set up whole ZulipApp, not just MaterialApp
This way, the ReactionChipsList gets our theme extensions and lots of other stuff for free, so it's more representative. We're about to add a theme extension for this page, so it's helpful to do this now.
1 parent 26a96dc commit fa3f012

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

test/widgets/emoji_reaction_test.dart

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import 'package:flutter_test/flutter_test.dart';
1010
import 'package:zulip/api/model/events.dart';
1111
import 'package:zulip/api/model/model.dart';
1212
import 'package:zulip/model/store.dart';
13+
import 'package:zulip/widgets/app.dart';
1314
import 'package:zulip/widgets/emoji_reaction.dart';
14-
import 'package:zulip/widgets/store.dart';
15+
import 'package:zulip/widgets/page.dart';
1516

1617
import '../example_data.dart' as eg;
1718
import '../flutter_checks.dart';
@@ -46,25 +47,28 @@ void main() {
4647
}) async {
4748
final message = eg.streamMessage(reactions: reactions);
4849

49-
await tester.pumpWidget(
50-
MaterialApp(
51-
home: Directionality(
52-
textDirection: textDirection,
53-
child: GlobalStoreWidget(
54-
child: PerAccountStoreWidget(
55-
accountId: eg.selfAccount.id,
56-
child: Center(
57-
child: ColoredBox(
58-
color: Colors.white,
59-
child: SizedBox(
60-
width: width,
61-
child: ReactionChipsList(
62-
messageId: message.id,
63-
reactions: message.reactions!,
64-
)))))))));
65-
66-
// global store, per-account store
67-
await tester.pumpAndSettle();
50+
final locale = switch (textDirection) {
51+
TextDirection.ltr => const Locale('en'),
52+
TextDirection.rtl => const Locale('ar'),
53+
};
54+
tester.platformDispatcher.localeTestValue = locale;
55+
tester.platformDispatcher.localesTestValue = [locale];
56+
addTearDown(tester.platformDispatcher.clearLocaleTestValue);
57+
addTearDown(tester.platformDispatcher.clearLocalesTestValue);
58+
59+
await tester.pumpWidget(const ZulipApp());
60+
await tester.pump();
61+
final navigator = await ZulipApp.navigator;
62+
navigator.push(MaterialAccountWidgetRoute(accountId: eg.selfAccount.id, page: Center(
63+
child: ColoredBox(
64+
color: Colors.white,
65+
child: SizedBox(
66+
width: width,
67+
child: ReactionChipsList(
68+
messageId: message.id,
69+
reactions: message.reactions!,
70+
))))));
71+
await tester.pumpAndSettle(); // global store, per-account store
6872

6973
final reactionChipsList = tester.element(find.byType(ReactionChipsList));
7074
check(Directionality.of(reactionChipsList)).equals(textDirection);

0 commit comments

Comments
 (0)