diff --git a/test/widgets/inbox_test.dart b/test/widgets/inbox_test.dart index 63aad6292c..08e72edcf4 100644 --- a/test/widgets/inbox_test.dart +++ b/test/widgets/inbox_test.dart @@ -9,9 +9,11 @@ import 'package:zulip/widgets/color.dart'; import 'package:zulip/widgets/home.dart'; import 'package:zulip/widgets/icons.dart'; import 'package:zulip/widgets/channel_colors.dart'; +import 'package:zulip/widgets/message_list.dart'; import 'package:zulip/widgets/theme.dart'; import 'package:zulip/widgets/unread_count_badge.dart'; +import '../api/fake_api.dart'; import '../example_data.dart' as eg; import '../flutter_checks.dart'; import '../model/binding.dart'; @@ -229,8 +231,71 @@ void main() { check(text).style.isNotNull().color.isNotNull().isSameColorAs(expectedTextColor); }); - // TODO test that tapping a conversation row opens the message list - // for the conversation + group('navigation', () { + testWidgets('tapping a topic row opens the message list', (tester) async { + final stream = eg.stream(); + final subscription = eg.subscription(stream); + const topic = 'lunch'; + final message = eg.streamMessage(stream: stream, topic: topic); + + await setupPage(tester, + streams: [stream], + subscriptions: [subscription], + unreadMessages: [message]); + + final connection = store.connection as FakeApiConnection; + + connection.prepare( + json: eg.newestGetMessagesResult(messages: [ + eg.streamMessage(stream: stream, topic: topic, + flags: [MessageFlag.read]), + ], foundOldest: false).toJson(), + ); + + connection.prepare( + json: eg.newestGetMessagesResult(messages: [], foundOldest: true).toJson(), + ); + + await tester.tap(find.text(topic)); + await tester.pumpAndSettle(); + + check(find.byType(HomePage)).findsNothing(); + check(find.byType(MessageListPage)).findsOne(); + + check(find.text(topic)).findsAny(); + + }); + + testWidgets('tapping a DM row opens the message list', (tester) async { + final otherUser = eg.otherUser; + final message = eg.dmMessage(from: otherUser, to: [eg.selfUser]); + + await setupPage(tester, + users: [eg.selfUser, otherUser], + unreadMessages: [message]); + + final connection = store.connection as FakeApiConnection; + + connection.prepare( + json: eg.newestGetMessagesResult(messages: [ + eg.dmMessage(from: otherUser, to: [eg.selfUser], flags: [MessageFlag.read]), + ], foundOldest: false).toJson(), + ); + + connection.prepare( + json: eg.newestGetMessagesResult(messages: [], foundOldest: true).toJson(), + ); + + await tester.tap(find.text(otherUser.fullName)); + await tester.pumpAndSettle(); + + check(find.byType(HomePage)).findsNothing(); + check(find.byType(MessageListPage)).findsOne(); + + check(find.text(otherUser.fullName)).findsAny(); + }); + + }); // Tests for the topic action sheet are in test/widgets/action_sheet_test.dart.