Skip to content

Commit 3d36968

Browse files
committed
display test [nfc]: Make openNotification public
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 31020b6 commit 3d36968

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/notifications/display_test.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ RemoveFcmMessage removeFcmMessage(List<Message> zulipMessages, {Account? account
9292
}) as RemoveFcmMessage;
9393
}
9494

95+
Future<void> openNotification(WidgetTester tester, Account account, Message message) async {
96+
final data = messageFcmMessage(message, account: account);
97+
final intentDataUrl = NotificationOpenPayload(
98+
realmUrl: data.realmUrl,
99+
userId: data.userId,
100+
narrow: switch (data.recipient) {
101+
FcmMessageChannelRecipient(:var streamId, :var topic) =>
102+
TopicNarrow(streamId, topic),
103+
FcmMessageDmRecipient(:var allRecipientIds) =>
104+
DmNarrow(allRecipientIds: allRecipientIds, selfUserId: data.userId),
105+
}).buildUrl();
106+
unawaited(
107+
WidgetsBinding.instance.handlePushRoute(intentDataUrl.toString()));
108+
await tester.idle(); // let navigateForNotification find navigator
109+
}
110+
95111
void main() {
96112
TestZulipBinding.ensureInitialized();
97113
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
@@ -958,22 +974,6 @@ void main() {
958974
check(pushedRoutes).isEmpty();
959975
}
960976

961-
Future<void> openNotification(WidgetTester tester, Account account, Message message) async {
962-
final data = messageFcmMessage(message, account: account);
963-
final intentDataUrl = NotificationOpenPayload(
964-
realmUrl: data.realmUrl,
965-
userId: data.userId,
966-
narrow: switch (data.recipient) {
967-
FcmMessageChannelRecipient(:var streamId, :var topic) =>
968-
TopicNarrow(streamId, topic),
969-
FcmMessageDmRecipient(:var allRecipientIds) =>
970-
DmNarrow(allRecipientIds: allRecipientIds, selfUserId: data.userId),
971-
}).buildUrl();
972-
unawaited(
973-
WidgetsBinding.instance.handlePushRoute(intentDataUrl.toString()));
974-
await tester.idle(); // let navigateForNotification find navigator
975-
}
976-
977977
void matchesNavigation(Subject<Route<void>> route, Account account, Message message) {
978978
route.isA<MaterialAccountWidgetRoute>()
979979
..accountId.equals(account.id)

0 commit comments

Comments
 (0)