diff options
author | Dhruv Srivastava <dhruvsri@google.com> | 2019-11-07 15:59:36 +0100 |
---|---|---|
committer | Paladox <thomasmulhall410@yahoo.com> | 2019-11-07 22:00:08 +0000 |
commit | 9a4dfccae1dd5f77d214aa047df51624e0efb62c (patch) | |
tree | 47eeed831bdf37bd0125e83c53210396f9607078 | |
parent | b5a5a3c9bc1a23485326b4d15eae2a75bebabbaf (diff) |
Remove robot comments without human reply from "Comment Threads" tab
Change-Id: I948b7d6fb2e1b0bbf4248c9f3ac7b3faa57652b4
-rw-r--r-- | polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js | 14 | ||||
-rw-r--r-- | polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.html | 109 |
2 files changed, 111 insertions, 12 deletions
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js index 0cbec84c5c..be2f0ea256 100644 --- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js +++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list.js @@ -108,6 +108,20 @@ } else if (unresolvedOnly) { return c.unresolved; } else { + const comments = c && c.thread && c.thread.comments; + let robotComment = false; + let humanReplyToRobotComment = false; + comments.forEach(comment => { + if (comment.robot_id) { + robotComment = true; + } else if (robotComment) { + // Robot comment exists and human comment exists after it + humanReplyToRobotComment = true; + } + }); + if (robotComment) { + return humanReplyToRobotComment ? c : false; + } return c; } }).map(threadInfo => threadInfo.thread); diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.html b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.html index bd4a6ac7b3..ff65aa81ca 100644 --- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.html +++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.html @@ -170,6 +170,68 @@ limitations under the License. rootId: 'zcf0b9fa_fe1a5f62', start_datetime: '2018-02-09 18:49:18.000000000', }, + { + comments: [ + { + __path: '/COMMIT_MSG', + author: { + _account_id: 1000000, + name: 'user', + username: 'user', + }, + patch_set: 4, + id: 'rc1', + line: 5, + updated: '2019-02-08 18:49:18.000000000', + message: 'test', + unresolved: true, + robot_id: 'rc1', + }, + ], + patchNum: 4, + path: '/COMMIT_MSG', + line: 5, + rootId: 'rc1', + start_datetime: '2019-02-08 18:49:18.000000000', + }, + { + comments: [ + { + __path: '/COMMIT_MSG', + author: { + _account_id: 1000000, + name: 'user', + username: 'user', + }, + patch_set: 4, + id: 'rc2', + line: 5, + updated: '2019-03-08 18:49:18.000000000', + message: 'test', + unresolved: true, + robot_id: 'rc2', + }, + { + __path: '/COMMIT_MSG', + author: { + _account_id: 1000000, + name: 'user', + username: 'user', + }, + patch_set: 4, + id: 'c2_1', + line: 5, + updated: '2019-03-08 18:49:18.000000000', + message: 'test', + unresolved: true, + }, + ], + patchNum: 4, + path: '/COMMIT_MSG', + line: 5, + rootId: 'rc2', + start_datetime: '2019-03-08 18:49:18.000000000', + }, ]; flushAsynchronousOperations(); threadElements = Polymer.dom(element.root) @@ -194,46 +256,69 @@ limitations under the License. }); test('_computeSortedThreads', () => { - assert.equal(element._sortedThreads.length, 5); + assert.equal(element._sortedThreads.length, 7); // Draft and unresolved assert.equal(element._sortedThreads[0].thread.rootId, 'ecf0b9fa_fe1a5f62'); - // unresolved + // Unresolved robot comment assert.equal(element._sortedThreads[1].thread.rootId, + 'rc2'); + // Unresolved robot comment + assert.equal(element._sortedThreads[2].thread.rootId, + 'rc1'); + // unresolved + assert.equal(element._sortedThreads[3].thread.rootId, 'scaddf38_44770ec1'); // unresolved - assert.equal(element._sortedThreads[2].thread.rootId, + assert.equal(element._sortedThreads[4].thread.rootId, '8caddf38_44770ec1'); // resolved and draft - assert.equal(element._sortedThreads[3].thread.rootId, + assert.equal(element._sortedThreads[5].thread.rootId, 'zcf0b9fa_fe1a5f62'); // resolved - assert.equal(element._sortedThreads[4].thread.rootId, + assert.equal(element._sortedThreads[6].thread.rootId, '09a9fb0a_1484e6cf'); }); + test('filtered threads do not contain robot comments without reply', () => { + const thread = element.threads.find(thread => thread.rootId === 'rc1'); + assert.equal(element._filteredThreads.includes(thread), false); + }); + + test('filtered threads contains robot comments with reply', () => { + const thread = element.threads.find(thread => thread.rootId === 'rc2'); + assert.equal(element._filteredThreads.includes(thread), true); + }); + + test('thread removal', () => { - threadElements[1].fire('thread-discard', {rootId: 'scaddf38_44770ec1'}); + threadElements[1].fire('thread-discard', {rootId: 'rc2'}); flushAsynchronousOperations(); - assert.equal(element._sortedThreads.length, 4); + assert.equal(element._sortedThreads.length, 6); assert.equal(element._sortedThreads[0].thread.rootId, 'ecf0b9fa_fe1a5f62'); - // unresolved + // Unresolved robot comment assert.equal(element._sortedThreads[1].thread.rootId, + 'rc1'); + // unresolved + assert.equal(element._sortedThreads[2].thread.rootId, + 'scaddf38_44770ec1'); + // unresolved + assert.equal(element._sortedThreads[3].thread.rootId, '8caddf38_44770ec1'); // resolved and draft - assert.equal(element._sortedThreads[2].thread.rootId, + assert.equal(element._sortedThreads[4].thread.rootId, 'zcf0b9fa_fe1a5f62'); // resolved - assert.equal(element._sortedThreads[3].thread.rootId, + assert.equal(element._sortedThreads[5].thread.rootId, '09a9fb0a_1484e6cf'); }); - test('toggle unresolved only shows unressolved comments', () => { + test('toggle unresolved only shows unresolved comments', () => { MockInteractions.tap(element.$.unresolvedToggle); flushAsynchronousOperations(); assert.equal(Polymer.dom(element.root) - .querySelectorAll('gr-comment-thread').length, 3); + .querySelectorAll('gr-comment-thread').length, 5); }); test('toggle drafts only shows threads with draft comments', () => { |