Skip to content

Commit 8ab7f74

Browse files
committed
notif test [nfc]: Make openNotification public
Signed-off-by: Zixuan James Li <[email protected]>
1 parent ee004fa commit 8ab7f74

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

test/notifications/display_test.dart

Lines changed: 16 additions & 15 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;
@@ -991,21 +1007,6 @@ void main() {
9911007
check(pushedRoutes).isEmpty();
9921008
}
9931009

994-
Future<void> openNotification(WidgetTester tester, Account account, Message message) async {
995-
final data = messageFcmMessage(message, account: account);
996-
final intentDataUrl = NotificationOpenPayload(
997-
realmUrl: data.realmUrl,
998-
userId: data.userId,
999-
narrow: switch (data.recipient) {
1000-
FcmMessageChannelRecipient(:var streamId, :var topic) =>
1001-
TopicNarrow(streamId, topic),
1002-
FcmMessageDmRecipient(:var allRecipientIds) =>
1003-
DmNarrow(allRecipientIds: allRecipientIds, selfUserId: data.userId),
1004-
}).buildUrl();
1005-
unawaited(
1006-
WidgetsBinding.instance.handlePushRoute(intentDataUrl.toString()));
1007-
await tester.idle(); // let navigateForNotification find navigator
1008-
}
10091010

10101011
void matchesNavigation(Subject<Route<void>> route, Account account, Message message) {
10111012
route.isA<MaterialAccountWidgetRoute>()

0 commit comments

Comments
 (0)