commit 8c1ce6748d6bd10d9003af599f7c6795d3986dfe Author: Dhruv Srivastava Date: Fri Oct 2 11:54:23 2020 +0200 Capture vote from Uploaded patch set message Change-Id: I5509c5e9a26ad449a31f4938ed96255c41f482c1 diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts index d627071..87d443b 100644 --- a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts +++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts @@ -44,8 +44,8 @@ import {RestApiService} from '../../../services/services/gr-rest-api/gr-rest-api import {CommentThread} from '../../diff/gr-comment-api/gr-comment-api'; import {hasOwnProperty} from '../../../utils/common-util'; -const PATCH_SET_PREFIX_PATTERN = /^Patch Set \d+:\s*(.*)/; -const LABEL_TITLE_SCORE_PATTERN = /^(-?)([A-Za-z0-9-]+?)([+-]\d+)?$/; +const PATCH_SET_PREFIX_PATTERN = /^(?:Uploaded\s*)?(?:P|p)atch (?:S|s)et \d+:\s*(.*)/; +const LABEL_TITLE_SCORE_PATTERN = /^(-?)([A-Za-z0-9-]+?)([+-]\d+)?[.]?$/; declare global { interface HTMLElementTagNameMap { diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js index 2e2b278..a705d45 100644 --- a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js +++ b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.js @@ -315,6 +315,32 @@ suite('gr-message tests', () => { assert.isFalse(scoreChips[2].classList.contains('min')); }); + test('Uploaded patch set X', () => { + element.message = { + author: {}, + expanded: false, + message: 'Uploaded patch set 1:' + + 'Verified+1 Code-Review-2 Trybot-Label3+1 Blub+1', + }; + element.labelExtremes = { + 'Verified': {max: 1, min: -1}, + 'Code-Review': {max: 2, min: -2}, + 'Trybot-Label3': {max: 3, min: 0}, + }; + flush(); + const scoreChips = element.root.querySelectorAll('.score'); + assert.equal(scoreChips.length, 3); + + assert.isTrue(scoreChips[0].classList.contains('positive')); + assert.isTrue(scoreChips[0].classList.contains('max')); + + assert.isTrue(scoreChips[1].classList.contains('negative')); + assert.isTrue(scoreChips[1].classList.contains('min')); + + assert.isTrue(scoreChips[2].classList.contains('positive')); + assert.isFalse(scoreChips[2].classList.contains('min')); + }); + test('removed votes', () => { element.message = { author: {},