Enable arrow-body-style
with as-needed
requireReturnForObjectLiteral for readability Change-Id: I433937b44757939a31ca92512f0aaf0884f86d27
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"no-confusing-arrow": "error",
|
"no-confusing-arrow": "error",
|
||||||
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
|
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
|
||||||
|
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }],
|
||||||
"arrow-parens": ["error", "as-needed"],
|
"arrow-parens": ["error", "as-needed"],
|
||||||
"block-spacing": ["error", "always"],
|
"block-spacing": ["error", "always"],
|
||||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||||
|
@@ -146,10 +146,10 @@ limitations under the License.
|
|||||||
value: obj[key],
|
value: obj[key],
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) =>
|
||||||
// Since IDs are strings, use localeCompare.
|
// Since IDs are strings, use localeCompare.
|
||||||
return a.id.localeCompare(b.id);
|
a.id.localeCompare(b.id)
|
||||||
});
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -64,12 +64,11 @@ limitations under the License.
|
|||||||
getAdminMenuLinks, opt_options));
|
getAdminMenuLinks, opt_options));
|
||||||
}
|
}
|
||||||
return getAccountCapabilities()
|
return getAccountCapabilities()
|
||||||
.then(capabilities => {
|
.then(capabilities => this._filterLinks(
|
||||||
return this._filterLinks(link => {
|
link => !link.capability
|
||||||
return !link.capability ||
|
|| capabilities.hasOwnProperty(link.capability),
|
||||||
capabilities.hasOwnProperty(link.capability);
|
getAdminMenuLinks,
|
||||||
}, getAdminMenuLinks, opt_options);
|
opt_options));
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,15 +91,17 @@ limitations under the License.
|
|||||||
const isExernalLink = link => link.url[0] !== '/';
|
const isExernalLink = link => link.url[0] !== '/';
|
||||||
|
|
||||||
// Append top-level links that are defined by plugins.
|
// Append top-level links that are defined by plugins.
|
||||||
links.push(...getAdminMenuLinks().map(link => ({
|
links.push(...getAdminMenuLinks().map(link => {
|
||||||
url: link.url,
|
return {
|
||||||
name: link.text,
|
url: link.url,
|
||||||
capability: link.capability || null,
|
name: link.text,
|
||||||
noBaseUrl: !isExernalLink(link),
|
capability: link.capability || null,
|
||||||
view: null,
|
noBaseUrl: !isExernalLink(link),
|
||||||
viewableToAll: !link.capability,
|
view: null,
|
||||||
target: isExernalLink(link) ? '_blank' : null,
|
viewableToAll: !link.capability,
|
||||||
})));
|
target: isExernalLink(link) ? '_blank' : null,
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
|
||||||
links = links.filter(filterFn);
|
links = links.filter(filterFn);
|
||||||
|
|
||||||
|
@@ -95,9 +95,8 @@ limitations under the License.
|
|||||||
|
|
||||||
if (expected.pluginGeneratedLinks) {
|
if (expected.pluginGeneratedLinks) {
|
||||||
for (const link of expected.pluginGeneratedLinks) {
|
for (const link of expected.pluginGeneratedLinks) {
|
||||||
const linkMatch = res.links.find(l => {
|
const linkMatch = res.links
|
||||||
return (l.url === link.url && l.name === link.text);
|
.find(l => (l.url === link.url && l.name === link.text));
|
||||||
});
|
|
||||||
assert.isTrue(!!linkMatch);
|
assert.isTrue(!!linkMatch);
|
||||||
|
|
||||||
// External links should open in new tab.
|
// External links should open in new tab.
|
||||||
@@ -325,7 +324,9 @@ limitations under the License.
|
|||||||
let options;
|
let options;
|
||||||
const generatedLinks = [
|
const generatedLinks = [
|
||||||
{text: 'without capability', url: '/without'},
|
{text: 'without capability', url: '/without'},
|
||||||
{text: 'with capability', url: '/with', capability: 'pluginCapability'},
|
{text: 'with capability',
|
||||||
|
url: '/with',
|
||||||
|
capability: 'pluginCapability'},
|
||||||
];
|
];
|
||||||
menuLinkStub.returns(generatedLinks);
|
menuLinkStub.returns(generatedLinks);
|
||||||
expected = Object.assign(expected, {
|
expected = Object.assign(expected, {
|
||||||
|
@@ -46,9 +46,7 @@ limitations under the License.
|
|||||||
* @return {!Array}
|
* @return {!Array}
|
||||||
*/
|
*/
|
||||||
getComplementColumns(columns) {
|
getComplementColumns(columns) {
|
||||||
return this.columnNames.filter(column => {
|
return this.columnNames.filter(column => !columns.includes(column));
|
||||||
return !columns.includes(column);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -150,9 +150,8 @@ limitations under the License.
|
|||||||
if (!change) { return []; }
|
if (!change) { return []; }
|
||||||
let patchNums = [];
|
let patchNums = [];
|
||||||
if (change.revisions && Object.keys(change.revisions).length) {
|
if (change.revisions && Object.keys(change.revisions).length) {
|
||||||
const revisions = Object.keys(change.revisions).map(sha => {
|
const revisions = Object.keys(change.revisions)
|
||||||
return Object.assign({sha}, change.revisions[sha]);
|
.map(sha => Object.assign({sha}, change.revisions[sha]));
|
||||||
});
|
|
||||||
patchNums =
|
patchNums =
|
||||||
Gerrit.PatchSetBehavior.sortRevisions(revisions)
|
Gerrit.PatchSetBehavior.sortRevisions(revisions)
|
||||||
.map(e => {
|
.map(e => {
|
||||||
|
@@ -170,9 +170,7 @@ limitations under the License.
|
|||||||
messages: [],
|
messages: [],
|
||||||
work_in_progress: initialWip,
|
work_in_progress: initialWip,
|
||||||
};
|
};
|
||||||
const revs = Object.keys(tagsByRevision).sort((a, b) => {
|
const revs = Object.keys(tagsByRevision).sort((a, b) => a - b);
|
||||||
return a - b;
|
|
||||||
});
|
|
||||||
for (const rev of revs) {
|
for (const rev of revs) {
|
||||||
for (const tag of tagsByRevision[rev]) {
|
for (const tag of tagsByRevision[rev]) {
|
||||||
change.messages.push({
|
change.messages.push({
|
||||||
@@ -190,9 +188,7 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
const verifier = {
|
const verifier = {
|
||||||
assertWip(revision, expectedWip) {
|
assertWip(revision, expectedWip) {
|
||||||
const patchNum = patchNums.find(patchNum => {
|
const patchNum = patchNums.find(patchNum => patchNum.num == revision);
|
||||||
return patchNum.num == revision;
|
|
||||||
});
|
|
||||||
if (!patchNum) {
|
if (!patchNum) {
|
||||||
assert.fail('revision ' + revision + ' not found');
|
assert.fail('revision ' + revision + ' not found');
|
||||||
}
|
}
|
||||||
|
@@ -146,9 +146,8 @@
|
|||||||
allPermissions = labelOptions.concat(
|
allPermissions = labelOptions.concat(
|
||||||
this.toSortedArray(this.permissionValues));
|
this.toSortedArray(this.permissionValues));
|
||||||
}
|
}
|
||||||
return allPermissions.filter(permission => {
|
return allPermissions
|
||||||
return !this.section.value.permissions[permission.id];
|
.filter(permission => !this.section.value.permissions[permission.id]);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_computeHideEditClass(section) {
|
_computeHideEditClass(section) {
|
||||||
@@ -248,7 +247,8 @@
|
|||||||
|
|
||||||
_computeSectionClass(editing, canUpload, ownerOf, editingRef, deleted) {
|
_computeSectionClass(editing, canUpload, ownerOf, editingRef, deleted) {
|
||||||
const classList = [];
|
const classList = [];
|
||||||
if (editing && this._isEditEnabled(canUpload, ownerOf, this.section.id)) {
|
if (editing
|
||||||
|
&& this._isEditEnabled(canUpload, ownerOf, this.section.id)) {
|
||||||
classList.push('editing');
|
classList.push('editing');
|
||||||
}
|
}
|
||||||
if (editingRef) {
|
if (editingRef) {
|
||||||
|
@@ -127,9 +127,10 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('filter', () => {
|
suite('filter', () => {
|
||||||
test('_paramsChanged', done => {
|
test('_paramsChanged', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getGroups', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(groups);
|
element.$.restAPI,
|
||||||
});
|
'getGroups',
|
||||||
|
() => Promise.resolve(groups));
|
||||||
const value = {
|
const value = {
|
||||||
filter: 'test',
|
filter: 'test',
|
||||||
offset: 25,
|
offset: 25,
|
||||||
|
@@ -101,13 +101,15 @@ limitations under the License.
|
|||||||
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
||||||
name: 'test-user',
|
name: 'test-user',
|
||||||
}));
|
}));
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
element.reload().then(() => {
|
element.reload().then(() => {
|
||||||
assert.equal(element._filteredLinks.length, 3);
|
assert.equal(element._filteredLinks.length, 3);
|
||||||
|
|
||||||
@@ -127,9 +129,11 @@ limitations under the License.
|
|||||||
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
||||||
name: 'test-user',
|
name: 'test-user',
|
||||||
}));
|
}));
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({});
|
element.$.restAPI,
|
||||||
});
|
'getAccountCapabilities',
|
||||||
|
() => Promise.resolve({})
|
||||||
|
);
|
||||||
element.reload().then(() => {
|
element.reload().then(() => {
|
||||||
assert.equal(element._filteredLinks.length, 2);
|
assert.equal(element._filteredLinks.length, 2);
|
||||||
|
|
||||||
@@ -185,13 +189,14 @@ limitations under the License.
|
|||||||
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
||||||
name: 'test-user',
|
name: 'test-user',
|
||||||
}));
|
}));
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
|
}));
|
||||||
element.reload().then(() => {
|
element.reload().then(() => {
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
assert.equal(Polymer.dom(element.root)
|
assert.equal(Polymer.dom(element.root)
|
||||||
@@ -214,13 +219,14 @@ limitations under the License.
|
|||||||
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
sandbox.stub(element.$.restAPI, 'getAccount').returns(Promise.resolve({
|
||||||
name: 'test-user',
|
name: 'test-user',
|
||||||
}));
|
}));
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
|
}));
|
||||||
element.reload().then(() => {
|
element.reload().then(() => {
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
assert.equal(element._filteredLinks.length, 3);
|
assert.equal(element._filteredLinks.length, 3);
|
||||||
@@ -239,16 +245,18 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Nav is reloaded when repo changes', () => {
|
test('Nav is reloaded when repo changes', () => {
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
sandbox.stub(element.$.restAPI, 'getAccount', () => {
|
}));
|
||||||
return Promise.resolve({_id: 1});
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
|
'getAccount',
|
||||||
|
() => Promise.resolve({_id: 1}));
|
||||||
sandbox.stub(element, 'reload');
|
sandbox.stub(element, 'reload');
|
||||||
element.params = {repo: 'Test Repo', adminView: 'gr-repo'};
|
element.params = {repo: 'Test Repo', adminView: 'gr-repo'};
|
||||||
assert.equal(element.reload.callCount, 1);
|
assert.equal(element.reload.callCount, 1);
|
||||||
@@ -259,16 +267,18 @@ limitations under the License.
|
|||||||
|
|
||||||
test('Nav is reloaded when group changes', () => {
|
test('Nav is reloaded when group changes', () => {
|
||||||
sandbox.stub(element, '_computeGroupName');
|
sandbox.stub(element, '_computeGroupName');
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
sandbox.stub(element.$.restAPI, 'getAccount', () => {
|
}));
|
||||||
return Promise.resolve({_id: 1});
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
|
'getAccount',
|
||||||
|
() => Promise.resolve({_id: 1}));
|
||||||
sandbox.stub(element, 'reload');
|
sandbox.stub(element, 'reload');
|
||||||
element.params = {groupId: '1', adminView: 'gr-group'};
|
element.params = {groupId: '1', adminView: 'gr-group'};
|
||||||
assert.equal(element.reload.callCount, 1);
|
assert.equal(element.reload.callCount, 1);
|
||||||
@@ -304,7 +314,9 @@ limitations under the License.
|
|||||||
assert.isOk(element.$$('.mainHeader'));
|
assert.isOk(element.$$('.mainHeader'));
|
||||||
element._subsectionLinks = undefined;
|
element._subsectionLinks = undefined;
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
assert.equal(getComputedStyle(element.$$('.mainHeader')).display, 'none');
|
assert.equal(
|
||||||
|
getComputedStyle(element.$$('.mainHeader')).display,
|
||||||
|
'none');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Dropdown only triggers navigation on explicit select', done => {
|
test('Dropdown only triggers navigation on explicit select', done => {
|
||||||
@@ -314,16 +326,18 @@ limitations under the License.
|
|||||||
view: Gerrit.Nav.View.REPO,
|
view: Gerrit.Nav.View.REPO,
|
||||||
detail: Gerrit.Nav.RepoDetailView.ACCESS,
|
detail: Gerrit.Nav.RepoDetailView.ACCESS,
|
||||||
};
|
};
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
sandbox.stub(element.$.restAPI, 'getAccount', () => {
|
}));
|
||||||
return Promise.resolve({_id: 1});
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
|
'getAccount',
|
||||||
|
() => Promise.resolve({_id: 1}));
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
const expectedFilteredLinks = [
|
const expectedFilteredLinks = [
|
||||||
{
|
{
|
||||||
@@ -475,16 +489,18 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('_computeSelectedClass', () => {
|
suite('_computeSelectedClass', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(element.$.restAPI, 'getAccountCapabilities', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({
|
element.$.restAPI,
|
||||||
createGroup: true,
|
'getAccountCapabilities',
|
||||||
createProject: true,
|
() => Promise.resolve({
|
||||||
viewPlugins: true,
|
createGroup: true,
|
||||||
});
|
createProject: true,
|
||||||
});
|
viewPlugins: true,
|
||||||
sandbox.stub(element.$.restAPI, 'getAccount', () => {
|
}));
|
||||||
return Promise.resolve({_id: 1});
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
|
'getAccount',
|
||||||
|
() => Promise.resolve({_id: 1}));
|
||||||
|
|
||||||
return element.reload();
|
return element.reload();
|
||||||
});
|
});
|
||||||
|
@@ -81,9 +81,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveStub = sandbox.stub(element.$.restAPI,
|
const saveStub = sandbox.stub(element.$.restAPI,
|
||||||
'createChange', () => {
|
'createChange', () => Promise.resolve({}));
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
|
||||||
|
|
||||||
element.branch = 'test-branch';
|
element.branch = 'test-branch';
|
||||||
element.topic = 'test-topic';
|
element.topic = 'test-topic';
|
||||||
@@ -109,9 +107,7 @@ limitations under the License.
|
|||||||
configured_value: 'TRUE',
|
configured_value: 'TRUE',
|
||||||
inherited_value: false,
|
inherited_value: false,
|
||||||
};
|
};
|
||||||
sandbox.stub(element, '_formatBooleanString', () => {
|
sandbox.stub(element, '_formatBooleanString', () => Promise.resolve(true));
|
||||||
return Promise.resolve(true);
|
|
||||||
});
|
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
const configInputObj = {
|
const configInputObj = {
|
||||||
@@ -123,9 +119,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveStub = sandbox.stub(element.$.restAPI,
|
const saveStub = sandbox.stub(element.$.restAPI,
|
||||||
'createChange', () => {
|
'createChange', () => Promise.resolve({}));
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
|
||||||
|
|
||||||
element.branch = 'test-branch';
|
element.branch = 'test-branch';
|
||||||
element.topic = 'test-topic';
|
element.topic = 'test-topic';
|
||||||
|
@@ -56,9 +56,10 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('branch created', done => {
|
test('branch created', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'createRepoBranch', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({});
|
element.$.restAPI,
|
||||||
});
|
'createRepoBranch',
|
||||||
|
() => Promise.resolve({}));
|
||||||
|
|
||||||
assert.isFalse(element.hasNewItemName);
|
assert.isFalse(element.hasNewItemName);
|
||||||
|
|
||||||
@@ -77,9 +78,10 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('tag created', done => {
|
test('tag created', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'createRepoTag', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({});
|
element.$.restAPI,
|
||||||
});
|
'createRepoTag',
|
||||||
|
() => Promise.resolve({}));
|
||||||
|
|
||||||
assert.isFalse(element.hasNewItemName);
|
assert.isFalse(element.hasNewItemName);
|
||||||
|
|
||||||
@@ -98,9 +100,10 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('tag created with annotations', done => {
|
test('tag created with annotations', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'createRepoTag', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({});
|
element.$.restAPI,
|
||||||
});
|
'createRepoTag',
|
||||||
|
() => Promise.resolve({}));
|
||||||
|
|
||||||
assert.isFalse(element.hasNewItemName);
|
assert.isFalse(element.hasNewItemName);
|
||||||
|
|
||||||
|
@@ -66,9 +66,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveStub = sandbox.stub(element.$.restAPI,
|
const saveStub = sandbox.stub(element.$.restAPI,
|
||||||
'createRepo', () => {
|
'createRepo', () => Promise.resolve({}));
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.isFalse(element.hasNewRepoName);
|
assert.isFalse(element.hasNewRepoName);
|
||||||
|
|
||||||
|
@@ -153,9 +153,10 @@ limitations under the License.
|
|||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
sandbox.stub(element, 'getBaseUrl').returns('https://test/site');
|
sandbox.stub(element, 'getBaseUrl').returns('https://test/site');
|
||||||
element.groupId = 1;
|
element.groupId = 1;
|
||||||
groupStub = sandbox.stub(element.$.restAPI, 'getGroupConfig', () => {
|
groupStub = sandbox.stub(
|
||||||
return Promise.resolve(groups);
|
element.$.restAPI,
|
||||||
});
|
'getGroupConfig',
|
||||||
|
() => Promise.resolve(groups));
|
||||||
return element._loadGroupDetails();
|
return element._loadGroupDetails();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -181,9 +182,7 @@ limitations under the License.
|
|||||||
const memberName = 'test-admin';
|
const memberName = 'test-admin';
|
||||||
|
|
||||||
const saveStub = sandbox.stub(element.$.restAPI, 'saveGroupMembers',
|
const saveStub = sandbox.stub(element.$.restAPI, 'saveGroupMembers',
|
||||||
() => {
|
() => Promise.resolve({}));
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
|
||||||
|
|
||||||
const button = element.$.saveGroupMember;
|
const button = element.$.saveGroupMember;
|
||||||
|
|
||||||
@@ -208,9 +207,7 @@ limitations under the License.
|
|||||||
const includedGroupName = 'testName';
|
const includedGroupName = 'testName';
|
||||||
|
|
||||||
const saveIncludedGroupStub = sandbox.stub(
|
const saveIncludedGroupStub = sandbox.stub(
|
||||||
element.$.restAPI, 'saveIncludedGroup', () => {
|
element.$.restAPI, 'saveIncludedGroup', () => Promise.resolve({}));
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
|
||||||
|
|
||||||
const button = element.$.saveIncludedGroups;
|
const button = element.$.saveIncludedGroups;
|
||||||
|
|
||||||
@@ -248,35 +245,31 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_getAccountSuggestions empty', () => {
|
test('_getAccountSuggestions empty', () => element
|
||||||
return element._getAccountSuggestions('nonexistent').then(accounts => {
|
._getAccountSuggestions('nonexistent').then(accounts => {
|
||||||
assert.equal(accounts.length, 0);
|
assert.equal(accounts.length, 0);
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
test('_getAccountSuggestions non-empty', () => {
|
test('_getAccountSuggestions non-empty', () => element
|
||||||
return element._getAccountSuggestions('test-').then(accounts => {
|
._getAccountSuggestions('test-').then(accounts => {
|
||||||
assert.equal(accounts.length, 3);
|
assert.equal(accounts.length, 3);
|
||||||
assert.equal(accounts[0].name,
|
assert.equal(accounts[0].name,
|
||||||
'test-account <test.account@example.com>');
|
'test-account <test.account@example.com>');
|
||||||
assert.equal(accounts[1].name, 'test-admin <test.admin@example.com>');
|
assert.equal(accounts[1].name, 'test-admin <test.admin@example.com>');
|
||||||
assert.equal(accounts[2].name, 'test-git');
|
assert.equal(accounts[2].name, 'test-git');
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
test('_getGroupSuggestions empty', () => {
|
test('_getGroupSuggestions empty', () => element
|
||||||
return element._getGroupSuggestions('nonexistent').then(groups => {
|
._getGroupSuggestions('nonexistent').then(groups => {
|
||||||
assert.equal(groups.length, 0);
|
assert.equal(groups.length, 0);
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
test('_getGroupSuggestions non-empty', () => {
|
test('_getGroupSuggestions non-empty', () => element
|
||||||
return element._getGroupSuggestions('test').then(groups => {
|
._getGroupSuggestions('test').then(groups => {
|
||||||
assert.equal(groups.length, 2);
|
assert.equal(groups.length, 2);
|
||||||
assert.equal(groups[0].name, 'test-admin');
|
assert.equal(groups[0].name, 'test-admin');
|
||||||
assert.equal(groups[1].name, 'test/Administrator (admin)');
|
assert.equal(groups[1].name, 'test/Administrator (admin)');
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
test('_computeHideItemClass returns string for admin', () => {
|
test('_computeHideItemClass returns string for admin', () => {
|
||||||
const admin = true;
|
const admin = true;
|
||||||
|
@@ -56,9 +56,11 @@ limitations under the License.
|
|||||||
getLoggedIn() { return Promise.resolve(true); },
|
getLoggedIn() { return Promise.resolve(true); },
|
||||||
});
|
});
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
groupStub = sandbox.stub(element.$.restAPI, 'getGroupConfig', () => {
|
groupStub = sandbox.stub(
|
||||||
return Promise.resolve(group);
|
element.$.restAPI,
|
||||||
});
|
'getGroupConfig',
|
||||||
|
() => Promise.resolve(group)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
teardown(() => {
|
teardown(() => {
|
||||||
@@ -74,9 +76,10 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('default values are populated with internal group', done => {
|
test('default values are populated with internal group', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getIsGroupOwner', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(true);
|
element.$.restAPI,
|
||||||
});
|
'getIsGroupOwner',
|
||||||
|
() => Promise.resolve(true));
|
||||||
element.groupId = 1;
|
element.groupId = 1;
|
||||||
element._loadGroup().then(() => {
|
element._loadGroup().then(() => {
|
||||||
assert.isTrue(element._groupIsInternal);
|
assert.isTrue(element._groupIsInternal);
|
||||||
@@ -89,12 +92,14 @@ limitations under the License.
|
|||||||
const groupExternal = Object.assign({}, group);
|
const groupExternal = Object.assign({}, group);
|
||||||
groupExternal.id = 'external-group-id';
|
groupExternal.id = 'external-group-id';
|
||||||
groupStub.restore();
|
groupStub.restore();
|
||||||
groupStub = sandbox.stub(element.$.restAPI, 'getGroupConfig', () => {
|
groupStub = sandbox.stub(
|
||||||
return Promise.resolve(groupExternal);
|
element.$.restAPI,
|
||||||
});
|
'getGroupConfig',
|
||||||
sandbox.stub(element.$.restAPI, 'getIsGroupOwner', () => {
|
() => Promise.resolve(groupExternal));
|
||||||
return Promise.resolve(true);
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
|
'getIsGroupOwner',
|
||||||
|
() => Promise.resolve(true));
|
||||||
element.groupId = 1;
|
element.groupId = 1;
|
||||||
element._loadGroup().then(() => {
|
element._loadGroup().then(() => {
|
||||||
assert.isFalse(element._groupIsInternal);
|
assert.isFalse(element._groupIsInternal);
|
||||||
@@ -114,13 +119,15 @@ limitations under the License.
|
|||||||
element._groupName = groupName;
|
element._groupName = groupName;
|
||||||
element._groupOwner = true;
|
element._groupOwner = true;
|
||||||
|
|
||||||
sandbox.stub(element.$.restAPI, 'getIsGroupOwner', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(true);
|
element.$.restAPI,
|
||||||
});
|
'getIsGroupOwner',
|
||||||
|
() => Promise.resolve(true));
|
||||||
|
|
||||||
sandbox.stub(element.$.restAPI, 'saveGroupName', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({status: 200});
|
element.$.restAPI,
|
||||||
});
|
'saveGroupName',
|
||||||
|
() => Promise.resolve({status: 200}));
|
||||||
|
|
||||||
const button = element.$.inputUpdateNameBtn;
|
const button = element.$.inputUpdateNameBtn;
|
||||||
|
|
||||||
@@ -154,9 +161,10 @@ limitations under the License.
|
|||||||
test('test for undefined group name', done => {
|
test('test for undefined group name', done => {
|
||||||
groupStub.restore();
|
groupStub.restore();
|
||||||
|
|
||||||
sandbox.stub(element.$.restAPI, 'getGroupConfig', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({});
|
element.$.restAPI,
|
||||||
});
|
'getGroupConfig',
|
||||||
|
() => Promise.resolve({}));
|
||||||
|
|
||||||
assert.isUndefined(element.groupId);
|
assert.isUndefined(element.groupId);
|
||||||
|
|
||||||
|
@@ -209,9 +209,8 @@
|
|||||||
|
|
||||||
_computeLabelValues(values) {
|
_computeLabelValues(values) {
|
||||||
const valuesArr = [];
|
const valuesArr = [];
|
||||||
const keys = Object.keys(values).sort((a, b) => {
|
const keys = Object.keys(values)
|
||||||
return parseInt(a, 10) - parseInt(b, 10);
|
.sort((a, b) => parseInt(a, 10) - parseInt(b, 10));
|
||||||
});
|
|
||||||
|
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
let text = values[key];
|
let text = values[key];
|
||||||
@@ -255,9 +254,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Does not return groups in which we already have rules for.
|
// Does not return groups in which we already have rules for.
|
||||||
return groups.filter(group => {
|
return groups
|
||||||
return !this._groupsWithRules[group.value.id];
|
.filter(group => !this._groupsWithRules[group.value.id]);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +266,8 @@
|
|||||||
_handleAddRuleItem(e) {
|
_handleAddRuleItem(e) {
|
||||||
// The group id is encoded, but have to decode in order for the access
|
// The group id is encoded, but have to decode in order for the access
|
||||||
// API to work as expected.
|
// API to work as expected.
|
||||||
const groupId = decodeURIComponent(e.detail.value.id).replace(/\+/g, ' ');
|
const groupId = decodeURIComponent(e.detail.value.id)
|
||||||
|
.replace(/\+/g, ' ');
|
||||||
this.set(['permission', 'value', 'rules', groupId], {});
|
this.set(['permission', 'value', 'rules', groupId], {});
|
||||||
|
|
||||||
// Purposely don't recompute sorted array so that the newly added rule
|
// Purposely don't recompute sorted array so that the newly added rule
|
||||||
|
@@ -125,9 +125,10 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('filter', () => {
|
suite('filter', () => {
|
||||||
test('_paramsChanged', done => {
|
test('_paramsChanged', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getPlugins', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(plugins);
|
element.$.restAPI,
|
||||||
});
|
'getPlugins',
|
||||||
|
() => Promise.resolve(plugins));
|
||||||
const value = {
|
const value = {
|
||||||
filter: 'test',
|
filter: 'test',
|
||||||
offset: 25,
|
offset: 25,
|
||||||
|
@@ -44,9 +44,10 @@ limitations under the License.
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
repoStub = sandbox.stub(element.$.restAPI, 'getProjectConfig', () => {
|
repoStub = sandbox.stub(
|
||||||
return Promise.resolve({});
|
element.$.restAPI,
|
||||||
});
|
'getProjectConfig',
|
||||||
|
() => Promise.resolve({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
teardown(() => {
|
teardown(() => {
|
||||||
|
@@ -297,9 +297,10 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('filter', () => {
|
suite('filter', () => {
|
||||||
test('_paramsChanged', done => {
|
test('_paramsChanged', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoBranches', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(branches);
|
element.$.restAPI,
|
||||||
});
|
'getRepoBranches',
|
||||||
|
() => Promise.resolve(branches));
|
||||||
const params = {
|
const params = {
|
||||||
detail: 'branches',
|
detail: 'branches',
|
||||||
repo: 'test',
|
repo: 'test',
|
||||||
@@ -480,9 +481,10 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('filter', () => {
|
suite('filter', () => {
|
||||||
test('_paramsChanged', done => {
|
test('_paramsChanged', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoTags', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(tags);
|
element.$.restAPI,
|
||||||
});
|
'getRepoTags',
|
||||||
|
() => Promise.resolve(tags));
|
||||||
const params = {
|
const params = {
|
||||||
repo: 'test',
|
repo: 'test',
|
||||||
detail: 'tags',
|
detail: 'tags',
|
||||||
|
@@ -127,9 +127,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('_paramsChanged', done => {
|
test('_paramsChanged', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getRepos', () => {
|
sandbox.stub(element.$.restAPI, 'getRepos', () => Promise.resolve(repos));
|
||||||
return Promise.resolve(repos);
|
|
||||||
});
|
|
||||||
const value = {
|
const value = {
|
||||||
filter: 'test',
|
filter: 'test',
|
||||||
offset: 25,
|
offset: 25,
|
||||||
|
@@ -49,7 +49,8 @@
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const {config} = dataRecord.base;
|
const {config} = dataRecord.base;
|
||||||
return Object.keys(config).map(_key => ({_key, info: config[_key]}));
|
return Object.keys(config)
|
||||||
|
.map(_key => { return {_key, info: config[_key]}; });
|
||||||
}
|
}
|
||||||
|
|
||||||
_isArray(type) {
|
_isArray(type) {
|
||||||
|
@@ -136,7 +136,7 @@
|
|||||||
|
|
||||||
const pluginConfig = configRecord.base;
|
const pluginConfig = configRecord.base;
|
||||||
return Object.keys(pluginConfig)
|
return Object.keys(pluginConfig)
|
||||||
.map(name => ({name, config: pluginConfig[name]}));
|
.map(name => { return {name, config: pluginConfig[name]}; });
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadRepo() {
|
_loadRepo() {
|
||||||
|
@@ -120,9 +120,10 @@ limitations under the License.
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
repoStub = sandbox.stub(element.$.restAPI, 'getProjectConfig', () => {
|
repoStub = sandbox.stub(
|
||||||
return Promise.resolve(repoConf);
|
element.$.restAPI,
|
||||||
});
|
'getProjectConfig',
|
||||||
|
() => Promise.resolve(repoConf));
|
||||||
});
|
});
|
||||||
|
|
||||||
teardown(() => {
|
teardown(() => {
|
||||||
@@ -187,12 +188,11 @@ limitations under the License.
|
|||||||
|
|
||||||
test('form defaults to read only when logged in and not admin', done => {
|
test('form defaults to read only when logged in and not admin', done => {
|
||||||
element.repo = REPO;
|
element.repo = REPO;
|
||||||
sandbox.stub(element, '_getLoggedIn', () => {
|
sandbox.stub(element, '_getLoggedIn', () => Promise.resolve(true));
|
||||||
return Promise.resolve(true);
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoAccess', () => {
|
'getRepoAccess',
|
||||||
return Promise.resolve({'test-repo': {}});
|
() => Promise.resolve({'test-repo': {}}));
|
||||||
});
|
|
||||||
element._loadRepo().then(() => {
|
element._loadRepo().then(() => {
|
||||||
assert.isTrue(element._readOnly);
|
assert.isTrue(element._readOnly);
|
||||||
done();
|
done();
|
||||||
@@ -280,12 +280,11 @@ limitations under the License.
|
|||||||
suite('admin', () => {
|
suite('admin', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
element.repo = REPO;
|
element.repo = REPO;
|
||||||
sandbox.stub(element, '_getLoggedIn', () => {
|
sandbox.stub(element, '_getLoggedIn', () => Promise.resolve(true));
|
||||||
return Promise.resolve(true);
|
sandbox.stub(
|
||||||
});
|
element.$.restAPI,
|
||||||
sandbox.stub(element.$.restAPI, 'getRepoAccess', () => {
|
'getRepoAccess',
|
||||||
return Promise.resolve({'test-repo': {is_owner: true}});
|
() => Promise.resolve({'test-repo': {is_owner: true}}));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('all form elements are enabled', done => {
|
test('all form elements are enabled', done => {
|
||||||
@@ -308,14 +307,13 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('inherited submit type value is calculated correctly', () => {
|
test('inherited submit type value is calculated correctly', () => element
|
||||||
return element._loadRepo().then(() => {
|
._loadRepo().then(() => {
|
||||||
const sel = element.$.submitTypeSelect;
|
const sel = element.$.submitTypeSelect;
|
||||||
assert.equal(sel.bindValue, 'INHERIT');
|
assert.equal(sel.bindValue, 'INHERIT');
|
||||||
assert.equal(
|
assert.equal(
|
||||||
sel.nativeSelect.options[0].text, 'Inherit (Merge if necessary)');
|
sel.nativeSelect.options[0].text, 'Inherit (Merge if necessary)');
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
test('fields update and save correctly', () => {
|
test('fields update and save correctly', () => {
|
||||||
const configInputObj = {
|
const configInputObj = {
|
||||||
@@ -338,9 +336,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveStub = sandbox.stub(element.$.restAPI, 'saveRepoConfig'
|
const saveStub = sandbox.stub(element.$.restAPI, 'saveRepoConfig'
|
||||||
, () => {
|
, () => Promise.resolve({}));
|
||||||
return Promise.resolve({});
|
|
||||||
});
|
|
||||||
|
|
||||||
const button = Polymer.dom(element.root).querySelector('gr-button');
|
const button = Polymer.dom(element.root).querySelector('gr-button');
|
||||||
|
|
||||||
|
@@ -234,11 +234,8 @@
|
|||||||
_processQuery(query) {
|
_processQuery(query) {
|
||||||
let tokens = query.split(' ');
|
let tokens = query.split(' ');
|
||||||
const invalidTokens = ['limit:', 'age:', '-age:'];
|
const invalidTokens = ['limit:', 'age:', '-age:'];
|
||||||
tokens = tokens.filter(token => {
|
tokens = tokens.filter(token => !invalidTokens
|
||||||
return !invalidTokens.some(invalidToken => {
|
.some(invalidToken => token.startsWith(invalidToken)));
|
||||||
return token.startsWith(invalidToken);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return tokens.join(' ');
|
return tokens.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -218,13 +218,15 @@
|
|||||||
const lastResultSet = changes.pop();
|
const lastResultSet = changes.pop();
|
||||||
this._showNewUserHelp = lastResultSet.length == 0;
|
this._showNewUserHelp = lastResultSet.length == 0;
|
||||||
}
|
}
|
||||||
this._results = changes.map((results, i) => ({
|
this._results = changes.map((results, i) => {
|
||||||
name: res.sections[i].name,
|
return {
|
||||||
countLabel: this._computeSectionCountLabel(results),
|
name: res.sections[i].name,
|
||||||
query: res.sections[i].query,
|
countLabel: this._computeSectionCountLabel(results),
|
||||||
results,
|
query: res.sections[i].query,
|
||||||
isOutgoing: res.sections[i].isOutgoing,
|
results,
|
||||||
})).filter((section, i) => i < res.sections.length && (
|
isOutgoing: res.sections[i].isOutgoing,
|
||||||
|
};
|
||||||
|
}).filter((section, i) => i < res.sections.length && (
|
||||||
!res.sections[i].hideIfEmpty ||
|
!res.sections[i].hideIfEmpty ||
|
||||||
section.results.length));
|
section.results.length));
|
||||||
});
|
});
|
||||||
|
@@ -561,9 +561,8 @@
|
|||||||
if (type !== ActionType.CHANGE && type !== ActionType.REVISION) {
|
if (type !== ActionType.CHANGE && type !== ActionType.REVISION) {
|
||||||
throw Error(`Invalid action type given: ${type}`);
|
throw Error(`Invalid action type given: ${type}`);
|
||||||
}
|
}
|
||||||
const index = this._actionPriorityOverrides.findIndex(action => {
|
const index = this._actionPriorityOverrides
|
||||||
return action.type === type && action.key === key;
|
.findIndex(action => action.type === type && action.key === key);
|
||||||
});
|
|
||||||
const action = {
|
const action = {
|
||||||
type,
|
type,
|
||||||
key,
|
key,
|
||||||
@@ -726,9 +725,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getValuesFor(obj) {
|
_getValuesFor(obj) {
|
||||||
return Object.keys(obj).map(key => {
|
return Object.keys(obj).map(key => obj[key]);
|
||||||
return obj[key];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_getLabelStatus(label) {
|
_getLabelStatus(label) {
|
||||||
@@ -793,9 +790,8 @@
|
|||||||
|
|
||||||
hideQuickApproveAction() {
|
hideQuickApproveAction() {
|
||||||
this._topLevelSecondaryActions =
|
this._topLevelSecondaryActions =
|
||||||
this._topLevelSecondaryActions.filter(sa => {
|
this._topLevelSecondaryActions
|
||||||
return sa.key !== QUICK_APPROVE_ACTION.key;
|
.filter(sa => sa.key !== QUICK_APPROVE_ACTION.key);
|
||||||
});
|
|
||||||
this._hideQuickApproveAction = true;
|
this._hideQuickApproveAction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,13 +849,13 @@
|
|||||||
|
|
||||||
let additionalActions = (additionalActionsChangeRecord &&
|
let additionalActions = (additionalActionsChangeRecord &&
|
||||||
additionalActionsChangeRecord.base) || [];
|
additionalActionsChangeRecord.base) || [];
|
||||||
additionalActions = additionalActions.filter(a => {
|
additionalActions = additionalActions
|
||||||
return a.__type === type;
|
.filter(a => a.__type === type)
|
||||||
}).map(a => {
|
.map(a => {
|
||||||
a.__primary = primaryActionKeys.includes(a.__key);
|
a.__primary = primaryActionKeys.includes(a.__key);
|
||||||
// Triggers a re-render by ensuring object inequality.
|
// Triggers a re-render by ensuring object inequality.
|
||||||
return Object.assign({}, a);
|
return Object.assign({}, a);
|
||||||
});
|
});
|
||||||
return result.concat(additionalActions).concat(pluginActions);
|
return result.concat(additionalActions).concat(pluginActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -996,9 +992,7 @@
|
|||||||
this._showActionDialog(this.$.confirmAbandonDialog);
|
this._showActionDialog(this.$.confirmAbandonDialog);
|
||||||
break;
|
break;
|
||||||
case QUICK_APPROVE_ACTION.key:
|
case QUICK_APPROVE_ACTION.key:
|
||||||
action = this._allActionValues.find(o => {
|
action = this._allActionValues.find(o => o.key === key);
|
||||||
return o.key === key;
|
|
||||||
});
|
|
||||||
this._fireAction(
|
this._fireAction(
|
||||||
this._prependSlash(key), action, true, action.payload);
|
this._prependSlash(key), action, true, action.payload);
|
||||||
break;
|
break;
|
||||||
@@ -1196,9 +1190,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getActionOverflowIndex(type, key) {
|
_getActionOverflowIndex(type, key) {
|
||||||
return this._overflowActions.findIndex(action => {
|
return this._overflowActions
|
||||||
return action.type === type && action.key === key;
|
.findIndex(action => action.type === type && action.key === key);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setLoadingOnButtonWithKey(type, key) {
|
_setLoadingOnButtonWithKey(type, key) {
|
||||||
@@ -1460,9 +1453,8 @@
|
|||||||
|
|
||||||
_getActionPriority(action) {
|
_getActionPriority(action) {
|
||||||
if (action.__type && action.__key) {
|
if (action.__type && action.__key) {
|
||||||
const overrideAction = this._actionPriorityOverrides.find(i => {
|
const overrideAction = this._actionPriorityOverrides
|
||||||
return i.type === action.__type && i.key === action.__key;
|
.find(i => i.type === action.__type && i.key === action.__key);
|
||||||
});
|
|
||||||
|
|
||||||
if (overrideAction !== undefined) {
|
if (overrideAction !== undefined) {
|
||||||
return overrideAction.priority;
|
return overrideAction.priority;
|
||||||
|
@@ -220,9 +220,8 @@ limitations under the License.
|
|||||||
|
|
||||||
test('delete buttons have explicit labels', done => {
|
test('delete buttons have explicit labels', done => {
|
||||||
flush(() => {
|
flush(() => {
|
||||||
const deleteItems = element.$.moreActions.items.filter(item => {
|
const deleteItems = element.$.moreActions.items
|
||||||
return item.id.startsWith('delete');
|
.filter(item => item.id.startsWith('delete'));
|
||||||
});
|
|
||||||
assert.equal(deleteItems.length, 1);
|
assert.equal(deleteItems.length, 1);
|
||||||
assert.notEqual(deleteItems[0].name);
|
assert.notEqual(deleteItems[0].name);
|
||||||
assert.equal(deleteItems[0].name, 'Delete change');
|
assert.equal(deleteItems[0].name, 'Delete change');
|
||||||
@@ -261,7 +260,7 @@ limitations under the License.
|
|||||||
sandbox.stub(element.$.restAPI, 'getFromProjectLookup')
|
sandbox.stub(element.$.restAPI, 'getFromProjectLookup')
|
||||||
.returns(Promise.resolve('test'));
|
.returns(Promise.resolve('test'));
|
||||||
sandbox.stub(element, 'fetchChangeUpdates',
|
sandbox.stub(element, 'fetchChangeUpdates',
|
||||||
() => { return Promise.resolve({isLatest: true}); });
|
() => Promise.resolve({isLatest: true}));
|
||||||
sandbox.stub(element.$.overlay, 'open').returns(Promise.resolve());
|
sandbox.stub(element.$.overlay, 'open').returns(Promise.resolve());
|
||||||
element.change = {
|
element.change = {
|
||||||
revisions: {
|
revisions: {
|
||||||
@@ -284,7 +283,7 @@ limitations under the License.
|
|||||||
sandbox.stub(element.$.restAPI, 'getFromProjectLookup')
|
sandbox.stub(element.$.restAPI, 'getFromProjectLookup')
|
||||||
.returns(Promise.resolve('test'));
|
.returns(Promise.resolve('test'));
|
||||||
sandbox.stub(element, 'fetchChangeUpdates',
|
sandbox.stub(element, 'fetchChangeUpdates',
|
||||||
() => { return Promise.resolve({isLatest: true}); });
|
() => Promise.resolve({isLatest: true}));
|
||||||
sandbox.stub(element.$.overlay, 'open').returns(Promise.resolve());
|
sandbox.stub(element.$.overlay, 'open').returns(Promise.resolve());
|
||||||
element.change = {
|
element.change = {
|
||||||
revisions: {
|
revisions: {
|
||||||
@@ -318,7 +317,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('submit change with plugin hook', done => {
|
test('submit change with plugin hook', done => {
|
||||||
sandbox.stub(element, '_canSubmitChange',
|
sandbox.stub(element, '_canSubmitChange',
|
||||||
() => { return false; });
|
() => false);
|
||||||
const fireActionStub = sandbox.stub(element, '_fireAction');
|
const fireActionStub = sandbox.stub(element, '_fireAction');
|
||||||
flush(() => {
|
flush(() => {
|
||||||
const submitButton = element.$$('gr-button[data-action-key="submit"]');
|
const submitButton = element.$$('gr-button[data-action-key="submit"]');
|
||||||
@@ -819,9 +818,9 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
const newRevertMsg = 'Modified revert msg';
|
const newRevertMsg = 'Modified revert msg';
|
||||||
sandbox.stub(element, '_modifyRevertMsg',
|
sandbox.stub(element, '_modifyRevertMsg',
|
||||||
() => { return newRevertMsg; });
|
() => newRevertMsg);
|
||||||
sandbox.stub(element.$.confirmRevertDialog, 'populateRevertMessage',
|
sandbox.stub(element.$.confirmRevertDialog, 'populateRevertMessage',
|
||||||
() => { return 'original msg'; });
|
() => 'original msg');
|
||||||
flush(() => {
|
flush(() => {
|
||||||
const revertButton =
|
const revertButton =
|
||||||
element.$$('gr-button[data-action-key="revert"]');
|
element.$$('gr-button[data-action-key="revert"]');
|
||||||
@@ -837,7 +836,7 @@ limitations under the License.
|
|||||||
current_revision: 'abc1234',
|
current_revision: 'abc1234',
|
||||||
};
|
};
|
||||||
sandbox.stub(element.$.confirmRevertDialog, 'populateRevertMessage',
|
sandbox.stub(element.$.confirmRevertDialog, 'populateRevertMessage',
|
||||||
() => { return 'original msg'; });
|
() => 'original msg');
|
||||||
const revertButton = element.$$('gr-button[data-action-key="revert"]');
|
const revertButton = element.$$('gr-button[data-action-key="revert"]');
|
||||||
MockInteractions.tap(revertButton);
|
MockInteractions.tap(revertButton);
|
||||||
|
|
||||||
@@ -1398,15 +1397,13 @@ limitations under the License.
|
|||||||
sandbox.stub(element, 'async', fn => fn());
|
sandbox.stub(element, 'async', fn => fn());
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeGetChange = numTries => {
|
const makeGetChange = numTries => () => {
|
||||||
return () => {
|
if (numTries === 1) {
|
||||||
if (numTries === 1) {
|
return Promise.resolve({_number: 123});
|
||||||
return Promise.resolve({_number: 123});
|
} else {
|
||||||
} else {
|
numTries--;
|
||||||
numTries--;
|
return Promise.resolve(undefined);
|
||||||
return Promise.resolve(undefined);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
test('succeed', () => {
|
test('succeed', () => {
|
||||||
@@ -1457,15 +1454,14 @@ limitations under the License.
|
|||||||
'navigateToChange').returns(Promise.resolve(true));
|
'navigateToChange').returns(Promise.resolve(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('change action', () => {
|
test('change action', () => element
|
||||||
return element._send('DELETE', payload, '/endpoint', false, cleanup)
|
._send('DELETE', payload, '/endpoint', false, cleanup)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
assert.isFalse(onShowError.called);
|
assert.isFalse(onShowError.called);
|
||||||
assert.isTrue(cleanup.calledOnce);
|
assert.isTrue(cleanup.calledOnce);
|
||||||
assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint',
|
assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint',
|
||||||
null, payload));
|
null, payload));
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
suite('show revert submission dialog', () => {
|
suite('show revert submission dialog', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
@@ -1549,15 +1545,14 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('revision action', () => {
|
test('revision action', () => element
|
||||||
return element._send('DELETE', payload, '/endpoint', true, cleanup)
|
._send('DELETE', payload, '/endpoint', true, cleanup)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
assert.isFalse(onShowError.called);
|
assert.isFalse(onShowError.called);
|
||||||
assert.isTrue(cleanup.calledOnce);
|
assert.isTrue(cleanup.calledOnce);
|
||||||
assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint',
|
assert.isTrue(sendStub.calledWith(42, 'DELETE', '/endpoint',
|
||||||
12, payload));
|
12, payload));
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
suite('failure modes', () => {
|
suite('failure modes', () => {
|
||||||
|
@@ -608,11 +608,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diffDrafts[draft.path].push(draft);
|
diffDrafts[draft.path].push(draft);
|
||||||
diffDrafts[draft.path].sort((c1, c2) => {
|
diffDrafts[draft.path].sort((c1, c2) =>
|
||||||
// No line number means that it’s a file comment. Sort it above the
|
// No line number means that it’s a file comment. Sort it above the
|
||||||
// others.
|
// others.
|
||||||
return (c1.line || -1) - (c2.line || -1);
|
(c1.line || -1) - (c2.line || -1)
|
||||||
});
|
);
|
||||||
this._diffDrafts = diffDrafts;
|
this._diffDrafts = diffDrafts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@
|
|||||||
_handleMessageReply(e) {
|
_handleMessageReply(e) {
|
||||||
const msg = e.detail.message.message;
|
const msg = e.detail.message.message;
|
||||||
const quoteStr = msg.split('\n').map(
|
const quoteStr = msg.split('\n').map(
|
||||||
line => { return '> ' + line; })
|
line => '> ' + line)
|
||||||
.join('\n') + '\n\n';
|
.join('\n') + '\n\n';
|
||||||
this.$.replyDialog.quote = quoteStr;
|
this.$.replyDialog.quote = quoteStr;
|
||||||
this._openReplyDialog(this.$.replyDialog.FocusTarget.BODY);
|
this._openReplyDialog(this.$.replyDialog.FocusTarget.BODY);
|
||||||
@@ -1093,9 +1093,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const drafts = (changeRecord && changeRecord.base) || {};
|
const drafts = (changeRecord && changeRecord.base) || {};
|
||||||
const draftCount = Object.keys(drafts).reduce((count, file) => {
|
const draftCount = Object.keys(drafts)
|
||||||
return count + drafts[file].length;
|
.reduce((count, file) => count + drafts[file].length, 0);
|
||||||
}, 0);
|
|
||||||
|
|
||||||
let label = 'Reply';
|
let label = 'Reply';
|
||||||
if (draftCount > 0) {
|
if (draftCount > 0) {
|
||||||
@@ -1401,9 +1400,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_reloadDraftsWithCallback(e) {
|
_reloadDraftsWithCallback(e) {
|
||||||
return this._reloadDrafts().then(() => {
|
return this._reloadDrafts().then(() => e.detail.resolve());
|
||||||
return e.detail.resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -91,9 +91,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
getCustomCssValue = cssParam => {
|
getCustomCssValue = cssParam => util.getComputedStyleValue(cssParam, element);
|
||||||
return util.getComputedStyleValue(cssParam, element);
|
|
||||||
};
|
|
||||||
|
|
||||||
test('_handleMessageAnchorTap', () => {
|
test('_handleMessageAnchorTap', () => {
|
||||||
element._changeNum = '1';
|
element._changeNum = '1';
|
||||||
@@ -725,10 +723,10 @@ limitations under the License.
|
|||||||
|
|
||||||
test('don’t reload entire page when patchRange changes', () => {
|
test('don’t reload entire page when patchRange changes', () => {
|
||||||
const reloadStub = sandbox.stub(element, '_reload',
|
const reloadStub = sandbox.stub(element, '_reload',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
const reloadPatchDependentStub = sandbox.stub(element,
|
const reloadPatchDependentStub = sandbox.stub(element,
|
||||||
'_reloadPatchNumDependentResources',
|
'_reloadPatchNumDependentResources',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
const relatedClearSpy = sandbox.spy(element.$.relatedChanges, 'clear');
|
const relatedClearSpy = sandbox.spy(element.$.relatedChanges, 'clear');
|
||||||
const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs');
|
const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs');
|
||||||
|
|
||||||
@@ -753,7 +751,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('reload entire page when patchRange doesnt change', () => {
|
test('reload entire page when patchRange doesnt change', () => {
|
||||||
const reloadStub = sandbox.stub(element, '_reload',
|
const reloadStub = sandbox.stub(element, '_reload',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs');
|
const collapseStub = sandbox.stub(element.$.fileList, 'collapseAllDiffs');
|
||||||
const value = {
|
const value = {
|
||||||
view: Gerrit.Nav.View.CHANGE,
|
view: Gerrit.Nav.View.CHANGE,
|
||||||
@@ -769,11 +767,9 @@ limitations under the License.
|
|||||||
test('related changes are updated and new patch selected after rebase',
|
test('related changes are updated and new patch selected after rebase',
|
||||||
done => {
|
done => {
|
||||||
element._changeNum = '42';
|
element._changeNum = '42';
|
||||||
sandbox.stub(element, 'computeLatestPatchNum', () => {
|
sandbox.stub(element, 'computeLatestPatchNum', () => 1);
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
sandbox.stub(element, '_reload',
|
sandbox.stub(element, '_reload',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
const e = {detail: {action: 'rebase'}};
|
const e = {detail: {action: 'rebase'}};
|
||||||
element._handleReloadChange(e).then(() => {
|
element._handleReloadChange(e).then(() => {
|
||||||
assert.isTrue(navigateToChangeStub.lastCall.calledWithExactly(
|
assert.isTrue(navigateToChangeStub.lastCall.calledWithExactly(
|
||||||
@@ -783,7 +779,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('related changes are not updated after other action', done => {
|
test('related changes are not updated after other action', done => {
|
||||||
sandbox.stub(element, '_reload', () => { return Promise.resolve(); });
|
sandbox.stub(element, '_reload', () => Promise.resolve());
|
||||||
sandbox.stub(element.$.relatedChanges, 'reload');
|
sandbox.stub(element.$.relatedChanges, 'reload');
|
||||||
const e = {detail: {action: 'abandon'}};
|
const e = {detail: {action: 'abandon'}};
|
||||||
element._handleReloadChange(e).then(() => {
|
element._handleReloadChange(e).then(() => {
|
||||||
@@ -929,14 +925,12 @@ limitations under the License.
|
|||||||
|
|
||||||
test('topic is coalesced to null', done => {
|
test('topic is coalesced to null', done => {
|
||||||
sandbox.stub(element, '_changeChanged');
|
sandbox.stub(element, '_changeChanged');
|
||||||
sandbox.stub(element.$.restAPI, 'getChangeDetail', () => {
|
sandbox.stub(element.$.restAPI, 'getChangeDetail', () => Promise.resolve({
|
||||||
return Promise.resolve({
|
id: '123456789',
|
||||||
id: '123456789',
|
labels: {},
|
||||||
labels: {},
|
current_revision: 'foo',
|
||||||
current_revision: 'foo',
|
revisions: {foo: {commit: {}}},
|
||||||
revisions: {foo: {commit: {}}},
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
element._getChangeDetail().then(() => {
|
element._getChangeDetail().then(() => {
|
||||||
assert.isNull(element._change.topic);
|
assert.isNull(element._change.topic);
|
||||||
@@ -946,14 +940,12 @@ limitations under the License.
|
|||||||
|
|
||||||
test('commit sha is populated from getChangeDetail', done => {
|
test('commit sha is populated from getChangeDetail', done => {
|
||||||
sandbox.stub(element, '_changeChanged');
|
sandbox.stub(element, '_changeChanged');
|
||||||
sandbox.stub(element.$.restAPI, 'getChangeDetail', () => {
|
sandbox.stub(element.$.restAPI, 'getChangeDetail', () => Promise.resolve({
|
||||||
return Promise.resolve({
|
id: '123456789',
|
||||||
id: '123456789',
|
labels: {},
|
||||||
labels: {},
|
current_revision: 'foo',
|
||||||
current_revision: 'foo',
|
revisions: {foo: {commit: {}}},
|
||||||
revisions: {foo: {commit: {}}},
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
element._getChangeDetail().then(() => {
|
element._getChangeDetail().then(() => {
|
||||||
assert.equal('foo', element._commitInfo.commit);
|
assert.equal('foo', element._commitInfo.commit);
|
||||||
@@ -963,20 +955,16 @@ limitations under the License.
|
|||||||
|
|
||||||
test('edit is added to change', () => {
|
test('edit is added to change', () => {
|
||||||
sandbox.stub(element, '_changeChanged');
|
sandbox.stub(element, '_changeChanged');
|
||||||
sandbox.stub(element.$.restAPI, 'getChangeDetail', () => {
|
sandbox.stub(element.$.restAPI, 'getChangeDetail', () => Promise.resolve({
|
||||||
return Promise.resolve({
|
id: '123456789',
|
||||||
id: '123456789',
|
labels: {},
|
||||||
labels: {},
|
current_revision: 'foo',
|
||||||
current_revision: 'foo',
|
revisions: {foo: {commit: {}}},
|
||||||
revisions: {foo: {commit: {}}},
|
}));
|
||||||
});
|
sandbox.stub(element, '_getEdit', () => Promise.resolve({
|
||||||
});
|
base_patch_set_number: 1,
|
||||||
sandbox.stub(element, '_getEdit', () => {
|
commit: {commit: 'bar'},
|
||||||
return Promise.resolve({
|
}));
|
||||||
base_patch_set_number: 1,
|
|
||||||
commit: {commit: 'bar'},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
element._patchRange = {};
|
element._patchRange = {};
|
||||||
|
|
||||||
return element._getChangeDetail().then(() => {
|
return element._getChangeDetail().then(() => {
|
||||||
@@ -1097,12 +1085,8 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('revert dialog opened with revert param', done => {
|
test('revert dialog opened with revert param', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getLoggedIn', () => {
|
sandbox.stub(element.$.restAPI, 'getLoggedIn', () => Promise.resolve(true));
|
||||||
return Promise.resolve(true);
|
sandbox.stub(Gerrit, 'awaitPluginsLoaded', () => Promise.resolve());
|
||||||
});
|
|
||||||
sandbox.stub(Gerrit, 'awaitPluginsLoaded', () => {
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
element._patchRange = {
|
element._patchRange = {
|
||||||
basePatchNum: 'PARENT',
|
basePatchNum: 'PARENT',
|
||||||
@@ -1173,7 +1157,7 @@ limitations under the License.
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(element.$.replyDialog, '_draftChanged');
|
sandbox.stub(element.$.replyDialog, '_draftChanged');
|
||||||
sandbox.stub(element.$.replyDialog, 'fetchChangeUpdates',
|
sandbox.stub(element.$.replyDialog, 'fetchChangeUpdates',
|
||||||
() => { return Promise.resolve({isLatest: true}); });
|
() => Promise.resolve({isLatest: true}));
|
||||||
element._change = {labels: {}};
|
element._change = {labels: {}};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1222,7 +1206,7 @@ limitations under the License.
|
|||||||
suite('commit message expand/collapse', () => {
|
suite('commit message expand/collapse', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(element, 'fetchChangeUpdates',
|
sandbox.stub(element, 'fetchChangeUpdates',
|
||||||
() => { return Promise.resolve({isLatest: false}); });
|
() => Promise.resolve({isLatest: false}));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('commitCollapseToggle hidden for short commit message', () => {
|
test('commitCollapseToggle hidden for short commit message', () => {
|
||||||
@@ -1260,7 +1244,7 @@ limitations under the License.
|
|||||||
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
||||||
sandbox.stub(element, '_getScrollHeight', () => 60);
|
sandbox.stub(element, '_getScrollHeight', () => 60);
|
||||||
sandbox.stub(element, '_getLineHeight', () => 5);
|
sandbox.stub(element, '_getLineHeight', () => 5);
|
||||||
sandbox.stub(window, 'matchMedia', () => ({matches: true}));
|
sandbox.stub(window, 'matchMedia', () => { return {matches: true}; });
|
||||||
element.$.relatedChanges.dispatchEvent(
|
element.$.relatedChanges.dispatchEvent(
|
||||||
new CustomEvent('new-section-loaded'));
|
new CustomEvent('new-section-loaded'));
|
||||||
assert.isTrue(element.$.relatedChangesToggle.classList
|
assert.isTrue(element.$.relatedChangesToggle.classList
|
||||||
@@ -1275,7 +1259,7 @@ limitations under the License.
|
|||||||
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
||||||
sandbox.stub(element, '_getScrollHeight', () => 40);
|
sandbox.stub(element, '_getScrollHeight', () => 40);
|
||||||
sandbox.stub(element, '_getLineHeight', () => 5);
|
sandbox.stub(element, '_getLineHeight', () => 5);
|
||||||
sandbox.stub(window, 'matchMedia', () => ({matches: true}));
|
sandbox.stub(window, 'matchMedia', () => { return {matches: true}; });
|
||||||
element.$.relatedChanges.dispatchEvent(
|
element.$.relatedChanges.dispatchEvent(
|
||||||
new CustomEvent('new-section-loaded'));
|
new CustomEvent('new-section-loaded'));
|
||||||
assert.isFalse(element.$.relatedChangesToggle.classList
|
assert.isFalse(element.$.relatedChangesToggle.classList
|
||||||
@@ -1285,7 +1269,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('relatedChangesToggle functions', () => {
|
test('relatedChangesToggle functions', () => {
|
||||||
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
||||||
sandbox.stub(window, 'matchMedia', () => ({matches: false}));
|
sandbox.stub(window, 'matchMedia', () => { return {matches: false}; });
|
||||||
element._relatedChangesLoading = false;
|
element._relatedChangesLoading = false;
|
||||||
assert.isTrue(element._relatedChangesCollapsed);
|
assert.isTrue(element._relatedChangesCollapsed);
|
||||||
assert.isTrue(
|
assert.isTrue(
|
||||||
@@ -1299,7 +1283,7 @@ limitations under the License.
|
|||||||
test('_updateRelatedChangeMaxHeight without commit toggle', () => {
|
test('_updateRelatedChangeMaxHeight without commit toggle', () => {
|
||||||
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
||||||
sandbox.stub(element, '_getLineHeight', () => 12);
|
sandbox.stub(element, '_getLineHeight', () => 12);
|
||||||
sandbox.stub(window, 'matchMedia', () => ({matches: false}));
|
sandbox.stub(window, 'matchMedia', () => { return {matches: false}; });
|
||||||
|
|
||||||
// 50 (existing height) - 30 (extra height) = 20 (adjusted height).
|
// 50 (existing height) - 30 (extra height) = 20 (adjusted height).
|
||||||
// 20 (max existing height) % 12 (line height) = 6 (remainder).
|
// 20 (max existing height) % 12 (line height) = 6 (remainder).
|
||||||
@@ -1316,7 +1300,7 @@ limitations under the License.
|
|||||||
element._latestCommitMessage = _.times(31, String).join('\n');
|
element._latestCommitMessage = _.times(31, String).join('\n');
|
||||||
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
||||||
sandbox.stub(element, '_getLineHeight', () => 12);
|
sandbox.stub(element, '_getLineHeight', () => 12);
|
||||||
sandbox.stub(window, 'matchMedia', () => ({matches: false}));
|
sandbox.stub(window, 'matchMedia', () => { return {matches: false}; });
|
||||||
|
|
||||||
// 50 (existing height) % 12 (line height) = 2 (remainder).
|
// 50 (existing height) % 12 (line height) = 2 (remainder).
|
||||||
// 50 (existing height) - 2 (remainder) = 48 (max height to set).
|
// 50 (existing height) - 2 (remainder) = 48 (max height to set).
|
||||||
@@ -1332,7 +1316,7 @@ limitations under the License.
|
|||||||
element._latestCommitMessage = _.times(31, String).join('\n');
|
element._latestCommitMessage = _.times(31, String).join('\n');
|
||||||
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
sandbox.stub(element, '_getOffsetHeight', () => 50);
|
||||||
sandbox.stub(element, '_getLineHeight', () => 12);
|
sandbox.stub(element, '_getLineHeight', () => 12);
|
||||||
sandbox.stub(window, 'matchMedia', () => ({matches: true}));
|
sandbox.stub(window, 'matchMedia', () => { return {matches: true}; });
|
||||||
|
|
||||||
element._updateRelatedChangeMaxHeight();
|
element._updateRelatedChangeMaxHeight();
|
||||||
|
|
||||||
@@ -1383,7 +1367,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('_startUpdateCheckTimer up-to-date', () => {
|
test('_startUpdateCheckTimer up-to-date', () => {
|
||||||
sandbox.stub(element, 'fetchChangeUpdates',
|
sandbox.stub(element, 'fetchChangeUpdates',
|
||||||
() => { return Promise.resolve({isLatest: true}); });
|
() => Promise.resolve({isLatest: true}));
|
||||||
|
|
||||||
element._serverConfig = {change: {update_delay: 12345}};
|
element._serverConfig = {change: {update_delay: 12345}};
|
||||||
|
|
||||||
@@ -1394,7 +1378,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('_startUpdateCheckTimer out-of-date shows an alert', done => {
|
test('_startUpdateCheckTimer out-of-date shows an alert', done => {
|
||||||
sandbox.stub(element, 'fetchChangeUpdates',
|
sandbox.stub(element, 'fetchChangeUpdates',
|
||||||
() => { return Promise.resolve({isLatest: false}); });
|
() => Promise.resolve({isLatest: false}));
|
||||||
element.addEventListener('show-alert', e => {
|
element.addEventListener('show-alert', e => {
|
||||||
assert.equal(e.detail.message,
|
assert.equal(e.detail.message,
|
||||||
'A newer patch set has been uploaded');
|
'A newer patch set has been uploaded');
|
||||||
|
@@ -298,9 +298,7 @@
|
|||||||
this._filesByPath = filesByPath;
|
this._filesByPath = filesByPath;
|
||||||
}));
|
}));
|
||||||
promises.push(this._getLoggedIn()
|
promises.push(this._getLoggedIn()
|
||||||
.then(loggedIn => {
|
.then(loggedIn => this._loggedIn = loggedIn)
|
||||||
return this._loggedIn = loggedIn;
|
|
||||||
})
|
|
||||||
.then(loggedIn => {
|
.then(loggedIn => {
|
||||||
if (!loggedIn) { return; }
|
if (!loggedIn) { return; }
|
||||||
|
|
||||||
@@ -1065,30 +1063,28 @@
|
|||||||
|
|
||||||
return (new Promise(resolve => {
|
return (new Promise(resolve => {
|
||||||
this.fire('reload-drafts', {resolve});
|
this.fire('reload-drafts', {resolve});
|
||||||
})).then(() => {
|
})).then(() => this.asyncForeach(paths, (path, cancel) => {
|
||||||
return this.asyncForeach(paths, (path, cancel) => {
|
this._cancelForEachDiff = cancel;
|
||||||
this._cancelForEachDiff = cancel;
|
|
||||||
|
|
||||||
iter++;
|
iter++;
|
||||||
console.log('Expanding diff', iter, 'of', initialCount, ':',
|
console.log('Expanding diff', iter, 'of', initialCount, ':',
|
||||||
path);
|
path);
|
||||||
const diffElem = this._findDiffByPath(path, diffElements);
|
const diffElem = this._findDiffByPath(path, diffElements);
|
||||||
diffElem.comments = this.changeComments.getCommentsBySideForPath(
|
diffElem.comments = this.changeComments.getCommentsBySideForPath(
|
||||||
path, this.patchRange, this.projectConfig);
|
path, this.patchRange, this.projectConfig);
|
||||||
const promises = [diffElem.reload()];
|
const promises = [diffElem.reload()];
|
||||||
if (this._loggedIn && !this.diffPrefs.manual_review) {
|
if (this._loggedIn && !this.diffPrefs.manual_review) {
|
||||||
promises.push(this._reviewFile(path, true));
|
promises.push(this._reviewFile(path, true));
|
||||||
}
|
}
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this._cancelForEachDiff = null;
|
this._cancelForEachDiff = null;
|
||||||
this._nextRenderParams = null;
|
this._nextRenderParams = null;
|
||||||
console.log('Finished expanding', initialCount, 'diff(s)');
|
console.log('Finished expanding', initialCount, 'diff(s)');
|
||||||
this.$.reporting.timeEndWithAverage(EXPAND_ALL_TIMING_LABEL,
|
this.$.reporting.timeEndWithAverage(EXPAND_ALL_TIMING_LABEL,
|
||||||
EXPAND_ALL_AVG_TIMING_LABEL, initialCount);
|
EXPAND_ALL_AVG_TIMING_LABEL, initialCount);
|
||||||
this.$.diffCursor.handleDiffUpdate();
|
this.$.diffCursor.handleDiffUpdate();
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel the rendering work of every diff in the list */
|
/** Cancel the rendering work of every diff in the list */
|
||||||
@@ -1143,9 +1139,9 @@
|
|||||||
// comments due to use in the _handleCommentUpdate function.
|
// comments due to use in the _handleCommentUpdate function.
|
||||||
// The comment thread already has a side associated with it, so
|
// The comment thread already has a side associated with it, so
|
||||||
// set the comment's side to match.
|
// set the comment's side to match.
|
||||||
threadEl.comments = newComments.map(c => {
|
threadEl.comments = newComments.map(c => Object.assign(
|
||||||
return Object.assign(c, {__commentSide: threadEl.commentSide});
|
c, {__commentSide: threadEl.commentSide}
|
||||||
});
|
));
|
||||||
Polymer.dom.flush();
|
Polymer.dom.flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -115,7 +115,7 @@ limitations under the License.
|
|||||||
patchNum: '2',
|
patchNum: '2',
|
||||||
};
|
};
|
||||||
saveStub = sandbox.stub(element, '_saveReviewedState',
|
saveStub = sandbox.stub(element, '_saveReviewedState',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
});
|
});
|
||||||
|
|
||||||
teardown(() => {
|
teardown(() => {
|
||||||
@@ -1477,9 +1477,7 @@ limitations under the License.
|
|||||||
basePatchNum: 'PARENT',
|
basePatchNum: 'PARENT',
|
||||||
patchNum: '2',
|
patchNum: '2',
|
||||||
};
|
};
|
||||||
sandbox.stub(window, 'fetch', () => {
|
sandbox.stub(window, 'fetch', () => Promise.resolve());
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -115,9 +115,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderedValues = Object.keys(values).sort((a, b) => {
|
const orderedValues = Object.keys(values).sort((a, b) => a - b);
|
||||||
return a - b;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < orderedValues.length; i++) {
|
for (let i = 0; i < orderedValues.length; i++) {
|
||||||
values[orderedValues[i]] = i;
|
values[orderedValues[i]] = i;
|
||||||
|
@@ -207,7 +207,7 @@
|
|||||||
return scoresRaw.split(' ')
|
return scoresRaw.split(' ')
|
||||||
.map(s => s.match(LABEL_TITLE_SCORE_PATTERN))
|
.map(s => s.match(LABEL_TITLE_SCORE_PATTERN))
|
||||||
.filter(ms => ms && ms.length === 3)
|
.filter(ms => ms && ms.length === 3)
|
||||||
.map(ms => ({label: ms[1], value: ms[2]}));
|
.map(ms => { return {label: ms[1], value: ms[2]}; });
|
||||||
}
|
}
|
||||||
|
|
||||||
_computeScoreClass(score, labelExtremes) {
|
_computeScoreClass(score, labelExtremes) {
|
||||||
|
@@ -324,9 +324,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getHumanMessages(messages) {
|
_getHumanMessages(messages) {
|
||||||
return messages.filter(msg => {
|
return messages.filter(msg => !this._isAutomated(msg));
|
||||||
return !this._isAutomated(msg);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_computeShowHideTextHidden(visibleMessages, messages,
|
_computeShowHideTextHidden(visibleMessages, messages,
|
||||||
|
@@ -354,7 +354,7 @@
|
|||||||
changeRevision = rev;
|
changeRevision = rev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const commits = relatedChanges.map(c => { return c.commit; });
|
const commits = relatedChanges.map(c => c.commit);
|
||||||
let pos = commits.length - 1;
|
let pos = commits.length - 1;
|
||||||
|
|
||||||
while (pos >= 0) {
|
while (pos >= 0) {
|
||||||
|
@@ -136,23 +136,24 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
function stubSaveReview(jsonResponseProducer) {
|
function stubSaveReview(jsonResponseProducer) {
|
||||||
return sandbox.stub(element, '_saveReview', review => {
|
return sandbox.stub(
|
||||||
return new Promise((resolve, reject) => {
|
element,
|
||||||
try {
|
'_saveReview',
|
||||||
const result = jsonResponseProducer(review) || {};
|
review => new Promise((resolve, reject) => {
|
||||||
const resultStr =
|
try {
|
||||||
element.$.restAPI.JSON_PREFIX + JSON.stringify(result);
|
const result = jsonResponseProducer(review) || {};
|
||||||
resolve({
|
const resultStr =
|
||||||
ok: true,
|
element.$.restAPI.JSON_PREFIX + JSON.stringify(result);
|
||||||
text() {
|
resolve({
|
||||||
return Promise.resolve(resultStr);
|
ok: true,
|
||||||
},
|
text() {
|
||||||
});
|
return Promise.resolve(resultStr);
|
||||||
} catch (err) {
|
},
|
||||||
reject(err);
|
});
|
||||||
}
|
} catch (err) {
|
||||||
});
|
reject(err);
|
||||||
});
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
test('default to publishing drafts with reply', done => {
|
test('default to publishing drafts with reply', done => {
|
||||||
@@ -379,7 +380,8 @@ limitations under the License.
|
|||||||
observer = overlayObserver('closed');
|
observer = overlayObserver('closed');
|
||||||
const expected = 'Group name has 10 members';
|
const expected = 'Group name has 10 members';
|
||||||
assert.notEqual(
|
assert.notEqual(
|
||||||
element.$.reviewerConfirmationOverlay.innerText.indexOf(expected),
|
element.$.reviewerConfirmationOverlay.innerText
|
||||||
|
.indexOf(expected),
|
||||||
-1);
|
-1);
|
||||||
MockInteractions.tap(noButton); // close the overlay
|
MockInteractions.tap(noButton); // close the overlay
|
||||||
return observer;
|
return observer;
|
||||||
@@ -982,9 +984,10 @@ limitations under the License.
|
|||||||
let startReviewStub;
|
let startReviewStub;
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
startReviewStub = sandbox.stub(element.$.restAPI, 'startReview', () => {
|
startReviewStub = sandbox.stub(
|
||||||
return Promise.resolve();
|
element.$.restAPI,
|
||||||
});
|
'startReview',
|
||||||
|
() => Promise.resolve());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ready property in review input on start review', () => {
|
test('ready property in review input on start review', () => {
|
||||||
|
@@ -102,10 +102,12 @@
|
|||||||
*/
|
*/
|
||||||
_permittedLabelsToNumericScores(labels) {
|
_permittedLabelsToNumericScores(labels) {
|
||||||
if (!labels) return [];
|
if (!labels) return [];
|
||||||
return Object.keys(labels).map(label => ({
|
return Object.keys(labels).map(label => {
|
||||||
label,
|
return {
|
||||||
scores: labels[label].map(v => parseInt(v, 10)),
|
label,
|
||||||
}));
|
scores: labels[label].map(v => parseInt(v, 10)),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,10 +118,12 @@
|
|||||||
*/
|
*/
|
||||||
_getMaxPermittedScores(change) {
|
_getMaxPermittedScores(change) {
|
||||||
return this._permittedLabelsToNumericScores(change.permitted_labels)
|
return this._permittedLabelsToNumericScores(change.permitted_labels)
|
||||||
.map(({label, scores}) => ({
|
.map(({label, scores}) => {
|
||||||
[label]: scores
|
return {
|
||||||
.map(v => parseInt(v, 10))
|
[label]: scores
|
||||||
.reduce((a, b) => Math.max(a, b))}))
|
.map(v => parseInt(v, 10))
|
||||||
|
.reduce((a, b) => Math.max(a, b))};
|
||||||
|
})
|
||||||
.reduce((acc, i) => Object.assign(acc, i), {});
|
.reduce((acc, i) => Object.assign(acc, i), {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +193,8 @@
|
|||||||
result = result.concat(reviewers[key]);
|
result = result.concat(reviewers[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._reviewers = result.filter(reviewer => {
|
this._reviewers = result
|
||||||
return reviewer._account_id != owner._account_id;
|
.filter(reviewer => reviewer._account_id != owner._account_id);
|
||||||
});
|
|
||||||
|
|
||||||
// If there is one or two more than the max reviewers, don't show the
|
// If there is one or two more than the max reviewers, don't show the
|
||||||
// 'show more' button, because it takes up just as much space.
|
// 'show more' button, because it takes up just as much space.
|
||||||
|
@@ -102,9 +102,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_interpolateUrl(url, replacements) {
|
_interpolateUrl(url, replacements) {
|
||||||
return url.replace(INTERPOLATE_URL_PATTERN, (match, p1) => {
|
return url.replace(
|
||||||
return replacements[p1] || '';
|
INTERPOLATE_URL_PATTERN,
|
||||||
});
|
(match, p1) => replacements[p1] || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
_accountName(account) {
|
_accountName(account) {
|
||||||
|
@@ -107,7 +107,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('show normal Error', done => {
|
test('show normal Error', done => {
|
||||||
const showErrorStub = sandbox.stub(element, '_showErrorDialog');
|
const showErrorStub = sandbox.stub(element, '_showErrorDialog');
|
||||||
const textSpy = sandbox.spy(() => { return Promise.resolve('ZOMG'); });
|
const textSpy = sandbox.spy(() => Promise.resolve('ZOMG'));
|
||||||
element.fire('server-error', {response: {status: 500, text: textSpy}});
|
element.fire('server-error', {response: {status: 500, text: textSpy}});
|
||||||
|
|
||||||
assert.isTrue(textSpy.called);
|
assert.isTrue(textSpy.called);
|
||||||
@@ -129,8 +129,9 @@ limitations under the License.
|
|||||||
'Error 409');
|
'Error 409');
|
||||||
assert.equal(element._constructServerErrorMsg({status, url}),
|
assert.equal(element._constructServerErrorMsg({status, url}),
|
||||||
'Error 409: \nEndpoint: /my/test/url');
|
'Error 409: \nEndpoint: /my/test/url');
|
||||||
assert.equal(element._constructServerErrorMsg({status, statusText, url}),
|
assert.equal(element.
|
||||||
'Error 409 (Conflict): \nEndpoint: /my/test/url');
|
_constructServerErrorMsg({status, statusText, url}),
|
||||||
|
'Error 409 (Conflict): \nEndpoint: /my/test/url');
|
||||||
assert.equal(element._constructServerErrorMsg({
|
assert.equal(element._constructServerErrorMsg({
|
||||||
status,
|
status,
|
||||||
statusText,
|
statusText,
|
||||||
@@ -142,9 +143,9 @@ limitations under the License.
|
|||||||
|
|
||||||
test('suppress TOO_MANY_FILES error', done => {
|
test('suppress TOO_MANY_FILES error', done => {
|
||||||
const showAlertStub = sandbox.stub(element, '_showAlert');
|
const showAlertStub = sandbox.stub(element, '_showAlert');
|
||||||
const textSpy = sandbox.spy(() => {
|
const textSpy = sandbox.spy(
|
||||||
return Promise.resolve('too many files to find conflicts');
|
() => Promise.resolve('too many files to find conflicts')
|
||||||
});
|
);
|
||||||
element.fire('server-error', {response: {status: 500, text: textSpy}});
|
element.fire('server-error', {response: {status: 500, text: textSpy}});
|
||||||
|
|
||||||
assert.isTrue(textSpy.called);
|
assert.isTrue(textSpy.called);
|
||||||
@@ -172,7 +173,7 @@ limitations under the License.
|
|||||||
// starts with authed state
|
// starts with authed state
|
||||||
element.$.restAPI.getLoggedIn();
|
element.$.restAPI.getLoggedIn();
|
||||||
const refreshStub = sandbox.stub(element.$.restAPI, 'getAccount',
|
const refreshStub = sandbox.stub(element.$.restAPI, 'getAccount',
|
||||||
() => { return Promise.resolve({}); });
|
() => Promise.resolve({}));
|
||||||
const toastSpy = sandbox.spy(element, '_createToastAlert');
|
const toastSpy = sandbox.spy(element, '_createToastAlert');
|
||||||
const windowOpen = sandbox.stub(window, 'open');
|
const windowOpen = sandbox.stub(window, 'open');
|
||||||
const responseText = Promise.resolve('Authentication required\n');
|
const responseText = Promise.resolve('Authentication required\n');
|
||||||
@@ -297,7 +298,10 @@ limitations under the License.
|
|||||||
test('show-error', () => {
|
test('show-error', () => {
|
||||||
const openStub = sandbox.stub(element.$.errorOverlay, 'open');
|
const openStub = sandbox.stub(element.$.errorOverlay, 'open');
|
||||||
const closeStub = sandbox.stub(element.$.errorOverlay, 'close');
|
const closeStub = sandbox.stub(element.$.errorOverlay, 'close');
|
||||||
const reportStub = sandbox.stub(element.$.reporting, 'reportErrorDialog');
|
const reportStub = sandbox.stub(
|
||||||
|
element.$.reporting,
|
||||||
|
'reportErrorDialog'
|
||||||
|
);
|
||||||
|
|
||||||
const message = 'test message';
|
const message = 'test message';
|
||||||
element.fire('show-error', {message});
|
element.fire('show-error', {message});
|
||||||
@@ -317,7 +321,9 @@ limitations under the License.
|
|||||||
const accountPromise = Promise.resolve({_account_id: 1234});
|
const accountPromise = Promise.resolve({_account_id: 1234});
|
||||||
sandbox.stub(element.$.restAPI, 'getAccount')
|
sandbox.stub(element.$.restAPI, 'getAccount')
|
||||||
.returns(accountPromise);
|
.returns(accountPromise);
|
||||||
const requestCheckStub = sandbox.stub(element, '_requestCheckLoggedIn');
|
const requestCheckStub = sandbox.stub(
|
||||||
|
element,
|
||||||
|
'_requestCheckLoggedIn');
|
||||||
const handleRefreshStub = sandbox.stub(element,
|
const handleRefreshStub = sandbox.stub(element,
|
||||||
'_handleCredentialRefreshed');
|
'_handleCredentialRefreshed');
|
||||||
const reloadStub = sandbox.stub(element, '_reloadPage');
|
const reloadStub = sandbox.stub(element, '_reloadPage');
|
||||||
@@ -344,7 +350,9 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('refresh loop continues on credential fail', done => {
|
test('refresh loop continues on credential fail', done => {
|
||||||
const requestCheckStub = sandbox.stub(element, '_requestCheckLoggedIn');
|
const requestCheckStub = sandbox.stub(
|
||||||
|
element,
|
||||||
|
'_requestCheckLoggedIn');
|
||||||
const handleRefreshStub = sandbox.stub(element,
|
const handleRefreshStub = sandbox.stub(element,
|
||||||
'_handleCredentialRefreshed');
|
'_handleCredentialRefreshed');
|
||||||
const reloadStub = sandbox.stub(element, '_reloadPage');
|
const reloadStub = sandbox.stub(element, '_reloadPage');
|
||||||
|
@@ -231,10 +231,10 @@
|
|||||||
const topMenuLinks = [];
|
const topMenuLinks = [];
|
||||||
links.forEach(link => { topMenuLinks[link.title] = link.links; });
|
links.forEach(link => { topMenuLinks[link.title] = link.links; });
|
||||||
for (const m of topMenus) {
|
for (const m of topMenus) {
|
||||||
const items = m.items.map(this._fixCustomMenuItem).filter(link => {
|
const items = m.items.map(this._fixCustomMenuItem).filter(link =>
|
||||||
// Ignore GWT project links
|
// Ignore GWT project links
|
||||||
return !link.url.includes('${projectName}');
|
!link.url.includes('${projectName}')
|
||||||
});
|
);
|
||||||
if (m.name in topMenuLinks) {
|
if (m.name in topMenuLinks) {
|
||||||
items.forEach(link => { topMenuLinks[m.name].push(link); });
|
items.forEach(link => { topMenuLinks[m.name].push(link); });
|
||||||
} else {
|
} else {
|
||||||
|
@@ -74,7 +74,7 @@ limitations under the License.
|
|||||||
test('_getChangeWeblinks', () => {
|
test('_getChangeWeblinks', () => {
|
||||||
const link = {name: 'test', url: 'test/url'};
|
const link = {name: 'test', url: 'test/url'};
|
||||||
const browserLink = {name: 'browser', url: 'browser/url'};
|
const browserLink = {name: 'browser', url: 'browser/url'};
|
||||||
const mapLinksToConfig = weblinks => ({options: {weblinks}});
|
const mapLinksToConfig = weblinks => { return {options: {weblinks}}; };
|
||||||
sandbox.stub(element, '_getBrowseCommitWeblink').returns(browserLink);
|
sandbox.stub(element, '_getBrowseCommitWeblink').returns(browserLink);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -200,9 +200,7 @@
|
|||||||
const trimmedInput = this._inputVal && this._inputVal.trim();
|
const trimmedInput = this._inputVal && this._inputVal.trim();
|
||||||
if (trimmedInput) {
|
if (trimmedInput) {
|
||||||
const predefinedOpOnlyQuery = SEARCH_OPERATORS_WITH_NEGATIONS.some(
|
const predefinedOpOnlyQuery = SEARCH_OPERATORS_WITH_NEGATIONS.some(
|
||||||
op => {
|
op => op.endsWith(':') && op === trimmedInput
|
||||||
return op.endsWith(':') && op === trimmedInput;
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
if (predefinedOpOnlyQuery) {
|
if (predefinedOpOnlyQuery) {
|
||||||
return;
|
return;
|
||||||
@@ -252,7 +250,7 @@
|
|||||||
default:
|
default:
|
||||||
return Promise.resolve(SEARCH_OPERATORS_WITH_NEGATIONS
|
return Promise.resolve(SEARCH_OPERATORS_WITH_NEGATIONS
|
||||||
.filter(operator => operator.includes(input))
|
.filter(operator => operator.includes(input))
|
||||||
.map(operator => ({text: operator})));
|
.map(operator => { return {text: operator}; }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,11 +59,9 @@ limitations under the License.
|
|||||||
assert.equal(element._inputVal, 'foo');
|
assert.equal(element._inputVal, 'foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
getActiveElement = () => {
|
getActiveElement = () => (document.activeElement.shadowRoot ?
|
||||||
return document.activeElement.shadowRoot ?
|
document.activeElement.shadowRoot.activeElement :
|
||||||
document.activeElement.shadowRoot.activeElement :
|
document.activeElement);
|
||||||
document.activeElement;
|
|
||||||
};
|
|
||||||
|
|
||||||
test('enter in search input fires event', done => {
|
test('enter in search input fires event', done => {
|
||||||
element.addEventListener('handle-search', () => {
|
element.addEventListener('handle-search', () => {
|
||||||
|
@@ -91,7 +91,7 @@
|
|||||||
.then(projects => {
|
.then(projects => {
|
||||||
if (!projects) { return []; }
|
if (!projects) { return []; }
|
||||||
const keys = Object.keys(projects);
|
const keys = Object.keys(projects);
|
||||||
return keys.map(key => ({text: predicate + ':' + key}));
|
return keys.map(key => { return {text: predicate + ':' + key}; });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
.then(groups => {
|
.then(groups => {
|
||||||
if (!groups) { return []; }
|
if (!groups) { return []; }
|
||||||
const keys = Object.keys(groups);
|
const keys = Object.keys(groups);
|
||||||
return keys.map(key => ({text: predicate + ':' + key}));
|
return keys.map(key => { return {text: predicate + ':' + key}; });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,12 +151,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_mapAccountsHelper(accounts, predicate) {
|
_mapAccountsHelper(accounts, predicate) {
|
||||||
return accounts.map(account => ({
|
return accounts.map(account => {
|
||||||
label: account.name || '',
|
return {
|
||||||
text: account.email ?
|
label: account.name || '',
|
||||||
`${predicate}:${account.email}` :
|
text: account.email ?
|
||||||
`${predicate}:"${this._accountOrAnon(account)}"`,
|
`${predicate}:${account.email}` :
|
||||||
}));
|
`${predicate}:"${this._accountOrAnon(account)}"`,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,8 +85,9 @@
|
|||||||
.getRobotCommentFixPreview(this.changeNum, this._patchNum, fixId)
|
.getRobotCommentFixPreview(this.changeNum, this._patchNum, fixId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
const previews = Object.keys(res).map(key =>
|
const previews = Object.keys(res).map(key => {
|
||||||
({filepath: key, preview: res[key]}));
|
return {filepath: key, preview: res[key]};
|
||||||
|
});
|
||||||
this._currentPreviews = previews;
|
this._currentPreviews = previews;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -39,9 +39,7 @@
|
|||||||
* file simpler by just using _reloadComments here instead.
|
* file simpler by just using _reloadComments here instead.
|
||||||
*/
|
*/
|
||||||
_reloadDraftsWithCallback(e) {
|
_reloadDraftsWithCallback(e) {
|
||||||
return this._reloadComments().then(() => {
|
return this._reloadComments().then(() => e.detail.resolve());
|
||||||
return e.detail.resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_reloadComments() {
|
_reloadComments() {
|
||||||
|
@@ -362,9 +362,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ChangeComments.prototype._sortComments = function(comments) {
|
ChangeComments.prototype._sortComments = function(comments) {
|
||||||
return comments.slice(0).sort((c1, c2) => {
|
return comments.slice(0)
|
||||||
return util.parseDate(c1.updated) - util.parseDate(c2.updated);
|
.sort(
|
||||||
});
|
(c1, c2) => util.parseDate(c1.updated) - util.parseDate(c2.updated)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -230,7 +230,7 @@
|
|||||||
GrDiffBuilder.prototype.getSectionsByLineRange = function(
|
GrDiffBuilder.prototype.getSectionsByLineRange = function(
|
||||||
startLine, endLine, opt_side) {
|
startLine, endLine, opt_side) {
|
||||||
return this.getGroupsByLineRange(startLine, endLine, opt_side).map(
|
return this.getGroupsByLineRange(startLine, endLine, opt_side).map(
|
||||||
group => { return group.element; });
|
group => group.element);
|
||||||
};
|
};
|
||||||
|
|
||||||
GrDiffBuilder.prototype._createContextControl = function(section, line) {
|
GrDiffBuilder.prototype._createContextControl = function(section, line) {
|
||||||
|
@@ -812,9 +812,8 @@ limitations under the License.
|
|||||||
sandbox.stub(builder, 'addColumns');
|
sandbox.stub(builder, 'addColumns');
|
||||||
builder.buildSectionElement = function(group) {
|
builder.buildSectionElement = function(group) {
|
||||||
const section = document.createElement('stub');
|
const section = document.createElement('stub');
|
||||||
section.textContent = group.lines.reduce((acc, line) => {
|
section.textContent = group.lines
|
||||||
return acc + line.text;
|
.reduce((acc, line) => acc + line.text, '');
|
||||||
}, '');
|
|
||||||
return section;
|
return section;
|
||||||
};
|
};
|
||||||
return builder;
|
return builder;
|
||||||
@@ -859,7 +858,7 @@ limitations under the License.
|
|||||||
const dispatchEventStub = sandbox.stub(element, 'dispatchEvent');
|
const dispatchEventStub = sandbox.stub(element, 'dispatchEvent');
|
||||||
element.render(keyLocations, {}).then(() => {
|
element.render(keyLocations, {}).then(() => {
|
||||||
const firedEventTypes = dispatchEventStub.getCalls()
|
const firedEventTypes = dispatchEventStub.getCalls()
|
||||||
.map(c => { return c.args[0].type; });
|
.map(c => c.args[0].type);
|
||||||
assert.include(firedEventTypes, 'render-start');
|
assert.include(firedEventTypes, 'render-start');
|
||||||
assert.include(firedEventTypes, 'render-content');
|
assert.include(firedEventTypes, 'render-content');
|
||||||
done();
|
done();
|
||||||
|
@@ -165,9 +165,7 @@
|
|||||||
|
|
||||||
moveToNextChunk(opt_clipToTop) {
|
moveToNextChunk(opt_clipToTop) {
|
||||||
this.$.cursorManager.next(this._isFirstRowOfChunk.bind(this),
|
this.$.cursorManager.next(this._isFirstRowOfChunk.bind(this),
|
||||||
target => {
|
target => target.parentNode.scrollHeight, opt_clipToTop);
|
||||||
return target.parentNode.scrollHeight;
|
|
||||||
}, opt_clipToTop);
|
|
||||||
this._fixSide();
|
this._fixSide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,9 +271,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
createCommentInPlace() {
|
createCommentInPlace() {
|
||||||
const diffWithRangeSelected = this.diffs.find(diff => {
|
const diffWithRangeSelected = this.diffs
|
||||||
return diff.isRangeSelected();
|
.find(diff => diff.isRangeSelected());
|
||||||
});
|
|
||||||
if (diffWithRangeSelected) {
|
if (diffWithRangeSelected) {
|
||||||
diffWithRangeSelected.createRangeComment();
|
diffWithRangeSelected.createRangeComment();
|
||||||
} else {
|
} else {
|
||||||
@@ -404,9 +401,7 @@
|
|||||||
|
|
||||||
_getStops() {
|
_getStops() {
|
||||||
return this.diffs.reduce(
|
return this.diffs.reduce(
|
||||||
(stops, diff) => {
|
(stops, diff) => stops.concat(diff.getCursorStops()), []);
|
||||||
return stops.concat(diff.getCursorStops());
|
|
||||||
}, []);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateStops() {
|
_updateStops() {
|
||||||
|
@@ -123,9 +123,8 @@ limitations under the License.
|
|||||||
element.comments.left.push(comment);
|
element.comments.left.push(comment);
|
||||||
comment.id = id;
|
comment.id = id;
|
||||||
element.fire('comment-discard', {comment});
|
element.fire('comment-discard', {comment});
|
||||||
const drafts = element.comments.left.filter(item => {
|
const drafts = element.comments.left
|
||||||
return item.__draftID === draftID;
|
.filter(item => item.__draftID === draftID);
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 0);
|
assert.equal(drafts.length, 0);
|
||||||
assert.isTrue(diffCommentsModifiedStub.called);
|
assert.isTrue(diffCommentsModifiedStub.called);
|
||||||
});
|
});
|
||||||
@@ -145,9 +144,8 @@ limitations under the License.
|
|||||||
element.comments.left.push(comment);
|
element.comments.left.push(comment);
|
||||||
comment.id = id;
|
comment.id = id;
|
||||||
element.fire('comment-save', {comment});
|
element.fire('comment-save', {comment});
|
||||||
const drafts = element.comments.left.filter(item => {
|
const drafts = element.comments.left
|
||||||
return item.__draftID === draftID;
|
.filter(item => item.__draftID === draftID);
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.equal(drafts[0].id, id);
|
assert.equal(drafts[0].id, id);
|
||||||
assert.isTrue(diffCommentsModifiedStub.called);
|
assert.isTrue(diffCommentsModifiedStub.called);
|
||||||
@@ -508,10 +506,10 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
sandbox.stub(element.$.restAPI,
|
sandbox.stub(element.$.restAPI,
|
||||||
'getB64FileContents',
|
'getB64FileContents',
|
||||||
(changeId, patchNum, path, opt_parentIndex) => {
|
(changeId, patchNum, path, opt_parentIndex) => Promise.resolve(
|
||||||
return Promise.resolve(opt_parentIndex === 1 ? mockFile1 :
|
opt_parentIndex === 1 ? mockFile1 :
|
||||||
mockFile2);
|
mockFile2)
|
||||||
});
|
);
|
||||||
|
|
||||||
element.patchRange = {basePatchNum: 'PARENT', patchNum: 1};
|
element.patchRange = {basePatchNum: 'PARENT', patchNum: 1};
|
||||||
element.comments = {
|
element.comments = {
|
||||||
@@ -1382,7 +1380,8 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('starts syntax layer processing on render event', done => {
|
test('starts syntax layer processing on render event', done => {
|
||||||
sandbox.stub(element.$.syntaxLayer, 'process').returns(Promise.resolve());
|
sandbox.stub(element.$.syntaxLayer, 'process')
|
||||||
|
.returns(Promise.resolve());
|
||||||
sandbox.stub(element.$.restAPI, 'getDiff').returns(
|
sandbox.stub(element.$.restAPI, 'getDiff').returns(
|
||||||
Promise.resolve({content: []}));
|
Promise.resolve({content: []}));
|
||||||
element.reload();
|
element.reload();
|
||||||
|
@@ -500,7 +500,7 @@ limitations under the License.
|
|||||||
test('breaks down shared chunks w/ whole-file', () => {
|
test('breaks down shared chunks w/ whole-file', () => {
|
||||||
const size = 120 * 2 + 5;
|
const size = 120 * 2 + 5;
|
||||||
const content = [{
|
const content = [{
|
||||||
ab: _.times(size, () => { return `${Math.random()}`; }),
|
ab: _.times(size, () => `${Math.random()}`),
|
||||||
}];
|
}];
|
||||||
element.context = -1;
|
element.context = -1;
|
||||||
const result = element._splitLargeChunks(content);
|
const result = element._splitLargeChunks(content);
|
||||||
@@ -511,7 +511,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('does not break-down common chunks w/ context', () => {
|
test('does not break-down common chunks w/ context', () => {
|
||||||
const content = [{
|
const content = [{
|
||||||
ab: _.times(75, () => { return `${Math.random()}`; }),
|
ab: _.times(75, () => `${Math.random()}`),
|
||||||
}];
|
}];
|
||||||
element.context = 4;
|
element.context = 4;
|
||||||
const result =
|
const result =
|
||||||
@@ -897,7 +897,7 @@ limitations under the License.
|
|||||||
assert.isAtMost(subResult.length, size);
|
assert.isAtMost(subResult.length, size);
|
||||||
}
|
}
|
||||||
const flattened = result
|
const flattened = result
|
||||||
.reduce((a, b) => { return a.concat(b); }, []);
|
.reduce((a, b) => a.concat(b), []);
|
||||||
assert.deepEqual(flattened, array);
|
assert.deepEqual(flattened, array);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -169,7 +169,7 @@
|
|||||||
},
|
},
|
||||||
_panelFloatingDisabled: {
|
_panelFloatingDisabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: () => { return window.PANEL_FLOATING_DISABLED; },
|
value: () => window.PANEL_FLOATING_DISABLED,
|
||||||
},
|
},
|
||||||
_editMode: {
|
_editMode: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@@ -281,8 +281,11 @@ limitations under the License.
|
|||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||||
assert.isTrue(element._loading);
|
assert.isTrue(element._loading);
|
||||||
assert(diffNavStub.lastCall.calledWithExactly(element._change, 'chell.go',
|
assert(diffNavStub.lastCall.calledWithExactly(
|
||||||
'10', '5'),
|
element._change,
|
||||||
|
'chell.go',
|
||||||
|
'10',
|
||||||
|
'5'),
|
||||||
'Should navigate to /c/42/5..10/chell.go');
|
'Should navigate to /c/42/5..10/chell.go');
|
||||||
element._path = 'chell.go';
|
element._path = 'chell.go';
|
||||||
|
|
||||||
@@ -342,8 +345,11 @@ limitations under the License.
|
|||||||
element._path = 'glados.txt';
|
element._path = 'glados.txt';
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||||
assert(diffNavStub.lastCall.calledWithExactly(element._change, 'chell.go',
|
assert(diffNavStub.lastCall.calledWithExactly(
|
||||||
'1', PARENT), 'Should navigate to /c/42/1/chell.go');
|
element._change,
|
||||||
|
'chell.go',
|
||||||
|
'1',
|
||||||
|
PARENT), 'Should navigate to /c/42/1/chell.go');
|
||||||
element._path = 'chell.go';
|
element._path = 'chell.go';
|
||||||
|
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||||
@@ -429,12 +435,14 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('url params', () => {
|
suite('url params', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(Gerrit.Nav, 'getUrlForDiff', (c, p, pn, bpn) => {
|
sandbox.stub(
|
||||||
return `${c._number}-${p}-${pn}-${bpn}`;
|
Gerrit.Nav,
|
||||||
});
|
'getUrlForDiff',
|
||||||
sandbox.stub(Gerrit.Nav, 'getUrlForChange', (c, pn, bpn) => {
|
(c, p, pn, bpn) => `${c._number}-${p}-${pn}-${bpn}`);
|
||||||
return `${c._number}-${pn}-${bpn}`;
|
sandbox.stub(
|
||||||
});
|
Gerrit.Nav
|
||||||
|
, 'getUrlForChange',
|
||||||
|
(c, pn, bpn) => `${c._number}-${pn}-${bpn}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_formattedFiles', () => {
|
test('_formattedFiles', () => {
|
||||||
|
@@ -374,10 +374,11 @@
|
|||||||
.map(commentRangeFromThreadEl)
|
.map(commentRangeFromThreadEl)
|
||||||
.filter(({range}) => range);
|
.filter(({range}) => range);
|
||||||
for (const removedCommentRange of removedCommentRanges) {
|
for (const removedCommentRange of removedCommentRanges) {
|
||||||
const i = this._commentRanges.findIndex(commentRange => {
|
const i = this._commentRanges
|
||||||
return commentRange.side === removedCommentRange.side &&
|
.findIndex(
|
||||||
Gerrit.rangesEqual(commentRange.range, removedCommentRange.range);
|
cr => cr.side === removedCommentRange.side &&
|
||||||
});
|
Gerrit.rangesEqual(cr.range, removedCommentRange.range)
|
||||||
|
);
|
||||||
this.splice('_commentRanges', i, 1);
|
this.splice('_commentRanges', i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +585,7 @@
|
|||||||
* @param {string=} side
|
* @param {string=} side
|
||||||
* @param {!Object=} range
|
* @param {!Object=} range
|
||||||
*/
|
*/
|
||||||
_createComment(lineEl, lineNum=undefined, side=undefined, range=undefined) {
|
_createComment(lineEl, lineNum, side, range) {
|
||||||
const contentText = this.$.diffBuilder.getContentByLineEl(lineEl);
|
const contentText = this.$.diffBuilder.getContentByLineEl(lineEl);
|
||||||
const contentEl = contentText.parentElement;
|
const contentEl = contentText.parentElement;
|
||||||
side = side ||
|
side = side ||
|
||||||
@@ -870,13 +871,12 @@
|
|||||||
_computeDiffHeaderItems(diffInfoRecord) {
|
_computeDiffHeaderItems(diffInfoRecord) {
|
||||||
const diffInfo = diffInfoRecord.base;
|
const diffInfo = diffInfoRecord.base;
|
||||||
if (!diffInfo || !diffInfo.diff_header) { return []; }
|
if (!diffInfo || !diffInfo.diff_header) { return []; }
|
||||||
return diffInfo.diff_header.filter(item => {
|
return diffInfo.diff_header
|
||||||
return !(item.startsWith('diff --git ') ||
|
.filter(item => !(item.startsWith('diff --git ') ||
|
||||||
item.startsWith('index ') ||
|
item.startsWith('index ') ||
|
||||||
item.startsWith('+++ ') ||
|
item.startsWith('+++ ') ||
|
||||||
item.startsWith('--- ') ||
|
item.startsWith('--- ') ||
|
||||||
item === 'Binary files differ');
|
item === 'Binary files differ'));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {boolean} */
|
/** @return {boolean} */
|
||||||
|
@@ -271,39 +271,37 @@
|
|||||||
const rangesCache = new Map();
|
const rangesCache = new Map();
|
||||||
|
|
||||||
this._processPromise = util.makeCancelable(this._loadHLJS()
|
this._processPromise = util.makeCancelable(this._loadHLJS()
|
||||||
.then(() => {
|
.then(() => new Promise(resolve => {
|
||||||
return new Promise(resolve => {
|
const nextStep = () => {
|
||||||
const nextStep = () => {
|
this._processHandle = null;
|
||||||
this._processHandle = null;
|
this._processNextLine(state, rangesCache);
|
||||||
this._processNextLine(state, rangesCache);
|
|
||||||
|
|
||||||
// Move to the next line in the section.
|
// Move to the next line in the section.
|
||||||
state.lineIndex++;
|
state.lineIndex++;
|
||||||
|
|
||||||
// If the section has been exhausted, move to the next one.
|
// If the section has been exhausted, move to the next one.
|
||||||
if (this._isSectionDone(state)) {
|
if (this._isSectionDone(state)) {
|
||||||
state.lineIndex = 0;
|
state.lineIndex = 0;
|
||||||
state.sectionIndex++;
|
state.sectionIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all sections have been exhausted, finish.
|
// If all sections have been exhausted, finish.
|
||||||
if (state.sectionIndex >= this.diff.content.length) {
|
if (state.sectionIndex >= this.diff.content.length) {
|
||||||
resolve();
|
resolve();
|
||||||
this._notify(state);
|
this._notify(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.lineIndex % 100 === 0) {
|
if (state.lineIndex % 100 === 0) {
|
||||||
this._notify(state);
|
this._notify(state);
|
||||||
this._processHandle = this.async(nextStep, ASYNC_DELAY);
|
this._processHandle = this.async(nextStep, ASYNC_DELAY);
|
||||||
} else {
|
} else {
|
||||||
nextStep.call(this);
|
nextStep.call(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this._processHandle = this.async(nextStep, 1);
|
this._processHandle = this.async(nextStep, 1);
|
||||||
});
|
})));
|
||||||
}));
|
|
||||||
return this._processPromise
|
return this._processPromise
|
||||||
.finally(() => { this._processPromise = null; });
|
.finally(() => { this._processPromise = null; });
|
||||||
}
|
}
|
||||||
|
@@ -194,7 +194,7 @@ limitations under the License.
|
|||||||
const mockHLJS = getMockHLJS();
|
const mockHLJS = getMockHLJS();
|
||||||
const highlightSpy = sinon.spy(mockHLJS, 'highlight');
|
const highlightSpy = sinon.spy(mockHLJS, 'highlight');
|
||||||
sandbox.stub(element.$.libLoader, 'getHLJS',
|
sandbox.stub(element.$.libLoader, 'getHLJS',
|
||||||
() => { return Promise.resolve(mockHLJS); });
|
() => Promise.resolve(mockHLJS));
|
||||||
const processNextSpy = sandbox.spy(element, '_processNextLine');
|
const processNextSpy = sandbox.spy(element, '_processNextLine');
|
||||||
const processPromise = element.process();
|
const processPromise = element.process();
|
||||||
|
|
||||||
|
@@ -90,9 +90,10 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('_paramsChanged', done => {
|
test('_paramsChanged', done => {
|
||||||
sandbox.stub(element.$.restAPI, 'getDocumentationSearches', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve(documentationSearches);
|
element.$.restAPI,
|
||||||
});
|
'getDocumentationSearches',
|
||||||
|
() => Promise.resolve(documentationSearches));
|
||||||
const value = {
|
const value = {
|
||||||
filter: 'test',
|
filter: 'test',
|
||||||
};
|
};
|
||||||
|
@@ -336,13 +336,12 @@ suite('gr-edit-controls tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('openOpenDialog', () => {
|
test('openOpenDialog', () => element.openOpenDialog('test/path.cpp')
|
||||||
return element.openOpenDialog('test/path.cpp').then(() => {
|
.then(() => {
|
||||||
assert.isFalse(element.$.openDialog.hasAttribute('hidden'));
|
assert.isFalse(element.$.openDialog.hasAttribute('hidden'));
|
||||||
assert.equal(element.$.openDialog.querySelector('gr-autocomplete').text,
|
assert.equal(element.$.openDialog.querySelector('gr-autocomplete').text,
|
||||||
'test/path.cpp');
|
'test/path.cpp');
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
test('_getDialogFromEvent', () => {
|
test('_getDialogFromEvent', () => {
|
||||||
const spy = sandbox.spy(element, '_getDialogFromEvent');
|
const spy = sandbox.spy(element, '_getDialogFromEvent');
|
||||||
|
@@ -82,9 +82,7 @@ limitations under the License.
|
|||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
appElement = () => {
|
appElement = () => element.$['app-element'];
|
||||||
return element.$['app-element'];
|
|
||||||
};
|
|
||||||
|
|
||||||
test('reporting', () => {
|
test('reporting', () => {
|
||||||
assert.isTrue(appElement().$.reporting.appStarted.calledOnce);
|
assert.isTrue(appElement().$.reporting.appStarted.calledOnce);
|
||||||
|
@@ -56,11 +56,9 @@ limitations under the License.
|
|||||||
assert.isOk(element);
|
assert.isOk(element);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('open uses open() from gr-overlay', () => {
|
test('open uses open() from gr-overlay', () => element.open().then(() => {
|
||||||
return element.open().then(() => {
|
assert.isTrue(element.$.overlay.open.called);
|
||||||
assert.isTrue(element.$.overlay.open.called);
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('close uses close() from gr-overlay', () => {
|
test('close uses close() from gr-overlay', () => {
|
||||||
element.close();
|
element.close();
|
||||||
|
@@ -69,26 +69,22 @@ limitations under the License.
|
|||||||
instance = new GrPopupInterface(plugin);
|
instance = new GrPopupInterface(plugin);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('open', () => {
|
test('open', () => instance.open().then(api => {
|
||||||
return instance.open().then(api => {
|
assert.strictEqual(api, instance);
|
||||||
assert.strictEqual(api, instance);
|
const manual = document.createElement('div');
|
||||||
const manual = document.createElement('div');
|
manual.id = 'foobar';
|
||||||
manual.id = 'foobar';
|
manual.innerHTML = 'manual content';
|
||||||
manual.innerHTML = 'manual content';
|
api._getElement().appendChild(manual);
|
||||||
api._getElement().appendChild(manual);
|
flushAsynchronousOperations();
|
||||||
flushAsynchronousOperations();
|
assert.equal(
|
||||||
assert.equal(
|
container.querySelector('#foobar').textContent, 'manual content');
|
||||||
container.querySelector('#foobar').textContent, 'manual content');
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('close', () => {
|
test('close', () => instance.open().then(api => {
|
||||||
return instance.open().then(api => {
|
assert.isTrue(api._getElement().node.opened);
|
||||||
assert.isTrue(api._getElement().node.opened);
|
api.close();
|
||||||
api.close();
|
assert.isFalse(api._getElement().node.opened);
|
||||||
assert.isFalse(api._getElement().node.opened);
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
suite('components', () => {
|
suite('components', () => {
|
||||||
@@ -96,20 +92,16 @@ limitations under the License.
|
|||||||
instance = new GrPopupInterface(plugin, 'gr-user-test-popup');
|
instance = new GrPopupInterface(plugin, 'gr-user-test-popup');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('open', () => {
|
test('open', () => instance.open().then(api => {
|
||||||
return instance.open().then(api => {
|
assert.isNotNull(
|
||||||
assert.isNotNull(
|
Polymer.dom(container).querySelector('gr-user-test-popup'));
|
||||||
Polymer.dom(container).querySelector('gr-user-test-popup'));
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('close', () => {
|
test('close', () => instance.open().then(api => {
|
||||||
return instance.open().then(api => {
|
assert.isTrue(api._getElement().node.opened);
|
||||||
assert.isTrue(api._getElement().node.opened);
|
api.close();
|
||||||
api.close();
|
assert.isFalse(api._getElement().node.opened);
|
||||||
assert.isFalse(api._getElement().node.opened);
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -59,9 +59,7 @@
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push(this.$.restAPI.getAccountGroups().then(groups => {
|
promises.push(this.$.restAPI.getAccountGroups().then(groups => {
|
||||||
this._groups = groups.sort((a, b) => {
|
this._groups = groups.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push(this.$.restAPI.getAccountAgreements().then(agreements => {
|
promises.push(this.$.restAPI.getAccountAgreements().then(agreements => {
|
||||||
|
@@ -90,7 +90,7 @@ limitations under the License.
|
|||||||
const lastKey = keys[Object.keys(keys)[1]];
|
const lastKey = keys[Object.keys(keys)[1]];
|
||||||
|
|
||||||
const saveStub = sinon.stub(element.$.restAPI, 'deleteAccountGPGKey',
|
const saveStub = sinon.stub(element.$.restAPI, 'deleteAccountGPGKey',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
|
|
||||||
assert.equal(element._keysToRemove.length, 0);
|
assert.equal(element._keysToRemove.length, 0);
|
||||||
assert.isFalse(element.hasUnsavedChanges);
|
assert.isFalse(element.hasUnsavedChanges);
|
||||||
@@ -146,7 +146,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addStub = sinon.stub(element.$.restAPI, 'addAccountGPGKey',
|
const addStub = sinon.stub(element.$.restAPI, 'addAccountGPGKey',
|
||||||
() => { return Promise.resolve(newKeyObject); });
|
() => Promise.resolve(newKeyObject));
|
||||||
|
|
||||||
element._newKey = newKeyString;
|
element._newKey = newKeyString;
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ limitations under the License.
|
|||||||
const newKeyString = 'not even close to valid';
|
const newKeyString = 'not even close to valid';
|
||||||
|
|
||||||
const addStub = sinon.stub(element.$.restAPI, 'addAccountGPGKey',
|
const addStub = sinon.stub(element.$.restAPI, 'addAccountGPGKey',
|
||||||
() => { return Promise.reject(new Error('error')); });
|
() => Promise.reject(new Error('error')));
|
||||||
|
|
||||||
element._newKey = newKeyString;
|
element._newKey = newKeyString;
|
||||||
|
|
||||||
|
@@ -30,9 +30,7 @@
|
|||||||
|
|
||||||
loadData() {
|
loadData() {
|
||||||
return this.$.restAPI.getAccountGroups().then(groups => {
|
return this.$.restAPI.getAccountGroups().then(groups => {
|
||||||
this._groups = groups.sort((a, b) => {
|
this._groups = groups.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,11 +58,9 @@ limitations under the License.
|
|||||||
const nextPassword = 'the new password';
|
const nextPassword = 'the new password';
|
||||||
let generateResolve;
|
let generateResolve;
|
||||||
const generateStub = sinon.stub(element.$.restAPI,
|
const generateStub = sinon.stub(element.$.restAPI,
|
||||||
'generateAccountHttpPassword', () => {
|
'generateAccountHttpPassword', () => new Promise(resolve => {
|
||||||
return new Promise(resolve => {
|
generateResolve = resolve;
|
||||||
generateResolve = resolve;
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.isNotOk(element._generatedPassword);
|
assert.isNotOk(element._generatedPassword);
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ limitations under the License.
|
|||||||
let menu;
|
let menu;
|
||||||
|
|
||||||
function assertMenuNamesEqual(element, expected) {
|
function assertMenuNamesEqual(element, expected) {
|
||||||
const names = element.menuItems.map(i => { return i.name; });
|
const names = element.menuItems.map(i => i.name);
|
||||||
assert.equal(names.length, expected.length);
|
assert.equal(names.length, expected.length);
|
||||||
for (let i = 0; i < names.length; i++) {
|
for (let i = 0; i < names.length; i++) {
|
||||||
assert.equal(names[i], expected[i]);
|
assert.equal(names[i], expected[i]);
|
||||||
|
@@ -70,7 +70,7 @@ limitations under the License.
|
|||||||
|
|
||||||
function stubAddAccountEmail(statusCode) {
|
function stubAddAccountEmail(statusCode) {
|
||||||
return sandbox.stub(element.$.restAPI, 'addAccountEmail',
|
return sandbox.stub(element.$.restAPI, 'addAccountEmail',
|
||||||
() => { return Promise.resolve({status: statusCode}); });
|
() => Promise.resolve({status: statusCode}));
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(done => {
|
setup(done => {
|
||||||
@@ -487,9 +487,10 @@ limitations under the License.
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(element.$.emailEditor, 'loadData');
|
sandbox.stub(element.$.emailEditor, 'loadData');
|
||||||
sandbox.stub(element.$.restAPI, 'confirmEmail', () => {
|
sandbox.stub(
|
||||||
return new Promise(resolve => { resolveConfirm = resolve; });
|
element.$.restAPI,
|
||||||
});
|
'confirmEmail',
|
||||||
|
() => new Promise(resolve => { resolveConfirm = resolve; }));
|
||||||
element.params = {emailToken: 'foo'};
|
element.params = {emailToken: 'foo'};
|
||||||
element.attached();
|
element.attached();
|
||||||
});
|
});
|
||||||
|
@@ -81,7 +81,7 @@ limitations under the License.
|
|||||||
const lastKey = keys[1];
|
const lastKey = keys[1];
|
||||||
|
|
||||||
const saveStub = sinon.stub(element.$.restAPI, 'deleteAccountSSHKey',
|
const saveStub = sinon.stub(element.$.restAPI, 'deleteAccountSSHKey',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
|
|
||||||
assert.equal(element._keysToRemove.length, 0);
|
assert.equal(element._keysToRemove.length, 0);
|
||||||
assert.isFalse(element.hasUnsavedChanges);
|
assert.isFalse(element.hasUnsavedChanges);
|
||||||
@@ -132,7 +132,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addStub = sinon.stub(element.$.restAPI, 'addAccountSSHKey',
|
const addStub = sinon.stub(element.$.restAPI, 'addAccountSSHKey',
|
||||||
() => { return Promise.resolve(newKeyObject); });
|
() => Promise.resolve(newKeyObject));
|
||||||
|
|
||||||
element._newKey = newKeyString;
|
element._newKey = newKeyString;
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ limitations under the License.
|
|||||||
const newKeyString = 'not even close to valid';
|
const newKeyString = 'not even close to valid';
|
||||||
|
|
||||||
const addStub = sinon.stub(element.$.restAPI, 'addAccountSSHKey',
|
const addStub = sinon.stub(element.$.restAPI, 'addAccountSSHKey',
|
||||||
() => { return Promise.reject(new Error('error')); });
|
() => Promise.reject(new Error('error')));
|
||||||
|
|
||||||
element._newKey = newKeyString;
|
element._newKey = newKeyString;
|
||||||
|
|
||||||
|
@@ -68,9 +68,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return deletePromise
|
return deletePromise
|
||||||
.then(() => {
|
.then(() => this.$.restAPI.saveWatchedProjects(this._projects))
|
||||||
return this.$.restAPI.saveWatchedProjects(this._projects);
|
|
||||||
})
|
|
||||||
.then(projects => {
|
.then(projects => {
|
||||||
this._projects = projects;
|
this._projects = projects;
|
||||||
this._projectsToRemove = [];
|
this._projectsToRemove = [];
|
||||||
|
@@ -88,7 +88,7 @@ limitations under the License.
|
|||||||
function getKeysOfRow(row) {
|
function getKeysOfRow(row) {
|
||||||
const boxes = rows[row].querySelectorAll('input[checked]');
|
const boxes = rows[row].querySelectorAll('input[checked]');
|
||||||
return Array.prototype.map.call(boxes,
|
return Array.prototype.map.call(boxes,
|
||||||
e => { return e.getAttribute('data-key'); });
|
e => e.getAttribute('data-key'));
|
||||||
}
|
}
|
||||||
|
|
||||||
let checkedKeys = getKeysOfRow(0);
|
let checkedKeys = getKeysOfRow(0);
|
||||||
|
@@ -80,9 +80,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getHasAvatars() {
|
_getHasAvatars() {
|
||||||
return this.$.restAPI.getConfig().then(cfg => {
|
return this.$.restAPI.getConfig()
|
||||||
return Promise.resolve(!!(cfg && cfg.plugin && cfg.plugin.has_avatars));
|
.then(cfg => Promise.resolve(!!(
|
||||||
});
|
cfg && cfg.plugin && cfg.plugin.has_avatars
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,13 +67,11 @@ limitations under the License.
|
|||||||
|
|
||||||
suite('stubbed values for querySuggestions', () => {
|
suite('stubbed values for querySuggestions', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
element.querySuggestions = input => {
|
element.querySuggestions = input => Promise.resolve([
|
||||||
return Promise.resolve([
|
suggestion1,
|
||||||
suggestion1,
|
suggestion2,
|
||||||
suggestion2,
|
suggestion3,
|
||||||
suggestion3,
|
]);
|
||||||
]);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -333,15 +333,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
additions() {
|
additions() {
|
||||||
return this.accounts.filter(account => {
|
return this.accounts
|
||||||
return account._pendingAdd;
|
.filter(account => account._pendingAdd)
|
||||||
}).map(account => {
|
.map(account => {
|
||||||
if (account._group) {
|
if (account._group) {
|
||||||
return {group: account};
|
return {group: account};
|
||||||
} else {
|
} else {
|
||||||
return {account};
|
return {account};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_computeEntryHidden(maxCount, accountsRecord, readonly) {
|
_computeEntryHidden(maxCount, accountsRecord, readonly) {
|
||||||
|
@@ -54,15 +54,13 @@ limitations under the License.
|
|||||||
|
|
||||||
test('renders', () => {
|
test('renders', () => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.spy(input => {
|
const queryStub = sandbox.spy(input => promise = Promise.resolve([
|
||||||
return promise = Promise.resolve([
|
{name: input + ' 0', value: 0},
|
||||||
{name: input + ' 0', value: 0},
|
{name: input + ' 1', value: 1},
|
||||||
{name: input + ' 1', value: 1},
|
{name: input + ' 2', value: 2},
|
||||||
{name: input + ' 2', value: 2},
|
{name: input + ' 3', value: 3},
|
||||||
{name: input + ' 3', value: 3},
|
{name: input + ' 4', value: 4},
|
||||||
{name: input + ' 4', value: 4},
|
]));
|
||||||
]);
|
|
||||||
});
|
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
assert.isTrue(element.$.suggestions.isHidden);
|
assert.isTrue(element.$.suggestions.isHidden);
|
||||||
assert.equal(element.$.suggestions.$.cursor.index, -1);
|
assert.equal(element.$.suggestions.$.cursor.index, -1);
|
||||||
@@ -104,11 +102,9 @@ limitations under the License.
|
|||||||
|
|
||||||
test('esc key behavior', done => {
|
test('esc key behavior', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.spy(() => {
|
const queryStub = sandbox.spy(() => promise = Promise.resolve([
|
||||||
return promise = Promise.resolve([
|
{name: 'blah', value: 123},
|
||||||
{name: 'blah', value: 123},
|
]));
|
||||||
]);
|
|
||||||
});
|
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
|
|
||||||
assert.isTrue(element.$.suggestions.isHidden);
|
assert.isTrue(element.$.suggestions.isHidden);
|
||||||
@@ -135,15 +131,13 @@ limitations under the License.
|
|||||||
|
|
||||||
test('emits commit and handles cursor movement', done => {
|
test('emits commit and handles cursor movement', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.spy(input => {
|
const queryStub = sandbox.spy(input => promise = Promise.resolve([
|
||||||
return promise = Promise.resolve([
|
{name: input + ' 0', value: 0},
|
||||||
{name: input + ' 0', value: 0},
|
{name: input + ' 1', value: 1},
|
||||||
{name: input + ' 1', value: 1},
|
{name: input + ' 2', value: 2},
|
||||||
{name: input + ' 2', value: 2},
|
{name: input + ' 3', value: 3},
|
||||||
{name: input + ' 3', value: 3},
|
{name: input + ' 4', value: 4},
|
||||||
{name: input + ' 4', value: 4},
|
]));
|
||||||
]);
|
|
||||||
});
|
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
|
|
||||||
assert.isTrue(element.$.suggestions.isHidden);
|
assert.isTrue(element.$.suggestions.isHidden);
|
||||||
@@ -188,7 +182,8 @@ limitations under the License.
|
|||||||
test('clear-on-commit behavior (off)', done => {
|
test('clear-on-commit behavior (off)', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.spy(() => {
|
const queryStub = sandbox.spy(() => {
|
||||||
return promise = Promise.resolve([{name: 'suggestion', value: 0}]);
|
promise = Promise.resolve([{name: 'suggestion', value: 0}]);
|
||||||
|
return promise;
|
||||||
});
|
});
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
focusOnInput(element);
|
focusOnInput(element);
|
||||||
@@ -210,7 +205,8 @@ limitations under the License.
|
|||||||
test('clear-on-commit behavior (on)', done => {
|
test('clear-on-commit behavior (on)', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.spy(() => {
|
const queryStub = sandbox.spy(() => {
|
||||||
return promise = Promise.resolve([{name: 'suggestion', value: 0}]);
|
promise = Promise.resolve([{name: 'suggestion', value: 0}]);
|
||||||
|
return promise;
|
||||||
});
|
});
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
focusOnInput(element);
|
focusOnInput(element);
|
||||||
@@ -231,9 +227,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('threshold guards the query', () => {
|
test('threshold guards the query', () => {
|
||||||
const queryStub = sandbox.spy(() => {
|
const queryStub = sandbox.spy(() => Promise.resolve([]));
|
||||||
return Promise.resolve([]);
|
|
||||||
});
|
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
element.threshold = 2;
|
element.threshold = 2;
|
||||||
focusOnInput(element);
|
focusOnInput(element);
|
||||||
@@ -244,9 +238,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('noDebounce=false debounces the query', () => {
|
test('noDebounce=false debounces the query', () => {
|
||||||
const queryStub = sandbox.spy(() => {
|
const queryStub = sandbox.spy(() => Promise.resolve([]));
|
||||||
return Promise.resolve([]);
|
|
||||||
});
|
|
||||||
let callback;
|
let callback;
|
||||||
const debounceStub = sandbox.stub(element, 'debounce',
|
const debounceStub = sandbox.stub(element, 'debounce',
|
||||||
(name, cb) => { callback = cb; });
|
(name, cb) => { callback = cb; });
|
||||||
@@ -276,7 +268,9 @@ limitations under the License.
|
|||||||
test('when focused', done => {
|
test('when focused', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.stub()
|
const queryStub = sandbox.stub()
|
||||||
.returns(promise = Promise.resolve([{name: 'suggestion', value: 0}]));
|
.returns(promise = Promise.resolve([
|
||||||
|
{name: 'suggestion', value: 0},
|
||||||
|
]));
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
element.suggestOnlyWhenFocus = true;
|
element.suggestOnlyWhenFocus = true;
|
||||||
focusOnInput(element);
|
focusOnInput(element);
|
||||||
@@ -293,7 +287,9 @@ limitations under the License.
|
|||||||
test('when not focused', done => {
|
test('when not focused', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.stub()
|
const queryStub = sandbox.stub()
|
||||||
.returns(promise = Promise.resolve([{name: 'suggestion', value: 0}]));
|
.returns(promise = Promise.resolve([
|
||||||
|
{name: 'suggestion', value: 0},
|
||||||
|
]));
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
element.suggestOnlyWhenFocus = true;
|
element.suggestOnlyWhenFocus = true;
|
||||||
element.text = 'bla';
|
element.text = 'bla';
|
||||||
@@ -308,7 +304,9 @@ limitations under the License.
|
|||||||
test('suggestions should not carry over', done => {
|
test('suggestions should not carry over', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.stub()
|
const queryStub = sandbox.stub()
|
||||||
.returns(promise = Promise.resolve([{name: 'suggestion', value: 0}]));
|
.returns(promise = Promise.resolve([
|
||||||
|
{name: 'suggestion', value: 0},
|
||||||
|
]));
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
focusOnInput(element);
|
focusOnInput(element);
|
||||||
element.text = 'bla';
|
element.text = 'bla';
|
||||||
@@ -324,7 +322,9 @@ limitations under the License.
|
|||||||
test('multi completes only the last part of the query', done => {
|
test('multi completes only the last part of the query', done => {
|
||||||
let promise;
|
let promise;
|
||||||
const queryStub = sandbox.stub()
|
const queryStub = sandbox.stub()
|
||||||
.returns(promise = Promise.resolve([{name: 'suggestion', value: 0}]));
|
.returns(promise = Promise.resolve([
|
||||||
|
{name: 'suggestion', value: 0},
|
||||||
|
]));
|
||||||
element.query = queryStub;
|
element.query = queryStub;
|
||||||
focusOnInput(element);
|
focusOnInput(element);
|
||||||
element.text = 'blah blah';
|
element.text = 'blah blah';
|
||||||
@@ -449,7 +449,12 @@ limitations under the License.
|
|||||||
// Must set the value, because the MockInteraction does not.
|
// Must set the value, because the MockInteraction does not.
|
||||||
element.$.input.value = 'file:x';
|
element.$.input.value = 'file:x';
|
||||||
assert.isTrue(keydownSpy.calledOnce);
|
assert.isTrue(keydownSpy.calledOnce);
|
||||||
MockInteractions.pressAndReleaseKeyOn(element.$.input, 13, null, 'enter');
|
MockInteractions.pressAndReleaseKeyOn(
|
||||||
|
element.$.input,
|
||||||
|
13,
|
||||||
|
null,
|
||||||
|
'enter'
|
||||||
|
);
|
||||||
assert.isTrue(keydownSpy.calledTwice);
|
assert.isTrue(keydownSpy.calledTwice);
|
||||||
assert.equal(element.text, 'file:x');
|
assert.equal(element.text, 'file:x');
|
||||||
});
|
});
|
||||||
|
@@ -105,9 +105,10 @@ limitations under the License.
|
|||||||
test('dom for existing account', () => {
|
test('dom for existing account', () => {
|
||||||
assert.isFalse(element.hasAttribute('hidden'));
|
assert.isFalse(element.hasAttribute('hidden'));
|
||||||
|
|
||||||
sandbox.stub(element, '_getConfig', () => {
|
sandbox.stub(
|
||||||
return Promise.resolve({plugin: {has_avatars: true}});
|
element,
|
||||||
});
|
'_getConfig',
|
||||||
|
() => Promise.resolve({plugin: {has_avatars: true}}));
|
||||||
|
|
||||||
element.imageSize = 64;
|
element.imageSize = 64;
|
||||||
element.account = {
|
element.account = {
|
||||||
@@ -139,9 +140,7 @@ limitations under the License.
|
|||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
|
|
||||||
stub('gr-avatar', {
|
stub('gr-avatar', {
|
||||||
_getConfig: () => {
|
_getConfig: () => Promise.resolve({plugin: {has_avatars: true}}),
|
||||||
return Promise.resolve({plugin: {has_avatars: true}});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
@@ -176,9 +175,7 @@ limitations under the License.
|
|||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
|
|
||||||
stub('gr-avatar', {
|
stub('gr-avatar', {
|
||||||
_getConfig: () => {
|
_getConfig: () => Promise.resolve({}),
|
||||||
return Promise.resolve({});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
|
@@ -280,9 +280,7 @@ limitations under the License.
|
|||||||
MockInteractions.tap(replyBtn);
|
MockInteractions.tap(replyBtn);
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
const drafts = element._orderedComments.filter(c => {
|
const drafts = element._orderedComments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.notOk(drafts[0].message, 'message should be empty');
|
assert.notOk(drafts[0].message, 'message should be empty');
|
||||||
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
||||||
@@ -299,9 +297,7 @@ limitations under the License.
|
|||||||
MockInteractions.tap(quoteBtn);
|
MockInteractions.tap(quoteBtn);
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
const drafts = element._orderedComments.filter(c => {
|
const drafts = element._orderedComments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.equal(drafts[0].message, '> is this a crossover episode!?\n\n');
|
assert.equal(drafts[0].message, '> is this a crossover episode!?\n\n');
|
||||||
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
||||||
@@ -330,9 +326,7 @@ limitations under the License.
|
|||||||
MockInteractions.tap(quoteBtn);
|
MockInteractions.tap(quoteBtn);
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
const drafts = element._orderedComments.filter(c => {
|
const drafts = element._orderedComments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.equal(drafts[0].message,
|
assert.equal(drafts[0].message,
|
||||||
'> is this a crossover episode!?\n> It might be!\n\n');
|
'> is this a crossover episode!?\n> It might be!\n\n');
|
||||||
@@ -352,9 +346,7 @@ limitations under the License.
|
|||||||
const ackBtn = element.$.ackBtn;
|
const ackBtn = element.$.ackBtn;
|
||||||
MockInteractions.tap(ackBtn);
|
MockInteractions.tap(ackBtn);
|
||||||
flush(() => {
|
flush(() => {
|
||||||
const drafts = element.comments.filter(c => {
|
const drafts = element.comments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.equal(drafts[0].message, 'Ack');
|
assert.equal(drafts[0].message, 'Ack');
|
||||||
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
||||||
@@ -375,9 +367,7 @@ limitations under the License.
|
|||||||
const doneBtn = element.$.doneBtn;
|
const doneBtn = element.$.doneBtn;
|
||||||
MockInteractions.tap(doneBtn);
|
MockInteractions.tap(doneBtn);
|
||||||
flush(() => {
|
flush(() => {
|
||||||
const drafts = element.comments.filter(c => {
|
const drafts = element.comments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.equal(drafts[0].message, 'Done');
|
assert.equal(drafts[0].message, 'Done');
|
||||||
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
assert.equal(drafts[0].in_reply_to, 'baf0414d_60047215');
|
||||||
@@ -415,9 +405,7 @@ limitations under the License.
|
|||||||
const commentEl = element.$$('gr-comment');
|
const commentEl = element.$$('gr-comment');
|
||||||
assert.ok(commentEl);
|
assert.ok(commentEl);
|
||||||
commentEl.addEventListener('create-fix-comment', () => {
|
commentEl.addEventListener('create-fix-comment', () => {
|
||||||
const drafts = element._orderedComments.filter(c => {
|
const drafts = element._orderedComments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 1);
|
assert.equal(drafts.length, 1);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
drafts[0].message, '> is this a crossover episode!?\n\nPlease fix.');
|
drafts[0].message, '> is this a crossover episode!?\n\nPlease fix.');
|
||||||
@@ -446,9 +434,7 @@ limitations under the License.
|
|||||||
Polymer.dom(element.root).querySelectorAll('gr-comment')[1];
|
Polymer.dom(element.root).querySelectorAll('gr-comment')[1];
|
||||||
assert.ok(draftEl);
|
assert.ok(draftEl);
|
||||||
draftEl.addEventListener('comment-discard', () => {
|
draftEl.addEventListener('comment-discard', () => {
|
||||||
const drafts = element.comments.filter(c => {
|
const drafts = element.comments.filter(c => c.__draft == true);
|
||||||
return c.__draft == true;
|
|
||||||
});
|
|
||||||
assert.equal(drafts.length, 0);
|
assert.equal(drafts.length, 0);
|
||||||
assert.isTrue(saveOrDiscardStub.called);
|
assert.isTrue(saveOrDiscardStub.called);
|
||||||
assert.equal(saveOrDiscardStub.lastCall.args[0].detail.rootId,
|
assert.equal(saveOrDiscardStub.lastCall.args[0].detail.rootId,
|
||||||
@@ -507,9 +493,7 @@ limitations under the License.
|
|||||||
MockInteractions.tap(replyBtn);
|
MockInteractions.tap(replyBtn);
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
const editing = element._orderedComments.filter(c => {
|
const editing = element._orderedComments.filter(c => c.__editing == true);
|
||||||
return c.__editing == true;
|
|
||||||
});
|
|
||||||
assert.equal(editing.length, 1);
|
assert.equal(editing.length, 1);
|
||||||
assert.equal(!!editing[0].__otherEditing, false);
|
assert.equal(!!editing[0].__otherEditing, false);
|
||||||
});
|
});
|
||||||
|
@@ -164,7 +164,7 @@
|
|||||||
*/
|
*/
|
||||||
_overlays: {
|
_overlays: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: () => ({}),
|
value: () => { return {}; },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -325,10 +325,9 @@
|
|||||||
_computeHasHumanReply() {
|
_computeHasHumanReply() {
|
||||||
if (!this.comment || !this.comments) return;
|
if (!this.comment || !this.comments) return;
|
||||||
// hide please fix button for robot comment that has human reply
|
// hide please fix button for robot comment that has human reply
|
||||||
this._hasHumanReply = this.comments.some(c => {
|
this._hasHumanReply = this.comments
|
||||||
return c.in_reply_to && c.in_reply_to === this.comment.id &&
|
.some(c => c.in_reply_to && c.in_reply_to === this.comment.id &&
|
||||||
!c.robot_id;
|
!c.robot_id);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -89,15 +89,13 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
|
|
||||||
suite('24 hours time format preference', () => {
|
suite('24 hours time format preference', () => {
|
||||||
setup(() => {
|
setup(() => stubRestAPI(
|
||||||
return stubRestAPI(
|
{time_format: 'HHMM_24', relative_date_in_change_table: false}
|
||||||
{time_format: 'HHMM_24', relative_date_in_change_table: false}
|
).then(() => {
|
||||||
).then(() => {
|
element = fixture('basic');
|
||||||
element = fixture('basic');
|
sandbox.stub(element, '_getUtcOffsetString').returns('');
|
||||||
sandbox.stub(element, '_getUtcOffsetString').returns('');
|
return element._loadPreferences();
|
||||||
return element._loadPreferences();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('invalid dates are quietly rejected', () => {
|
test('invalid dates are quietly rejected', () => {
|
||||||
assert.notOk((new Date('foo')).valueOf());
|
assert.notOk((new Date('foo')).valueOf());
|
||||||
@@ -138,16 +136,16 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
suite('12 hours time format preference', () => {
|
suite('12 hours time format preference', () => {
|
||||||
setup(() => {
|
setup(() =>
|
||||||
// relative_date_in_change_table is not set when false.
|
// relative_date_in_change_table is not set when false.
|
||||||
return stubRestAPI(
|
stubRestAPI(
|
||||||
{time_format: 'HHMM_12'}
|
{time_format: 'HHMM_12'}
|
||||||
).then(() => {
|
).then(() => {
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
sandbox.stub(element, '_getUtcOffsetString').returns('');
|
sandbox.stub(element, '_getUtcOffsetString').returns('');
|
||||||
return element._loadPreferences();
|
return element._loadPreferences();
|
||||||
});
|
})
|
||||||
});
|
);
|
||||||
|
|
||||||
test('Within 24 hours on same day', done => {
|
test('Within 24 hours on same day', done => {
|
||||||
testDates('2015-07-29 20:34:14.985000000',
|
testDates('2015-07-29 20:34:14.985000000',
|
||||||
@@ -159,15 +157,13 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
suite('relative date preference', () => {
|
suite('relative date preference', () => {
|
||||||
setup(() => {
|
setup(() => stubRestAPI(
|
||||||
return stubRestAPI(
|
{time_format: 'HHMM_12', relative_date_in_change_table: true}
|
||||||
{time_format: 'HHMM_12', relative_date_in_change_table: true}
|
).then(() => {
|
||||||
).then(() => {
|
element = fixture('basic');
|
||||||
element = fixture('basic');
|
sandbox.stub(element, '_getUtcOffsetString').returns('');
|
||||||
sandbox.stub(element, '_getUtcOffsetString').returns('');
|
return element._loadPreferences();
|
||||||
return element._loadPreferences();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Within 24 hours on same day', done => {
|
test('Within 24 hours on same day', done => {
|
||||||
testDates('2015-07-29 20:34:14.985000000',
|
testDates('2015-07-29 20:34:14.985000000',
|
||||||
@@ -187,14 +183,12 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
suite('logged in', () => {
|
suite('logged in', () => {
|
||||||
setup(() => {
|
setup(() => stubRestAPI(
|
||||||
return stubRestAPI(
|
{time_format: 'HHMM_12', relative_date_in_change_table: true}
|
||||||
{time_format: 'HHMM_12', relative_date_in_change_table: true}
|
).then(() => {
|
||||||
).then(() => {
|
element = fixture('basic');
|
||||||
element = fixture('basic');
|
return element._loadPreferences();
|
||||||
return element._loadPreferences();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Preferences are respected', () => {
|
test('Preferences are respected', () => {
|
||||||
assert.equal(element._timeFormat, 'h:mm A');
|
assert.equal(element._timeFormat, 'h:mm A');
|
||||||
@@ -203,12 +197,10 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
suite('logged out', () => {
|
suite('logged out', () => {
|
||||||
setup(() => {
|
setup(() => stubRestAPI(null).then(() => {
|
||||||
return stubRestAPI(null).then(() => {
|
element = fixture('basic');
|
||||||
element = fixture('basic');
|
return element._loadPreferences();
|
||||||
return element._loadPreferences();
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Default preferences are respected', () => {
|
test('Default preferences are respected', () => {
|
||||||
assert.equal(element._timeFormat, 'HH:mm');
|
assert.equal(element._timeFormat, 'HH:mm');
|
||||||
|
@@ -131,7 +131,7 @@ limitations under the License.
|
|||||||
test('saves scheme to preferences', () => {
|
test('saves scheme to preferences', () => {
|
||||||
element._loggedIn = true;
|
element._loggedIn = true;
|
||||||
const savePrefsStub = sandbox.stub(element.$.restAPI, 'savePreferences',
|
const savePrefsStub = sandbox.stub(element.$.restAPI, 'savePreferences',
|
||||||
() => { return Promise.resolve(); });
|
() => Promise.resolve());
|
||||||
|
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
|
@@ -120,9 +120,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!value) { return; }
|
if (!value) { return; }
|
||||||
const selectedObj = items.find(item => {
|
const selectedObj = items.find(item => item.value + '' === value + '');
|
||||||
return item.value + '' === value + '';
|
|
||||||
});
|
|
||||||
if (!selectedObj) { return; }
|
if (!selectedObj) { return; }
|
||||||
this.text = selectedObj.triggerText? selectedObj.triggerText :
|
this.text = selectedObj.triggerText? selectedObj.triggerText :
|
||||||
selectedObj.text;
|
selectedObj.text;
|
||||||
|
@@ -62,9 +62,8 @@
|
|||||||
|
|
||||||
GrChangeActionsInterface.prototype.removePrimaryActionKey = function(key) {
|
GrChangeActionsInterface.prototype.removePrimaryActionKey = function(key) {
|
||||||
ensureEl(this);
|
ensureEl(this);
|
||||||
this._el.primaryActionKeys = this._el.primaryActionKeys.filter(k => {
|
this._el.primaryActionKeys = this._el.primaryActionKeys
|
||||||
return k !== key;
|
.filter(k => k !== key);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GrChangeActionsInterface.prototype.hideQuickApproveAction = function() {
|
GrChangeActionsInterface.prototype.hideQuickApproveAction = function() {
|
||||||
|
@@ -304,11 +304,11 @@ limitations under the License.
|
|||||||
|
|
||||||
test('submitchange', () => {
|
test('submitchange', () => {
|
||||||
plugin.on(element.EventType.SUBMIT_CHANGE, throwErrFn);
|
plugin.on(element.EventType.SUBMIT_CHANGE, throwErrFn);
|
||||||
plugin.on(element.EventType.SUBMIT_CHANGE, () => { return true; });
|
plugin.on(element.EventType.SUBMIT_CHANGE, () => true);
|
||||||
assert.isTrue(element.canSubmitChange());
|
assert.isTrue(element.canSubmitChange());
|
||||||
assert.isTrue(errorStub.calledOnce);
|
assert.isTrue(errorStub.calledOnce);
|
||||||
plugin.on(element.EventType.SUBMIT_CHANGE, () => { return false; });
|
plugin.on(element.EventType.SUBMIT_CHANGE, () => false);
|
||||||
plugin.on(element.EventType.SUBMIT_CHANGE, () => { return true; });
|
plugin.on(element.EventType.SUBMIT_CHANGE, () => true);
|
||||||
assert.isFalse(element.canSubmitChange());
|
assert.isFalse(element.canSubmitChange());
|
||||||
assert.isTrue(errorStub.calledTwice);
|
assert.isTrue(errorStub.calledTwice);
|
||||||
});
|
});
|
||||||
@@ -326,9 +326,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('getLoggedIn', done => {
|
test('getLoggedIn', done => {
|
||||||
// fake fetch for authCheck
|
// fake fetch for authCheck
|
||||||
sandbox.stub(window, 'fetch', () => {
|
sandbox.stub(window, 'fetch', () => Promise.resolve({status: 204}));
|
||||||
return Promise.resolve({status: 204});
|
|
||||||
});
|
|
||||||
plugin.restApi().getLoggedIn()
|
plugin.restApi().getLoggedIn()
|
||||||
.then(loggedIn => {
|
.then(loggedIn => {
|
||||||
assert.isTrue(loggedIn);
|
assert.isTrue(loggedIn);
|
||||||
|
@@ -369,9 +369,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('relative path should honor getBaseUrl', () => {
|
test('relative path should honor getBaseUrl', () => {
|
||||||
const testUrl = '/test';
|
const testUrl = '/test';
|
||||||
sandbox.stub(Gerrit.BaseUrlBehavior, 'getBaseUrl', () => {
|
sandbox.stub(Gerrit.BaseUrlBehavior, 'getBaseUrl', () => testUrl);
|
||||||
return testUrl;
|
|
||||||
});
|
|
||||||
|
|
||||||
Gerrit._loadPlugins([
|
Gerrit._loadPlugins([
|
||||||
'foo/bar.js',
|
'foo/bar.js',
|
||||||
|
@@ -84,10 +84,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_repoResponseToSuggestions(res) {
|
_repoResponseToSuggestions(res) {
|
||||||
return res.map(repo => ({
|
return res.map(repo => {
|
||||||
name: repo.name,
|
return {
|
||||||
value: this.singleDecodeURL(repo.id),
|
name: repo.name,
|
||||||
}));
|
value: this.singleDecodeURL(repo.id),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_branchResponseToSuggestions(res) {
|
_branchResponseToSuggestions(res) {
|
||||||
|
@@ -126,17 +126,16 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not query when repo is unset', () => {
|
test('does not query when repo is unset', () => element
|
||||||
return element._getRepoBranchesSuggestions('')
|
._getRepoBranchesSuggestions('')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
assert.isFalse(element.$.restAPI.getRepoBranches.called);
|
assert.isFalse(element.$.restAPI.getRepoBranches.called);
|
||||||
element.repo = 'gerrit';
|
element.repo = 'gerrit';
|
||||||
return element._getRepoBranchesSuggestions('');
|
return element._getRepoBranchesSuggestions('');
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
assert.isTrue(element.$.restAPI.getRepoBranches.called);
|
assert.isTrue(element.$.restAPI.getRepoBranches.called);
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -801,7 +801,7 @@
|
|||||||
let queryString = '';
|
let queryString = '';
|
||||||
if (opt_params) {
|
if (opt_params) {
|
||||||
queryString = '?q=' + opt_params
|
queryString = '?q=' + opt_params
|
||||||
.map(param => { return encodeURIComponent(param); })
|
.map(param => encodeURIComponent(param))
|
||||||
.join('&q=');
|
.join('&q=');
|
||||||
}
|
}
|
||||||
return this._fetchSharedCacheURL({
|
return this._fetchSharedCacheURL({
|
||||||
@@ -823,9 +823,9 @@
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(capabilities => {
|
.then(
|
||||||
return capabilities && capabilities.administrateServer;
|
capabilities => capabilities && capabilities.administrateServer
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultPreferences() {
|
getDefaultPreferences() {
|
||||||
@@ -1644,14 +1644,12 @@
|
|||||||
this.awaitPendingDiffDrafts(),
|
this.awaitPendingDiffDrafts(),
|
||||||
this.getChangeActionURL(changeNum, patchNum, '/review'),
|
this.getChangeActionURL(changeNum, patchNum, '/review'),
|
||||||
];
|
];
|
||||||
return Promise.all(promises).then(([, url]) => {
|
return Promise.all(promises).then(([, url]) => this._restApiHelper.send({
|
||||||
return this._restApiHelper.send({
|
method: 'POST',
|
||||||
method: 'POST',
|
url,
|
||||||
url,
|
body: review,
|
||||||
body: review,
|
errFn: opt_errFn,
|
||||||
errFn: opt_errFn,
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getChangeEdit(changeNum, opt_download_commands) {
|
getChangeEdit(changeNum, opt_download_commands) {
|
||||||
@@ -2015,9 +2013,9 @@
|
|||||||
|
|
||||||
_setRanges(comments) {
|
_setRanges(comments) {
|
||||||
comments = comments || [];
|
comments = comments || [];
|
||||||
comments.sort((a, b) => {
|
comments.sort(
|
||||||
return util.parseDate(a.updated) - util.parseDate(b.updated);
|
(a, b) => util.parseDate(a.updated) - util.parseDate(b.updated)
|
||||||
});
|
);
|
||||||
for (const comment of comments) {
|
for (const comment of comments) {
|
||||||
this._setRange(comments, comment);
|
this._setRange(comments, comment);
|
||||||
}
|
}
|
||||||
@@ -2041,14 +2039,12 @@
|
|||||||
* @param {string|number=} opt_patchNum
|
* @param {string|number=} opt_patchNum
|
||||||
* @return {!Promise<!Object>} Diff comments response.
|
* @return {!Promise<!Object>} Diff comments response.
|
||||||
*/
|
*/
|
||||||
const fetchComments = opt_patchNum => {
|
const fetchComments = opt_patchNum => this._getChangeURLAndFetch({
|
||||||
return this._getChangeURLAndFetch({
|
changeNum,
|
||||||
changeNum,
|
endpoint,
|
||||||
endpoint,
|
patchNum: opt_patchNum,
|
||||||
patchNum: opt_patchNum,
|
reportEndpointAsIs: true,
|
||||||
reportEndpointAsIs: true,
|
});
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!opt_basePatchNum && !opt_patchNum && !opt_path) {
|
if (!opt_basePatchNum && !opt_patchNum && !opt_path) {
|
||||||
return fetchComments();
|
return fetchComments();
|
||||||
@@ -2089,12 +2085,10 @@
|
|||||||
promises.push(fetchPromise);
|
promises.push(fetchPromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(promises).then(() => {
|
return Promise.all(promises).then(() => Promise.resolve({
|
||||||
return Promise.resolve({
|
baseComments,
|
||||||
baseComments,
|
comments,
|
||||||
comments,
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2467,9 +2461,7 @@
|
|||||||
|
|
||||||
probePath(path) {
|
probePath(path) {
|
||||||
return fetch(new Request(path, {method: 'HEAD'}))
|
return fetch(new Request(path, {method: 'HEAD'}))
|
||||||
.then(response => {
|
.then(response => response.ok);
|
||||||
return response.ok;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2597,19 +2589,18 @@
|
|||||||
const anonymizedEndpoint = req.reportEndpointAsIs ?
|
const anonymizedEndpoint = req.reportEndpointAsIs ?
|
||||||
req.endpoint : req.anonymizedEndpoint;
|
req.endpoint : req.anonymizedEndpoint;
|
||||||
|
|
||||||
return this._changeBaseURL(req.changeNum, req.patchNum).then(url => {
|
return this._changeBaseURL(req.changeNum, req.patchNum)
|
||||||
return this._restApiHelper.send({
|
.then(url => this._restApiHelper.send({
|
||||||
method: req.method,
|
method: req.method,
|
||||||
url: url + req.endpoint,
|
url: url + req.endpoint,
|
||||||
body: req.body,
|
body: req.body,
|
||||||
errFn: req.errFn,
|
errFn: req.errFn,
|
||||||
contentType: req.contentType,
|
contentType: req.contentType,
|
||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
parseResponse: req.parseResponse,
|
parseResponse: req.parseResponse,
|
||||||
anonymizedUrl: anonymizedEndpoint ?
|
anonymizedUrl: anonymizedEndpoint ?
|
||||||
(anonymizedBaseUrl + anonymizedEndpoint) : undefined,
|
(anonymizedBaseUrl + anonymizedEndpoint) : undefined,
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2623,16 +2614,15 @@
|
|||||||
req.endpoint : req.anonymizedEndpoint;
|
req.endpoint : req.anonymizedEndpoint;
|
||||||
const anonymizedBaseUrl = req.patchNum ?
|
const anonymizedBaseUrl = req.patchNum ?
|
||||||
ANONYMIZED_REVISION_BASE_URL : ANONYMIZED_CHANGE_BASE_URL;
|
ANONYMIZED_REVISION_BASE_URL : ANONYMIZED_CHANGE_BASE_URL;
|
||||||
return this._changeBaseURL(req.changeNum, req.patchNum).then(url => {
|
return this._changeBaseURL(req.changeNum, req.patchNum)
|
||||||
return this._restApiHelper.fetchJSON({
|
.then(url => this._restApiHelper.fetchJSON({
|
||||||
url: url + req.endpoint,
|
url: url + req.endpoint,
|
||||||
errFn: req.errFn,
|
errFn: req.errFn,
|
||||||
params: req.params,
|
params: req.params,
|
||||||
fetchOptions: req.fetchOptions,
|
fetchOptions: req.fetchOptions,
|
||||||
anonymizedUrl: anonymizedEndpoint ?
|
anonymizedUrl: anonymizedEndpoint ?
|
||||||
(anonymizedBaseUrl + anonymizedEndpoint) : undefined,
|
(anonymizedBaseUrl + anonymizedEndpoint) : undefined,
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -66,22 +66,20 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('parent diff comments are properly grouped', done => {
|
test('parent diff comments are properly grouped', done => {
|
||||||
sandbox.stub(element._restApiHelper, 'fetchJSON', () => {
|
sandbox.stub(element._restApiHelper, 'fetchJSON', () => Promise.resolve({
|
||||||
return Promise.resolve({
|
'/COMMIT_MSG': [],
|
||||||
'/COMMIT_MSG': [],
|
'sieve.go': [
|
||||||
'sieve.go': [
|
{
|
||||||
{
|
updated: '2017-02-03 22:32:28.000000000',
|
||||||
updated: '2017-02-03 22:32:28.000000000',
|
message: 'this isn’t quite right',
|
||||||
message: 'this isn’t quite right',
|
},
|
||||||
},
|
{
|
||||||
{
|
side: 'PARENT',
|
||||||
side: 'PARENT',
|
message: 'how did this work in the first place?',
|
||||||
message: 'how did this work in the first place?',
|
updated: '2017-02-03 22:33:28.000000000',
|
||||||
updated: '2017-02-03 22:33:28.000000000',
|
},
|
||||||
},
|
],
|
||||||
],
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
element._getDiffComments('42', '', 'PARENT', 1, 'sieve.go').then(
|
element._getDiffComments('42', '', 'PARENT', 1, 'sieve.go').then(
|
||||||
obj => {
|
obj => {
|
||||||
assert.equal(obj.baseComments.length, 1);
|
assert.equal(obj.baseComments.length, 1);
|
||||||
@@ -430,15 +428,12 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
const preferenceSetup = function(testJSON, loggedIn, smallScreen) {
|
const preferenceSetup = function(testJSON, loggedIn, smallScreen) {
|
||||||
sandbox.stub(element, 'getLoggedIn', () => {
|
sandbox.stub(element, 'getLoggedIn', () => Promise.resolve(loggedIn));
|
||||||
return Promise.resolve(loggedIn);
|
sandbox.stub(element, '_isNarrowScreen', () => smallScreen);
|
||||||
});
|
sandbox.stub(
|
||||||
sandbox.stub(element, '_isNarrowScreen', () => {
|
element._restApiHelper,
|
||||||
return smallScreen;
|
'fetchCacheURL',
|
||||||
});
|
() => Promise.resolve(testJSON));
|
||||||
sandbox.stub(element._restApiHelper, 'fetchCacheURL', () => {
|
|
||||||
return Promise.resolve(testJSON);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
test('getPreferences returns correctly on small screens logged in',
|
test('getPreferences returns correctly on small screens logged in',
|
||||||
@@ -537,9 +532,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getEditPreferences returns correct defaults', done => {
|
test('getEditPreferences returns correct defaults', done => {
|
||||||
sandbox.stub(element, 'getLoggedIn', () => {
|
sandbox.stub(element, 'getLoggedIn', () => Promise.resolve(false));
|
||||||
return Promise.resolve(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
element.getEditPreferences().then(obj => {
|
element.getEditPreferences().then(obj => {
|
||||||
assert.equal(obj.auto_close_brackets, false);
|
assert.equal(obj.auto_close_brackets, false);
|
||||||
@@ -982,12 +975,12 @@ limitations under the License.
|
|||||||
toHexStub = sandbox.stub(element, 'listChangesOptionsToHex',
|
toHexStub = sandbox.stub(element, 'listChangesOptionsToHex',
|
||||||
options => 'deadbeef');
|
options => 'deadbeef');
|
||||||
sandbox.stub(element, '_getChangeDetail',
|
sandbox.stub(element, '_getChangeDetail',
|
||||||
async (changeNum, options) => ({changeNum, options}));
|
async (changeNum, options) => { return {changeNum, options}; });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('signed pushes disabled', async () => {
|
test('signed pushes disabled', async () => {
|
||||||
const {PUSH_CERTIFICATES} = element.ListChangesOption;
|
const {PUSH_CERTIFICATES} = element.ListChangesOption;
|
||||||
sandbox.stub(element, 'getConfig', async () => ({}));
|
sandbox.stub(element, 'getConfig', async () => { return {}; });
|
||||||
const {changeNum, options} = await element.getChangeDetail(123);
|
const {changeNum, options} = await element.getChangeDetail(123);
|
||||||
assert.strictEqual(123, changeNum);
|
assert.strictEqual(123, changeNum);
|
||||||
assert.strictEqual('deadbeef', options);
|
assert.strictEqual('deadbeef', options);
|
||||||
|
@@ -97,9 +97,7 @@ limitations under the License.
|
|||||||
|
|
||||||
test('cached results', done => {
|
test('cached results', done => {
|
||||||
let n = 0;
|
let n = 0;
|
||||||
sandbox.stub(helper, 'fetchJSON', () => {
|
sandbox.stub(helper, 'fetchJSON', () => Promise.resolve(++n));
|
||||||
return Promise.resolve(++n);
|
|
||||||
});
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
promises.push(helper.fetchCacheURL('/foo'));
|
promises.push(helper.fetchCacheURL('/foo'));
|
||||||
promises.push(helper.fetchCacheURL('/foo'));
|
promises.push(helper.fetchCacheURL('/foo'));
|
||||||
@@ -164,7 +162,7 @@ limitations under the License.
|
|||||||
cancel() { cancelCalled = true; },
|
cancel() { cancelCalled = true; },
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
const cancelCondition = () => { return true; };
|
const cancelCondition = () => true;
|
||||||
helper.fetchJSON({url: '/dummy/url', cancelCondition}).then(
|
helper.fetchJSON({url: '/dummy/url', cancelCondition}).then(
|
||||||
obj => {
|
obj => {
|
||||||
assert.isUndefined(obj);
|
assert.isUndefined(obj);
|
||||||
|
@@ -54,9 +54,10 @@
|
|||||||
* are used.
|
* are used.
|
||||||
*/
|
*/
|
||||||
GrReviewerUpdatesParser.prototype._filterRemovedMessages = function() {
|
GrReviewerUpdatesParser.prototype._filterRemovedMessages = function() {
|
||||||
this.result.messages = this.result.messages.filter(message => {
|
this.result.messages = this.result.messages
|
||||||
return message.tag !== 'autogenerated:gerrit:deleteReviewer';
|
.filter(
|
||||||
});
|
message => message.tag !== 'autogenerated:gerrit:deleteReviewer'
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -253,12 +253,10 @@ limitations under the License.
|
|||||||
|
|
||||||
test('_advanceUpdates', () => {
|
test('_advanceUpdates', () => {
|
||||||
const T0 = util.parseDate('2017-02-17 19:04:18.000000000').getTime();
|
const T0 = util.parseDate('2017-02-17 19:04:18.000000000').getTime();
|
||||||
const tplus = delta => {
|
const tplus = delta => new Date(T0 + delta)
|
||||||
return new Date(T0 + delta)
|
.toISOString()
|
||||||
.toISOString()
|
.replace('T', ' ')
|
||||||
.replace('T', ' ')
|
.replace('Z', '000000');
|
||||||
.replace('Z', '000000');
|
|
||||||
};
|
|
||||||
const change = {
|
const change = {
|
||||||
reviewer_updates: [{
|
reviewer_updates: [{
|
||||||
date: tplus(0),
|
date: tplus(0),
|
||||||
|
@@ -302,9 +302,9 @@
|
|||||||
this._formatSuggestions(ALL_SUGGESTIONS);
|
this._formatSuggestions(ALL_SUGGESTIONS);
|
||||||
this.disableEnterKeyForSelectingEmoji = true;
|
this.disableEnterKeyForSelectingEmoji = true;
|
||||||
} else {
|
} else {
|
||||||
const matches = ALL_SUGGESTIONS.filter(suggestion => {
|
const matches = ALL_SUGGESTIONS
|
||||||
return suggestion.match.includes(emojiText);
|
.filter(suggestion => suggestion.match.includes(emojiText))
|
||||||
}).slice(0, MAX_ITEMS_DROPDOWN);
|
.slice(0, MAX_ITEMS_DROPDOWN);
|
||||||
this._formatSuggestions(matches);
|
this._formatSuggestions(matches);
|
||||||
this.disableEnterKeyForSelectingEmoji = false;
|
this.disableEnterKeyForSelectingEmoji = false;
|
||||||
}
|
}
|
||||||
|
@@ -31,9 +31,7 @@
|
|||||||
.then(groups => {
|
.then(groups => {
|
||||||
if (!groups) { return []; }
|
if (!groups) { return []; }
|
||||||
const keys = Object.keys(groups);
|
const keys = Object.keys(groups);
|
||||||
return keys.map(key => {
|
return keys.map(key => Object.assign({}, groups[key], {name: key}));
|
||||||
return Object.assign({}, groups[key], {name: key});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -181,9 +181,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
sandbox.stub(GrDisplayNameUtils, '_accountEmail',
|
sandbox.stub(GrDisplayNameUtils, '_accountEmail',
|
||||||
() => {
|
() => '');
|
||||||
return '';
|
|
||||||
});
|
|
||||||
|
|
||||||
suggestion = provider.makeSuggestionItem(account3);
|
suggestion = provider.makeSuggestionItem(account3);
|
||||||
assert.deepEqual(suggestion, {
|
assert.deepEqual(suggestion, {
|
||||||
|
@@ -11,15 +11,11 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
|
|||||||
describe('example ', () => {
|
describe('example ', () => {
|
||||||
let driver;
|
let driver;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => setup().then(d => driver = d));
|
||||||
return setup().then(d => driver = d);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => cleanup());
|
||||||
return cleanup();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should update title', () => {
|
it('should update title', () => driver.wait(
|
||||||
return driver.wait(until.titleIs('status:open · Gerrit Code Review'), 5000);
|
until.titleIs('status:open · Gerrit Code Review'), 5000
|
||||||
});
|
));
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user