Skip to content

Commit 7770762

Browse files
gnpricechrisbobbe
authored andcommitted
new-dms test: Include self-user in users list
1 parent 53fbf77 commit 7770762

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

test/widgets/new_dm_sheet_test.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import 'test_app.dart';
2525
late PerAccountStore store;
2626

2727
Future<void> setupSheet(WidgetTester tester, {
28+
User? selfUser,
2829
required List<User> users,
2930
List<int>? mutedUserIds,
3031
}) async {
@@ -34,17 +35,18 @@ Future<void> setupSheet(WidgetTester tester, {
3435
final testNavObserver = TestNavigatorObserver()
3536
..onPushed = (route, _) => lastPushedRoute = route;
3637

37-
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot(
38-
realmUsers: users,
39-
));
40-
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
38+
selfUser ??= eg.selfUser;
39+
final account = eg.account(user: selfUser);
40+
await testBinding.globalStore.add(account, eg.initialSnapshot(
41+
realmUsers: [selfUser, ...users]));
42+
store = await testBinding.globalStore.perAccount(account.id);
4143
if (mutedUserIds != null) {
4244
await store.setMutedUsers(mutedUserIds);
4345
}
4446

4547
await tester.pumpWidget(TestZulipApp(
4648
navigatorObservers: [testNavObserver],
47-
accountId: eg.selfAccount.id,
49+
accountId: account.id,
4850
child: const HomePage()));
4951
await tester.pumpAndSettle();
5052

@@ -124,7 +126,7 @@ void main() {
124126
];
125127

126128
testWidgets('shows full list initially', (tester) async {
127-
await setupSheet(tester, users: testUsers);
129+
await setupSheet(tester, selfUser: testUsers[0], users: testUsers);
128130
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
129131
check(findText(includePlaceholders: false, 'Bob Brown')).findsOne();
130132
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
@@ -144,7 +146,8 @@ void main() {
144146
testWidgets('deactivated users excluded', (tester) async {
145147
// Omit a deactivated user both before there's a query…
146148
final deactivatedUser = eg.user(fullName: 'Impostor Charlie', isActive: false);
147-
await setupSheet(tester, users: [...testUsers, deactivatedUser]);
149+
await setupSheet(tester, selfUser: testUsers[0],
150+
users: [...testUsers, deactivatedUser]);
148151
check(findText(includePlaceholders: false, 'Impostor Charlie')).findsNothing();
149152
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
150153
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(3);
@@ -160,7 +163,7 @@ void main() {
160163
testWidgets('muted users excluded', (tester) async {
161164
// Omit muted users both before there's a query…
162165
final mutedUser = eg.user(fullName: 'Someone Muted');
163-
await setupSheet(tester,
166+
await setupSheet(tester, selfUser: testUsers[0],
164167
users: [...testUsers, mutedUser], mutedUserIds: [mutedUser.userId]);
165168
check(findText(includePlaceholders: false, 'Someone Muted')).findsNothing();
166169
check(findText(includePlaceholders: false, 'Muted user')).findsNothing();
@@ -255,7 +258,7 @@ void main() {
255258
}
256259

257260
testWidgets('tapping user chip deselects the user', (tester) async {
258-
await setupSheet(tester, users: [eg.selfUser, eg.otherUser, eg.thirdUser]);
261+
await setupSheet(tester, users: [eg.otherUser, eg.thirdUser]);
259262

260263
await tester.tap(findUserTile(eg.otherUser));
261264
await tester.pump();
@@ -267,7 +270,7 @@ void main() {
267270

268271
testWidgets('selecting and deselecting a user', (tester) async {
269272
final user = eg.user(fullName: 'Test User');
270-
await setupSheet(tester, users: [eg.selfUser, user]);
273+
await setupSheet(tester, users: [user]);
271274

272275
checkUserSelected(tester, user, false);
273276
checkUserSelected(tester, eg.selfUser, false);
@@ -286,7 +289,7 @@ void main() {
286289

287290
testWidgets('other user selection deselects self user', (tester) async {
288291
final otherUser = eg.user(fullName: 'Other User');
289-
await setupSheet(tester, users: [eg.selfUser, otherUser]);
292+
await setupSheet(tester, users: [otherUser]);
290293

291294
await tester.tap(findUserTile(eg.selfUser));
292295
await tester.pump();
@@ -301,7 +304,7 @@ void main() {
301304

302305
testWidgets('other user selection hides self user', (tester) async {
303306
final otherUser = eg.user(fullName: 'Other User');
304-
await setupSheet(tester, users: [eg.selfUser, otherUser]);
307+
await setupSheet(tester, users: [otherUser]);
305308

306309
check(findText(includePlaceholders: false, eg.selfUser.fullName)).findsOne();
307310

0 commit comments

Comments
 (0)