Skip to content

Commit

Permalink
nav: Add a button for MentionsNarrow.
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Jul 16, 2024
1 parent cd4ae57 commit d51d274
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
6 changes: 6 additions & 0 deletions lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ class HomePage extends StatelessWidget {
narrow: const CombinedFeedNarrow())),
child: Text(zulipLocalizations.combinedFeedPageTitle)),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => Navigator.push(context,
MessageListPage.buildRoute(context: context,
narrow: const MentionsNarrow())),
child: Text(zulipLocalizations.mentionsPageTitle)),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => Navigator.push(context,
InboxPage.buildRoute(context: context)),
Expand Down
46 changes: 23 additions & 23 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -950,29 +950,6 @@ void main() {
check(store.unreads).oldUnreadsMissing.isTrue();
});

testWidgets('MentionsNarrow on legacy server', (WidgetTester tester) async {
await setupMessageListPage(tester,
narrow: const MentionsNarrow(),
messages: [eg.streamMessage(flags: [MessageFlag.mentioned])],
unreadMsgs: eg.unreadMsgs(mentions: [message.id]),
);
check(isMarkAsReadButtonVisible(tester)).isTrue();

connection.zulipFeatureLevel = 154;
connection.prepare(json:
UpdateMessageFlagsResult(messages: [message.id]).toJson());
await tester.tap(find.byType(MarkAsReadWidget));
check(connection.lastRequest).isA<http.Request>()
..method.equals('POST')
..url.path.equals('/api/v1/messages/flags')
..bodyFields.deepEquals({
'messages': jsonEncode([message.id]),
'op': 'add',
'flag': 'read',
});
await tester.pumpAndSettle();
});

testWidgets('StreamNarrow on legacy server', (WidgetTester tester) async {
final narrow = StreamNarrow(message.streamId);
await setupMessageListPage(tester,
Expand Down Expand Up @@ -1039,6 +1016,29 @@ void main() {
await tester.pumpAndSettle(); // process pending timers
});

testWidgets('MentionsNarrow on legacy server', (WidgetTester tester) async {
await setupMessageListPage(tester,
narrow: const MentionsNarrow(),
messages: [eg.streamMessage(flags: [MessageFlag.mentioned])],
unreadMsgs: eg.unreadMsgs(mentions: [message.id]),
);
check(isMarkAsReadButtonVisible(tester)).isTrue();

connection.zulipFeatureLevel = 154;
connection.prepare(json:
UpdateMessageFlagsResult(messages: [message.id]).toJson());
await tester.tap(find.byType(MarkAsReadWidget));
check(connection.lastRequest).isA<http.Request>()
..method.equals('POST')
..url.path.equals('/api/v1/messages/flags')
..bodyFields.deepEquals({
'messages': jsonEncode([message.id]),
'op': 'add',
'flag': 'read',
});
await tester.pumpAndSettle();
});

testWidgets('catch-all api errors', (WidgetTester tester) async {
final zulipLocalizations = GlobalLocalizations.zulipLocalizations;
const narrow = CombinedFeedNarrow();
Expand Down

0 comments on commit d51d274

Please sign in to comment.