Merge "Fix comments sometimes not showing up in patch set select"
This commit is contained in:
@@ -34,15 +34,21 @@
|
|||||||
_baseDropdownContent: {
|
_baseDropdownContent: {
|
||||||
type: Object,
|
type: Object,
|
||||||
computed: '_computeBaseDropdownContent(availablePatches, patchNum,' +
|
computed: '_computeBaseDropdownContent(availablePatches, patchNum,' +
|
||||||
'_sortedRevisions, revisions)',
|
'_sortedRevisions, revisions, comments)',
|
||||||
},
|
},
|
||||||
_patchDropdownContent: {
|
_patchDropdownContent: {
|
||||||
type: Object,
|
type: Object,
|
||||||
computed: '_computePatchDropdownContent(availablePatches,' +
|
computed: '_computePatchDropdownContent(availablePatches,' +
|
||||||
'basePatchNum, _sortedRevisions, revisions)',
|
'basePatchNum, _sortedRevisions, revisions, comments)',
|
||||||
},
|
},
|
||||||
changeNum: String,
|
changeNum: String,
|
||||||
comments: Array,
|
// In the case of a patch range select (like diff view) comments should
|
||||||
|
// be an empty array, so that the patch and base content computed values
|
||||||
|
// get triggered.
|
||||||
|
comments: {
|
||||||
|
type: Object,
|
||||||
|
value: () => { return {}; },
|
||||||
|
},
|
||||||
/** @type {{ meta_a: !Array, meta_b: !Array}} */
|
/** @type {{ meta_a: !Array, meta_b: !Array}} */
|
||||||
filesWeblinks: Object,
|
filesWeblinks: Object,
|
||||||
patchNum: String,
|
patchNum: String,
|
||||||
@@ -58,7 +64,7 @@
|
|||||||
behaviors: [Gerrit.PatchSetBehavior],
|
behaviors: [Gerrit.PatchSetBehavior],
|
||||||
|
|
||||||
_computeBaseDropdownContent(availablePatches, patchNum, _sortedRevisions,
|
_computeBaseDropdownContent(availablePatches, patchNum, _sortedRevisions,
|
||||||
revisions) {
|
revisions, comments) {
|
||||||
const dropdownContent = [];
|
const dropdownContent = [];
|
||||||
dropdownContent.push({
|
dropdownContent.push({
|
||||||
text: 'Base',
|
text: 'Base',
|
||||||
@@ -72,7 +78,7 @@
|
|||||||
triggerText: `Patchset ${basePatchNum}`,
|
triggerText: `Patchset ${basePatchNum}`,
|
||||||
text: `Patchset ${basePatchNum}` +
|
text: `Patchset ${basePatchNum}` +
|
||||||
this._computePatchSetCommentsString(this.comments, basePatchNum),
|
this._computePatchSetCommentsString(this.comments, basePatchNum),
|
||||||
mobileText: this._computeMobileText(basePatchNum, this.comments,
|
mobileText: this._computeMobileText(basePatchNum, comments,
|
||||||
revisions),
|
revisions),
|
||||||
bottomText: `${this._computePatchSetDescription(
|
bottomText: `${this._computePatchSetDescription(
|
||||||
revisions, basePatchNum)}`,
|
revisions, basePatchNum)}`,
|
||||||
@@ -89,7 +95,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_computePatchDropdownContent(availablePatches, basePatchNum,
|
_computePatchDropdownContent(availablePatches, basePatchNum,
|
||||||
_sortedRevisions, revisions) {
|
_sortedRevisions, revisions, comments) {
|
||||||
const dropdownContent = [];
|
const dropdownContent = [];
|
||||||
for (const patch of availablePatches) {
|
for (const patch of availablePatches) {
|
||||||
const patchNum = patch.num;
|
const patchNum = patch.num;
|
||||||
@@ -101,8 +107,7 @@
|
|||||||
text: `${patchNum === 'edit' ? '': 'Patchset '}${patchNum}` +
|
text: `${patchNum === 'edit' ? '': 'Patchset '}${patchNum}` +
|
||||||
`${this._computePatchSetCommentsString(
|
`${this._computePatchSetCommentsString(
|
||||||
this.comments, patchNum)}`,
|
this.comments, patchNum)}`,
|
||||||
mobileText: this._computeMobileText(patchNum, this.comments,
|
mobileText: this._computeMobileText(patchNum, comments, revisions),
|
||||||
revisions),
|
|
||||||
bottomText: `${this._computePatchSetDescription(
|
bottomText: `${this._computePatchSetDescription(
|
||||||
revisions, patchNum)}`,
|
revisions, patchNum)}`,
|
||||||
value: patchNum,
|
value: patchNum,
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('_computeBaseDropdownContent', () => {
|
test('_computeBaseDropdownContent', () => {
|
||||||
element.comments = {};
|
const comments = {};
|
||||||
const availablePatches = [
|
const availablePatches = [
|
||||||
{num: 1},
|
{num: 1},
|
||||||
{num: 2},
|
{num: 2},
|
||||||
@@ -143,7 +143,7 @@ limitations under the License.
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
assert.deepEqual(element._computeBaseDropdownContent(availablePatches,
|
assert.deepEqual(element._computeBaseDropdownContent(availablePatches,
|
||||||
patchNum, sortedRevisions, revisions), expectedResult);
|
patchNum, sortedRevisions, revisions, comments), expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_computeBaseDropdownContent called when patchNum updates', () => {
|
test('_computeBaseDropdownContent called when patchNum updates', () => {
|
||||||
@@ -170,6 +170,35 @@ limitations under the License.
|
|||||||
assert.equal(element._computeBaseDropdownContent.callCount, 1);
|
assert.equal(element._computeBaseDropdownContent.callCount, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_computeBaseDropdownContent called when comments update', () => {
|
||||||
|
element.revisions = [
|
||||||
|
{commit: {}},
|
||||||
|
{commit: {}},
|
||||||
|
{commit: {}},
|
||||||
|
{commit: {}},
|
||||||
|
];
|
||||||
|
element.availablePatches = [
|
||||||
|
{num: 1},
|
||||||
|
{num: 2},
|
||||||
|
{num: 3},
|
||||||
|
{num: 'edit'},
|
||||||
|
];
|
||||||
|
element.patchNum = 2;
|
||||||
|
element.basePatchNum = 'PARENT';
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
|
// Should be recomputed for each available patch
|
||||||
|
sandbox.stub(element, '_computeBaseDropdownContent');
|
||||||
|
assert.equal(element._computeBaseDropdownContent.callCount, 0);
|
||||||
|
element.set('comments', {
|
||||||
|
file: [{
|
||||||
|
message: 'test',
|
||||||
|
patch_set: 2,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
assert.equal(element._computeBaseDropdownContent.callCount, 1);
|
||||||
|
});
|
||||||
|
|
||||||
test('_computePatchDropdownContent called when basePatchNum updates', () => {
|
test('_computePatchDropdownContent called when basePatchNum updates', () => {
|
||||||
element.revisions = [
|
element.revisions = [
|
||||||
{commit: {}},
|
{commit: {}},
|
||||||
@@ -193,8 +222,37 @@ limitations under the License.
|
|||||||
assert.equal(element._computePatchDropdownContent.callCount, 1);
|
assert.equal(element._computePatchDropdownContent.callCount, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_computePatchDropdownContent called when comments update', () => {
|
||||||
|
element.revisions = [
|
||||||
|
{commit: {}},
|
||||||
|
{commit: {}},
|
||||||
|
{commit: {}},
|
||||||
|
{commit: {}},
|
||||||
|
];
|
||||||
|
element.availablePatches = [
|
||||||
|
{num: 1},
|
||||||
|
{num: 2},
|
||||||
|
{num: 3},
|
||||||
|
{num: 'edit'},
|
||||||
|
];
|
||||||
|
element.patchNum = 2;
|
||||||
|
element.basePatchNum = 'PARENT';
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
|
// Should be recomputed for each available patch
|
||||||
|
sandbox.stub(element, '_computePatchDropdownContent');
|
||||||
|
assert.equal(element._computePatchDropdownContent.callCount, 0);
|
||||||
|
element.set('comments', {
|
||||||
|
file: [{
|
||||||
|
message: 'test',
|
||||||
|
patch_set: 2,
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
assert.equal(element._computePatchDropdownContent.callCount, 1);
|
||||||
|
});
|
||||||
|
|
||||||
test('_computePatchDropdownContent', () => {
|
test('_computePatchDropdownContent', () => {
|
||||||
element.comments = {};
|
const comments = {};
|
||||||
const availablePatches = [
|
const availablePatches = [
|
||||||
{num: 1},
|
{num: 1},
|
||||||
{num: 2},
|
{num: 2},
|
||||||
@@ -255,7 +313,7 @@ limitations under the License.
|
|||||||
];
|
];
|
||||||
|
|
||||||
assert.deepEqual(element._computePatchDropdownContent(availablePatches,
|
assert.deepEqual(element._computePatchDropdownContent(availablePatches,
|
||||||
basePatchNum, sortedRevisions, revisions), expectedResult);
|
basePatchNum, sortedRevisions, revisions, comments), expectedResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('filesWeblinks', () => {
|
test('filesWeblinks', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user