Assign selected revision correctly if current patch is edit
Change-Id: I78fec2ad8989b2053e5b8b8748de0f4734962d1f
This commit is contained in:
parent
2e5531ccee
commit
936be82cf6
@ -1821,7 +1821,8 @@
|
||||
if (!this._selectedRevision) {
|
||||
return;
|
||||
}
|
||||
const patchNum = parseInt(patchNumStr, 10);
|
||||
// If patchNumStr is"edit", then patchNum is undefined hence an OR
|
||||
const patchNum = parseInt(patchNumStr, 10) || patchNumStr;
|
||||
if (patchNum === this._selectedRevision._number) {
|
||||
return;
|
||||
}
|
||||
|
@ -1617,6 +1617,30 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('_selectedRevision is assigned when patchNum is edit', () => {
|
||||
const revision1 = {_number: 1, commit: {parents: []}};
|
||||
const revision2 = {_number: 2, commit: {parents: []}};
|
||||
const revision3 = {_number: 'edit', commit: {parents: []}};
|
||||
sandbox.stub(element.$.restAPI, 'getChangeDetail').returns(
|
||||
Promise.resolve({
|
||||
revisions: {
|
||||
aaa: revision1,
|
||||
bbb: revision2,
|
||||
ccc: revision3,
|
||||
},
|
||||
labels: {},
|
||||
actions: {},
|
||||
current_revision: 'ccc',
|
||||
change_id: 'loremipsumdolorsitamet',
|
||||
}));
|
||||
sandbox.stub(element, '_getEdit').returns(Promise.resolve());
|
||||
sandbox.stub(element, '_getPreferences').returns(Promise.resolve({}));
|
||||
element._patchRange = {patchNum: 'edit'};
|
||||
return element._getChangeDetail().then(() => {
|
||||
assert.strictEqual(element._selectedRevision, revision3);
|
||||
});
|
||||
});
|
||||
|
||||
test('_sendShowChangeEvent', () => {
|
||||
element._change = {labels: {}};
|
||||
element._patchRange = {patchNum: 4};
|
||||
|
Loading…
x
Reference in New Issue
Block a user