Merge "Check for response.ok before redirect for applyfix"
This commit is contained in:
@@ -181,11 +181,17 @@
|
||||
return;
|
||||
}
|
||||
this._isApplyFixLoading = true;
|
||||
return this.$.restAPI.applyFixSuggestion(this.changeNum, this._patchNum,
|
||||
this._currentFix.fix_id).then(res => {
|
||||
Gerrit.Nav.navigateToChange(this.change, 'edit', this._patchNum);
|
||||
this._close();
|
||||
});
|
||||
return this.$.restAPI
|
||||
.applyFixSuggestion(
|
||||
this.changeNum, this._patchNum, this._currentFix.fix_id
|
||||
)
|
||||
.then(res => {
|
||||
if (res && res.ok) {
|
||||
Gerrit.Nav.navigateToChange(this.change, 'edit', this._patchNum);
|
||||
this._close();
|
||||
}
|
||||
this._isApplyFixLoading = false;
|
||||
});
|
||||
},
|
||||
|
||||
getFixDescription(currentFix) {
|
||||
|
@@ -153,10 +153,10 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('apply fix button should call apply' +
|
||||
test('apply fix button should call apply ' +
|
||||
'and navigate to change view', done => {
|
||||
sandbox.stub(element.$.restAPI, 'applyFixSuggestion')
|
||||
.returns(Promise.resolve());
|
||||
.returns(Promise.resolve({ok: true}));
|
||||
sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||
element._currentFix = {fix_id: '123'};
|
||||
|
||||
@@ -175,6 +175,22 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('should not navigate to change view if incorect reponse', done => {
|
||||
sandbox.stub(element.$.restAPI, 'applyFixSuggestion')
|
||||
.returns(Promise.resolve({}));
|
||||
sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||
element._currentFix = {fix_id: '123'};
|
||||
|
||||
element._handleApplyFix().then(() => {
|
||||
assert.isTrue(element.$.restAPI.applyFixSuggestion
|
||||
.calledWithExactly('1', 2, '123'));
|
||||
assert.isTrue(Gerrit.Nav.navigateToChange.notCalled);
|
||||
|
||||
assert.equal(element._isApplyFixLoading, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('select fix forward and back of multiple suggested fixes', done => {
|
||||
sandbox.stub(element.$.restAPI, 'getRobotCommentFixPreview')
|
||||
.returns(Promise.resolve({
|
||||
|
Reference in New Issue
Block a user