Remove the feature of redirecting x..x to x
Theoretically you may enter a URL with a patchset range of `x..x`, which
we currently immediately redirect to just `x`, which is nice, but it
adds a fair amount of complexity and hinders the router refactoring
substantially. It will be trivial to bring this feature back once the
refactoring is completed, but TBH even if we forget, there will
unlikely be any user who cares or runs into this.
Release-Notes: skip
Google-Bug-Id: b/244279450
Change-Id: I4740fb25475fe98104633855dd74ee646b5354ec
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
index 136ae2e..2fdda8d 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
@@ -328,16 +328,14 @@
basePatchNum: 4 as BasePatchSetNum,
patchNum: 4 as RevisionPatchSetNum,
};
- const needsRedirect = router.normalizePatchRangeParams(params);
- assert.isTrue(needsRedirect);
+ router.normalizePatchRangeParams(params);
assert.equal(params.basePatchNum, PARENT);
assert.equal(params.patchNum, 4 as RevisionPatchSetNum);
});
test('range n.. normalizes to n', () => {
const params: PatchRangeParams = {basePatchNum: 4 as BasePatchSetNum};
- const needsRedirect = router.normalizePatchRangeParams(params);
- assert.isFalse(needsRedirect);
+ router.normalizePatchRangeParams(params);
assert.equal(params.basePatchNum, PARENT);
assert.equal(params.patchNum, 4 as RevisionPatchSetNum);
});
@@ -1197,8 +1195,6 @@
});
suite('handleChangeRoute', () => {
- let normalizeRangeStub: sinon.SinonStub;
-
function makeParams(
_path: string,
_hash: string
@@ -1218,23 +1214,10 @@
}
setup(() => {
- normalizeRangeStub = sinon.stub(router, 'normalizePatchRangeParams');
stubRestApi('setInProjectLookup');
});
- test('needs redirect', () => {
- normalizeRangeStub.returns(true);
- sinon.stub(router, 'generateUrl').returns('foo');
- const ctx = makeParams('', '');
- router.handleChangeRoute(ctx);
- assert.isTrue(normalizeRangeStub.called);
- assert.isFalse(setParamsStub.called);
- assert.isTrue(redirectStub.calledOnce);
- assert.isTrue(redirectStub.calledWithExactly('foo'));
- });
-
test('change view', () => {
- normalizeRangeStub.returns(false);
sinon.stub(router, 'generateUrl').returns('foo');
const ctx = makeParams('', '');
assertDataToParams(ctx, 'handleChangeRoute', {
@@ -1245,11 +1228,9 @@
patchNum: 7 as RevisionPatchSetNum,
});
assert.isFalse(redirectStub.called);
- assert.isTrue(normalizeRangeStub.called);
});
test('params', () => {
- normalizeRangeStub.returns(false);
sinon.stub(router, 'generateUrl').returns('foo');
const ctx = makeParams('', '');
ctx.queryMap.set('tab', 'checks');
@@ -1270,8 +1251,6 @@
});
suite('handleDiffRoute', () => {
- let normalizeRangeStub: sinon.SinonStub;
-
function makeParams(
path: string,
hash: string
@@ -1294,23 +1273,10 @@
}
setup(() => {
- normalizeRangeStub = sinon.stub(router, 'normalizePatchRangeParams');
stubRestApi('setInProjectLookup');
});
- test('needs redirect', () => {
- normalizeRangeStub.returns(true);
- sinon.stub(router, 'generateUrl').returns('foo');
- const ctx = makeParams('', '');
- router.handleDiffRoute(ctx);
- assert.isTrue(normalizeRangeStub.called);
- assert.isFalse(setParamsStub.called);
- assert.isTrue(redirectStub.calledOnce);
- assert.isTrue(redirectStub.calledWithExactly('foo'));
- });
-
test('diff view', () => {
- normalizeRangeStub.returns(false);
sinon.stub(router, 'generateUrl').returns('foo');
const ctx = makeParams('foo/bar/baz', 'b44');
assertDataToParams(ctx, 'handleDiffRoute', {
@@ -1324,7 +1290,6 @@
lineNum: 44,
});
assert.isFalse(redirectStub.called);
- assert.isTrue(normalizeRangeStub.called);
});
test('comment route', () => {
@@ -1370,10 +1335,6 @@
});
test('handleDiffEditRoute', () => {
- const normalizeRangeSpy = sinon.spy(
- router,
- 'normalizePatchRangeParams'
- );
stubRestApi('setInProjectLookup');
const ctx = {
...createPageContext(),
@@ -1396,17 +1357,10 @@
router.handleDiffEditRoute(ctx);
assert.isFalse(redirectStub.called);
- assert.isTrue(normalizeRangeSpy.calledOnce);
- assert.deepEqual(normalizeRangeSpy.lastCall.args[0], appParams);
- assert.isFalse(normalizeRangeSpy.lastCall.returnValue);
assert.deepEqual(setParamsStub.lastCall.args[0], appParams);
});
test('handleDiffEditRoute with lineNum', () => {
- const normalizeRangeSpy = sinon.spy(
- router,
- 'normalizePatchRangeParams'
- );
stubRestApi('setInProjectLookup');
const ctx = {
...createPageContext(),
@@ -1429,17 +1383,10 @@
router.handleDiffEditRoute(ctx);
assert.isFalse(redirectStub.called);
- assert.isTrue(normalizeRangeSpy.calledOnce);
- assert.deepEqual(normalizeRangeSpy.lastCall.args[0], appParams);
- assert.isFalse(normalizeRangeSpy.lastCall.returnValue);
assert.deepEqual(setParamsStub.lastCall.args[0], appParams);
});
test('handleChangeEditRoute', () => {
- const normalizeRangeSpy = sinon.spy(
- router,
- 'normalizePatchRangeParams'
- );
stubRestApi('setInProjectLookup');
const ctx = {
...createPageContext(),
@@ -1461,9 +1408,6 @@
router.handleChangeEditRoute(ctx);
assert.isFalse(redirectStub.called);
- assert.isTrue(normalizeRangeSpy.calledOnce);
- assert.deepEqual(normalizeRangeSpy.lastCall.args[0], appParams);
- assert.isFalse(normalizeRangeSpy.lastCall.returnValue);
assert.deepEqual(setParamsStub.lastCall.args[0], appParams);
});
});