Skip to content

Commit

Permalink
widget tests: Use whole [zulipThemeData] where [theme.extensions] is …
Browse files Browse the repository at this point in the history
…needed

This makes the tests more representative, and also more flexible
when we want to change the [MaterialApp.theme] that our widgets want
to consume.
  • Loading branch information
chrisbobbe committed May 22, 2024
1 parent 4939022 commit 2e5a264
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
7 changes: 4 additions & 3 deletions test/widgets/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:zulip/widgets/icons.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/store.dart';
import 'package:share_plus_platform_interface/method_channel/method_channel_share.dart';
import 'package:zulip/widgets/theme.dart';
import '../api/fake_api.dart';

import '../example_data.dart' as eg;
Expand Down Expand Up @@ -56,15 +57,15 @@ Future<void> setupToMessageActionSheet(WidgetTester tester, {
messages: [message],
).toJson());

await tester.pumpWidget(
await tester.pumpWidget(Builder(builder: (context) =>
MaterialApp(
theme: ThemeData(extensions: [ContentTheme()]),
theme: zulipThemeData(context),
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
supportedLocales: ZulipLocalizations.supportedLocales,
home: GlobalStoreWidget(
child: PerAccountStoreWidget(
accountId: eg.selfAccount.id,
child: MessageListPage(narrow: narrow)))));
child: MessageListPage(narrow: narrow))))));

// global store, per-account store, and message list get loaded
await tester.pumpAndSettle();
Expand Down
8 changes: 4 additions & 4 deletions test/widgets/autocomplete_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import 'package:zulip/api/route/messages.dart';
import 'package:zulip/model/compose.dart';
import 'package:zulip/model/narrow.dart';
import 'package:zulip/model/store.dart';
import 'package:zulip/widgets/content.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/store.dart';
import 'package:zulip/widgets/theme.dart';

import '../api/fake_api.dart';
import '../example_data.dart' as eg;
Expand Down Expand Up @@ -49,9 +49,9 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {

prepareBoringImageHttpClient();

await tester.pumpWidget(
await tester.pumpWidget(Builder(builder: (context) =>
MaterialApp(
theme: ThemeData(extensions: [ContentTheme()]),
theme: zulipThemeData(context),
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
supportedLocales: ZulipLocalizations.supportedLocales,
home: GlobalStoreWidget(
Expand All @@ -61,7 +61,7 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {
narrow: DmNarrow(
allRecipientIds: [eg.selfUser.userId, eg.otherUser.userId],
selfUserId: eg.selfUser.userId,
))))));
)))))));

// global store, per-account store, and message list get loaded
await tester.pumpAndSettle();
Expand Down
7 changes: 2 additions & 5 deletions test/widgets/content_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:zulip/widgets/icons.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/page.dart';
import 'package:zulip/widgets/store.dart';
import 'package:zulip/widgets/text.dart';
import 'package:zulip/widgets/theme.dart';

import '../example_data.dart' as eg;
import '../flutter_checks.dart';
Expand Down Expand Up @@ -129,10 +129,7 @@ void main() {
await tester.pumpWidget(
Builder(builder: (context) =>
MaterialApp(
theme: ThemeData(
typography: zulipTypography(context),
extensions: [ContentTheme()],
),
theme: zulipThemeData(context),
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
supportedLocales: ZulipLocalizations.supportedLocales,
navigatorObservers: navObservers,
Expand Down
7 changes: 4 additions & 3 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:zulip/widgets/content.dart';
import 'package:zulip/widgets/icons.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/store.dart';
import 'package:zulip/widgets/theme.dart';

import '../api/fake_api.dart';
import '../example_data.dart' as eg;
Expand Down Expand Up @@ -66,15 +67,15 @@ void main() {
connection.prepare(json:
newestResult(foundOldest: foundOldest, messages: messages).toJson());

await tester.pumpWidget(
await tester.pumpWidget(Builder(builder: (context) =>
MaterialApp(
theme: ThemeData(extensions: [ContentTheme()]),
theme: zulipThemeData(context),
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
supportedLocales: ZulipLocalizations.supportedLocales,
home: GlobalStoreWidget(
child: PerAccountStoreWidget(
accountId: eg.selfAccount.id,
child: MessageListPage(narrow: narrow)))));
child: MessageListPage(narrow: narrow))))));

// global store, per-account store, and message list get loaded
await tester.pumpAndSettle();
Expand Down
9 changes: 5 additions & 4 deletions test/widgets/profile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/page.dart';
import 'package:zulip/widgets/profile.dart';
import 'package:zulip/widgets/store.dart';
import 'package:zulip/widgets/theme.dart';

import '../example_data.dart' as eg;
import '../model/binding.dart';
Expand Down Expand Up @@ -41,15 +42,15 @@ Future<void> setupPage(WidgetTester tester, {
}

await tester.pumpWidget(
GlobalStoreWidget(
child: MaterialApp(
theme: ThemeData(extensions: [ContentTheme()]),
GlobalStoreWidget(child: Builder(builder: (context) =>
MaterialApp(
theme: zulipThemeData(context),
navigatorObservers: navigatorObserver != null ? [navigatorObserver] : [],
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
supportedLocales: ZulipLocalizations.supportedLocales,
home: PerAccountStoreWidget(
accountId: eg.selfAccount.id,
child: ProfilePage(userId: pageUserId)))));
child: ProfilePage(userId: pageUserId))))));

// global store, per-account store, and page get loaded
await tester.pumpAndSettle();
Expand Down

0 comments on commit 2e5a264

Please sign in to comment.