Skip to content

Commit ee71b42

Browse files
committed
profile: Distinguish isBot: true users with a bot marker
1 parent 3aaebdb commit ee71b42

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

lib/widgets/profile.dart

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import '../api/model/model.dart';
77
import '../model/content.dart';
88
import '../model/narrow.dart';
99
import 'content.dart';
10+
import 'icons.dart';
1011
import 'message_list.dart';
1112
import 'page.dart';
1213
import 'store.dart';
@@ -46,10 +47,23 @@ class ProfilePage extends StatelessWidget {
4647
Center(
4748
child: Avatar(userId: userId, size: 200, borderRadius: 200 / 8)),
4849
const SizedBox(height: 16),
49-
Text(user.fullName,
50-
textAlign: TextAlign.center,
51-
style: _TextStyles.primaryFieldText
52-
.merge(weightVariableTextStyle(context, wght: 700))),
50+
Row(
51+
mainAxisAlignment: MainAxisAlignment.center,
52+
children: [
53+
if (user.isBot) ...[
54+
const Icon(
55+
ZulipIcons.bot,
56+
size: 22,
57+
color: Color.fromARGB(255, 159, 173, 173),
58+
),
59+
const SizedBox(width: 10),
60+
],
61+
Flexible(child: Text(user.fullName,
62+
textAlign: TextAlign.center,
63+
style: _TextStyles.primaryFieldText
64+
.merge(weightVariableTextStyle(context, wght: 700)))),
65+
],
66+
),
5367
// TODO(#291) render email field
5468
Text(roleToLabel(user.role, zulipLocalizations),
5569
textAlign: TextAlign.center,

test/widgets/profile_test.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:zulip/api/model/initial_snapshot.dart';
77
import 'package:zulip/api/model/model.dart';
88
import 'package:zulip/model/narrow.dart';
99
import 'package:zulip/widgets/content.dart';
10+
import 'package:zulip/widgets/icons.dart';
1011
import 'package:zulip/widgets/message_list.dart';
1112
import 'package:zulip/widgets/page.dart';
1213
import 'package:zulip/widgets/profile.dart';
@@ -323,5 +324,37 @@ void main() {
323324

324325
check(find.textContaining(longString).evaluate()).length.equals(7);
325326
});
327+
328+
group('bot vs non-bot users', () {
329+
void checkUser(String fullName, {required bool isBot}) {
330+
final nameFinder = find.text(fullName);
331+
final botFinder = find.byIcon(ZulipIcons.bot);
332+
333+
check(nameFinder.evaluate()).isNotEmpty();
334+
if (isBot) {
335+
check(botFinder.evaluate().singleOrNull).isNotNull();
336+
final botAndNameRowFinder = find.ancestor(
337+
of: botFinder,
338+
matching: find.ancestor(of: nameFinder, matching: find.byType(Row)));
339+
check(botAndNameRowFinder.evaluate().singleOrNull).isNotNull();
340+
} else {
341+
check(botFinder.evaluate().singleOrNull).isNull();
342+
}
343+
}
344+
345+
testWidgets('page builds; bot icon is shown with bot user\'s fullName', (tester) async {
346+
final user = eg.user(isBot: true);
347+
await setupPage(tester, pageUserId: user.userId, users: [user]);
348+
349+
checkUser(user.fullName, isBot: true);
350+
});
351+
352+
testWidgets('page builds; bot icon is not shown with non-bot user\'s fullName', (tester) async {
353+
final user = eg.user(isBot: false);
354+
await setupPage(tester, pageUserId: user.userId, users: [user]);
355+
356+
checkUser(user.fullName, isBot: false);
357+
});
358+
});
326359
});
327360
}

0 commit comments

Comments
 (0)