Merge "Resolve TODO about removing SPECIAL_PATCH_SET_NUM"
This commit is contained in:
@@ -40,7 +40,6 @@ import {
|
||||
stubRestApi,
|
||||
TestKeyboardShortcutBinder,
|
||||
} from '../../../test/test-utils';
|
||||
import {SPECIAL_PATCH_SET_NUM} from '../../../utils/patch-set-util';
|
||||
import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
|
||||
import {
|
||||
createAppElementChangeViewParams,
|
||||
@@ -2775,7 +2774,7 @@ suite('gr-change-view tests', () => {
|
||||
});
|
||||
|
||||
element.set('_change.revisions.rev2', {
|
||||
_number: SPECIAL_PATCH_SET_NUM.EDIT,
|
||||
_number: EditPatchSetNum,
|
||||
});
|
||||
flush();
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import './gr-diff-view.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {ChangeStatus} from '../../../constants/constants.js';
|
||||
import {TestKeyboardShortcutBinder} from '../../../test/test-utils.js';
|
||||
import {SPECIAL_PATCH_SET_NUM} from '../../../utils/patch-set-util.js';
|
||||
import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
|
||||
import {_testOnly_findCommentById} from '../gr-comment-api/gr-comment-api.js';
|
||||
import {GerritView} from '../../../services/router/router-model.js';
|
||||
@@ -30,6 +29,7 @@ import {
|
||||
createComment,
|
||||
} from '../../../test/test-data-generators.js';
|
||||
import {stubRestApi} from '../../../test/test-utils.js';
|
||||
import {EditPatchSetNum} from '../../../types/common.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-diff-view');
|
||||
|
||||
@@ -1142,7 +1142,7 @@ suite('gr-diff-view tests', () => {
|
||||
test('file review status with edit loaded', () => {
|
||||
const saveReviewedStub = sinon.stub(element, '_saveReviewedState');
|
||||
|
||||
element._patchRange = {patchNum: SPECIAL_PATCH_SET_NUM.EDIT};
|
||||
element._patchRange = {patchNum: EditPatchSetNum};
|
||||
flush();
|
||||
|
||||
assert.isTrue(element._editMode);
|
||||
@@ -1643,7 +1643,7 @@ suite('gr-diff-view tests', () => {
|
||||
element._patchRange = {patchNum: 1};
|
||||
// Reviewed checkbox should be shown.
|
||||
assert.isTrue(isVisible(element.$.reviewed));
|
||||
element.set('_patchRange.patchNum', SPECIAL_PATCH_SET_NUM.EDIT);
|
||||
element.set('_patchRange.patchNum', EditPatchSetNum);
|
||||
flush();
|
||||
|
||||
assert.isFalse(isVisible(element.$.reviewed));
|
||||
|
||||
@@ -23,8 +23,8 @@ import {getComputedStyleValue} from '../../../utils/dom-util.js';
|
||||
import {_setHiddenScroll} from '../../../scripts/hiddenscroll.js';
|
||||
import {runA11yAudit} from '../../../test/a11y-test-utils.js';
|
||||
import '@polymer/paper-button/paper-button.js';
|
||||
import {SPECIAL_PATCH_SET_NUM} from '../../../utils/patch-set-util.js';
|
||||
import {stubRestApi} from '../../../test/test-utils.js';
|
||||
import {EditPatchSetNum, ParentPatchSetNum} from '../../../types/common.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-diff');
|
||||
|
||||
@@ -568,7 +568,7 @@ suite('gr-diff tests', () => {
|
||||
});
|
||||
|
||||
test('addDraftAtLine on an edit', () => {
|
||||
element.patchRange.basePatchNum = SPECIAL_PATCH_SET_NUM.EDIT;
|
||||
element.patchRange.basePatchNum = EditPatchSetNum;
|
||||
sinon.stub(element, '_selectLine');
|
||||
sinon.stub(element, '_createComment');
|
||||
const alertSpy = sinon.spy();
|
||||
@@ -579,8 +579,8 @@ suite('gr-diff tests', () => {
|
||||
});
|
||||
|
||||
test('addDraftAtLine on an edit base', () => {
|
||||
element.patchRange.patchNum = SPECIAL_PATCH_SET_NUM.EDIT;
|
||||
element.patchRange.basePatchNum = SPECIAL_PATCH_SET_NUM.PARENT;
|
||||
element.patchRange.patchNum = EditPatchSetNum;
|
||||
element.patchRange.basePatchNum = ParentPatchSetNum;
|
||||
sinon.stub(element, '_selectLine');
|
||||
sinon.stub(element, '_createComment');
|
||||
const alertSpy = sinon.spy();
|
||||
|
||||
@@ -24,9 +24,9 @@ import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||
import {RevisionInfo} from '../../shared/revision-info/revision-info.js';
|
||||
import {createCommentApiMockWithTemplateElement} from '../../../test/mocks/comment-api';
|
||||
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
import {SPECIAL_PATCH_SET_NUM} from '../../../utils/patch-set-util.js';
|
||||
import {ChangeComments} from '../gr-comment-api/gr-comment-api.js';
|
||||
import {stubRestApi} from '../../../test/test-utils.js';
|
||||
import {EditPatchSetNum} from '../../../types/common.js';
|
||||
|
||||
const commentApiMockElement = createCommentApiMockWithTemplateElement(
|
||||
'gr-patch-range-select-comment-api-mock', html`
|
||||
@@ -72,7 +72,7 @@ suite('gr-patch-range-select tests', () => {
|
||||
};
|
||||
const sortedRevisions = [
|
||||
{_number: 3},
|
||||
{_number: SPECIAL_PATCH_SET_NUM.EDIT, basePatchNum: 2},
|
||||
{_number: EditPatchSetNum, basePatchNum: 2},
|
||||
{_number: 2},
|
||||
{_number: 1},
|
||||
];
|
||||
@@ -86,7 +86,7 @@ suite('gr-patch-range-select tests', () => {
|
||||
}
|
||||
assert.isTrue(element._computeLeftDisabled('3', patchRange.patchNum));
|
||||
|
||||
patchRange.basePatchNum = SPECIAL_PATCH_SET_NUM.EDIT;
|
||||
patchRange.basePatchNum = EditPatchSetNum;
|
||||
assert.isTrue(element._computeLeftDisabled('3', patchRange.patchNum,
|
||||
sortedRevisions));
|
||||
assert.isTrue(element._computeRightDisabled(patchRange.basePatchNum, '1',
|
||||
@@ -96,7 +96,7 @@ suite('gr-patch-range-select tests', () => {
|
||||
assert.isFalse(element._computeRightDisabled(patchRange.basePatchNum, '3',
|
||||
sortedRevisions));
|
||||
assert.isTrue(element._computeRightDisabled(patchRange.basePatchNum,
|
||||
SPECIAL_PATCH_SET_NUM.EDIT, sortedRevisions));
|
||||
EditPatchSetNum, sortedRevisions));
|
||||
});
|
||||
|
||||
test('_computeBaseDropdownContent', () => {
|
||||
@@ -120,7 +120,7 @@ suite('gr-patch-range-select tests', () => {
|
||||
const patchNum = 1;
|
||||
const sortedRevisions = [
|
||||
{_number: 3, created: 'Mon, 01 Jan 2001 00:00:00 GMT'},
|
||||
{_number: SPECIAL_PATCH_SET_NUM.EDIT, basePatchNum: 2},
|
||||
{_number: EditPatchSetNum, basePatchNum: 2},
|
||||
{_number: 2, description: 'description'},
|
||||
{_number: 1},
|
||||
];
|
||||
@@ -284,7 +284,7 @@ suite('gr-patch-range-select tests', () => {
|
||||
const basePatchNum = 1;
|
||||
const sortedRevisions = [
|
||||
{_number: 3, created: 'Mon, 01 Jan 2001 00:00:00 GMT'},
|
||||
{_number: SPECIAL_PATCH_SET_NUM.EDIT, basePatchNum: 2},
|
||||
{_number: EditPatchSetNum, basePatchNum: 2},
|
||||
{_number: 2, description: 'description'},
|
||||
{_number: 1},
|
||||
];
|
||||
|
||||
@@ -30,7 +30,6 @@ import {
|
||||
GerritNav,
|
||||
GenerateUrlEditViewParameters,
|
||||
} from '../../core/gr-navigation/gr-navigation';
|
||||
import {SPECIAL_PATCH_SET_NUM} from '../../../utils/patch-set-util';
|
||||
import {computeTruncatedPath} from '../../../utils/path-list-util';
|
||||
import {customElement, property} from '@polymer/decorators';
|
||||
import {ErrorCallback} from '../../../services/gr-rest-api/gr-rest-api';
|
||||
@@ -40,6 +39,7 @@ import {
|
||||
EditPreferencesInfo,
|
||||
Base64FileContent,
|
||||
NumericChangeId,
|
||||
EditPatchSetNum,
|
||||
} from '../../../types/common';
|
||||
import {GrStorage} from '../../shared/gr-storage/gr-storage';
|
||||
import {HttpMethod, NotifyType} from '../../../constants/constants';
|
||||
@@ -164,8 +164,7 @@ export class GrEditorView extends KeyboardShortcutMixin(
|
||||
|
||||
this._changeNum = value.changeNum;
|
||||
this._path = value.path;
|
||||
this._patchNum =
|
||||
value.patchNum || (SPECIAL_PATCH_SET_NUM.EDIT as PatchSetNum);
|
||||
this._patchNum = value.patchNum || (EditPatchSetNum as PatchSetNum);
|
||||
this._lineNum =
|
||||
typeof value.lineNum === 'string' ? Number(value.lineNum) : value.lineNum;
|
||||
|
||||
@@ -215,14 +214,14 @@ export class GrEditorView extends KeyboardShortcutMixin(
|
||||
|
||||
_viewEditInChangeView() {
|
||||
const patch = this._successfulSave
|
||||
? (SPECIAL_PATCH_SET_NUM.EDIT as PatchSetNum)
|
||||
? (EditPatchSetNum as PatchSetNum)
|
||||
: this._patchNum;
|
||||
if (this._change && patch)
|
||||
GerritNav.navigateToChange(
|
||||
this._change,
|
||||
patch,
|
||||
undefined,
|
||||
patch !== SPECIAL_PATCH_SET_NUM.EDIT
|
||||
patch !== EditPatchSetNum
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
import '../../../test/common-test-setup-karma.js';
|
||||
import './gr-editor-view.js';
|
||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||
import {SPECIAL_PATCH_SET_NUM} from '../../../utils/patch-set-util.js';
|
||||
import {HttpMethod} from '../../../constants/constants.js';
|
||||
import {stubRestApi} from '../../../test/test-utils.js';
|
||||
import {EditPatchSetNum} from '../../../types/common.js';
|
||||
|
||||
const basicFixture = fixtureFromElement('gr-editor-view');
|
||||
|
||||
@@ -321,15 +321,15 @@ suite('gr-editor-view tests', () => {
|
||||
element._change = {};
|
||||
navigateStub.restore();
|
||||
const navStub = sinon.stub(GerritNav, 'navigateToChange');
|
||||
element._patchNum = SPECIAL_PATCH_SET_NUM.EDIT;
|
||||
element._patchNum = EditPatchSetNum;
|
||||
element._viewEditInChangeView();
|
||||
assert.equal(navStub.lastCall.args[1], SPECIAL_PATCH_SET_NUM.EDIT);
|
||||
assert.equal(navStub.lastCall.args[1], EditPatchSetNum);
|
||||
element._patchNum = '1';
|
||||
element._viewEditInChangeView();
|
||||
assert.equal(navStub.lastCall.args[1], '1');
|
||||
element._successfulSave = true;
|
||||
element._viewEditInChangeView();
|
||||
assert.equal(navStub.lastCall.args[1], SPECIAL_PATCH_SET_NUM.EDIT);
|
||||
assert.equal(navStub.lastCall.args[1], EditPatchSetNum);
|
||||
});
|
||||
|
||||
suite('keyboard shortcuts', () => {
|
||||
|
||||
@@ -35,13 +35,6 @@ const WIP_TAGS = [
|
||||
// Tags identifying ChangeMessages that move change out of WIP state.
|
||||
const READY_TAGS = ['autogenerated:gerrit:setReadyForReview'];
|
||||
|
||||
// TODO(TS): Replace usages of these constants by
|
||||
// EditPatchSetNum and ParentPatchSetNum in common.ts.
|
||||
export const SPECIAL_PATCH_SET_NUM = {
|
||||
EDIT: 'edit',
|
||||
PARENT: 'PARENT',
|
||||
};
|
||||
|
||||
export const CURRENT = 'current';
|
||||
|
||||
export interface PatchSet {
|
||||
|
||||
Reference in New Issue
Block a user