Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions test/widgets/inbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.

Expand Down