Enable no-confusing-arrow
and newline-per-chained-call
Change-Id: I3b1a88301cfacf75593dea5e19a2e6b6b2869740
This commit is contained in:
parent
f6605f368b
commit
80cfe59582
@ -21,6 +21,8 @@
|
||||
"flushAsynchronousOperations": false
|
||||
},
|
||||
"rules": {
|
||||
"no-confusing-arrow": "error",
|
||||
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
|
||||
"arrow-parens": ["error", "as-needed"],
|
||||
"block-spacing": ["error", "always"],
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||
|
@ -139,15 +139,17 @@ limitations under the License.
|
||||
*/
|
||||
toSortedArray(obj) {
|
||||
if (!obj) { return []; }
|
||||
return Object.keys(obj).map(key => {
|
||||
return {
|
||||
id: key,
|
||||
value: obj[key],
|
||||
};
|
||||
}).sort((a, b) => {
|
||||
// Since IDs are strings, use localeCompare.
|
||||
return a.id.localeCompare(b.id);
|
||||
});
|
||||
return Object.keys(obj)
|
||||
.map(key => {
|
||||
return {
|
||||
id: key,
|
||||
value: obj[key],
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
// Since IDs are strings, use localeCompare.
|
||||
return a.id.localeCompare(b.id);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -124,9 +124,9 @@ limitations under the License.
|
||||
// Map a normal patchNum to 2 * (patchNum - 1) + 1... I.e. 1 -> 1,
|
||||
// 2 -> 3, 3 -> 5, etc.
|
||||
// Map an edit to the patchNum of parent*2... I.e. edit on 2 -> 4.
|
||||
const num = r => r._number === Gerrit.PatchSetBehavior.EDIT_NAME ?
|
||||
const num = r => (r._number === Gerrit.PatchSetBehavior.EDIT_NAME ?
|
||||
2 * editParent :
|
||||
2 * (r._number - 1) + 1;
|
||||
2 * (r._number - 1) + 1);
|
||||
return revisions.sort((a, b) => num(b) - num(a));
|
||||
},
|
||||
|
||||
|
@ -579,8 +579,9 @@ limitations under the License.
|
||||
remove: {},
|
||||
};
|
||||
|
||||
element.$$('gr-access-section').$$('gr-permission')._handleAddRuleItem(
|
||||
{detail: {value: {id: 'Maintainers'}}});
|
||||
element.$$('gr-access-section').$$('gr-permission')
|
||||
._handleAddRuleItem(
|
||||
{detail: {value: {id: 'Maintainers'}}});
|
||||
|
||||
flushAsynchronousOperations();
|
||||
assert.deepEqual(element._computeAddAndRemove(), expectedInput);
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
// Group by ref and sort by id.
|
||||
const dashboards = res.concat.apply([], res).sort((a, b) =>
|
||||
a.id < b.id ? -1 : 1);
|
||||
(a.id < b.id ? -1 : 1));
|
||||
const dashboardsByRef = {};
|
||||
dashboards.forEach(d => {
|
||||
if (!dashboardsByRef[d.ref]) {
|
||||
@ -64,12 +64,13 @@
|
||||
});
|
||||
|
||||
const dashboardBuilder = [];
|
||||
Object.keys(dashboardsByRef).sort().forEach(ref => {
|
||||
dashboardBuilder.push({
|
||||
section: ref,
|
||||
dashboards: dashboardsByRef[ref],
|
||||
});
|
||||
});
|
||||
Object.keys(dashboardsByRef).sort()
|
||||
.forEach(ref => {
|
||||
dashboardBuilder.push({
|
||||
section: ref,
|
||||
dashboards: dashboardsByRef[ref],
|
||||
});
|
||||
});
|
||||
|
||||
this._dashboards = dashboardBuilder;
|
||||
this._loading = false;
|
||||
|
@ -121,7 +121,8 @@
|
||||
} else {
|
||||
classes['u-gray-background'] = true;
|
||||
}
|
||||
return Object.keys(classes).sort().join(' ');
|
||||
return Object.keys(classes).sort()
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
_computeLabelValue(change, labelName) {
|
||||
|
@ -163,24 +163,26 @@
|
||||
// in an async so that attachment to the DOM can take place first.
|
||||
this.async(() => this.fire('title-change', {title: this._query}));
|
||||
|
||||
this._getPreferences().then(prefs => {
|
||||
this._changesPerPage = prefs.changes_per_page;
|
||||
return this._getChanges();
|
||||
}).then(changes => {
|
||||
changes = changes || [];
|
||||
if (this._query && changes.length === 1) {
|
||||
for (const query in LookupQueryPatterns) {
|
||||
if (LookupQueryPatterns.hasOwnProperty(query) &&
|
||||
this._getPreferences()
|
||||
.then(prefs => {
|
||||
this._changesPerPage = prefs.changes_per_page;
|
||||
return this._getChanges();
|
||||
})
|
||||
.then(changes => {
|
||||
changes = changes || [];
|
||||
if (this._query && changes.length === 1) {
|
||||
for (const query in LookupQueryPatterns) {
|
||||
if (LookupQueryPatterns.hasOwnProperty(query) &&
|
||||
this._query.match(LookupQueryPatterns[query])) {
|
||||
this._replaceCurrentLocation(
|
||||
Gerrit.Nav.getUrlForChange(changes[0]));
|
||||
return;
|
||||
this._replaceCurrentLocation(
|
||||
Gerrit.Nav.getUrlForChange(changes[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this._changes = changes;
|
||||
this._loading = false;
|
||||
});
|
||||
this._changes = changes;
|
||||
this._loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
_loadPreferences() {
|
||||
|
@ -181,12 +181,14 @@
|
||||
.then(() => {
|
||||
this._maybeShowDraftsBanner();
|
||||
this.$.reporting.dashboardDisplayed();
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
this.fire('title-change', {
|
||||
title: title || this._computeTitle(user),
|
||||
});
|
||||
console.warn(err);
|
||||
}).then(() => { this._loading = false; });
|
||||
})
|
||||
.then(() => { this._loading = false; });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,9 +203,9 @@
|
||||
if (!res) { return Promise.resolve(); }
|
||||
|
||||
const queries = res.sections
|
||||
.map(section => section.suffixForDashboard ?
|
||||
.map(section => (section.suffixForDashboard ?
|
||||
section.query + ' ' + section.suffixForDashboard :
|
||||
section.query);
|
||||
section.query));
|
||||
|
||||
if (checkForNewUser) {
|
||||
queries.push('owner:self limit:1');
|
||||
|
@ -474,16 +474,18 @@
|
||||
}
|
||||
|
||||
this._loading = true;
|
||||
return this._getRevisionActions().then(revisionActions => {
|
||||
if (!revisionActions) { return; }
|
||||
return this._getRevisionActions()
|
||||
.then(revisionActions => {
|
||||
if (!revisionActions) { return; }
|
||||
|
||||
this.revisionActions = this._updateRebaseAction(revisionActions);
|
||||
this._handleLoadingComplete();
|
||||
}).catch(err => {
|
||||
this.fire('show-alert', {message: ERR_REVISION_ACTIONS});
|
||||
this._loading = false;
|
||||
throw err;
|
||||
});
|
||||
this.revisionActions = this._updateRebaseAction(revisionActions);
|
||||
this._handleLoadingComplete();
|
||||
})
|
||||
.catch(err => {
|
||||
this.fire('show-alert', {message: ERR_REVISION_ACTIONS});
|
||||
this._loading = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
_handleLoadingComplete() {
|
||||
@ -515,7 +517,8 @@
|
||||
label,
|
||||
__type: type,
|
||||
__key: ADDITIONAL_ACTION_KEY_PREFIX +
|
||||
Math.random().toString(36).substr(2),
|
||||
Math.random().toString(36)
|
||||
.substr(2),
|
||||
};
|
||||
this.push('_additionalActions', action);
|
||||
return action.__key;
|
||||
|
@ -376,15 +376,18 @@
|
||||
_handleTopicRemoved(e) {
|
||||
const target = Polymer.dom(e).rootTarget;
|
||||
target.disabled = true;
|
||||
this.$.restAPI.setChangeTopic(this.change._number, null).then(() => {
|
||||
target.disabled = false;
|
||||
this.set(['change', 'topic'], '');
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('topic-changed', {bubbles: true, composed: true}));
|
||||
}).catch(err => {
|
||||
target.disabled = false;
|
||||
return;
|
||||
});
|
||||
this.$.restAPI.setChangeTopic(this.change._number, null)
|
||||
.then(() => {
|
||||
target.disabled = false;
|
||||
this.set(['change', 'topic'], '');
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('topic-changed',
|
||||
{bubbles: true, composed: true}));
|
||||
})
|
||||
.catch(err => {
|
||||
target.disabled = false;
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
_handleHashtagRemoved(e) {
|
||||
@ -396,7 +399,8 @@
|
||||
.then(newHashtag => {
|
||||
target.disabled = false;
|
||||
this.set(['change', 'hashtags'], newHashtag);
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
target.disabled = false;
|
||||
return;
|
||||
});
|
||||
|
@ -736,8 +736,8 @@ limitations under the License.
|
||||
Gerrit.install(
|
||||
p => {
|
||||
plugin = p;
|
||||
plugin.hook('change-metadata-item').getLastAttached().then(
|
||||
el => hookEl = el);
|
||||
plugin.hook('change-metadata-item').getLastAttached()
|
||||
.then(el => hookEl = el);
|
||||
},
|
||||
'0.1',
|
||||
'http://some/plugins/url.html');
|
||||
|
@ -362,16 +362,18 @@
|
||||
this._setDiffViewMode();
|
||||
});
|
||||
|
||||
Gerrit.awaitPluginsLoaded().then(() => {
|
||||
this._dynamicTabHeaderEndpoints =
|
||||
Gerrit.awaitPluginsLoaded()
|
||||
.then(() => {
|
||||
this._dynamicTabHeaderEndpoints =
|
||||
Gerrit._endpoints.getDynamicEndpoints('change-view-tab-header');
|
||||
this._dynamicTabContentEndpoints =
|
||||
this._dynamicTabContentEndpoints =
|
||||
Gerrit._endpoints.getDynamicEndpoints('change-view-tab-content');
|
||||
if (this._dynamicTabContentEndpoints.length !==
|
||||
if (this._dynamicTabContentEndpoints.length !==
|
||||
this._dynamicTabHeaderEndpoints.length) {
|
||||
console.warn('Different number of tab headers and tab content.');
|
||||
}
|
||||
}).then(() => this._setPrimaryTab());
|
||||
console.warn('Different number of tab headers and tab content.');
|
||||
}
|
||||
})
|
||||
.then(() => this._setPrimaryTab());
|
||||
|
||||
this.addEventListener('comment-save', this._handleCommentSave.bind(this));
|
||||
this.addEventListener('comment-refresh', this._reloadDrafts.bind(this));
|
||||
@ -413,15 +415,17 @@
|
||||
_setDiffViewMode(opt_reset) {
|
||||
if (!opt_reset && this.viewState.diffViewMode) { return; }
|
||||
|
||||
return this._getPreferences().then( prefs => {
|
||||
if (!this.viewState.diffMode) {
|
||||
this.set('viewState.diffMode', prefs.default_diff_view);
|
||||
}
|
||||
}).then(() => {
|
||||
if (!this.viewState.diffMode) {
|
||||
this.set('viewState.diffMode', 'SIDE_BY_SIDE');
|
||||
}
|
||||
});
|
||||
return this._getPreferences()
|
||||
.then( prefs => {
|
||||
if (!this.viewState.diffMode) {
|
||||
this.set('viewState.diffMode', prefs.default_diff_view);
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
if (!this.viewState.diffMode) {
|
||||
this.set('viewState.diffMode', 'SIDE_BY_SIDE');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_onOpenFixPreview(e) {
|
||||
@ -497,9 +501,10 @@
|
||||
message);
|
||||
this._editingCommitMessage = false;
|
||||
this._reloadWindow();
|
||||
}).catch(err => {
|
||||
this.$.commitMessageEditor.disabled = false;
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.$.commitMessageEditor.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
_reloadWindow() {
|
||||
@ -689,7 +694,8 @@
|
||||
_handleMessageReply(e) {
|
||||
const msg = e.detail.message.message;
|
||||
const quoteStr = msg.split('\n').map(
|
||||
line => { return '> ' + line; }).join('\n') + '\n\n';
|
||||
line => { return '> ' + line; })
|
||||
.join('\n') + '\n\n';
|
||||
this.$.replyDialog.quote = quoteStr;
|
||||
this._openReplyDialog(this.$.replyDialog.FocusTarget.BODY);
|
||||
}
|
||||
|
@ -1738,8 +1738,9 @@ limitations under the License.
|
||||
Gerrit.install(
|
||||
p => {
|
||||
plugin = p;
|
||||
plugin.hook('change-view-integration').getLastAttached().then(
|
||||
el => hookEl = el);
|
||||
plugin.hook('change-view-integration').getLastAttached()
|
||||
.then(
|
||||
el => hookEl = el);
|
||||
},
|
||||
'0.1',
|
||||
'http://some/plugins/url.html');
|
||||
|
@ -153,15 +153,17 @@ limitations under the License.
|
||||
|
||||
test('_getRecentChanges', () => {
|
||||
sandbox.spy(element, '_getRecentChanges');
|
||||
return element._getRecentChanges().then(() => {
|
||||
assert.deepEqual(element._recentChanges, recentChanges);
|
||||
assert.equal(element.$.restAPI.getChanges.callCount, 1);
|
||||
// When called a second time, should not re-request recent changes.
|
||||
element._getRecentChanges();
|
||||
}).then(() => {
|
||||
assert.equal(element._getRecentChanges.callCount, 2);
|
||||
assert.equal(element.$.restAPI.getChanges.callCount, 1);
|
||||
});
|
||||
return element._getRecentChanges()
|
||||
.then(() => {
|
||||
assert.deepEqual(element._recentChanges, recentChanges);
|
||||
assert.equal(element.$.restAPI.getChanges.callCount, 1);
|
||||
// When called a second time, should not re-request recent changes.
|
||||
element._getRecentChanges();
|
||||
})
|
||||
.then(() => {
|
||||
assert.equal(element._getRecentChanges.callCount, 2);
|
||||
assert.equal(element.$.restAPI.getChanges.callCount, 1);
|
||||
});
|
||||
});
|
||||
|
||||
test('_filterChanges', () => {
|
||||
|
@ -201,7 +201,8 @@
|
||||
this.set(['change', 'revisions', sha, 'description'], desc);
|
||||
this._patchsetDescription = desc;
|
||||
}
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
if (target) { target.disabled = false; }
|
||||
return;
|
||||
});
|
||||
|
@ -133,35 +133,37 @@ limitations under the License.
|
||||
|
||||
// Simulate tapping the remove button, but call function directly so that
|
||||
// can determine what happens after the promise is resolved.
|
||||
return element._handleDescriptionRemoved().then(() => {
|
||||
// The API stub should be called with an empty string for the new
|
||||
// description.
|
||||
assert.equal(putDescStub.lastCall.args[2], '');
|
||||
assert.equal(element.change.revisions.rev1.description, '');
|
||||
return element._handleDescriptionRemoved()
|
||||
.then(() => {
|
||||
// The API stub should be called with an empty string for the new
|
||||
// description.
|
||||
assert.equal(putDescStub.lastCall.args[2], '');
|
||||
assert.equal(element.change.revisions.rev1.description, '');
|
||||
|
||||
flushAsynchronousOperations();
|
||||
// The editable label should now be visible and the chip hidden.
|
||||
label = Polymer.dom(element.root).querySelector('#descriptionLabel');
|
||||
assert.isOk(label);
|
||||
assert.equal(getComputedStyle(chip).display, 'none');
|
||||
assert.notEqual(getComputedStyle(label).display, 'none');
|
||||
assert.isFalse(label.readOnly);
|
||||
// Edit the label to have a new value of test2, and save.
|
||||
label.editing = true;
|
||||
label._inputText = 'test2';
|
||||
label._save();
|
||||
flushAsynchronousOperations();
|
||||
// The API stub should be called with an `test2` for the new
|
||||
// description.
|
||||
assert.equal(putDescStub.callCount, 2);
|
||||
assert.equal(putDescStub.lastCall.args[2], 'test2');
|
||||
}).then(() => {
|
||||
flushAsynchronousOperations();
|
||||
// The chip should be visible again, and the label hidden.
|
||||
assert.equal(element.change.revisions.rev1.description, 'test2');
|
||||
assert.equal(getComputedStyle(label).display, 'none');
|
||||
assert.notEqual(getComputedStyle(chip).display, 'none');
|
||||
});
|
||||
flushAsynchronousOperations();
|
||||
// The editable label should now be visible and the chip hidden.
|
||||
label = Polymer.dom(element.root).querySelector('#descriptionLabel');
|
||||
assert.isOk(label);
|
||||
assert.equal(getComputedStyle(chip).display, 'none');
|
||||
assert.notEqual(getComputedStyle(label).display, 'none');
|
||||
assert.isFalse(label.readOnly);
|
||||
// Edit the label to have a new value of test2, and save.
|
||||
label.editing = true;
|
||||
label._inputText = 'test2';
|
||||
label._save();
|
||||
flushAsynchronousOperations();
|
||||
// The API stub should be called with an `test2` for the new
|
||||
// description.
|
||||
assert.equal(putDescStub.callCount, 2);
|
||||
assert.equal(putDescStub.lastCall.args[2], 'test2');
|
||||
})
|
||||
.then(() => {
|
||||
flushAsynchronousOperations();
|
||||
// The chip should be visible again, and the label hidden.
|
||||
assert.equal(element.change.revisions.rev1.description, 'test2');
|
||||
assert.equal(getComputedStyle(label).display, 'none');
|
||||
assert.notEqual(getComputedStyle(chip).display, 'none');
|
||||
});
|
||||
});
|
||||
|
||||
test('expandAllDiffs called when expand button clicked', () => {
|
||||
|
@ -297,15 +297,17 @@
|
||||
promises.push(this._getFiles().then(filesByPath => {
|
||||
this._filesByPath = filesByPath;
|
||||
}));
|
||||
promises.push(this._getLoggedIn().then(loggedIn => {
|
||||
return this._loggedIn = loggedIn;
|
||||
}).then(loggedIn => {
|
||||
if (!loggedIn) { return; }
|
||||
promises.push(this._getLoggedIn()
|
||||
.then(loggedIn => {
|
||||
return this._loggedIn = loggedIn;
|
||||
})
|
||||
.then(loggedIn => {
|
||||
if (!loggedIn) { return; }
|
||||
|
||||
return this._getReviewedFiles().then(reviewed => {
|
||||
this._reviewed = reviewed;
|
||||
});
|
||||
}));
|
||||
return this._getReviewedFiles().then(reviewed => {
|
||||
this._reviewed = reviewed;
|
||||
});
|
||||
}));
|
||||
|
||||
promises.push(this._getDiffPreferences().then(prefs => {
|
||||
this.diffPrefs = prefs;
|
||||
|
@ -686,7 +686,7 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('r key toggles reviewed flag', () => {
|
||||
const reducer = (accum, file) => file.isReviewed ? ++accum : accum;
|
||||
const reducer = (accum, file) => (file.isReviewed ? ++accum : accum);
|
||||
const getNumReviewed = () => element._files.reduce(reducer, 0);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
@ -865,7 +865,8 @@ limitations under the License.
|
||||
|
||||
// Click inside the diff. This should result in no additional calls to
|
||||
// _togglePathExpanded or _reviewFile.
|
||||
Polymer.dom(element.root).querySelector('gr-diff-host').click();
|
||||
Polymer.dom(element.root).querySelector('gr-diff-host')
|
||||
.click();
|
||||
assert.isTrue(clickSpy.calledTwice);
|
||||
assert.isTrue(toggleExpandSpy.calledOnce);
|
||||
assert.isFalse(reviewStub.called);
|
||||
|
@ -97,12 +97,13 @@
|
||||
|
||||
const labelsObj = labelRecord.base;
|
||||
if (!labelsObj) { return []; }
|
||||
return Object.keys(labelsObj).sort().map(key => {
|
||||
return {
|
||||
name: key,
|
||||
value: this._getVoteForAccount(labelsObj, key, this.account),
|
||||
};
|
||||
});
|
||||
return Object.keys(labelsObj).sort()
|
||||
.map(key => {
|
||||
return {
|
||||
name: key,
|
||||
value: this._getVoteForAccount(labelsObj, key, this.account),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
_computeColumns(permittedLabels) {
|
||||
|
@ -474,28 +474,31 @@
|
||||
this.disabled = true;
|
||||
|
||||
const errFn = this._handle400Error.bind(this);
|
||||
return this._saveReview(obj, errFn).then(response => {
|
||||
if (!response) {
|
||||
// Null or undefined response indicates that an error handler
|
||||
// took responsibility, so just return.
|
||||
return {};
|
||||
}
|
||||
if (!response.ok) {
|
||||
this.fire('server-error', {response});
|
||||
return {};
|
||||
}
|
||||
return this._saveReview(obj, errFn)
|
||||
.then(response => {
|
||||
if (!response) {
|
||||
// Null or undefined response indicates that an error handler
|
||||
// took responsibility, so just return.
|
||||
return {};
|
||||
}
|
||||
if (!response.ok) {
|
||||
this.fire('server-error', {response});
|
||||
return {};
|
||||
}
|
||||
|
||||
this.draft = '';
|
||||
this._includeComments = true;
|
||||
this.fire('send', null, {bubbles: false});
|
||||
return accountAdditions;
|
||||
}).then(result => {
|
||||
this.disabled = false;
|
||||
return result;
|
||||
}).catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
this.draft = '';
|
||||
this._includeComments = true;
|
||||
this.fire('send', null, {bubbles: false});
|
||||
return accountAdditions;
|
||||
})
|
||||
.then(result => {
|
||||
this.disabled = false;
|
||||
return result;
|
||||
})
|
||||
.catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
_focusOn(section) {
|
||||
|
@ -271,7 +271,8 @@ limitations under the License.
|
||||
test('getlabelValue when no score is selected', done => {
|
||||
flush(() => {
|
||||
element.$$('gr-label-scores')
|
||||
.$$(`gr-label-score-row[name="Code-Review"]`).setSelectedValue(-1);
|
||||
.$$(`gr-label-score-row[name="Code-Review"]`)
|
||||
.setSelectedValue(-1);
|
||||
assert.strictEqual(element.getLabelValue('Verified'), ' 0');
|
||||
done();
|
||||
});
|
||||
@ -372,73 +373,86 @@ limitations under the License.
|
||||
element._pendingConfirmationDetails);
|
||||
}
|
||||
|
||||
observer.then(() => {
|
||||
assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
observer = overlayObserver('closed');
|
||||
const expected = 'Group name has 10 members';
|
||||
assert.notEqual(
|
||||
element.$.reviewerConfirmationOverlay.innerText.indexOf(expected),
|
||||
-1);
|
||||
MockInteractions.tap(noButton); // close the overlay
|
||||
return observer;
|
||||
}).then(() => {
|
||||
assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
observer
|
||||
.then(() => {
|
||||
assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
observer = overlayObserver('closed');
|
||||
const expected = 'Group name has 10 members';
|
||||
assert.notEqual(
|
||||
element.$.reviewerConfirmationOverlay.innerText.indexOf(expected),
|
||||
-1);
|
||||
MockInteractions.tap(noButton); // close the overlay
|
||||
return observer;
|
||||
}).then(() => {
|
||||
assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
|
||||
// We should be focused on account entry input.
|
||||
assert.isTrue(
|
||||
isFocusInsideElement(element.$.reviewers.$.entry.$.input.$.input));
|
||||
// We should be focused on account entry input.
|
||||
assert.isTrue(
|
||||
isFocusInsideElement(
|
||||
element.$.reviewers.$.entry.$.input.$.input
|
||||
)
|
||||
);
|
||||
|
||||
// No reviewer/CC should have been added.
|
||||
assert.equal(element.$.ccs.additions().length, 0);
|
||||
assert.equal(element.$.reviewers.additions().length, 0);
|
||||
// No reviewer/CC should have been added.
|
||||
assert.equal(element.$.ccs.additions().length, 0);
|
||||
assert.equal(element.$.reviewers.additions().length, 0);
|
||||
|
||||
// Reopen confirmation dialog.
|
||||
observer = overlayObserver('opened');
|
||||
if (cc) {
|
||||
element._ccPendingConfirmation = {
|
||||
group,
|
||||
count: 10,
|
||||
};
|
||||
} else {
|
||||
element._reviewerPendingConfirmation = {
|
||||
group,
|
||||
count: 10,
|
||||
};
|
||||
}
|
||||
return observer;
|
||||
}).then(() => {
|
||||
assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
observer = overlayObserver('closed');
|
||||
MockInteractions.tap(yesButton); // Confirm the group.
|
||||
return observer;
|
||||
}).then(() => {
|
||||
assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
const additions = cc ?
|
||||
element.$.ccs.additions() :
|
||||
element.$.reviewers.additions();
|
||||
assert.deepEqual(
|
||||
additions,
|
||||
[
|
||||
{
|
||||
group: {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
confirmed: true,
|
||||
_group: true,
|
||||
_pendingAdd: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
// Reopen confirmation dialog.
|
||||
observer = overlayObserver('opened');
|
||||
if (cc) {
|
||||
element._ccPendingConfirmation = {
|
||||
group,
|
||||
count: 10,
|
||||
};
|
||||
} else {
|
||||
element._reviewerPendingConfirmation = {
|
||||
group,
|
||||
count: 10,
|
||||
};
|
||||
}
|
||||
return observer;
|
||||
})
|
||||
.then(() => {
|
||||
assert.isTrue(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
observer = overlayObserver('closed');
|
||||
MockInteractions.tap(yesButton); // Confirm the group.
|
||||
return observer;
|
||||
})
|
||||
.then(() => {
|
||||
assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
const additions = cc ?
|
||||
element.$.ccs.additions() :
|
||||
element.$.reviewers.additions();
|
||||
assert.deepEqual(
|
||||
additions,
|
||||
[
|
||||
{
|
||||
group: {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
confirmed: true,
|
||||
_group: true,
|
||||
_pendingAdd: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
// We should be focused on account entry input.
|
||||
if (cc) {
|
||||
assert.isTrue(
|
||||
isFocusInsideElement(element.$.ccs.$.entry.$.input.$.input));
|
||||
} else {
|
||||
assert.isTrue(
|
||||
isFocusInsideElement(element.$.reviewers.$.entry.$.input.$.input));
|
||||
}
|
||||
}).then(done);
|
||||
// We should be focused on account entry input.
|
||||
if (cc) {
|
||||
assert.isTrue(
|
||||
isFocusInsideElement(
|
||||
element.$.ccs.$.entry.$.input.$.input
|
||||
)
|
||||
);
|
||||
} else {
|
||||
assert.isTrue(
|
||||
isFocusInsideElement(
|
||||
element.$.reviewers.$.entry.$.input.$.input
|
||||
)
|
||||
);
|
||||
}
|
||||
})
|
||||
.then(done);
|
||||
}
|
||||
|
||||
test('cc confirmation', done => {
|
||||
@ -673,7 +687,8 @@ limitations under the License.
|
||||
// fail.
|
||||
|
||||
element.$$('gr-label-scores').$$(
|
||||
'gr-label-score-row[name="Verified"]').setSelectedValue(-1);
|
||||
'gr-label-score-row[name="Verified"]')
|
||||
.setSelectedValue(-1);
|
||||
MockInteractions.tap(element.$$('.send'));
|
||||
});
|
||||
});
|
||||
|
@ -249,10 +249,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
_handleAddTap(e) {
|
||||
|
@ -67,16 +67,18 @@
|
||||
|
||||
attached() {
|
||||
super.attached();
|
||||
this.$.restAPI.getLoggedIn().then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
return this.$.restAPI.getPreferences();
|
||||
}
|
||||
}).then(prefs => {
|
||||
if (prefs) {
|
||||
this._preferredDownloadCommand = prefs.download_command;
|
||||
this._preferredDownloadScheme = prefs.download_scheme;
|
||||
}
|
||||
});
|
||||
this.$.restAPI.getLoggedIn()
|
||||
.then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
return this.$.restAPI.getPreferences();
|
||||
}
|
||||
})
|
||||
.then(prefs => {
|
||||
if (prefs) {
|
||||
this._preferredDownloadCommand = prefs.download_command;
|
||||
this._preferredDownloadScheme = prefs.download_scheme;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_handleCloseTap(e) {
|
||||
|
@ -634,7 +634,8 @@
|
||||
* @return {!string} Everything after the first '#' ("a#b#c" -> "b#c").
|
||||
*/
|
||||
_getHashFromCanonicalPath(canonicalPath) {
|
||||
return canonicalPath.split('#').slice(1).join('#');
|
||||
return canonicalPath.split('#').slice(1)
|
||||
.join('#');
|
||||
}
|
||||
|
||||
_parseLineAddress(hash) {
|
||||
|
@ -135,7 +135,8 @@
|
||||
.then(accounts => {
|
||||
if (!accounts) { return []; }
|
||||
return this._mapAccountsHelper(accounts, predicate);
|
||||
}).then(accounts => {
|
||||
})
|
||||
.then(accounts => {
|
||||
// When the expression supplied is a beginning substring of 'self',
|
||||
// add it as an autocomplete option.
|
||||
if (SELF_EXPRESSION.startsWith(expression)) {
|
||||
|
@ -71,12 +71,15 @@ limitations under the License.
|
||||
},
|
||||
])
|
||||
);
|
||||
element._fetchAccounts('owner', 's').then(s => {
|
||||
assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'});
|
||||
assert.deepEqual(s[1], {text: 'owner:self'});
|
||||
}).then(() => element._fetchAccounts('owner', 'selfs')).then(s => {
|
||||
assert.notEqual(s[0], {text: 'owner:self'});
|
||||
});
|
||||
element._fetchAccounts('owner', 's')
|
||||
.then(s => {
|
||||
assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'});
|
||||
assert.deepEqual(s[1], {text: 'owner:self'});
|
||||
})
|
||||
.then(() => element._fetchAccounts('owner', 'selfs'))
|
||||
.then(s => {
|
||||
assert.notEqual(s[0], {text: 'owner:self'});
|
||||
});
|
||||
});
|
||||
|
||||
test('Inserts me as option when valid', () => {
|
||||
@ -88,12 +91,15 @@ limitations under the License.
|
||||
},
|
||||
])
|
||||
);
|
||||
return element._fetchAccounts('owner', 'm').then(s => {
|
||||
assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'});
|
||||
assert.deepEqual(s[1], {text: 'owner:me'});
|
||||
}).then(() => element._fetchAccounts('owner', 'meme')).then(s => {
|
||||
assert.notEqual(s[0], {text: 'owner:me'});
|
||||
});
|
||||
return element._fetchAccounts('owner', 'm')
|
||||
.then(s => {
|
||||
assert.deepEqual(s[0], {text: 'owner:fred@goog.co', label: 'fred'});
|
||||
assert.deepEqual(s[1], {text: 'owner:me'});
|
||||
})
|
||||
.then(() => element._fetchAccounts('owner', 'meme'))
|
||||
.then(s => {
|
||||
assert.notEqual(s[0], {text: 'owner:me'});
|
||||
});
|
||||
});
|
||||
|
||||
test('Autocompletes groups', () => {
|
||||
|
@ -89,7 +89,8 @@
|
||||
({filepath: key, preview: res[key]}));
|
||||
this._currentPreviews = previews;
|
||||
}
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
this._close();
|
||||
this.dispatchEvent(new CustomEvent('show-error', {
|
||||
bubbles: true,
|
||||
@ -175,13 +176,14 @@
|
||||
this._currentFix.fix_id).then(res => {
|
||||
Gerrit.Nav.navigateToChange(this.change, 'edit', this._patchNum);
|
||||
this._close();
|
||||
}).catch(err => {
|
||||
this.dispatchEvent(new CustomEvent('show-error', {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
detail: {message: `Error applying fix suggestion: ${err}`},
|
||||
}));
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.dispatchEvent(new CustomEvent('show-error', {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
detail: {message: `Error applying fix suggestion: ${err}`},
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
getFixDescription(currentFix) {
|
||||
|
@ -131,19 +131,21 @@ limitations under the License.
|
||||
|
||||
test('with loadAll first', done => {
|
||||
assert.isNotOk(element._changeComments);
|
||||
element.loadAll().then(() => {
|
||||
assert.isOk(element._changeComments);
|
||||
assert.equal(commentStub.callCount, 1);
|
||||
assert.equal(robotCommentStub.callCount, 1);
|
||||
assert.equal(draftStub.callCount, 1);
|
||||
return element.reloadDrafts();
|
||||
}).then(() => {
|
||||
assert.isOk(element._changeComments);
|
||||
assert.equal(commentStub.callCount, 1);
|
||||
assert.equal(robotCommentStub.callCount, 1);
|
||||
assert.equal(draftStub.callCount, 2);
|
||||
done();
|
||||
});
|
||||
element.loadAll()
|
||||
.then(() => {
|
||||
assert.isOk(element._changeComments);
|
||||
assert.equal(commentStub.callCount, 1);
|
||||
assert.equal(robotCommentStub.callCount, 1);
|
||||
assert.equal(draftStub.callCount, 1);
|
||||
return element.reloadDrafts();
|
||||
})
|
||||
.then(() => {
|
||||
assert.isOk(element._changeComments);
|
||||
assert.equal(commentStub.callCount, 1);
|
||||
assert.equal(robotCommentStub.callCount, 1);
|
||||
assert.equal(draftStub.callCount, 2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -322,7 +322,8 @@ limitations under the License.
|
||||
const lineNumberEl = document.createElement('td');
|
||||
|
||||
function slice(str, start, end) {
|
||||
return Array.from(str).slice(start, end).join('');
|
||||
return Array.from(str).slice(start, end)
|
||||
.join('');
|
||||
}
|
||||
|
||||
setup(() => {
|
||||
|
@ -377,7 +377,8 @@ limitations under the License.
|
||||
const getRangeAtStub = sandbox.stub();
|
||||
getRangeAtStub
|
||||
.onFirstCall().returns(startRange)
|
||||
.onSecondCall().returns(endRange);
|
||||
.onSecondCall()
|
||||
.returns(endRange);
|
||||
const selection = {
|
||||
rangeCount: 2,
|
||||
getRangeAt: getRangeAtStub,
|
||||
|
@ -412,7 +412,8 @@
|
||||
range.side);
|
||||
});
|
||||
});
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
console.warn('Loading coverage ranges failed: ', err);
|
||||
});
|
||||
}
|
||||
|
@ -361,12 +361,14 @@ limitations under the License.
|
||||
Promise.resolve({content: []}));
|
||||
element.patchRange = {};
|
||||
let reloadComplete = false;
|
||||
element.$.restAPI.getDiffPreferences().then(prefs => {
|
||||
element.prefs = prefs;
|
||||
return element.reload();
|
||||
}).then(() => {
|
||||
reloadComplete = true;
|
||||
});
|
||||
element.$.restAPI.getDiffPreferences()
|
||||
.then(prefs => {
|
||||
element.prefs = prefs;
|
||||
return element.reload();
|
||||
})
|
||||
.then(() => {
|
||||
reloadComplete = true;
|
||||
});
|
||||
// Multiple cascading microtasks are scheduled.
|
||||
setTimeout(() => {
|
||||
assert.isFalse(reloadComplete);
|
||||
|
@ -678,23 +678,25 @@
|
||||
promises.push(this._getChangeEdit(this._changeNum));
|
||||
|
||||
this._loading = true;
|
||||
return Promise.all(promises).then(r => {
|
||||
const edit = r[4];
|
||||
if (edit) {
|
||||
this.set('_change.revisions.' + edit.commit.commit, {
|
||||
_number: this.EDIT_NAME,
|
||||
basePatchNum: edit.base_patch_set_number,
|
||||
commit: edit.commit,
|
||||
return Promise.all(promises)
|
||||
.then(r => {
|
||||
const edit = r[4];
|
||||
if (edit) {
|
||||
this.set('_change.revisions.' + edit.commit.commit, {
|
||||
_number: this.EDIT_NAME,
|
||||
basePatchNum: edit.base_patch_set_number,
|
||||
commit: edit.commit,
|
||||
});
|
||||
}
|
||||
this._loading = false;
|
||||
this.$.diffHost.comments = this._commentsForDiff;
|
||||
return this.$.diffHost.reload(true);
|
||||
})
|
||||
.then(() => {
|
||||
this.$.reporting.diffViewFullyLoaded();
|
||||
// If diff view displayed has not ended yet, it ends here.
|
||||
this.$.reporting.diffViewDisplayed();
|
||||
});
|
||||
}
|
||||
this._loading = false;
|
||||
this.$.diffHost.comments = this._commentsForDiff;
|
||||
return this.$.diffHost.reload(true);
|
||||
}).then(() => {
|
||||
this.$.reporting.diffViewFullyLoaded();
|
||||
// If diff view displayed has not ended yet, it ends here.
|
||||
this.$.reporting.diffViewDisplayed();
|
||||
});
|
||||
}
|
||||
|
||||
_changeViewStateChanged(changeViewState) {
|
||||
|
@ -235,10 +235,11 @@ limitations under the License.
|
||||
// Should be recomputed for each available patch
|
||||
sandbox.stub(element, '_computeBaseDropdownContent');
|
||||
assert.equal(element._computeBaseDropdownContent.callCount, 0);
|
||||
commentApiWrapper.loadComments().then().then(() => {
|
||||
assert.equal(element._computeBaseDropdownContent.callCount, 1);
|
||||
done();
|
||||
});
|
||||
commentApiWrapper.loadComments().then()
|
||||
.then(() => {
|
||||
assert.equal(element._computeBaseDropdownContent.callCount, 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_computePatchDropdownContent called when basePatchNum updates', () => {
|
||||
@ -286,9 +287,10 @@ limitations under the License.
|
||||
// Should be recomputed for each available patch
|
||||
sandbox.stub(element, '_computePatchDropdownContent');
|
||||
assert.equal(element._computePatchDropdownContent.callCount, 0);
|
||||
commentApiWrapper.loadComments().then().then(() => {
|
||||
done();
|
||||
});
|
||||
commentApiWrapper.loadComments().then()
|
||||
.then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_computePatchDropdownContent', () => {
|
||||
|
@ -208,7 +208,7 @@
|
||||
return range;
|
||||
})
|
||||
// Sort the ranges so that hovering highlights are on top.
|
||||
.sort((a, b) => a.hovering && !b.hovering ? 1 : 0);
|
||||
.sort((a, b) => (a.hovering && !b.hovering ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,14 +148,16 @@
|
||||
ready() {
|
||||
super.ready();
|
||||
Gerrit._endpoints.onNewEndpoint(this.name, this._initModule.bind(this));
|
||||
Gerrit.awaitPluginsLoaded().then(() => Promise.all(
|
||||
Gerrit._endpoints.getPlugins(this.name).map(
|
||||
pluginUrl => this._import(pluginUrl)))
|
||||
).then(() =>
|
||||
Gerrit._endpoints
|
||||
.getDetails(this.name)
|
||||
.forEach(this._initModule, this)
|
||||
);
|
||||
Gerrit.awaitPluginsLoaded()
|
||||
.then(() => Promise.all(
|
||||
Gerrit._endpoints.getPlugins(this.name).map(
|
||||
pluginUrl => this._import(pluginUrl)))
|
||||
)
|
||||
.then(() =>
|
||||
Gerrit._endpoints
|
||||
.getDetails(this.name)
|
||||
.forEach(this._initModule, this)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,10 +96,11 @@ limitations under the License.
|
||||
assert.equal(module['someparam'], 'barbar');
|
||||
return decorationHook.getLastAttached().then(element => {
|
||||
assert.strictEqual(element, module);
|
||||
}).then(() => {
|
||||
element.remove();
|
||||
assert.equal(decorationHook.getAllAttached().length, 0);
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
element.remove();
|
||||
assert.equal(decorationHook.getAllAttached().length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('replacement', () => {
|
||||
@ -109,12 +110,14 @@ limitations under the License.
|
||||
element => element.nodeName === 'OTHER-MODULE');
|
||||
assert.isOk(module);
|
||||
assert.equal(module['someparam'], 'foofoo');
|
||||
return replacementHook.getLastAttached().then(element => {
|
||||
assert.strictEqual(element, module);
|
||||
}).then(() => {
|
||||
element.remove();
|
||||
assert.equal(replacementHook.getAllAttached().length, 0);
|
||||
});
|
||||
return replacementHook.getLastAttached()
|
||||
.then(element => {
|
||||
assert.strictEqual(element, module);
|
||||
})
|
||||
.then(() => {
|
||||
element.remove();
|
||||
assert.equal(replacementHook.getAllAttached().length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('late registration', done => {
|
||||
|
@ -81,7 +81,8 @@ limitations under the License.
|
||||
|
||||
test('skip theme if preloaded', () => {
|
||||
sandbox.stub(Gerrit, '_isPluginPreloaded')
|
||||
.withArgs('preloaded:gerrit-theme').returns(true);
|
||||
.withArgs('preloaded:gerrit-theme')
|
||||
.returns(true);
|
||||
sandbox.stub(Gerrit, '_loadPlugins');
|
||||
element.config = {
|
||||
default_theme: '/oof',
|
||||
|
@ -22,7 +22,8 @@
|
||||
this._title = '(no title)';
|
||||
// Generate default screen URL token, specific to plugin, and unique(ish).
|
||||
this._token =
|
||||
plugin.getPluginName() + Math.random().toString(36).substr(5);
|
||||
plugin.getPluginName() + Math.random().toString(36)
|
||||
.substr(5);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,8 @@
|
||||
this.$.newKey.disabled = false;
|
||||
this._newKey = '';
|
||||
this.loadData();
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
this.$.addButton.disabled = false;
|
||||
this.$.newKey.disabled = false;
|
||||
});
|
||||
|
@ -53,7 +53,8 @@ limitations under the License.
|
||||
const selector = 'tr:nth-child(' + (index + 1) + ') .move' +
|
||||
direction + 'Button';
|
||||
const button =
|
||||
element.$$('tbody').querySelector(selector).$$('paper-button');
|
||||
element.$$('tbody').querySelector(selector)
|
||||
.$$('paper-button');
|
||||
MockInteractions.tap(button);
|
||||
}
|
||||
|
||||
@ -147,14 +148,16 @@ limitations under the License.
|
||||
|
||||
// Tap the delete button for the middle item.
|
||||
MockInteractions.tap(element.$$('tbody')
|
||||
.querySelector('tr:nth-child(2) .remove-button').$$('paper-button'));
|
||||
.querySelector('tr:nth-child(2) .remove-button')
|
||||
.$$('paper-button'));
|
||||
|
||||
assertMenuNamesEqual(element, ['first name', 'third name']);
|
||||
|
||||
// Delete remaining items.
|
||||
for (let i = 0; i < 2; i++) {
|
||||
MockInteractions.tap(element.$$('tbody')
|
||||
.querySelector('tr:first-child .remove-button').$$('paper-button'));
|
||||
.querySelector('tr:first-child .remove-button')
|
||||
.$$('paper-button'));
|
||||
}
|
||||
assertMenuNamesEqual(element, []);
|
||||
|
||||
|
@ -146,11 +146,13 @@ limitations under the License.
|
||||
assert.equal(account.email, 'email');
|
||||
|
||||
// Save and verify new values are committed.
|
||||
save().then(() => {
|
||||
assert.equal(account.name, 'new name');
|
||||
assert.equal(account.username, 'new username');
|
||||
assert.equal(account.email, 'email3');
|
||||
}).then(done);
|
||||
save()
|
||||
.then(() => {
|
||||
assert.equal(account.name, 'new name');
|
||||
assert.equal(account.username, 'new username');
|
||||
assert.equal(account.email, 'email3');
|
||||
})
|
||||
.then(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -91,7 +91,8 @@
|
||||
this.$.newKey.disabled = false;
|
||||
this._newKey = '';
|
||||
this.push('_keys', key);
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
this.$.addButton.disabled = false;
|
||||
this.$.newKey.disabled = false;
|
||||
});
|
||||
|
@ -197,11 +197,13 @@ limitations under the License.
|
||||
return suggestion._account_id === accountId;
|
||||
};
|
||||
|
||||
element._getSuggestions().then(suggestions => {
|
||||
assert.deepEqual(suggestions,
|
||||
[{name: originalSuggestions[0].email,
|
||||
value: originalSuggestions[0]._account_id}]);
|
||||
}).then(done);
|
||||
element._getSuggestions()
|
||||
.then(suggestions => {
|
||||
assert.deepEqual(suggestions,
|
||||
[{name: originalSuggestions[0].email,
|
||||
value: originalSuggestions[0]._account_id}]);
|
||||
})
|
||||
.then(done);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -291,10 +291,11 @@
|
||||
this._fireSave();
|
||||
return obj;
|
||||
});
|
||||
}).catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
|
||||
return this._xhrPromise;
|
||||
}
|
||||
@ -568,10 +569,11 @@
|
||||
}
|
||||
|
||||
this._fireDiscard();
|
||||
}).catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.disabled = false;
|
||||
throw err;
|
||||
});
|
||||
|
||||
return this._xhrPromise;
|
||||
}
|
||||
|
@ -62,7 +62,9 @@ limitations under the License.
|
||||
expectedTooltip, done) {
|
||||
// Normalize and convert the date to mimic server response.
|
||||
dateStr = normalizedDate(dateStr)
|
||||
.toJSON().replace('T', ' ').slice(0, -1);
|
||||
.toJSON()
|
||||
.replace('T', ' ')
|
||||
.slice(0, -1);
|
||||
sandbox.useFakeTimers(normalizedDate(nowStr).getTime());
|
||||
element.dateStr = dateStr;
|
||||
flush(() => {
|
||||
|
@ -75,24 +75,26 @@
|
||||
|
||||
// TODO(taoalpha): to be deprecated.
|
||||
function send(method, url, opt_callback, opt_payload) {
|
||||
return getRestAPI().send(method, url, opt_payload).then(response => {
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
return response.text().then(text => {
|
||||
if (text) {
|
||||
return Promise.reject(new Error(text));
|
||||
return getRestAPI().send(method, url, opt_payload)
|
||||
.then(response => {
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
return response.text().then(text => {
|
||||
if (text) {
|
||||
return Promise.reject(new Error(text));
|
||||
} else {
|
||||
return Promise.reject(new Error(response.status));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(new Error(response.status));
|
||||
return getRestAPI().getResponseObject(response);
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (opt_callback) {
|
||||
opt_callback(response);
|
||||
}
|
||||
return response;
|
||||
});
|
||||
} else {
|
||||
return getRestAPI().getResponseObject(response);
|
||||
}
|
||||
}).then(response => {
|
||||
if (opt_callback) {
|
||||
opt_callback(response);
|
||||
}
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
// TEST only methods / properties
|
||||
|
@ -109,21 +109,22 @@
|
||||
|
||||
Gerrit.delete = function(url, opt_callback) {
|
||||
console.warn('.delete() is deprecated! Use plugin.restApi().delete()');
|
||||
return getRestAPI().send('DELETE', url).then(response => {
|
||||
if (response.status !== 204) {
|
||||
return response.text().then(text => {
|
||||
if (text) {
|
||||
return Promise.reject(new Error(text));
|
||||
} else {
|
||||
return Promise.reject(new Error(response.status));
|
||||
return getRestAPI().send('DELETE', url)
|
||||
.then(response => {
|
||||
if (response.status !== 204) {
|
||||
return response.text().then(text => {
|
||||
if (text) {
|
||||
return Promise.reject(new Error(text));
|
||||
} else {
|
||||
return Promise.reject(new Error(response.status));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (opt_callback) {
|
||||
opt_callback(response);
|
||||
}
|
||||
return response;
|
||||
});
|
||||
}
|
||||
if (opt_callback) {
|
||||
opt_callback(response);
|
||||
}
|
||||
return response;
|
||||
});
|
||||
};
|
||||
|
||||
Gerrit.awaitPluginsLoaded = function() {
|
||||
|
@ -329,10 +329,11 @@ limitations under the License.
|
||||
sandbox.stub(window, 'fetch', () => {
|
||||
return Promise.resolve({status: 204});
|
||||
});
|
||||
plugin.restApi().getLoggedIn().then(loggedIn => {
|
||||
assert.isTrue(loggedIn);
|
||||
done();
|
||||
});
|
||||
plugin.restApi().getLoggedIn()
|
||||
.then(loggedIn => {
|
||||
assert.isTrue(loggedIn);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('attributeHelper', () => {
|
||||
|
@ -121,10 +121,11 @@ limitations under the License.
|
||||
{status: 400, text() { return Promise.resolve('text'); }}));
|
||||
return instance.delete('/url').then(r => {
|
||||
throw new Error('Should not resolve');
|
||||
}).catch(err => {
|
||||
assert.isTrue(sendStub.calledWith('DELETE', '/url'));
|
||||
assert.equal('text', err.message);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
assert.isTrue(sendStub.calledWith('DELETE', '/url'));
|
||||
assert.equal('text', err.message);
|
||||
});
|
||||
});
|
||||
|
||||
test('getLoggedIn', () => {
|
||||
|
@ -133,7 +133,8 @@
|
||||
target.disabled = false;
|
||||
if (!response.ok) { return; }
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
target.disabled = false;
|
||||
return;
|
||||
});
|
||||
|
@ -59,7 +59,8 @@
|
||||
if (!this._hljsState.loading) {
|
||||
this._hljsState.loading = true;
|
||||
this._loadScript(this._getHLJSUrl())
|
||||
.then(this._onHLJSLibLoaded.bind(this)).catch(reject);
|
||||
.then(this._onHLJSLibLoaded.bind(this))
|
||||
.catch(reject);
|
||||
}
|
||||
|
||||
this._hljsState.callbacks.push(resolve);
|
||||
|
@ -315,17 +315,21 @@ limitations under the License.
|
||||
sandbox.stub(auth, '_isTokenValid');
|
||||
auth._isTokenValid
|
||||
.onFirstCall().returns(true)
|
||||
.onSecondCall().returns(false)
|
||||
.onThirdCall().returns(true);
|
||||
auth.fetch('/url-one').then(() => {
|
||||
getToken.returns(Promise.resolve(makeToken('bzzbb')));
|
||||
return auth.fetch('/url-two');
|
||||
}).then(() => {
|
||||
const [[firstUrl], [secondUrl]] = fetch.args;
|
||||
assert.equal(firstUrl, '/a/url-one?access_token=zbaz');
|
||||
assert.equal(secondUrl, '/a/url-two?access_token=bzzbb');
|
||||
done();
|
||||
});
|
||||
.onSecondCall()
|
||||
.returns(false)
|
||||
.onThirdCall()
|
||||
.returns(true);
|
||||
auth.fetch('/url-one')
|
||||
.then(() => {
|
||||
getToken.returns(Promise.resolve(makeToken('bzzbb')));
|
||||
return auth.fetch('/url-two');
|
||||
})
|
||||
.then(() => {
|
||||
const [[firstUrl], [secondUrl]] = fetch.args;
|
||||
assert.equal(firstUrl, '/a/url-one?access_token=zbaz');
|
||||
assert.equal(secondUrl, '/a/url-two?access_token=bzzbb');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('signed in token error falls back to anonymous', done => {
|
||||
|
@ -815,15 +815,17 @@
|
||||
}
|
||||
|
||||
getIsAdmin() {
|
||||
return this.getLoggedIn().then(isLoggedIn => {
|
||||
if (isLoggedIn) {
|
||||
return this.getAccountCapabilities();
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}).then(capabilities => {
|
||||
return capabilities && capabilities.administrateServer;
|
||||
});
|
||||
return this.getLoggedIn()
|
||||
.then(isLoggedIn => {
|
||||
if (isLoggedIn) {
|
||||
return this.getAccountCapabilities();
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
.then(capabilities => {
|
||||
return capabilities && capabilities.administrateServer;
|
||||
});
|
||||
}
|
||||
|
||||
getDefaultPreferences() {
|
||||
|
@ -650,15 +650,17 @@ limitations under the License.
|
||||
['Innocuous', 'hello'],
|
||||
]},
|
||||
};
|
||||
element._failForCreate200(Promise.resolve(result)).then(() => {
|
||||
assert.isTrue(false, 'Promise should not resolve');
|
||||
}).catch(e => {
|
||||
assert.isOk(e);
|
||||
assert.include(e.message, 'Saving draft resulted in HTTP 200');
|
||||
assert.include(e.message, 'hello');
|
||||
assert.notInclude(e.message, 'secret');
|
||||
done();
|
||||
});
|
||||
element._failForCreate200(Promise.resolve(result))
|
||||
.then(() => {
|
||||
assert.isTrue(false, 'Promise should not resolve');
|
||||
})
|
||||
.catch(e => {
|
||||
assert.isOk(e);
|
||||
assert.include(e.message, 'Saving draft resulted in HTTP 200');
|
||||
assert.include(e.message, 'hello');
|
||||
assert.notInclude(e.message, 'secret');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_failForCreate200 does not fail on 201', done => {
|
||||
@ -667,11 +669,13 @@ limitations under the License.
|
||||
status: 201,
|
||||
headers: {entries: () => []},
|
||||
};
|
||||
element._failForCreate200(Promise.resolve(result)).then(() => {
|
||||
done();
|
||||
}).catch(e => {
|
||||
assert.isTrue(false, 'Promise should not fail');
|
||||
});
|
||||
element._failForCreate200(Promise.resolve(result))
|
||||
.then(() => {
|
||||
done();
|
||||
})
|
||||
.catch(e => {
|
||||
assert.isTrue(false, 'Promise should not fail');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -180,20 +180,22 @@
|
||||
fetchOptions: req.fetchOptions,
|
||||
anonymizedUrl: req.reportUrlAsIs ? urlWithParams : req.anonymizedUrl,
|
||||
};
|
||||
return this.fetch(fetchReq).then(res => {
|
||||
if (req.cancelCondition && req.cancelCondition()) {
|
||||
res.body.cancel();
|
||||
return;
|
||||
}
|
||||
return res;
|
||||
}).catch(err => {
|
||||
if (req.errFn) {
|
||||
req.errFn.call(undefined, null, err);
|
||||
} else {
|
||||
this.fire('network-error', {error: err});
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
return this.fetch(fetchReq)
|
||||
.then(res => {
|
||||
if (req.cancelCondition && req.cancelCondition()) {
|
||||
res.body.cancel();
|
||||
return;
|
||||
}
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
if (req.errFn) {
|
||||
req.errFn.call(undefined, null, err);
|
||||
} else {
|
||||
this.fire('network-error', {error: err});
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,16 +311,18 @@
|
||||
return Promise.resolve(this._cache.get(req.url));
|
||||
}
|
||||
this._fetchPromisesCache.set(req.url,
|
||||
this.fetchJSON(req).then(response => {
|
||||
if (response !== undefined) {
|
||||
this._cache.set(req.url, response);
|
||||
}
|
||||
this._fetchPromisesCache.set(req.url, undefined);
|
||||
return response;
|
||||
}).catch(err => {
|
||||
this._fetchPromisesCache.set(req.url, undefined);
|
||||
throw err;
|
||||
})
|
||||
this.fetchJSON(req)
|
||||
.then(response => {
|
||||
if (response !== undefined) {
|
||||
this._cache.set(req.url, response);
|
||||
}
|
||||
this._fetchPromisesCache.set(req.url, undefined);
|
||||
return response;
|
||||
})
|
||||
.catch(err => {
|
||||
this._fetchPromisesCache.set(req.url, undefined);
|
||||
throw err;
|
||||
})
|
||||
);
|
||||
return this._fetchPromisesCache.get(req.url);
|
||||
}
|
||||
@ -360,14 +364,15 @@
|
||||
this.fire('server-error', {request: fetchReq, response});
|
||||
}
|
||||
return response;
|
||||
}).catch(err => {
|
||||
this.fire('network-error', {error: err});
|
||||
if (req.errFn) {
|
||||
return req.errFn.call(undefined, null, err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.fire('network-error', {error: err});
|
||||
if (req.errFn) {
|
||||
return req.errFn.call(undefined, null, err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
if (req.parseResponse) {
|
||||
return xhr.then(res => this.getResponseObject(res));
|
||||
|
@ -217,7 +217,9 @@
|
||||
const timestamp = util.parseDate(update.date).getTime() -
|
||||
GrReviewerUpdatesParser.MESSAGE_REVIEWERS_THRESHOLD_MILLIS;
|
||||
update.date = new Date(timestamp)
|
||||
.toISOString().replace('T', ' ').replace('Z', '000000');
|
||||
.toISOString()
|
||||
.replace('T', ' ')
|
||||
.replace('Z', '000000');
|
||||
}
|
||||
if (nextMessageDate && date > nextMessageDate) {
|
||||
break;
|
||||
|
@ -255,7 +255,9 @@ limitations under the License.
|
||||
const T0 = util.parseDate('2017-02-17 19:04:18.000000000').getTime();
|
||||
const tplus = delta => {
|
||||
return new Date(T0 + delta)
|
||||
.toISOString().replace('T', ' ').replace('Z', '000000');
|
||||
.toISOString()
|
||||
.replace('T', ' ')
|
||||
.replace('Z', '000000');
|
||||
};
|
||||
const change = {
|
||||
reviewer_updates: [{
|
||||
|
@ -7,7 +7,8 @@
|
||||
if (repoName !== 'All-Projects') {
|
||||
return false;
|
||||
}
|
||||
}).onTap(() => {
|
||||
})
|
||||
.onTap(() => {
|
||||
alert('Bork, bork!');
|
||||
});
|
||||
|
||||
|
@ -193,13 +193,16 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('getSuggestions', done => {
|
||||
provider.getSuggestions().then(reviewers => {
|
||||
// Default is no filtering.
|
||||
assert.equal(reviewers.length, 6);
|
||||
assert.deepEqual(reviewers,
|
||||
[redundantSuggestion1, redundantSuggestion2,
|
||||
redundantSuggestion3, suggestion1, suggestion2, suggestion3]);
|
||||
}).then(done);
|
||||
provider.getSuggestions()
|
||||
.then(reviewers => {
|
||||
// Default is no filtering.
|
||||
assert.equal(reviewers.length, 6);
|
||||
assert.deepEqual(reviewers,
|
||||
[redundantSuggestion1, redundantSuggestion2,
|
||||
redundantSuggestion3, suggestion1,
|
||||
suggestion2, suggestion3]);
|
||||
})
|
||||
.then(done);
|
||||
});
|
||||
|
||||
test('getSuggestions short circuits when logged out', () => {
|
||||
|
@ -78,7 +78,8 @@ fs.readdir('./polygerrit-ui/temp/behaviors/', (err, data) => {
|
||||
if (joinedErrors) {
|
||||
process.exit(1);
|
||||
}
|
||||
}).catch(e => {
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user