Use _handleReload to reload instead of navigating to change directly
* Remove reload-change event and use reload event as replacement.
* Use _handleReloadChange as a central place for reloading the change.
This change allows us to add checks if page should be reloaded or not
at one single place.
Change-Id: I43908be6a24edad52df269634205a5ee39a156dd
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js
index c853449..a66c6a2 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js
@@ -662,6 +662,13 @@
});
});
+ test('reload event from reply dialog is processed', () => {
+ const handleReloadStub = sinon.stub(element, '_reload');
+ element.$.replyDialog.dispatchEvent(new CustomEvent('reload',
+ {detail: {clearPatchset: true}, bubbles: true, composed: true}));
+ assert.isTrue(handleReloadStub.called);
+ });
+
test('shift + R should fetch and navigate to the latest patch set',
done => {
element._changeNum = '42';
@@ -681,16 +688,12 @@
actions: {},
};
- navigateToChangeStub.restore();
- navigateToChangeStub = sinon.stub(GerritNav, 'navigateToChange')
- .callsFake((change, patchNum, basePatchNum) => {
- assert.equal(change, element._change);
- assert.isUndefined(patchNum);
- assert.isUndefined(basePatchNum);
- done();
- });
-
+ const reloadChangeStub = sinon.stub(element, '_reload');
MockInteractions.pressAndReleaseKeyOn(element, 82, 'shift', 'r');
+ flush(() => {
+ assert.isTrue(reloadChangeStub.called);
+ done();
+ });
});
test('d should open download overlay', () => {
@@ -1308,7 +1311,7 @@
sinon.stub(element, '_reload').callsFake(() => Promise.resolve());
sinon.stub(element.$.relatedChanges, 'reload');
const e = {detail: {action: 'abandon'}};
- element._handleReloadChange(e).then(() => {
+ element._reload(e).then(() => {
assert.isFalse(navigateToChangeStub.called);
done();
});