Introduce mentions comments chip
Find the mention of the currently logged in user in unresolved
threads to show in the mention summary chip.
Google-bug-id: b/236921879
Screenshot: https://imgur.com/a/sWkt6to
Release-Notes: skip
Change-Id: I05157fb58e3e5e7b57207aa169ce3947584a34d2
diff --git a/polygerrit-ui/app/utils/comment-util_test.ts b/polygerrit-ui/app/utils/comment-util_test.ts
index 2cad710..4310396 100644
--- a/polygerrit-ui/app/utils/comment-util_test.ts
+++ b/polygerrit-ui/app/utils/comment-util_test.ts
@@ -15,8 +15,13 @@
getContentInCommentRange,
createUserFixSuggestion,
PROVIDED_FIX_ID,
+ getMentionedThreads,
} from './comment-util';
-import {createComment, createCommentThread} from '../test/test-data-generators';
+import {
+ createAccountWithEmail,
+ createComment,
+ createCommentThread,
+} from '../test/test-data-generators';
import {CommentSide} from '../constants/constants';
import {
PARENT,
@@ -83,6 +88,43 @@
});
});
+ test('getMentionedThreads', () => {
+ const account = createAccountWithEmail('abcd@def.com');
+ const threads = [
+ createCommentThread([
+ {
+ ...createComment(),
+ message: 'random text with no emails',
+ },
+ ]),
+ createCommentThread([
+ {
+ ...createComment(),
+ message: '@abcd@def.com please take a look',
+ },
+ {
+ ...createComment(),
+ message: '@abcd@def.com please take a look again at this',
+ },
+ ]),
+ createCommentThread([
+ {
+ ...createComment(),
+ message: '@abcd@def.com this is important',
+ },
+ ]),
+ ];
+ assert.deepEqual(getMentionedThreads(threads, account), [
+ threads[1],
+ threads[2],
+ ]);
+
+ assert.deepEqual(
+ getMentionedThreads(threads, createAccountWithEmail('xyz@def.com')),
+ []
+ );
+ });
+
test('comments sorting', () => {
const comments = [
{