Replace $$ with shadowRoot.querySelector

`$$` is deprecated: https://polymer-library.polymer-project.org/2.0/docs/upgrade

One exception here is for gr-select as its not a shadow dom component,
so use `this.querySelector` instead

Change-Id: Ib3fd45298da1b44325d47932e53e6185d25c13de
This commit is contained in:
Tao Zhou
2020-03-11 10:25:16 +01:00
parent 0220e03503
commit b800561d0e
81 changed files with 1036 additions and 545 deletions

View File

@@ -536,7 +536,8 @@ limitations under the License.
test('removing an added permission', () => { test('removing an added permission', () => {
element.editing = true; element.editing = true;
assert.equal(element._permissions.length, 1); assert.equal(element._permissions.length, 1);
element.$$('gr-permission').fire('added-permission-removed'); element.shadowRoot
.querySelector('gr-permission').fire('added-permission-removed');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(element._permissions.length, 0); assert.equal(element._permissions.length, 0);
}); });

View File

@@ -163,7 +163,8 @@ limitations under the License.
suite('create new', () => { suite('create new', () => {
test('_handleCreateClicked called when create-click fired', () => { test('_handleCreateClicked called when create-click fired', () => {
sandbox.stub(element, '_handleCreateClicked'); sandbox.stub(element, '_handleCreateClicked');
element.$$('gr-list-view').fire('create-clicked'); element.shadowRoot
.querySelector('gr-list-view').fire('create-clicked');
assert.isTrue(element._handleCreateClicked.called); assert.isTrue(element._handleCreateClicked.called);
}); });

View File

@@ -95,8 +95,10 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(Polymer.dom(element.root).querySelectorAll( assert.equal(Polymer.dom(element.root).querySelectorAll(
'.selected').length, 1); '.selected').length, 1);
assert.ok(element.$$('gr-repo-list')); assert.ok(element.shadowRoot
assert.isNotOk(element.$$('gr-admin-create-repo')); .querySelector('gr-repo-list'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-admin-create-repo'));
}); });
test('_filteredLinks admin', done => { test('_filteredLinks admin', done => {
@@ -203,7 +205,8 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(Polymer.dom(element.root) assert.equal(Polymer.dom(element.root)
.querySelectorAll('.sectionTitle').length, 3); .querySelectorAll('.sectionTitle').length, 3);
assert.equal(element.$$('.breadcrumbText').innerText, 'Test Repo'); assert.equal(element.shadowRoot
.querySelector('.breadcrumbText').innerText, 'Test Repo');
assert.equal( assert.equal(
element.shadowRoot.querySelector('#pageSelect').items.length, element.shadowRoot.querySelector('#pageSelect').items.length,
6 6
@@ -297,11 +300,13 @@ limitations under the License.
element.params = {group: 1, view: Gerrit.Nav.View.GROUP}; element.params = {group: 1, view: Gerrit.Nav.View.GROUP};
element._groupName = 'oldName'; element._groupName = 'oldName';
flushAsynchronousOperations(); flushAsynchronousOperations();
element.$$('gr-group').fire('name-changed', {name: newName}); element.shadowRoot
.querySelector('gr-group').fire('name-changed', {name: newName});
}); });
test('dropdown displays if there is a subsection', () => { test('dropdown displays if there is a subsection', () => {
assert.isNotOk(element.$$('.mainHeader')); assert.isNotOk(element.shadowRoot
.querySelector('.mainHeader'));
element._subsectionLinks = [ element._subsectionLinks = [
{ {
text: 'Home', text: 'Home',
@@ -313,11 +318,13 @@ limitations under the License.
}, },
]; ];
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('.mainHeader')); assert.isOk(element.shadowRoot
.querySelector('.mainHeader'));
element._subsectionLinks = undefined; element._subsectionLinks = undefined;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal( assert.equal(
getComputedStyle(element.$$('.mainHeader')).display, getComputedStyle(element.shadowRoot
.querySelector('.mainHeader')).display,
'none'); 'none');
}); });
@@ -521,7 +528,8 @@ limitations under the License.
openCreateModal: false, openCreateModal: false,
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'Repositories'); assert.equal(selected.textContent.trim(), 'Repositories');
}); });
@@ -534,7 +542,8 @@ limitations under the License.
element._repoName = 'foo'; element._repoName = 'foo';
return element.reload().then(() => { return element.reload().then(() => {
flushAsynchronousOperations(); flushAsynchronousOperations();
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'foo'); assert.equal(selected.textContent.trim(), 'foo');
}); });
@@ -549,7 +558,8 @@ limitations under the License.
element._repoName = 'foo'; element._repoName = 'foo';
return element.reload().then(() => { return element.reload().then(() => {
flushAsynchronousOperations(); flushAsynchronousOperations();
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'Access'); assert.equal(selected.textContent.trim(), 'Access');
}); });
@@ -564,7 +574,8 @@ limitations under the License.
element._repoName = 'foo'; element._repoName = 'foo';
return element.reload().then(() => { return element.reload().then(() => {
flushAsynchronousOperations(); flushAsynchronousOperations();
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'Dashboards'); assert.equal(selected.textContent.trim(), 'Dashboards');
}); });
@@ -597,7 +608,8 @@ limitations under the License.
openCreateModal: false, openCreateModal: false,
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'Groups'); assert.equal(selected.textContent.trim(), 'Groups');
}); });
@@ -614,7 +626,8 @@ limitations under the License.
.querySelectorAll('.subsectionItem'); .querySelectorAll('.subsectionItem');
assert.equal(subsectionItems.length, 2); assert.equal(subsectionItems.length, 2);
assert.isTrue(element._groupIsInternal); assert.isTrue(element._groupIsInternal);
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'foo'); assert.equal(selected.textContent.trim(), 'foo');
}); });
@@ -638,7 +651,8 @@ limitations under the License.
.querySelectorAll('.subsectionItem'); .querySelectorAll('.subsectionItem');
assert.equal(subsectionItems.length, 0); assert.equal(subsectionItems.length, 0);
assert.isFalse(element._groupIsInternal); assert.isFalse(element._groupIsInternal);
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'foo'); assert.equal(selected.textContent.trim(), 'foo');
}); });
@@ -653,7 +667,8 @@ limitations under the License.
element._groupName = 'foo'; element._groupName = 'foo';
return element.reload().then(() => { return element.reload().then(() => {
flushAsynchronousOperations(); flushAsynchronousOperations();
const selected = element.$$('gr-page-nav .selected'); const selected = element.shadowRoot
.querySelector('gr-page-nav .selected');
assert.isOk(selected); assert.isOk(selected);
assert.equal(selected.textContent.trim(), 'Members'); assert.equal(selected.textContent.trim(), 'Members');
}); });

View File

@@ -54,7 +54,8 @@ limitations under the License.
const confirmHandler = sandbox.stub(); const confirmHandler = sandbox.stub();
element.addEventListener('confirm', confirmHandler); element.addEventListener('confirm', confirmHandler);
sandbox.spy(element, '_handleConfirmTap'); sandbox.spy(element, '_handleConfirmTap');
element.$$('gr-dialog').fire('confirm'); element.shadowRoot
.querySelector('gr-dialog').fire('confirm');
assert.isTrue(confirmHandler.called); assert.isTrue(confirmHandler.called);
assert.isTrue(confirmHandler.calledOnce); assert.isTrue(confirmHandler.calledOnce);
assert.isTrue(element._handleConfirmTap.called); assert.isTrue(element._handleConfirmTap.called);
@@ -65,7 +66,8 @@ limitations under the License.
const cancelHandler = sandbox.stub(); const cancelHandler = sandbox.stub();
element.addEventListener('cancel', cancelHandler); element.addEventListener('cancel', cancelHandler);
sandbox.spy(element, '_handleCancelTap'); sandbox.spy(element, '_handleCancelTap');
element.$$('gr-dialog').fire('cancel'); element.shadowRoot
.querySelector('gr-dialog').fire('cancel');
assert.isTrue(cancelHandler.called); assert.isTrue(cancelHandler.called);
assert.isTrue(cancelHandler.calledOnce); assert.isTrue(cancelHandler.calledOnce);
assert.isTrue(element._handleCancelTap.called); assert.isTrue(element._handleCancelTap.called);

View File

@@ -345,7 +345,8 @@ limitations under the License.
element.groups = {}; element.groups = {};
element.$.groupAutocomplete.text = 'new group name'; element.$.groupAutocomplete.text = 'new group name';
assert.equal(element._rules.length, 2); assert.equal(element._rules.length, 2);
element.$$('gr-rule-editor').fire('added-rule-removed'); element.shadowRoot
.querySelector('gr-rule-editor').fire('added-rule-removed');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(element._rules.length, 1); assert.equal(element._rules.length, 1);
}); });

View File

@@ -158,15 +158,17 @@ limitations under the License.
assert.deepEqual(element._sections, assert.deepEqual(element._sections,
element.toSortedArray(accessRes.local)); element.toSortedArray(accessRes.local));
assert.deepEqual(element._labels, repoRes.labels); assert.deepEqual(element._labels, repoRes.labels);
assert.equal(getComputedStyle(element.$$('.weblinks')).display, assert.equal(getComputedStyle(element.shadowRoot
'block'); .querySelector('.weblinks')).display,
'block');
return element._repoChanged('Another New Repo'); return element._repoChanged('Another New Repo');
}) })
.then(() => { .then(() => {
assert.deepEqual(element._sections, assert.deepEqual(element._sections,
element.toSortedArray(accessRes2.local)); element.toSortedArray(accessRes2.local));
assert.equal(getComputedStyle(element.$$('.weblinks')).display, assert.equal(getComputedStyle(element.shadowRoot
'none'); .querySelector('.weblinks')).display,
'none');
done(); done();
}); });
}); });
@@ -332,7 +334,8 @@ limitations under the License.
test('removing an added section', () => { test('removing an added section', () => {
element.editing = true; element.editing = true;
assert.equal(element._sections.length, 1); assert.equal(element._sections.length, 1);
element.$$('gr-access-section').fire('added-section-removed'); element.shadowRoot
.querySelector('gr-access-section').fire('added-section-removed');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(element._sections.length, 0); assert.equal(element._sections.length, 0);
}); });
@@ -581,7 +584,9 @@ limitations under the License.
remove: {}, remove: {},
}; };
element.$$('gr-access-section').$$('gr-permission') element.shadowRoot
.querySelector('gr-access-section').shadowRoot
.querySelector('gr-permission')
._handleAddRuleItem( ._handleAddRuleItem(
{detail: {value: {id: 'Maintainers'}}}); {detail: {value: {id: 'Maintainers'}}});
@@ -651,7 +656,8 @@ limitations under the License.
}, },
remove: {}, remove: {},
}; };
element.$$('gr-access-section')._handleAddPermission(); element.shadowRoot
.querySelector('gr-access-section')._handleAddPermission();
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.deepEqual(element._computeAddAndRemove(), expectedInput); assert.deepEqual(element._computeAddAndRemove(), expectedInput);
@@ -678,7 +684,8 @@ limitations under the License.
remove: {}, remove: {},
}; };
const newPermission = const newPermission =
Polymer.dom(element.$$('gr-access-section').root).querySelectorAll( Polymer.dom(element.shadowRoot
.querySelector('gr-access-section').root).querySelectorAll(
'gr-permission')[2]; 'gr-permission')[2];
newPermission._handleAddRuleItem( newPermission._handleAddRuleItem(
{detail: {value: {id: 'Maintainers'}}}); {detail: {value: {id: 'Maintainers'}}});
@@ -799,8 +806,9 @@ limitations under the License.
remove: {}, remove: {},
}; };
newSection.$$('gr-permission')._handleAddRuleItem( newSection.shadowRoot
{detail: {value: {id: 'Maintainers'}}}); .querySelector('gr-permission')._handleAddRuleItem(
{detail: {value: {id: 'Maintainers'}}});
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.deepEqual(element._computeAddAndRemove(), expectedInput); assert.deepEqual(element._computeAddAndRemove(), expectedInput);
@@ -911,7 +919,8 @@ limitations under the License.
// Add a rule to the existing permission; // Add a rule to the existing permission;
const readPermission = const readPermission =
Polymer.dom(element.$$('gr-access-section').root).querySelectorAll( Polymer.dom(element.shadowRoot
.querySelector('gr-access-section').root).querySelectorAll(
'gr-permission')[1]; 'gr-permission')[1];
readPermission._handleAddRuleItem( readPermission._handleAddRuleItem(
{detail: {value: {id: 'Maintainers'}}}); {detail: {value: {id: 'Maintainers'}}});
@@ -988,8 +997,9 @@ limitations under the License.
.querySelectorAll('gr-access-section')[1]; .querySelectorAll('gr-access-section')[1];
newSection._handleAddPermission(); newSection._handleAddPermission();
flushAsynchronousOperations(); flushAsynchronousOperations();
newSection.$$('gr-permission')._handleAddRuleItem( newSection.shadowRoot
{detail: {value: {id: 'Maintainers'}}}); .querySelector('gr-permission')._handleAddRuleItem(
{detail: {value: {id: 'Maintainers'}}});
// Modify a the reference from the default value. // Modify a the reference from the default value.
element._local['refs/for/*'].updatedId = 'refs/for/new'; element._local['refs/for/*'].updatedId = 'refs/for/new';
@@ -1061,8 +1071,9 @@ limitations under the License.
.querySelectorAll('gr-access-section')[2]; .querySelectorAll('gr-access-section')[2];
newSection._handleAddPermission(); newSection._handleAddPermission();
flushAsynchronousOperations(); flushAsynchronousOperations();
newSection.$$('gr-permission')._handleAddRuleItem( newSection.shadowRoot
{detail: {value: {id: 'Maintainers'}}}); .querySelector('gr-permission')._handleAddRuleItem(
{detail: {value: {id: 'Maintainers'}}});
// Modify a the reference from the default value. // Modify a the reference from the default value.
element._local['refs/for/**'].updatedId = 'refs/for/new2'; element._local['refs/for/**'].updatedId = 'refs/for/new2';
expectedInput = { expectedInput = {

View File

@@ -94,7 +94,8 @@ limitations under the License.
test('successful creation of change', () => { test('successful creation of change', () => {
const change = {_number: '1'}; const change = {_number: '1'};
createChangeStub.returns(Promise.resolve(change)); createChangeStub.returns(Promise.resolve(change));
MockInteractions.tap(element.$.editRepoConfig.$$('gr-button')); MockInteractions.tap(element.$.editRepoConfig.shadowRoot
.querySelector('gr-button'));
return handleSpy.lastCall.returnValue.then(() => { return handleSpy.lastCall.returnValue.then(() => {
flushAsynchronousOperations(); flushAsynchronousOperations();
@@ -109,7 +110,8 @@ limitations under the License.
test('unsuccessful creation of change', () => { test('unsuccessful creation of change', () => {
createChangeStub.returns(Promise.resolve(null)); createChangeStub.returns(Promise.resolve(null));
MockInteractions.tap(element.$.editRepoConfig.$$('gr-button')); MockInteractions.tap(element.$.editRepoConfig.shadowRoot
.querySelector('gr-button'));
return handleSpy.lastCall.returnValue.then(() => { return handleSpy.lastCall.returnValue.then(() => {
flushAsynchronousOperations(); flushAsynchronousOperations();

View File

@@ -511,7 +511,8 @@ limitations under the License.
suite('create new', () => { suite('create new', () => {
test('_handleCreateClicked called when create-click fired', () => { test('_handleCreateClicked called when create-click fired', () => {
sandbox.stub(element, '_handleCreateClicked'); sandbox.stub(element, '_handleCreateClicked');
element.$$('gr-list-view').fire('create-clicked'); element.shadowRoot
.querySelector('gr-list-view').fire('create-clicked');
assert.isTrue(element._handleCreateClicked.called); assert.isTrue(element._handleCreateClicked.called);
}); });

View File

@@ -174,7 +174,8 @@ limitations under the License.
suite('create new', () => { suite('create new', () => {
test('_handleCreateClicked called when create-click fired', () => { test('_handleCreateClicked called when create-click fired', () => {
sandbox.stub(element, '_handleCreateClicked'); sandbox.stub(element, '_handleCreateClicked');
element.$$('gr-list-view').fire('create-clicked'); element.shadowRoot
.querySelector('gr-list-view').fire('create-clicked');
assert.isTrue(element._handleCreateClicked.called); assert.isTrue(element._handleCreateClicked.called);
}); });

View File

@@ -100,7 +100,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const editor = element.$$('gr-plugin-config-array-editor'); const editor = element.shadowRoot
.querySelector('gr-plugin-config-array-editor');
assert.ok(editor); assert.ok(editor);
element._handleArrayChange({detail: 'test'}); element._handleArrayChange({detail: 'test'});
assert.isTrue(changeStub.called); assert.isTrue(changeStub.called);
@@ -114,7 +115,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const toggle = element.$$('paper-toggle-button'); const toggle = element.shadowRoot
.querySelector('paper-toggle-button');
assert.ok(toggle); assert.ok(toggle);
toggle.click(); toggle.click();
flushAsynchronousOperations(); flushAsynchronousOperations();
@@ -132,7 +134,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const input = element.$$('input'); const input = element.shadowRoot
.querySelector('input');
assert.ok(input); assert.ok(input);
input.value = 'newTest'; input.value = 'newTest';
input.dispatchEvent(new Event('input')); input.dispatchEvent(new Event('input'));
@@ -152,7 +155,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const select = element.$$('select'); const select = element.shadowRoot
.querySelector('select');
assert.ok(select); assert.ok(select);
select.value = 'newTest'; select.value = 'newTest';
select.dispatchEvent(new Event( select.dispatchEvent(new Event(

View File

@@ -139,9 +139,11 @@ limitations under the License.
for (const column of element.columnNames) { for (const column of element.columnNames) {
const elementClass = '.' + column.toLowerCase(); const elementClass = '.' + column.toLowerCase();
assert.isOk(element.$$(elementClass), assert.isOk(element.shadowRoot
`Expect ${elementClass} element to be found`); .querySelector(elementClass),
assert.isFalse(element.$$(elementClass).hidden); `Expect ${elementClass} element to be found`);
assert.isFalse(element.shadowRoot
.querySelector(elementClass).hidden);
} }
}); });
@@ -161,9 +163,11 @@ limitations under the License.
for (const column of element.columnNames) { for (const column of element.columnNames) {
const elementClass = '.' + column.toLowerCase(); const elementClass = '.' + column.toLowerCase();
if (column === 'Repo') { if (column === 'Repo') {
assert.isTrue(element.$$(elementClass).hidden); assert.isTrue(element.shadowRoot
.querySelector(elementClass).hidden);
} else { } else {
assert.isFalse(element.$$(elementClass).hidden); assert.isFalse(element.shadowRoot
.querySelector(elementClass).hidden);
} }
} }
}); });
@@ -175,14 +179,17 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
const elementClass = '.bad'; const elementClass = '.bad';
assert.isNotOk(element.$$(elementClass)); assert.isNotOk(element.shadowRoot
.querySelector(elementClass));
}); });
test('assignee only displayed if there is one', () => { test('assignee only displayed if there is one', () => {
element.change = {}; element.change = {};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('.assignee gr-account-link')); assert.isNotOk(element.shadowRoot
assert.equal(element.$$('.assignee').textContent.trim(), '--'); .querySelector('.assignee gr-account-link'));
assert.equal(element.shadowRoot
.querySelector('.assignee').textContent.trim(), '--');
element.change = { element.change = {
assignee: { assignee: {
name: 'test', name: 'test',
@@ -190,7 +197,8 @@ limitations under the License.
}, },
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('.assignee gr-account-link')); assert.isOk(element.shadowRoot
.querySelector('.assignee gr-account-link'));
}); });
test('TShirt sizing tooltip', () => { test('TShirt sizing tooltip', () => {

View File

@@ -378,7 +378,8 @@
} }
const changeEl = changeEls[index]; const changeEl = changeEls[index];
changeEl.$$('gr-change-star').toggleStar(); changeEl.shadowRoot
.querySelector('gr-change-star').toggleStar();
} }
_changeForIndex(index) { _changeForIndex(index) {

View File

@@ -347,7 +347,8 @@ limitations under the License.
test('all columns visible', () => { test('all columns visible', () => {
for (const column of element.columnNames) { for (const column of element.columnNames) {
const elementClass = '.' + element._lowerCase(column); const elementClass = '.' + element._lowerCase(column);
assert.isFalse(element.$$(elementClass).hidden); assert.isFalse(element.shadowRoot
.querySelector(elementClass).hidden);
} }
}); });
}); });
@@ -381,7 +382,8 @@ limitations under the License.
test('all columns visible', () => { test('all columns visible', () => {
for (const column of element.changeTableColumns) { for (const column of element.changeTableColumns) {
const elementClass = '.' + element._lowerCase(column); const elementClass = '.' + element._lowerCase(column);
assert.isFalse(element.$$(elementClass).hidden); assert.isFalse(element.shadowRoot
.querySelector(elementClass).hidden);
} }
}); });
}); });
@@ -415,9 +417,11 @@ limitations under the License.
for (const column of element.changeTableColumns) { for (const column of element.changeTableColumns) {
const elementClass = '.' + column.toLowerCase(); const elementClass = '.' + column.toLowerCase();
if (column === 'Repo') { if (column === 'Repo') {
assert.isTrue(element.$$(elementClass).hidden); assert.isTrue(element.shadowRoot
.querySelector(elementClass).hidden);
} else { } else {
assert.isFalse(element.$$(elementClass).hidden); assert.isFalse(element.shadowRoot
.querySelector(elementClass).hidden);
} }
} }
}); });
@@ -443,7 +447,8 @@ limitations under the License.
test('bad column does not exist', () => { test('bad column does not exist', () => {
const elementClass = '.bad'; const elementClass = '.bad';
assert.isNotOk(element.$$(elementClass)); assert.isNotOk(element.shadowRoot
.querySelector(elementClass));
}); });
}); });

View File

@@ -48,7 +48,8 @@ limitations under the License.
test('Create change tap', done => { test('Create change tap', done => {
element.addEventListener('create-tap', () => done()); element.addEventListener('create-tap', () => done());
MockInteractions.tap(element.$$('gr-button')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button'));
}); });
}); });
</script> </script>

View File

@@ -103,11 +103,13 @@ limitations under the License.
test('_showDraftsBanner', () => { test('_showDraftsBanner', () => {
element._showDraftsBanner = false; element._showDraftsBanner = false;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(isHidden(element.$$('.banner'))); assert.isTrue(isHidden(element.shadowRoot
.querySelector('.banner')));
element._showDraftsBanner = true; element._showDraftsBanner = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(isHidden(element.$$('.banner'))); assert.isFalse(isHidden(element.shadowRoot
.querySelector('.banner')));
}); });
test('delete tap opens dialog', () => { test('delete tap opens dialog', () => {
@@ -115,7 +117,8 @@ limitations under the License.
element._showDraftsBanner = true; element._showDraftsBanner = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('.banner .delete')); MockInteractions.tap(element.shadowRoot
.querySelector('.banner .delete'));
assert.isTrue(element._handleOpenDeleteDialog.called); assert.isTrue(element._handleOpenDeleteDialog.called);
}); });
@@ -330,12 +333,14 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(element.$.emptyOutgoing.textContent.trim(), 'No changes'); assert.equal(element.$.emptyOutgoing.textContent.trim(), 'No changes');
assert.isNotOk(element.$$('gr-create-change-help')); assert.isNotOk(element.shadowRoot
.querySelector('gr-create-change-help'));
element._showNewUserHelp = true; element._showNewUserHelp = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.notEqual(element.$.emptyOutgoing.textContent.trim(), 'No changes'); assert.notEqual(element.$.emptyOutgoing.textContent.trim(), 'No changes');
assert.isOk(element.$$('gr-create-change-help')); assert.isOk(element.shadowRoot
.querySelector('gr-create-change-help'));
}); });
test('_computeUserHeaderClass', () => { test('_computeUserHeaderClass', () => {

View File

@@ -1254,7 +1254,8 @@
} }
// Otherwise it's a top-level action. // Otherwise it's a top-level action.
const buttonEl = this.$$(`[data-action-key="${buttonKey}"]`); const buttonEl = this.shadowRoot
.querySelector(`[data-action-key="${buttonKey}"]`);
buttonEl.setAttribute('loading', true); buttonEl.setAttribute('loading', true);
buttonEl.disabled = true; buttonEl.disabled = true;
return function() { return function() {

View File

@@ -201,7 +201,8 @@ limitations under the License.
test('hide revision action', done => { test('hide revision action', done => {
flush(() => { flush(() => {
const buttonEl = element.$$('[data-action-key="submit"]'); const buttonEl = element.shadowRoot
.querySelector('[data-action-key="submit"]');
assert.isOk(buttonEl); assert.isOk(buttonEl);
assert.throws(element.setActionHidden.bind(element, 'invalid type')); assert.throws(element.setActionHidden.bind(element, 'invalid type'));
element.setActionHidden(element.ActionType.REVISION, element.setActionHidden(element.ActionType.REVISION,
@@ -211,13 +212,15 @@ limitations under the License.
element.RevisionActions.SUBMIT, true); element.RevisionActions.SUBMIT, true);
assert.lengthOf(element._hiddenActions, 1); assert.lengthOf(element._hiddenActions, 1);
flush(() => { flush(() => {
const buttonEl = element.$$('[data-action-key="submit"]'); const buttonEl = element.shadowRoot
.querySelector('[data-action-key="submit"]');
assert.isNotOk(buttonEl); assert.isNotOk(buttonEl);
element.setActionHidden(element.ActionType.REVISION, element.setActionHidden(element.ActionType.REVISION,
element.RevisionActions.SUBMIT, false); element.RevisionActions.SUBMIT, false);
flush(() => { flush(() => {
const buttonEl = element.$$('[data-action-key="submit"]'); const buttonEl = element.shadowRoot
.querySelector('[data-action-key="submit"]');
assert.isOk(buttonEl); assert.isOk(buttonEl);
assert.isFalse(buttonEl.hasAttribute('hidden')); assert.isFalse(buttonEl.hasAttribute('hidden'));
done(); done();
@@ -294,7 +297,8 @@ limitations under the License.
}; };
element.latestPatchNum = '2'; element.latestPatchNum = '2';
const submitButton = element.$$('gr-button[data-action-key="submit"]'); const submitButton = element.shadowRoot
.querySelector('gr-button[data-action-key="submit"]');
assert.ok(submitButton); assert.ok(submitButton);
MockInteractions.tap(submitButton); MockInteractions.tap(submitButton);
@@ -318,7 +322,8 @@ limitations under the License.
element.latestPatchNum = '2'; element.latestPatchNum = '2';
const submitIcon = const submitIcon =
element.$$('gr-button[data-action-key="submit"] iron-icon'); element.shadowRoot
.querySelector('gr-button[data-action-key="submit"] iron-icon');
assert.ok(submitIcon); assert.ok(submitIcon);
MockInteractions.tap(submitIcon); MockInteractions.tap(submitIcon);
}); });
@@ -344,7 +349,8 @@ limitations under the License.
() => 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.shadowRoot
.querySelector('gr-button[data-action-key="submit"]');
assert.ok(submitButton); assert.ok(submitButton);
MockInteractions.tap(submitButton); MockInteractions.tap(submitButton);
assert.equal(fireActionStub.callCount, 0); assert.equal(fireActionStub.callCount, 0);
@@ -386,7 +392,8 @@ limitations under the License.
'fetchRecentChanges').returns(Promise.resolve([])); 'fetchRecentChanges').returns(Promise.resolve([]));
element._hasKnownChainState = true; element._hasKnownChainState = true;
flush(() => { flush(() => {
const rebaseButton = element.$$('gr-button[data-action-key="rebase"]'); const rebaseButton = element.shadowRoot
.querySelector('gr-button[data-action-key="rebase"]');
MockInteractions.tap(rebaseButton); MockInteractions.tap(rebaseButton);
const rebaseAction = { const rebaseAction = {
__key: 'rebase', __key: 'rebase',
@@ -410,7 +417,8 @@ limitations under the License.
const fetchChangesStub = sandbox.stub(element.$.confirmRebase, const fetchChangesStub = sandbox.stub(element.$.confirmRebase,
'fetchRecentChanges').returns(Promise.resolve([])); 'fetchRecentChanges').returns(Promise.resolve([]));
element._hasKnownChainState = true; element._hasKnownChainState = true;
const rebaseButton = element.$$('gr-button[data-action-key="rebase"]'); const rebaseButton = element.shadowRoot
.querySelector('gr-button[data-action-key="rebase"]');
MockInteractions.tap(rebaseButton); MockInteractions.tap(rebaseButton);
assert.isTrue(fetchChangesStub.calledOnce); assert.isTrue(fetchChangesStub.calledOnce);
@@ -425,7 +433,8 @@ limitations under the License.
test('two dialogs are not shown at the same time', done => { test('two dialogs are not shown at the same time', done => {
element._hasKnownChainState = true; element._hasKnownChainState = true;
flush(() => { flush(() => {
const rebaseButton = element.$$('gr-button[data-action-key="rebase"]'); const rebaseButton = element.shadowRoot
.querySelector('gr-button[data-action-key="rebase"]');
assert.ok(rebaseButton); assert.ok(rebaseButton);
MockInteractions.tap(rebaseButton); MockInteractions.tap(rebaseButton);
flushAsynchronousOperations(); flushAsynchronousOperations();
@@ -474,11 +483,16 @@ limitations under the License.
element.set('disableEdit', true); element.set('disableEdit', true);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="publishEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="rebaseEdit"]')); .querySelector('gr-button[data-action-key="publishEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="deleteEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); .querySelector('gr-button[data-action-key="rebaseEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="stopEdit"]')); assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="deleteEdit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="stopEdit"]'));
}); });
test('shows confirm dialog for delete edit', () => { test('shows confirm dialog for delete edit', () => {
@@ -491,7 +505,8 @@ limitations under the License.
MockInteractions.tap( MockInteractions.tap(
element.shadowRoot element.shadowRoot
.querySelector('#confirmDeleteEditDialog') .querySelector('#confirmDeleteEditDialog')
.$$('gr-button[primary]')); .shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(fireActionStub.lastCall.args[0], '/edit'); assert.equal(fireActionStub.lastCall.args[0], '/edit');
@@ -503,10 +518,14 @@ limitations under the License.
element.change = {status: 'MERGED'}; element.change = {status: 'MERGED'};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="publishEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="rebaseEdit"]')); .querySelector('gr-button[data-action-key="publishEdit"]'));
assert.isOk(element.$$('gr-button[data-action-key="deleteEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); .querySelector('gr-button[data-action-key="rebaseEdit"]'));
assert.isOk(element.shadowRoot
.querySelector('gr-button[data-action-key="deleteEdit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
}); });
test('edit patchset is loaded, needs rebase', () => { test('edit patchset is loaded, needs rebase', () => {
@@ -516,11 +535,16 @@ limitations under the License.
element.editBasedOnCurrentPatchSet = false; element.editBasedOnCurrentPatchSet = false;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="publishEdit"]')); assert.isNotOk(element.shadowRoot
assert.isOk(element.$$('gr-button[data-action-key="rebaseEdit"]')); .querySelector('gr-button[data-action-key="publishEdit"]'));
assert.isOk(element.$$('gr-button[data-action-key="deleteEdit"]')); assert.isOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); .querySelector('gr-button[data-action-key="rebaseEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="stopEdit"]')); assert.isOk(element.shadowRoot
.querySelector('gr-button[data-action-key="deleteEdit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="stopEdit"]'));
}); });
test('edit patchset is loaded, does not need rebase', () => { test('edit patchset is loaded, does not need rebase', () => {
@@ -530,11 +554,16 @@ limitations under the License.
element.editBasedOnCurrentPatchSet = true; element.editBasedOnCurrentPatchSet = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('gr-button[data-action-key="publishEdit"]')); assert.isOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="rebaseEdit"]')); .querySelector('gr-button[data-action-key="publishEdit"]'));
assert.isOk(element.$$('gr-button[data-action-key="deleteEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); .querySelector('gr-button[data-action-key="rebaseEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="stopEdit"]')); assert.isOk(element.shadowRoot
.querySelector('gr-button[data-action-key="deleteEdit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="stopEdit"]'));
}); });
test('edit mode is loaded, no edit patchset', () => { test('edit mode is loaded, no edit patchset', () => {
@@ -543,11 +572,16 @@ limitations under the License.
element.change = {status: 'NEW'}; element.change = {status: 'NEW'};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="publishEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="rebaseEdit"]')); .querySelector('gr-button[data-action-key="publishEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="deleteEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); .querySelector('gr-button[data-action-key="rebaseEdit"]'));
assert.isOk(element.$$('gr-button[data-action-key="stopEdit"]')); assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="deleteEdit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
assert.isOk(element.shadowRoot
.querySelector('gr-button[data-action-key="stopEdit"]'));
}); });
test('normal patch set', () => { test('normal patch set', () => {
@@ -556,11 +590,16 @@ limitations under the License.
element.change = {status: 'NEW'}; element.change = {status: 'NEW'};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="publishEdit"]')); assert.isNotOk(element.shadowRoot
assert.isNotOk(element.$$('gr-button[data-action-key="rebaseEdit"]')); .querySelector('gr-button[data-action-key="publishEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="deleteEdit"]')); assert.isNotOk(element.shadowRoot
assert.isOk(element.$$('gr-button[data-action-key="edit"]')); .querySelector('gr-button[data-action-key="rebaseEdit"]'));
assert.isNotOk(element.$$('gr-button[data-action-key="stopEdit"]')); assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="deleteEdit"]'));
assert.isOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="stopEdit"]'));
}); });
test('edit action', done => { test('edit action', done => {
@@ -569,17 +608,21 @@ limitations under the License.
element.change = {status: 'NEW'}; element.change = {status: 'NEW'};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); assert.isNotOk(element.shadowRoot
assert.isOk(element.$$('gr-button[data-action-key="stopEdit"]')); .querySelector('gr-button[data-action-key="edit"]'));
assert.isOk(element.shadowRoot
.querySelector('gr-button[data-action-key="stopEdit"]'));
element.change = {status: 'MERGED'}; element.change = {status: 'MERGED'};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]')); assert.isNotOk(element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]'));
element.change = {status: 'NEW'}; element.change = {status: 'NEW'};
element.set('editMode', false); element.set('editMode', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
const editButton = element.$$('gr-button[data-action-key="edit"]'); const editButton = element.shadowRoot
.querySelector('gr-button[data-action-key="edit"]');
assert.isOk(editButton); assert.isOk(editButton);
MockInteractions.tap(editButton); MockInteractions.tap(editButton);
}); });
@@ -708,12 +751,14 @@ limitations under the License.
assert.equal(e.detail.node.getAttribute('data-action-key'), key); assert.equal(e.detail.node.getAttribute('data-action-key'), key);
element.removeActionButton(key); element.removeActionButton(key);
flush(() => { flush(() => {
assert.notOk(element.$$('[data-action-key="' + key + '"]')); assert.notOk(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
done(); done();
}); });
}); });
flush(() => { flush(() => {
MockInteractions.tap(element.$$('[data-action-key="' + key + '"]')); MockInteractions.tap(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
}); });
}); });
@@ -723,7 +768,8 @@ limitations under the License.
const cleanup = element._setLoadingOnButtonWithKey(type, key); const cleanup = element._setLoadingOnButtonWithKey(type, key);
assert.equal(element._actionLoadingMessage, 'Rebasing...'); assert.equal(element._actionLoadingMessage, 'Rebasing...');
const button = element.$$('[data-action-key="' + key + '"]'); const button = element.shadowRoot
.querySelector('[data-action-key="' + key + '"]');
assert.isTrue(button.hasAttribute('loading')); assert.isTrue(button.hasAttribute('loading'));
assert.isTrue(button.disabled); assert.isTrue(button.disabled);
@@ -773,7 +819,8 @@ limitations under the License.
element.$.confirmAbandonDialog.message = newAbandonMsg; element.$.confirmAbandonDialog.message = newAbandonMsg;
flush(() => { flush(() => {
const abandonButton = const abandonButton =
element.$$('gr-button[data-action-key="abandon"]'); element.shadowRoot
.querySelector('gr-button[data-action-key="abandon"]');
MockInteractions.tap(abandonButton); MockInteractions.tap(abandonButton);
assert.equal(element.$.confirmAbandonDialog.message, newAbandonMsg); assert.equal(element.$.confirmAbandonDialog.message, newAbandonMsg);
@@ -784,7 +831,8 @@ limitations under the License.
test('abandon change with no message', done => { test('abandon change with no message', done => {
flush(() => { flush(() => {
const abandonButton = const abandonButton =
element.$$('gr-button[data-action-key="abandon"]'); element.shadowRoot
.querySelector('gr-button[data-action-key="abandon"]');
MockInteractions.tap(abandonButton); MockInteractions.tap(abandonButton);
assert.isUndefined(element.$.confirmAbandonDialog.message); assert.isUndefined(element.$.confirmAbandonDialog.message);
@@ -795,7 +843,8 @@ limitations under the License.
test('works', () => { test('works', () => {
element.$.confirmAbandonDialog.message = 'original message'; element.$.confirmAbandonDialog.message = 'original message';
const restoreButton = const restoreButton =
element.$$('gr-button[data-action-key="abandon"]'); element.shadowRoot
.querySelector('gr-button[data-action-key="abandon"]');
MockInteractions.tap(restoreButton); MockInteractions.tap(restoreButton);
element.$.confirmAbandonDialog.message = 'foo message'; element.$.confirmAbandonDialog.message = 'foo message';
@@ -1059,7 +1108,8 @@ limitations under the License.
test('make sure the mark private change button is not outside of the ' + test('make sure the mark private change button is not outside of the ' +
'overflow menu', done => { 'overflow menu', done => {
flush(() => { flush(() => {
assert.isNotOk(element.$$('[data-action-key="private"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="private"]'));
done(); done();
}); });
}); });
@@ -1067,12 +1117,15 @@ limitations under the License.
test('private change', done => { test('private change', done => {
flush(() => { flush(() => {
assert.isOk( assert.isOk(
element.$.moreActions.$$('span[data-id="private-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="private-change"]'));
element.setActionOverflow('change', 'private', false); element.setActionOverflow('change', 'private', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="private"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="private"]'));
assert.isNotOk( assert.isNotOk(
element.$.moreActions.$$('span[data-id="private-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="private-change"]'));
done(); done();
}); });
}); });
@@ -1105,7 +1158,8 @@ limitations under the License.
test('make sure the unmark private change button is not outside of the ' + test('make sure the unmark private change button is not outside of the ' +
'overflow menu', done => { 'overflow menu', done => {
flush(() => { flush(() => {
assert.isNotOk(element.$$('[data-action-key="private.delete"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="private.delete"]'));
done(); done();
}); });
}); });
@@ -1113,13 +1167,16 @@ limitations under the License.
test('unmark the private change', done => { test('unmark the private change', done => {
flush(() => { flush(() => {
assert.isOk( assert.isOk(
element.$.moreActions.$$('span[data-id="private.delete-change"]') element.$.moreActions.shadowRoot
.querySelector('span[data-id="private.delete-change"]')
); );
element.setActionOverflow('change', 'private.delete', false); element.setActionOverflow('change', 'private.delete', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="private.delete"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="private.delete"]'));
assert.isNotOk( assert.isNotOk(
element.$.moreActions.$$('span[data-id="private.delete-change"]') element.$.moreActions.shadowRoot
.querySelector('span[data-id="private.delete-change"]')
); );
done(); done();
}); });
@@ -1158,7 +1215,8 @@ limitations under the License.
MockInteractions.tap( MockInteractions.tap(
element.shadowRoot element.shadowRoot
.querySelector('#confirmDeleteDialog') .querySelector('#confirmDeleteDialog')
.$$('gr-button[primary]')); .shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(fireActionStub.calledWith('/', deleteAction, false)); assert.isTrue(fireActionStub.calledWith('/', deleteAction, false));
}); });
@@ -1168,7 +1226,8 @@ limitations under the License.
MockInteractions.tap( MockInteractions.tap(
element.shadowRoot element.shadowRoot
.querySelector('#confirmDeleteDialog') .querySelector('#confirmDeleteDialog')
.$$('gr-button:not([primary])')); .shadowRoot
.querySelector('gr-button:not([primary])'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(element.shadowRoot assert.isTrue(element.shadowRoot
.querySelector('#confirmDeleteDialog').hidden); .querySelector('#confirmDeleteDialog').hidden);
@@ -1202,16 +1261,20 @@ limitations under the License.
test('make sure the ignore button is not outside of the overflow menu', test('make sure the ignore button is not outside of the overflow menu',
() => { () => {
assert.isNotOk(element.$$('[data-action-key="ignore"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="ignore"]'));
}); });
test('ignoring change', () => { test('ignoring change', () => {
assert.isOk(element.$.moreActions.$$('span[data-id="ignore-change"]')); assert.isOk(element.$.moreActions.shadowRoot
.querySelector('span[data-id="ignore-change"]'));
element.setActionOverflow('change', 'ignore', false); element.setActionOverflow('change', 'ignore', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="ignore"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="ignore"]'));
assert.isNotOk( assert.isNotOk(
element.$.moreActions.$$('span[data-id="ignore-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="ignore-change"]'));
}); });
}); });
@@ -1240,17 +1303,21 @@ limitations under the License.
}); });
test('unignore button is not outside of the overflow menu', () => { test('unignore button is not outside of the overflow menu', () => {
assert.isNotOk(element.$$('[data-action-key="unignore"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="unignore"]'));
}); });
test('unignoring change', () => { test('unignoring change', () => {
assert.isOk( assert.isOk(
element.$.moreActions.$$('span[data-id="unignore-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="unignore-change"]'));
element.setActionOverflow('change', 'unignore', false); element.setActionOverflow('change', 'unignore', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="unignore"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="unignore"]'));
assert.isNotOk( assert.isNotOk(
element.$.moreActions.$$('span[data-id="unignore-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="unignore-change"]'));
}); });
}); });
@@ -1280,17 +1347,21 @@ limitations under the License.
test('make sure the reviewed button is not outside of the overflow menu', test('make sure the reviewed button is not outside of the overflow menu',
() => { () => {
assert.isNotOk(element.$$('[data-action-key="reviewed"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="reviewed"]'));
}); });
test('reviewing change', () => { test('reviewing change', () => {
assert.isOk( assert.isOk(
element.$.moreActions.$$('span[data-id="reviewed-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="reviewed-change"]'));
element.setActionOverflow('change', 'reviewed', false); element.setActionOverflow('change', 'reviewed', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="reviewed"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="reviewed"]'));
assert.isNotOk( assert.isNotOk(
element.$.moreActions.$$('span[data-id="reviewed-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="reviewed-change"]'));
}); });
}); });
@@ -1319,17 +1390,21 @@ limitations under the License.
}); });
test('unreviewed button not outside of the overflow menu', () => { test('unreviewed button not outside of the overflow menu', () => {
assert.isNotOk(element.$$('[data-action-key="unreviewed"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="unreviewed"]'));
}); });
test('unreviewed change', () => { test('unreviewed change', () => {
assert.isOk( assert.isOk(
element.$.moreActions.$$('span[data-id="unreviewed-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="unreviewed-change"]'));
element.setActionOverflow('change', 'unreviewed', false); element.setActionOverflow('change', 'unreviewed', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="unreviewed"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="unreviewed"]'));
assert.isNotOk( assert.isNotOk(
element.$.moreActions.$$('span[data-id="unreviewed-change"]')); element.$.moreActions.shadowRoot
.querySelector('span[data-id="unreviewed-change"]'));
}); });
}); });
@@ -1358,13 +1433,15 @@ limitations under the License.
test('added when can approve', () => { test('added when can approve', () => {
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNotNull(approveButton); assert.isNotNull(approveButton);
}); });
test('hide quick approve', () => { test('hide quick approve', () => {
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNotNull(approveButton); assert.isNotNull(approveButton);
assert.isFalse(element._hideQuickApproveAction); assert.isFalse(element._hideQuickApproveAction);
@@ -1372,7 +1449,8 @@ limitations under the License.
element.hideQuickApproveAction(); element.hideQuickApproveAction();
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButtonUpdated = const approveButtonUpdated =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNull(approveButtonUpdated); assert.isNull(approveButtonUpdated);
assert.isTrue(element._hideQuickApproveAction); assert.isTrue(element._hideQuickApproveAction);
}); });
@@ -1398,7 +1476,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNull(approveButton); assert.isNull(approveButton);
}); });
@@ -1414,14 +1493,16 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNull(approveButton); assert.isNull(approveButton);
}); });
test('approves when tapped', () => { test('approves when tapped', () => {
const fireActionStub = sandbox.stub(element, '_fireAction'); const fireActionStub = sandbox.stub(element, '_fireAction');
MockInteractions.tap( MockInteractions.tap(
element.$$('gr-button[data-action-key=\'review\']')); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(fireActionStub.called); assert.isTrue(fireActionStub.called);
assert.isTrue(fireActionStub.calledWith('/review')); assert.isTrue(fireActionStub.calledWith('/review'));
@@ -1443,7 +1524,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNull(approveButton); assert.isNull(approveButton);
}); });
@@ -1466,7 +1548,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.equal(approveButton.getAttribute('data-label'), 'foo+1'); assert.equal(approveButton.getAttribute('data-label'), 'foo+1');
}); });
@@ -1489,7 +1572,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.isNull(approveButton); assert.isNull(approveButton);
}); });
@@ -1512,7 +1596,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const approveButton = const approveButton =
element.$$('gr-button[data-action-key=\'review\']'); element.shadowRoot
.querySelector('gr-button[data-action-key=\'review\']');
assert.equal(approveButton.getAttribute('data-label'), 'bar+2'); assert.equal(approveButton.getAttribute('data-label'), 'bar+2');
}); });
}); });
@@ -1545,21 +1630,25 @@ limitations under the License.
suite('setActionOverflow', () => { suite('setActionOverflow', () => {
test('move action from overflow', () => { test('move action from overflow', () => {
assert.isNotOk(element.$$('[data-action-key="cherrypick"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="cherrypick"]'));
assert.strictEqual( assert.strictEqual(
element.$.moreActions.items[0].id, 'cherrypick-revision'); element.$.moreActions.items[0].id, 'cherrypick-revision');
element.setActionOverflow('revision', 'cherrypick', false); element.setActionOverflow('revision', 'cherrypick', false);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('[data-action-key="cherrypick"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="cherrypick"]'));
assert.notEqual( assert.notEqual(
element.$.moreActions.items[0].id, 'cherrypick-revision'); element.$.moreActions.items[0].id, 'cherrypick-revision');
}); });
test('move action to overflow', () => { test('move action to overflow', () => {
assert.isOk(element.$$('[data-action-key="submit"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="submit"]'));
element.setActionOverflow('revision', 'submit', true); element.setActionOverflow('revision', 'submit', true);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotOk(element.$$('[data-action-key="submit"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="submit"]'));
assert.strictEqual( assert.strictEqual(
element.$.moreActions.items[3].id, 'submit-revision'); element.$.moreActions.items[3].id, 'submit-revision');
}); });

View File

@@ -491,7 +491,7 @@
if (this._topicReadOnly || this.change.topic) { return; } if (this._topicReadOnly || this.change.topic) { return; }
// Cannot use `this.$.ID` syntax because the element exists inside of a // Cannot use `this.$.ID` syntax because the element exists inside of a
// dom-if. // dom-if.
this.$$('.topicEditableLabel').open(); this.shadowRoot.querySelector('.topicEditableLabel').open();
} }
_getReviewerSuggestionsProvider(change) { _getReviewerSuggestionsProvider(change) {

View File

@@ -109,7 +109,8 @@ limitations under the License.
test('show strategy for open change', () => { test('show strategy for open change', () => {
element.change = {status: 'NEW', submit_type: 'CHERRY_PICK', labels: {}}; element.change = {status: 'NEW', submit_type: 'CHERRY_PICK', labels: {}};
flushAsynchronousOperations(); flushAsynchronousOperations();
const strategy = element.$$('.strategy'); const strategy = element.shadowRoot
.querySelector('.strategy');
assert.ok(strategy); assert.ok(strategy);
assert.isFalse(strategy.hasAttribute('hidden')); assert.isFalse(strategy.hasAttribute('hidden'));
assert.equal(strategy.children[1].innerHTML, 'Cherry Pick'); assert.equal(strategy.children[1].innerHTML, 'Cherry Pick');
@@ -118,7 +119,8 @@ limitations under the License.
test('hide strategy for closed change', () => { test('hide strategy for closed change', () => {
element.change = {status: 'MERGED', labels: {}}; element.change = {status: 'MERGED', labels: {}};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(element.$$('.strategy').hasAttribute('hidden')); assert.isTrue(element.shadowRoot
.querySelector('.strategy').hasAttribute('hidden'));
}); });
test('weblinks use Gerrit.Nav interface', () => { test('weblinks use Gerrit.Nav interface', () => {
@@ -520,7 +522,9 @@ limitations under the License.
element.account = {}; element.account = {};
element.change = change; element.change = change;
flushAsynchronousOperations(); flushAsynchronousOperations();
const button = element.$$('gr-linked-chip').$$('gr-button'); const button = element.shadowRoot
.querySelector('gr-linked-chip').shadowRoot
.querySelector('gr-button');
assert.isTrue(button.hasAttribute('hidden')); assert.isTrue(button.hasAttribute('hidden'));
}); });
@@ -529,7 +533,9 @@ limitations under the License.
change.actions.topic.enabled = true; change.actions.topic.enabled = true;
element.change = change; element.change = change;
flushAsynchronousOperations(); flushAsynchronousOperations();
const button = element.$$('gr-linked-chip').$$('gr-button'); const button = element.shadowRoot
.querySelector('gr-linked-chip').shadowRoot
.querySelector('gr-button');
assert.isFalse(button.hasAttribute('hidden')); assert.isFalse(button.hasAttribute('hidden'));
}); });
}); });
@@ -574,7 +580,9 @@ limitations under the License.
element.account = {}; element.account = {};
element.change = change; element.change = change;
flushAsynchronousOperations(); flushAsynchronousOperations();
const button = element.$$('gr-linked-chip').$$('gr-button'); const button = element.shadowRoot
.querySelector('gr-linked-chip').shadowRoot
.querySelector('gr-button');
assert.isTrue(button.hasAttribute('hidden')); assert.isTrue(button.hasAttribute('hidden'));
}); });
@@ -584,7 +592,9 @@ limitations under the License.
change.actions.hashtags.enabled = true; change.actions.hashtags.enabled = true;
element.change = change; element.change = change;
flushAsynchronousOperations(); flushAsynchronousOperations();
const button = element.$$('gr-linked-chip').$$('gr-button'); const button = element.shadowRoot
.querySelector('gr-linked-chip').shadowRoot
.querySelector('gr-button');
assert.isFalse(button.hasAttribute('hidden')); assert.isFalse(button.hasAttribute('hidden'));
}); });
}); });
@@ -683,7 +693,8 @@ limitations under the License.
test('topic removal', () => { test('topic removal', () => {
sandbox.stub(element.$.restAPI, 'setChangeTopic').returns( sandbox.stub(element.$.restAPI, 'setChangeTopic').returns(
Promise.resolve()); Promise.resolve());
const chip = element.$$('gr-linked-chip'); const chip = element.shadowRoot
.querySelector('gr-linked-chip');
const remove = chip.$.remove; const remove = chip.$.remove;
const topicChangedSpy = sandbox.spy(); const topicChangedSpy = sandbox.spy();
element.addEventListener('topic-changed', topicChangedSpy); element.addEventListener('topic-changed', topicChangedSpy);
@@ -720,7 +731,8 @@ limitations under the License.
element.change = {actions: {topic: {enabled: true}}}; element.change = {actions: {topic: {enabled: true}}};
flushAsynchronousOperations(); flushAsynchronousOperations();
const label = element.$$('.topicEditableLabel'); const label = element.shadowRoot
.querySelector('.topicEditableLabel');
assert.ok(label); assert.ok(label);
sandbox.stub(label, 'open'); sandbox.stub(label, 'open');
element.editTopic(); element.editTopic();

View File

@@ -101,12 +101,15 @@ limitations under the License.
element._optionalLabels = [{label: 'test'}]; element._optionalLabels = [{label: 'test'}];
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.ok(element.$$('section.optional')); assert.ok(element.shadowRoot
MockInteractions.tap(element.$$('.showHide')); .querySelector('section.optional'));
MockInteractions.tap(element.shadowRoot
.querySelector('.showHide'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(element._showOptionalLabels); assert.isFalse(element._showOptionalLabels);
assert.isTrue(isHidden(element.$$('section.optional'))); assert.isTrue(isHidden(element.shadowRoot
.querySelector('section.optional')));
}); });
test('properly converts satisfied labels', () => { test('properly converts satisfied labels', () => {
@@ -121,9 +124,12 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.ok(element.$$('.approved')); assert.ok(element.shadowRoot
assert.ok(element.$$('.name')); .querySelector('.approved'));
assert.equal(element.$$('.name').text, 'Verified'); assert.ok(element.shadowRoot
.querySelector('.name'));
assert.equal(element.shadowRoot
.querySelector('.name').text, 'Verified');
}); });
test('properly converts unsatisfied labels', () => { test('properly converts unsatisfied labels', () => {
@@ -137,7 +143,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const name = element.$$('.name'); const name = element.shadowRoot
.querySelector('.name');
assert.ok(name); assert.ok(name);
assert.isFalse(name.hasAttribute('hidden')); assert.isFalse(name.hasAttribute('hidden'));
assert.equal(name.text, 'Verified'); assert.equal(name.text, 'Verified');
@@ -152,7 +159,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const changeIsWip = element.$$('.title'); const changeIsWip = element.shadowRoot
.querySelector('.title');
assert.ok(changeIsWip); assert.ok(changeIsWip);
}); });
@@ -167,7 +175,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const requirement = element.$$('.requirement'); const requirement = element.shadowRoot
.querySelector('.requirement');
assert.ok(requirement); assert.ok(requirement);
assert.isFalse(requirement.hasAttribute('hidden')); assert.isFalse(requirement.hasAttribute('hidden'));
assert.ok(requirement.querySelector('.approved')); assert.ok(requirement.querySelector('.approved'));
@@ -186,7 +195,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const requirement = element.$$('.requirement'); const requirement = element.shadowRoot
.querySelector('.requirement');
assert.ok(requirement); assert.ok(requirement);
assert.ok(requirement.querySelector('.approved')); assert.ok(requirement.querySelector('.approved'));
}); });
@@ -202,7 +212,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const requirement = element.$$('.requirement'); const requirement = element.shadowRoot
.querySelector('.requirement');
assert.ok(requirement); assert.ok(requirement);
assert.strictEqual(requirement.querySelector('.approved'), null); assert.strictEqual(requirement.querySelector('.approved'), null);
}); });
@@ -218,7 +229,8 @@ limitations under the License.
}; };
flushAsynchronousOperations(); flushAsynchronousOperations();
const requirement = element.$$('.requirement'); const requirement = element.shadowRoot
.querySelector('.requirement');
assert.ok(requirement); assert.ok(requirement);
assert.strictEqual(requirement.querySelector('.approved'), null); assert.strictEqual(requirement.querySelector('.approved'), null);
}); });

View File

@@ -471,11 +471,11 @@
} }
get messagesList() { get messagesList() {
return this.$$('gr-messages-list'); return this.shadowRoot.querySelector('gr-messages-list');
} }
get threadList() { get threadList() {
return this.$$('gr-thread-list'); return this.shadowRoot.querySelector('gr-thread-list');
} }
/** /**

View File

@@ -732,7 +732,8 @@ limitations under the License.
assert.equal(element._currentView, CommentTabs.CHANGE_LOG); assert.equal(element._currentView, CommentTabs.CHANGE_LOG);
// Switch to comment thread tab // Switch to comment thread tab
MockInteractions.tap(element.$$('paper-tab.commentThreads')); MockInteractions.tap(element.shadowRoot
.querySelector('paper-tab.commentThreads'));
assert.equal(element.$.commentTabs.selected, assert.equal(element.$.commentTabs.selected,
CommentTabs.COMMENT_THREADS); CommentTabs.COMMENT_THREADS);
assert.equal(element._currentView, CommentTabs.COMMENT_THREADS); assert.equal(element._currentView, CommentTabs.COMMENT_THREADS);
@@ -2191,7 +2192,8 @@ limitations under the License.
const stub = sandbox.stub(element, '_handleToggleStar'); const stub = sandbox.stub(element, '_handleToggleStar');
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$.changeStar.$$('button')); MockInteractions.tap(element.$.changeStar.shadowRoot
.querySelector('button'));
assert.isTrue(stub.called); assert.isTrue(stub.called);
}); });

View File

@@ -55,7 +55,8 @@ limitations under the License.
element.addEventListener('confirm', confirmHandler); element.addEventListener('confirm', confirmHandler);
sandbox.spy(element, '_handleConfirmTap'); sandbox.spy(element, '_handleConfirmTap');
sandbox.spy(element, '_confirm'); sandbox.spy(element, '_confirm');
element.$$('gr-dialog').fire('confirm'); element.shadowRoot
.querySelector('gr-dialog').fire('confirm');
assert.isTrue(confirmHandler.called); assert.isTrue(confirmHandler.called);
assert.isTrue(confirmHandler.calledOnce); assert.isTrue(confirmHandler.calledOnce);
assert.isTrue(element._handleConfirmTap.called); assert.isTrue(element._handleConfirmTap.called);
@@ -68,7 +69,8 @@ limitations under the License.
const cancelHandler = sandbox.stub(); const cancelHandler = sandbox.stub();
element.addEventListener('cancel', cancelHandler); element.addEventListener('cancel', cancelHandler);
sandbox.spy(element, '_handleCancelTap'); sandbox.spy(element, '_handleCancelTap');
element.$$('gr-dialog').fire('cancel'); element.shadowRoot
.querySelector('gr-dialog').fire('cancel');
assert.isTrue(cancelHandler.called); assert.isTrue(cancelHandler.called);
assert.isTrue(cancelHandler.calledOnce); assert.isTrue(cancelHandler.calledOnce);
assert.isTrue(element._handleCancelTap.called); assert.isTrue(element._handleCancelTap.called);

View File

@@ -52,7 +52,8 @@ limitations under the License.
const confirmHandler = sandbox.stub(); const confirmHandler = sandbox.stub();
element.addEventListener('confirm', confirmHandler); element.addEventListener('confirm', confirmHandler);
sandbox.spy(element, '_handleConfirmTap'); sandbox.spy(element, '_handleConfirmTap');
element.$$('gr-dialog').fire('confirm'); element.shadowRoot
.querySelector('gr-dialog').fire('confirm');
assert.isTrue(confirmHandler.called); assert.isTrue(confirmHandler.called);
assert.isTrue(confirmHandler.calledOnce); assert.isTrue(confirmHandler.calledOnce);
assert.isTrue(element._handleConfirmTap.called); assert.isTrue(element._handleConfirmTap.called);
@@ -63,7 +64,8 @@ limitations under the License.
const cancelHandler = sandbox.stub(); const cancelHandler = sandbox.stub();
element.addEventListener('cancel', cancelHandler); element.addEventListener('cancel', cancelHandler);
sandbox.spy(element, '_handleCancelTap'); sandbox.spy(element, '_handleCancelTap');
element.$$('gr-dialog').fire('cancel'); element.shadowRoot
.querySelector('gr-dialog').fire('cancel');
assert.isTrue(cancelHandler.called); assert.isTrue(cancelHandler.called);
assert.isTrue(cancelHandler.calledOnce); assert.isTrue(cancelHandler.calledOnce);
assert.isTrue(element._handleCancelTap.called); assert.isTrue(element._handleCancelTap.called);

View File

@@ -56,10 +56,12 @@ limitations under the License.
element.action = {label: 'my-label'}; element.action = {label: 'my-label'};
element.change = {subject: 'my-subject'}; element.change = {subject: 'my-subject'};
flushAsynchronousOperations(); flushAsynchronousOperations();
const header = element.$$('.header'); const header = element.shadowRoot
.querySelector('.header');
assert.equal(header.textContent.trim(), 'my-label'); assert.equal(header.textContent.trim(), 'my-label');
const message = element.$$('.main p'); const message = element.shadowRoot
.querySelector('.main p');
assert.notEqual(message.textContent.length, 0); assert.notEqual(message.textContent.length, 0);
assert.notEqual(message.textContent.indexOf('my-subject'), -1); assert.notEqual(message.textContent.indexOf('my-subject'), -1);
}); });

View File

@@ -191,7 +191,8 @@ limitations under the License.
element.addEventListener('close', () => { element.addEventListener('close', () => {
done(); done();
}); });
MockInteractions.tap(element.$$('.closeButtonContainer gr-button')); MockInteractions.tap(element.shadowRoot
.querySelector('.closeButtonContainer gr-button'));
}); });
}); });

View File

@@ -204,7 +204,8 @@ limitations under the License.
}); });
test('fileViewActions are properly hidden', () => { test('fileViewActions are properly hidden', () => {
const actions = element.$$('.fileViewActions'); const actions = element.shadowRoot
.querySelector('.fileViewActions');
assert.equal(getComputedStyle(actions).display, 'none'); assert.equal(getComputedStyle(actions).display, 'none');
element.filesExpanded = GrFileListConstants.FilesExpandedState.SOME; element.filesExpanded = GrFileListConstants.FilesExpandedState.SOME;
flushAsynchronousOperations(); flushAsynchronousOperations();
@@ -286,12 +287,14 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(isVisible(element.$.diffPrefsContainer)); assert.isFalse(isVisible(element.$.diffPrefsContainer));
assert.isFalse(isVisible(element.$$('.descriptionContainer'))); assert.isFalse(isVisible(element.shadowRoot
.querySelector('.descriptionContainer')));
element.editMode = false; element.editMode = false;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(isVisible(element.$$('.descriptionContainer'))); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.descriptionContainer')));
assert.isTrue(isVisible(element.$.diffPrefsContainer)); assert.isTrue(isVisible(element.$.diffPrefsContainer));
}); });

View File

@@ -139,7 +139,8 @@ limitations under the License.
assert.equal( assert.equal(
Polymer.dom(element.root).querySelectorAll('.file-row').length, Polymer.dom(element.root).querySelectorAll('.file-row').length,
element.numFilesShown); element.numFilesShown);
const controlRow = element.$$('.controlRow'); const controlRow = element.shadowRoot
.querySelector('.controlRow');
assert.isFalse(controlRow.classList.contains('invisible')); assert.isFalse(controlRow.classList.contains('invisible'));
assert.equal(element.$.incrementButton.textContent.trim(), assert.equal(element.$.incrementButton.textContent.trim(),
'Show 300 more'); 'Show 300 more');
@@ -929,7 +930,8 @@ limitations under the License.
const toggleExpandSpy = sandbox.spy(element, '_togglePathExpanded'); const toggleExpandSpy = sandbox.spy(element, '_togglePathExpanded');
// Tap the edit controls. Should be ignored by _handleFileListClick. // Tap the edit controls. Should be ignored by _handleFileListClick.
MockInteractions.tap(element.$$('.editFileControls')); MockInteractions.tap(element.shadowRoot
.querySelector('.editFileControls'));
assert.isTrue(clickSpy.calledOnce); assert.isTrue(clickSpy.calledOnce);
assert.isFalse(toggleExpandSpy.called); assert.isFalse(toggleExpandSpy.called);
}); });
@@ -1010,7 +1012,8 @@ limitations under the License.
element._filesByPath = { element._filesByPath = {
'/COMMIT_MSG': {}, '/COMMIT_MSG': {},
}; };
assert.isNotOk(element.$$('.expanded')); assert.isNotOk(element.shadowRoot
.querySelector('.expanded'));
}); });
test('tapping row ignores links', () => { test('tapping row ignores links', () => {
@@ -1034,9 +1037,11 @@ limitations under the License.
MockInteractions.tap(commitMsgFile); MockInteractions.tap(commitMsgFile);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert(togglePathSpy.notCalled, 'file is opened as diff view'); assert(togglePathSpy.notCalled, 'file is opened as diff view');
assert.isNotOk(element.$$('.expanded')); assert.isNotOk(element.shadowRoot
assert.notEqual(getComputedStyle(element.$$('.show-hide')).display, .querySelector('.expanded'));
'none'); assert.notEqual(getComputedStyle(element.shadowRoot
.querySelector('.show-hide')).display,
'none');
}); });
test('_togglePathExpanded', () => { test('_togglePathExpanded', () => {
@@ -1045,19 +1050,22 @@ limitations under the License.
const renderSpy = sandbox.spy(element, '_renderInOrder'); const renderSpy = sandbox.spy(element, '_renderInOrder');
const collapseStub = sandbox.stub(element, '_clearCollapsedDiffs'); const collapseStub = sandbox.stub(element, '_clearCollapsedDiffs');
assert.equal(element.$$('iron-icon').icon, 'gr-icons:expand-more'); assert.equal(element.shadowRoot
.querySelector('iron-icon').icon, 'gr-icons:expand-more');
assert.equal(element._expandedFilePaths.length, 0); assert.equal(element._expandedFilePaths.length, 0);
element._togglePathExpanded(path); element._togglePathExpanded(path);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(collapseStub.lastCall.args[0].length, 0); assert.equal(collapseStub.lastCall.args[0].length, 0);
assert.equal(element.$$('iron-icon').icon, 'gr-icons:expand-less'); assert.equal(element.shadowRoot
.querySelector('iron-icon').icon, 'gr-icons:expand-less');
assert.equal(renderSpy.callCount, 1); assert.equal(renderSpy.callCount, 1);
assert.include(element._expandedFilePaths, path); assert.include(element._expandedFilePaths, path);
element._togglePathExpanded(path); element._togglePathExpanded(path);
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(element.$$('iron-icon').icon, 'gr-icons:expand-more'); assert.equal(element.shadowRoot
.querySelector('iron-icon').icon, 'gr-icons:expand-more');
assert.equal(renderSpy.callCount, 1); assert.equal(renderSpy.callCount, 1);
assert.notInclude(element._expandedFilePaths, path); assert.notInclude(element._expandedFilePaths, path);
assert.equal(collapseStub.lastCall.args[0].length, 1); assert.equal(collapseStub.lastCall.args[0].length, 1);

View File

@@ -111,8 +111,9 @@ limitations under the License.
const labelsChangedHandler = sandbox.stub(); const labelsChangedHandler = sandbox.stub();
element.addEventListener('labels-changed', labelsChangedHandler); element.addEventListener('labels-changed', labelsChangedHandler);
assert.ok(element.$.labelSelector); assert.ok(element.$.labelSelector);
MockInteractions.tap(element.$$( MockInteractions.tap(element.shadowRoot
'gr-button[data-value="-1"]')); .querySelector(
'gr-button[data-value="-1"]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.strictEqual(element.selectedValue, '-1'); assert.strictEqual(element.selectedValue, '-1');
assert.strictEqual(element.selectedItem assert.strictEqual(element.selectedItem
@@ -168,8 +169,9 @@ limitations under the License.
}); });
test('do not display tooltips on touch devices', () => { test('do not display tooltips on touch devices', () => {
const verifiedBtn = element.$$( const verifiedBtn = element.shadowRoot
'iron-selector > gr-button[data-value="-1"]'); .querySelector(
'iron-selector > gr-button[data-value="-1"]');
// On touch devices, tooltips should not be shown. // On touch devices, tooltips should not be shown.
verifiedBtn._isTouchDevice = true; verifiedBtn._isTouchDevice = true;

View File

@@ -47,7 +47,8 @@
for (const label in this.permittedLabels) { for (const label in this.permittedLabels) {
if (!this.permittedLabels.hasOwnProperty(label)) { continue; } if (!this.permittedLabels.hasOwnProperty(label)) { continue; }
const selectorEl = this.$$(`gr-label-score-row[name="${label}"]`); const selectorEl = this.shadowRoot
.querySelector(`gr-label-score-row[name="${label}"]`);
if (!selectorEl) { continue; } if (!selectorEl) { continue; }
// The user may have not voted on this label. // The user may have not voted on this label.

View File

@@ -111,7 +111,8 @@ limitations under the License.
test('get and set label scores', () => { test('get and set label scores', () => {
for (const label in element.permittedLabels) { for (const label in element.permittedLabels) {
if (element.permittedLabels.hasOwnProperty(label)) { if (element.permittedLabels.hasOwnProperty(label)) {
const row = element.$$('gr-label-score-row[name="' + label + '"]'); const row = element.shadowRoot
.querySelector('gr-label-score-row[name="' + label + '"]');
row.setSelectedValue(-1); row.setSelectedValue(-1);
} }
} }

View File

@@ -225,7 +225,8 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
const stub = sinon.stub(); const stub = sinon.stub();
element.addEventListener('message-anchor-tap', stub); element.addEventListener('message-anchor-tap', stub);
const dateEl = element.$$('.date'); const dateEl = element.shadowRoot
.querySelector('.date');
assert.ok(dateEl); assert.ok(dateEl);
MockInteractions.tap(dateEl); MockInteractions.tap(dateEl);

View File

@@ -93,7 +93,8 @@
} }
scrollToMessage(messageID) { scrollToMessage(messageID) {
let el = this.$$('[data-message-id="' + messageID + '"]'); let el = this.shadowRoot
.querySelector('[data-message-id="' + messageID + '"]');
// If the message is hidden, expand the hidden messages back to that // If the message is hidden, expand the hidden messages back to that
// point. // point.
if (!el) { if (!el) {
@@ -111,7 +112,8 @@
this.splice(...['_visibleMessages', 0, 0].concat(newMessages)); this.splice(...['_visibleMessages', 0, 0].concat(newMessages));
// Allow the dom-repeat to stamp. // Allow the dom-repeat to stamp.
Polymer.dom.flush(); Polymer.dom.flush();
el = this.$$('[data-message-id="' + messageID + '"]'); el = this.shadowRoot
.querySelector('[data-message-id="' + messageID + '"]');
} }
el.set('message.expanded', true); el.set('message.expanded', true);

View File

@@ -352,7 +352,9 @@ limitations under the License.
const messageID = messages[1].id; const messageID = messages[1].id;
element.scrollToMessage(messageID); element.scrollToMessage(messageID);
assert.isTrue( assert.isTrue(
element.$$('[data-message-id="' + messageID + '"]')._expanded); element.shadowRoot
.querySelector('[data-message-id="' + messageID + '"]')
._expanded);
assert.isTrue(scrollToStub.calledOnce); assert.isTrue(scrollToStub.calledOnce);
assert.isTrue(highlightStub.calledOnce); assert.isTrue(highlightStub.calledOnce);
@@ -372,7 +374,9 @@ limitations under the License.
assert.isTrue(highlightStub.calledOnce); assert.isTrue(highlightStub.calledOnce);
assert.equal(element._visibleMessages.length, 24); assert.equal(element._visibleMessages.length, 24);
assert.isTrue( assert.isTrue(
element.$$('[data-message-id="' + messageID + '"]')._expanded); element.shadowRoot
.querySelector('[data-message-id="' + messageID + '"]')
._expanded);
}); });
test('messages', () => { test('messages', () => {

View File

@@ -526,7 +526,8 @@ limitations under the License.
element._submittedTogether = {changes: [change]}; element._submittedTogether = {changes: [change]};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.notInclude(element.$.submittedTogether.className, 'hidden'); assert.notInclude(element.$.submittedTogether.className, 'hidden');
assert.isNull(element.$$('.note')); assert.isNull(element.shadowRoot
.querySelector('.note'));
}); });
test('no visible submitted together changes', () => { test('no visible submitted together changes', () => {
@@ -534,18 +535,22 @@ limitations under the License.
element._submittedTogether = {changes: [], non_visible_changes: 1}; element._submittedTogether = {changes: [], non_visible_changes: 1};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.notInclude(element.$.submittedTogether.className, 'hidden'); assert.notInclude(element.$.submittedTogether.className, 'hidden');
assert.isNotNull(element.$$('.note')); assert.isNotNull(element.shadowRoot
.querySelector('.note'));
assert.strictEqual( assert.strictEqual(
element.$$('.note').innerText, '(+ 1 non-visible change)'); element.shadowRoot
.querySelector('.note').innerText, '(+ 1 non-visible change)');
}); });
test('visible and non-visible submitted together changes', () => { test('visible and non-visible submitted together changes', () => {
element._submittedTogether = {changes: [change], non_visible_changes: 2}; element._submittedTogether = {changes: [change], non_visible_changes: 2};
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.notInclude(element.$.submittedTogether.className, 'hidden'); assert.notInclude(element.$.submittedTogether.className, 'hidden');
assert.isNotNull(element.$$('.note')); assert.isNotNull(element.shadowRoot
.querySelector('.note'));
assert.strictEqual( assert.strictEqual(
element.$$('.note').innerText, '(+ 2 non-visible changes)'); element.shadowRoot
.querySelector('.note').innerText, '(+ 2 non-visible changes)');
}); });
}); });
}); });

View File

@@ -123,12 +123,14 @@ limitations under the License.
sandbox.stub(element, '_purgeReviewersPendingRemove'); sandbox.stub(element, '_purgeReviewersPendingRemove');
element.$.ccs.$.entry.setText('test'); element.$.ccs.$.entry.setText('test');
MockInteractions.tap(element.$$('gr-button.send')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button.send'));
assert.isFalse(sendStub.called); assert.isFalse(sendStub.called);
flushAsynchronousOperations(); flushAsynchronousOperations();
element.$.ccs.$.entry.setText('test@test.test'); element.$.ccs.$.entry.setText('test@test.test');
MockInteractions.tap(element.$$('gr-button.send')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button.send'));
assert.isTrue(sendStub.called); assert.isTrue(sendStub.called);
}); });
@@ -147,7 +149,8 @@ limitations under the License.
element = fixture('basic'); element = fixture('basic');
setupElement(element); setupElement(element);
const importSpy = const importSpy =
sandbox.spy(element.$$('gr-endpoint-decorator'), '_import'); sandbox.spy(element.shadowRoot
.querySelector('gr-endpoint-decorator'), '_import');
Gerrit.awaitPluginsLoaded().then(() => { Gerrit.awaitPluginsLoaded().then(() => {
Promise.all(importSpy.returnValues).then(() => { Promise.all(importSpy.returnValues).then(() => {
flush(() => { flush(() => {

View File

@@ -304,14 +304,16 @@
setLabelValue(label, value) { setLabelValue(label, value) {
const selectorEl = const selectorEl =
this.$.labelScores.$$(`gr-label-score-row[name="${label}"]`); this.$.labelScores.shadowRoot
.querySelector(`gr-label-score-row[name="${label}"]`);
if (!selectorEl) { return; } if (!selectorEl) { return; }
selectorEl.setSelectedValue(value); selectorEl.setSelectedValue(value);
} }
getLabelValue(label) { getLabelValue(label) {
const selectorEl = const selectorEl =
this.$.labelScores.$$(`gr-label-score-row[name="${label}"]`); this.$.labelScores.shadowRoot
.querySelector(`gr-label-score-row[name="${label}"]`);
if (!selectorEl) { return null; } if (!selectorEl) { return null; }
return selectorEl.selectedValue; return selectorEl.selectedValue;

View File

@@ -184,7 +184,8 @@ limitations under the License.
// This is needed on non-Blink engines most likely due to the ways in // This is needed on non-Blink engines most likely due to the ways in
// which the dom-repeat elements are stamped. // which the dom-repeat elements are stamped.
flush(() => { flush(() => {
MockInteractions.tap(element.$$('.send')); MockInteractions.tap(element.shadowRoot
.querySelector('.send'));
}); });
}); });
}); });
@@ -218,7 +219,8 @@ limitations under the License.
// This is needed on non-Blink engines most likely due to the ways in // This is needed on non-Blink engines most likely due to the ways in
// which the dom-repeat elements are stamped. // which the dom-repeat elements are stamped.
flush(() => { flush(() => {
MockInteractions.tap(element.$$('.send')); MockInteractions.tap(element.shadowRoot
.querySelector('.send'));
}); });
}); });
}); });
@@ -258,14 +260,18 @@ limitations under the License.
// This is needed on non-Blink engines most likely due to the ways in // This is needed on non-Blink engines most likely due to the ways in
// which the dom-repeat elements are stamped. // which the dom-repeat elements are stamped.
flush(() => { flush(() => {
MockInteractions.tap(element.$$('.send')); MockInteractions.tap(element.shadowRoot
.querySelector('.send'));
assert.isTrue(element.disabled); assert.isTrue(element.disabled);
}); });
}); });
test('getlabelValue returns value', done => { test('getlabelValue returns value', done => {
flush(() => { flush(() => {
element.$$('gr-label-scores').$$(`gr-label-score-row[name="Verified"]`) element.shadowRoot
.querySelector('gr-label-scores')
.shadowRoot
.querySelector(`gr-label-score-row[name="Verified"]`)
.setSelectedValue(-1); .setSelectedValue(-1);
assert.equal('-1', element.getLabelValue('Verified')); assert.equal('-1', element.getLabelValue('Verified'));
done(); done();
@@ -274,8 +280,10 @@ limitations under the License.
test('getlabelValue when no score is selected', done => { test('getlabelValue when no score is selected', done => {
flush(() => { flush(() => {
element.$$('gr-label-scores') element.shadowRoot
.$$(`gr-label-score-row[name="Code-Review"]`) .querySelector('gr-label-scores')
.shadowRoot
.querySelector(`gr-label-score-row[name="Code-Review"]`)
.setSelectedValue(-1); .setSelectedValue(-1);
assert.strictEqual(element.getLabelValue('Verified'), ' 0'); assert.strictEqual(element.getLabelValue('Verified'), ' 0');
done(); done();
@@ -338,10 +346,12 @@ limitations under the License.
} }
function testConfirmationDialog(done, cc) { function testConfirmationDialog(done, cc) {
const yesButton = const yesButton = element
element.$$('.reviewerConfirmationButtons gr-button:first-child'); .shadowRoot
const noButton = .querySelector('.reviewerConfirmationButtons gr-button:first-child');
element.$$('.reviewerConfirmationButtons gr-button:last-child'); const noButton = element
.shadowRoot
.querySelector('.reviewerConfirmationButtons gr-button:last-child');
element._ccPendingConfirmation = null; element._ccPendingConfirmation = null;
element._reviewerPendingConfirmation = null; element._reviewerPendingConfirmation = null;
@@ -691,10 +701,13 @@ limitations under the License.
// The send button can be tapped before the others, causing the test to // The send button can be tapped before the others, causing the test to
// fail. // fail.
element.$$('gr-label-scores').$$( element.shadowRoot
'gr-label-score-row[name="Verified"]') .querySelector('gr-label-scores').shadowRoot
.querySelector(
'gr-label-score-row[name="Verified"]')
.setSelectedValue(-1); .setSelectedValue(-1);
MockInteractions.tap(element.$$('.send')); MockInteractions.tap(element.shadowRoot
.querySelector('.send'));
}); });
}); });
@@ -1024,13 +1037,15 @@ limitations under the License.
}); });
test('start review sets ready', () => { test('start review sets ready', () => {
MockInteractions.tap(element.$$('.send')); MockInteractions.tap(element.shadowRoot
.querySelector('.send'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(sendStub.calledWith(true, true)); assert.isTrue(sendStub.calledWith(true, true));
}); });
test('save review doesn\'t set ready', () => { test('save review doesn\'t set ready', () => {
MockInteractions.tap(element.$$('.save')); MockInteractions.tap(element.shadowRoot
.querySelector('.save'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(sendStub.calledWith(true, false)); assert.isTrue(sendStub.calledWith(true, false));
}); });
@@ -1187,13 +1202,15 @@ limitations under the License.
element.draftCommentThreads = []; element.draftCommentThreads = [];
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('gr-button.send')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button.send'));
assert.isFalse(sendStub.called); assert.isFalse(sendStub.called);
element.draftCommentThreads = [{comments: [{__draft: true}]}]; element.draftCommentThreads = [{comments: [{__draft: true}]}];
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('gr-button.send')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button.send'));
assert.isTrue(sendStub.called); assert.isTrue(sendStub.called);
}); });

View File

@@ -58,16 +58,19 @@ limitations under the License.
test('controls hidden on immutable element', () => { test('controls hidden on immutable element', () => {
element.mutable = false; element.mutable = false;
assert.isTrue(element.$$('.controlsContainer').hasAttribute('hidden')); assert.isTrue(element.shadowRoot
.querySelector('.controlsContainer').hasAttribute('hidden'));
element.mutable = true; element.mutable = true;
assert.isFalse(element.$$('.controlsContainer').hasAttribute('hidden')); assert.isFalse(element.shadowRoot
.querySelector('.controlsContainer').hasAttribute('hidden'));
}); });
test('add reviewer button opens reply dialog', done => { test('add reviewer button opens reply dialog', done => {
element.addEventListener('show-reply-dialog', () => { element.addEventListener('show-reply-dialog', () => {
done(); done();
}); });
MockInteractions.tap(element.$$('.addReviewer')); MockInteractions.tap(element.shadowRoot
.querySelector('.addReviewer'));
}); });
test('only show remove for removable reviewers', () => { test('only show remove for removable reviewers', () => {
@@ -123,7 +126,8 @@ limitations under the License.
const accountID = el.account._account_id || el.account.email; const accountID = el.account._account_id || el.account.email;
assert.ok(accountID); assert.ok(accountID);
const buttonEl = el.$$('gr-button'); const buttonEl = el.shadowRoot
.querySelector('gr-button');
assert.isNotNull(buttonEl); assert.isNotNull(buttonEl);
if (accountID == 2) { if (accountID == 2) {
assert.isTrue(buttonEl.hasAttribute('hidden')); assert.isTrue(buttonEl.hasAttribute('hidden'));
@@ -213,7 +217,8 @@ limitations under the License.
assert.equal(element._hiddenReviewerCount, 0); assert.equal(element._hiddenReviewerCount, 0);
assert.equal(element._displayedReviewers.length, 6); assert.equal(element._displayedReviewers.length, 6);
assert.equal(element._reviewers.length, 6); assert.equal(element._reviewers.length, 6);
assert.isTrue(element.$$('.hiddenReviewers').hidden); assert.isTrue(element.shadowRoot
.querySelector('.hiddenReviewers').hidden);
}); });
test('show all reviewers button with 8 reviewers', () => { test('show all reviewers button with 8 reviewers', () => {
@@ -236,7 +241,8 @@ limitations under the License.
assert.equal(element._hiddenReviewerCount, 3); assert.equal(element._hiddenReviewerCount, 3);
assert.equal(element._displayedReviewers.length, 5); assert.equal(element._displayedReviewers.length, 5);
assert.equal(element._reviewers.length, 8); assert.equal(element._reviewers.length, 8);
assert.isFalse(element.$$('.hiddenReviewers').hidden); assert.isFalse(element.shadowRoot
.querySelector('.hiddenReviewers').hidden);
}); });
test('no maxReviewersDisplayed', () => { test('no maxReviewersDisplayed', () => {
@@ -258,7 +264,8 @@ limitations under the License.
assert.equal(element._hiddenReviewerCount, 0); assert.equal(element._hiddenReviewerCount, 0);
assert.equal(element._displayedReviewers.length, 7); assert.equal(element._displayedReviewers.length, 7);
assert.equal(element._reviewers.length, 7); assert.equal(element._reviewers.length, 7);
assert.isTrue(element.$$('.hiddenReviewers').hidden); assert.isTrue(element.shadowRoot
.querySelector('.hiddenReviewers').hidden);
}); });
test('show all reviewers button', () => { test('show all reviewers button', () => {
@@ -281,14 +288,17 @@ limitations under the License.
assert.equal(element._hiddenReviewerCount, 95); assert.equal(element._hiddenReviewerCount, 95);
assert.equal(element._displayedReviewers.length, 5); assert.equal(element._displayedReviewers.length, 5);
assert.equal(element._reviewers.length, 100); assert.equal(element._reviewers.length, 100);
assert.isFalse(element.$$('.hiddenReviewers').hidden); assert.isFalse(element.shadowRoot
.querySelector('.hiddenReviewers').hidden);
MockInteractions.tap(element.$$('.hiddenReviewers')); MockInteractions.tap(element.shadowRoot
.querySelector('.hiddenReviewers'));
assert.equal(element._hiddenReviewerCount, 0); assert.equal(element._hiddenReviewerCount, 0);
assert.equal(element._displayedReviewers.length, 100); assert.equal(element._displayedReviewers.length, 100);
assert.equal(element._reviewers.length, 100); assert.equal(element._reviewers.length, 100);
assert.isTrue(element.$$('.hiddenReviewers').hidden); assert.isTrue(element.shadowRoot
.querySelector('.hiddenReviewers').hidden);
}); });
test('votable labels', () => { test('votable labels', () => {

View File

@@ -246,11 +246,13 @@ limitations under the License.
}); });
test('draft toggle only appears when logged in', () => { test('draft toggle only appears when logged in', () => {
assert.equal(getComputedStyle(element.$$('.draftToggle')).display, assert.equal(getComputedStyle(element.shadowRoot
'none'); .querySelector('.draftToggle')).display,
'none');
element.loggedIn = true; element.loggedIn = true;
assert.notEqual(getComputedStyle(element.$$('.draftToggle')).display, assert.notEqual(getComputedStyle(element.shadowRoot
'none'); .querySelector('.draftToggle')).display,
'none');
}); });
test('there are five threads by default', () => { test('there are five threads by default', () => {

View File

@@ -239,7 +239,8 @@ limitations under the License.
noInteractionOverlay.backdropElement.getAttribute('opened'), noInteractionOverlay.backdropElement.getAttribute('opened'),
''); '');
assert.isFalse(windowOpen.called); assert.isFalse(windowOpen.called);
MockInteractions.tap(toast.$$('gr-button.action')); MockInteractions.tap(toast.shadowRoot
.querySelector('gr-button.action'));
assert.isTrue(windowOpen.called); assert.isTrue(windowOpen.called);
// @see Issue 5822: noopener breaks closeAfterLogin // @see Issue 5822: noopener breaks closeAfterLogin

View File

@@ -59,30 +59,40 @@ limitations under the License.
test('link visibility', () => { test('link visibility', () => {
element.loading = true; element.loading = true;
assert.equal(getComputedStyle(element.$$('.accountContainer')).display, assert.equal(getComputedStyle(element.shadowRoot
'none'); .querySelector('.accountContainer')).display,
'none');
element.loading = false; element.loading = false;
element.loggedIn = false; element.loggedIn = false;
assert.notEqual(getComputedStyle(element.$$('.accountContainer')).display, assert.notEqual(getComputedStyle(element.shadowRoot
'none'); .querySelector('.accountContainer')).display,
assert.notEqual(getComputedStyle(element.$$('.loginButton')).display, 'none');
'none'); assert.notEqual(getComputedStyle(element.shadowRoot
assert.notEqual(getComputedStyle(element.$$('.registerButton')).display, .querySelector('.loginButton')).display,
'none'); 'none');
assert.equal(getComputedStyle(element.$$('gr-account-dropdown')).display, assert.notEqual(getComputedStyle(element.shadowRoot
'none'); .querySelector('.registerButton')).display,
assert.equal(getComputedStyle(element.$$('.settingsButton')).display, 'none');
'none'); assert.equal(getComputedStyle(element.shadowRoot
.querySelector('gr-account-dropdown')).display,
'none');
assert.equal(getComputedStyle(element.shadowRoot
.querySelector('.settingsButton')).display,
'none');
element.loggedIn = true; element.loggedIn = true;
assert.equal(getComputedStyle(element.$$('.loginButton')).display, assert.equal(getComputedStyle(element.shadowRoot
'none'); .querySelector('.loginButton')).display,
assert.equal(getComputedStyle(element.$$('.registerButton')).display, 'none');
'none'); assert.equal(getComputedStyle(element.shadowRoot
assert.notEqual(getComputedStyle(element.$$('gr-account-dropdown')) .querySelector('.registerButton')).display,
'none');
assert.notEqual(getComputedStyle(element.shadowRoot
.querySelector('gr-account-dropdown'))
.display, .display,
'none'); 'none');
assert.notEqual(getComputedStyle(element.$$('.settingsButton')).display, assert.notEqual(getComputedStyle(element.shadowRoot
'none'); .querySelector('.settingsButton')).display,
'none');
}); });
test('fix my menu item', () => { test('fix my menu item', () => {

View File

@@ -96,7 +96,8 @@ limitations under the License.
// The cursor has been initialized to the first delta. // The cursor has been initialized to the first delta.
assert.isOk(cursorElement.diffRow); assert.isOk(cursorElement.diffRow);
const firstDeltaRow = diffElement.$$('.section.delta .diff-row'); const firstDeltaRow = diffElement.shadowRoot
.querySelector('.section.delta .diff-row');
assert.equal(cursorElement.diffRow, firstDeltaRow); assert.equal(cursorElement.diffRow, firstDeltaRow);
cursorElement.moveDown(); cursorElement.moveDown();
@@ -152,10 +153,12 @@ limitations under the License.
// The cursor has been initialized to the first delta. // The cursor has been initialized to the first delta.
assert.isOk(cursorElement.diffRow); assert.isOk(cursorElement.diffRow);
let firstDeltaRow = diffElement.$$('.section.delta .diff-row'); let firstDeltaRow = diffElement.shadowRoot
.querySelector('.section.delta .diff-row');
assert.equal(cursorElement.diffRow, firstDeltaRow); assert.equal(cursorElement.diffRow, firstDeltaRow);
firstDeltaRow = diffElement.$$('.section.delta .diff-row'); firstDeltaRow = diffElement.shadowRoot
.querySelector('.section.delta .diff-row');
assert.equal(cursorElement.diffRow, firstDeltaRow); assert.equal(cursorElement.diffRow, firstDeltaRow);
cursorElement.moveDown(); cursorElement.moveDown();
@@ -175,7 +178,8 @@ limitations under the License.
// mode. // mode.
assert.equal(diffElement.viewMode, 'SIDE_BY_SIDE'); assert.equal(diffElement.viewMode, 'SIDE_BY_SIDE');
const firstDeltaSection = diffElement.$$('.section.delta'); const firstDeltaSection = diffElement.shadowRoot
.querySelector('.section.delta');
const firstDeltaRow = firstDeltaSection.querySelector('.diff-row'); const firstDeltaRow = firstDeltaSection.querySelector('.diff-row');
// Because the first delta in this diff is on the right, it should be set // Because the first delta in this diff is on the right, it should be set
@@ -383,7 +387,8 @@ limitations under the License.
test('expand context updates stops', done => { test('expand context updates stops', done => {
sandbox.spy(cursorElement, 'handleDiffUpdate'); sandbox.spy(cursorElement, 'handleDiffUpdate');
MockInteractions.tap(diffElement.$$('.showContext')); MockInteractions.tap(diffElement.shadowRoot
.querySelector('.showContext'));
flush(() => { flush(() => {
assert.isTrue(cursorElement.handleDiffUpdate.called); assert.isTrue(cursorElement.handleDiffUpdate.called);
done(); done();

View File

@@ -382,7 +382,7 @@
return; return;
} }
let actionBox = this.$$('gr-selection-action-box'); let actionBox = this.shadowRoot.querySelector('gr-selection-action-box');
if (!actionBox) { if (!actionBox) {
actionBox = document.createElement('gr-selection-action-box'); actionBox = document.createElement('gr-selection-action-box');
const root = Polymer.dom(this.root); const root = Polymer.dom(this.root);
@@ -429,7 +429,8 @@
_removeActionBox() { _removeActionBox() {
this.selectedRange = undefined; this.selectedRange = undefined;
const actionBox = this.$$('gr-selection-action-box'); const actionBox = this.shadowRoot
.querySelector('gr-selection-action-box');
if (actionBox) { if (actionBox) {
Polymer.dom(this.root).removeChild(actionBox); Polymer.dom(this.root).removeChild(actionBox);
} }

View File

@@ -316,7 +316,8 @@ limitations under the License.
const content = stubContent(1, 'right'); const content = stubContent(1, 'right');
sandbox.spy(element, '_positionActionBox'); sandbox.spy(element, '_positionActionBox');
emulateSelection(content.firstChild, 5, content.firstChild, 12); emulateSelection(content.firstChild, 5, content.firstChild, 12);
const actionBox = element.$$('gr-selection-action-box'); const actionBox = element.shadowRoot
.querySelector('gr-selection-action-box');
assert.isTrue(actionBox.positionBelow); assert.isTrue(actionBox.positionBelow);
}); });
@@ -326,7 +327,8 @@ limitations under the License.
sandbox.spy(element, '_positionActionBox'); sandbox.spy(element, '_positionActionBox');
emulateSelection( emulateSelection(
startContent.firstChild, 10, endContent.lastChild, 7); startContent.firstChild, 10, endContent.lastChild, 7);
const actionBox = element.$$('gr-selection-action-box'); const actionBox = element.shadowRoot
.querySelector('gr-selection-action-box');
assert.isTrue(actionBox.positionBelow); assert.isTrue(actionBox.positionBelow);
}); });
@@ -334,7 +336,8 @@ limitations under the License.
const content = stubContent(138, 'left'); const content = stubContent(138, 'left');
sandbox.spy(element, '_positionActionBox'); sandbox.spy(element, '_positionActionBox');
emulateSelection(content.firstChild, 5, content.firstChild, 12); emulateSelection(content.firstChild, 5, content.firstChild, 12);
const actionBox = element.$$('gr-selection-action-box'); const actionBox = element.shadowRoot
.querySelector('gr-selection-action-box');
const {range, side} = element.selectedRange; const {range, side} = element.selectedRange;
assert.deepEqual(range, { assert.deepEqual(range, {
start_line: 138, start_line: 138,
@@ -352,7 +355,8 @@ limitations under the License.
sandbox.spy(element, '_positionActionBox'); sandbox.spy(element, '_positionActionBox');
emulateSelection( emulateSelection(
startContent.firstChild, 10, endContent.lastChild, 7); startContent.firstChild, 10, endContent.lastChild, 7);
const actionBox = element.$$('gr-selection-action-box'); const actionBox = element.shadowRoot
.querySelector('gr-selection-action-box');
const {range, side} = element.selectedRange; const {range, side} = element.selectedRange;
assert.deepEqual(range, { assert.deepEqual(range, {
start_line: 119, start_line: 119,

View File

@@ -212,7 +212,10 @@ limitations under the License.
test('view does not start with displayLine classList', () => { test('view does not start with displayLine classList', () => {
assert.isFalse( assert.isFalse(
element.$$('.diffContainer').classList.contains('displayLine')); element.shadowRoot
.querySelector('.diffContainer')
.classList
.contains('displayLine'));
}); });
test('displayLine class added called when displayLine is true', () => { test('displayLine class added called when displayLine is true', () => {
@@ -220,7 +223,10 @@ limitations under the License.
element.displayLine = true; element.displayLine = true;
assert.isTrue(spy.called); assert.isTrue(spy.called);
assert.isTrue( assert.isTrue(
element.$$('.diffContainer').classList.contains('displayLine')); element.shadowRoot
.querySelector('.diffContainer')
.classList
.contains('displayLine'));
}); });
test('thread groups', () => { test('thread groups', () => {
@@ -631,7 +637,8 @@ limitations under the License.
test('adds .hiddenscroll', () => { test('adds .hiddenscroll', () => {
Gerrit.hiddenscroll = true; Gerrit.hiddenscroll = true;
element.displayLine = true; element.displayLine = true;
assert.include(element.$$('.diffContainer').className, 'hiddenscroll'); assert.include(element.shadowRoot
.querySelector('.diffContainer').className, 'hiddenscroll');
}); });
}); });

View File

@@ -94,7 +94,8 @@ limitations under the License.
openAutoCcmplete.text = 'src/test.cpp'; openAutoCcmplete.text = 'src/test.cpp';
assert.isTrue(queryStub.called); assert.isTrue(queryStub.called);
assert.isFalse(element.$.openDialog.disabled); assert.isFalse(element.$.openDialog.disabled);
MockInteractions.tap(element.$.openDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.openDialog.shadowRoot
.querySelector('gr-button[primary]'));
for (const stub of navStubs) { assert.isTrue(stub.called); } for (const stub of navStubs) { assert.isTrue(stub.called); }
assert.deepEqual(Gerrit.Nav.getEditUrlForDiff.lastCall.args, assert.deepEqual(Gerrit.Nav.getEditUrlForDiff.lastCall.args,
[element.change, 'src/test.cpp', element.patchNum]); [element.change, 'src/test.cpp', element.patchNum]);
@@ -109,7 +110,8 @@ limitations under the License.
openAutoCcmplete.noDebounce = true; openAutoCcmplete.noDebounce = true;
openAutoCcmplete.text = 'src/test.cpp'; openAutoCcmplete.text = 'src/test.cpp';
assert.isFalse(element.$.openDialog.disabled); assert.isFalse(element.$.openDialog.disabled);
MockInteractions.tap(element.$.openDialog.$$('gr-button')); MockInteractions.tap(element.$.openDialog.shadowRoot
.querySelector('gr-button'));
for (const stub of navStubs) { assert.isFalse(stub.called); } for (const stub of navStubs) { assert.isFalse(stub.called); }
assert.isTrue(closeDialogSpy.called); assert.isTrue(closeDialogSpy.called);
assert.equal(element._path, 'src/test.cpp'); assert.equal(element._path, 'src/test.cpp');
@@ -139,7 +141,8 @@ limitations under the License.
deleteAutocomplete.text = 'src/test.cpp'; deleteAutocomplete.text = 'src/test.cpp';
assert.isTrue(queryStub.called); assert.isTrue(queryStub.called);
assert.isFalse(element.$.deleteDialog.disabled); assert.isFalse(element.$.deleteDialog.disabled);
MockInteractions.tap(element.$.deleteDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.deleteDialog.shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(deleteStub.called); assert.isTrue(deleteStub.called);
@@ -162,7 +165,8 @@ limitations under the License.
deleteAutocomplete.text = 'src/test.cpp'; deleteAutocomplete.text = 'src/test.cpp';
assert.isTrue(queryStub.called); assert.isTrue(queryStub.called);
assert.isFalse(element.$.deleteDialog.disabled); assert.isFalse(element.$.deleteDialog.disabled);
MockInteractions.tap(element.$.deleteDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.deleteDialog.shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(deleteStub.called); assert.isTrue(deleteStub.called);
@@ -181,7 +185,8 @@ limitations under the License.
element.$.deleteDialog.querySelector('gr-autocomplete').text = element.$.deleteDialog.querySelector('gr-autocomplete').text =
'src/test.cpp'; 'src/test.cpp';
assert.isFalse(element.$.deleteDialog.disabled); assert.isFalse(element.$.deleteDialog.disabled);
MockInteractions.tap(element.$.deleteDialog.$$('gr-button')); MockInteractions.tap(element.$.deleteDialog.shadowRoot
.querySelector('gr-button'));
assert.isFalse(navStub.called); assert.isFalse(navStub.called);
assert.isTrue(closeDialogSpy.called); assert.isTrue(closeDialogSpy.called);
assert.equal(element._path, 'src/test.cpp'); assert.equal(element._path, 'src/test.cpp');
@@ -219,7 +224,8 @@ limitations under the License.
'src/test.newPath'; 'src/test.newPath';
assert.isFalse(element.$.renameDialog.disabled); assert.isFalse(element.$.renameDialog.disabled);
MockInteractions.tap(element.$.renameDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.renameDialog.shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(renameStub.called); assert.isTrue(renameStub.called);
@@ -247,7 +253,8 @@ limitations under the License.
'src/test.newPath'; 'src/test.newPath';
assert.isFalse(element.$.renameDialog.disabled); assert.isFalse(element.$.renameDialog.disabled);
MockInteractions.tap(element.$.renameDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.renameDialog.shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(renameStub.called); assert.isTrue(renameStub.called);
@@ -268,7 +275,8 @@ limitations under the License.
element.$.renameDialog.querySelector(inputSelector).bindValue = element.$.renameDialog.querySelector(inputSelector).bindValue =
'src/test.newPath'; 'src/test.newPath';
assert.isFalse(element.$.renameDialog.disabled); assert.isFalse(element.$.renameDialog.disabled);
MockInteractions.tap(element.$.renameDialog.$$('gr-button')); MockInteractions.tap(element.$.renameDialog.shadowRoot
.querySelector('gr-button'));
assert.isFalse(navStub.called); assert.isFalse(navStub.called);
assert.isTrue(closeDialogSpy.called); assert.isTrue(closeDialogSpy.called);
assert.equal(element._path, 'src/test.cpp'); assert.equal(element._path, 'src/test.cpp');
@@ -296,7 +304,8 @@ limitations under the License.
element._path = 'src/test.cpp'; element._path = 'src/test.cpp';
MockInteractions.tap(element.shadowRoot.querySelector('#restore')); MockInteractions.tap(element.shadowRoot.querySelector('#restore'));
return showDialogSpy.lastCall.returnValue.then(() => { return showDialogSpy.lastCall.returnValue.then(() => {
MockInteractions.tap(element.$.restoreDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.restoreDialog.shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(restoreStub.called); assert.isTrue(restoreStub.called);
@@ -314,7 +323,8 @@ limitations under the License.
element._path = 'src/test.cpp'; element._path = 'src/test.cpp';
MockInteractions.tap(element.shadowRoot.querySelector('#restore')); MockInteractions.tap(element.shadowRoot.querySelector('#restore'));
return showDialogSpy.lastCall.returnValue.then(() => { return showDialogSpy.lastCall.returnValue.then(() => {
MockInteractions.tap(element.$.restoreDialog.$$('gr-button[primary]')); MockInteractions.tap(element.$.restoreDialog.shadowRoot
.querySelector('gr-button[primary]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(restoreStub.called); assert.isTrue(restoreStub.called);
@@ -330,7 +340,8 @@ limitations under the License.
element._path = 'src/test.cpp'; element._path = 'src/test.cpp';
MockInteractions.tap(element.shadowRoot.querySelector('#restore')); MockInteractions.tap(element.shadowRoot.querySelector('#restore'));
return showDialogSpy.lastCall.returnValue.then(() => { return showDialogSpy.lastCall.returnValue.then(() => {
MockInteractions.tap(element.$.restoreDialog.$$('gr-button')); MockInteractions.tap(element.$.restoreDialog.shadowRoot
.querySelector('gr-button'));
assert.isFalse(navStub.called); assert.isFalse(navStub.called);
assert.isTrue(closeDialogSpy.called); assert.isTrue(closeDialogSpy.called);
assert.equal(element._path, 'src/test.cpp'); assert.equal(element._path, 'src/test.cpp');

View File

@@ -58,7 +58,8 @@ limitations under the License.
actions._open(); actions._open();
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(actions.$$('li [data-id="open"]')); MockInteractions.tap(actions.shadowRoot
.querySelector('li [data-id="open"]'));
assert.isTrue(fileActionHandler.called); assert.isTrue(fileActionHandler.called);
assert.deepEqual(fileActionHandler.lastCall.args[0].detail, assert.deepEqual(fileActionHandler.lastCall.args[0].detail,
{action: GrEditConstants.Actions.OPEN.id, path: 'foo'}); {action: GrEditConstants.Actions.OPEN.id, path: 'foo'});
@@ -70,7 +71,8 @@ limitations under the License.
actions._open(); actions._open();
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(actions.$$('li [data-id="delete"]')); MockInteractions.tap(actions.shadowRoot
.querySelector('li [data-id="delete"]'));
assert.isTrue(fileActionHandler.called); assert.isTrue(fileActionHandler.called);
assert.deepEqual(fileActionHandler.lastCall.args[0].detail, assert.deepEqual(fileActionHandler.lastCall.args[0].detail,
{action: GrEditConstants.Actions.DELETE.id, path: 'foo'}); {action: GrEditConstants.Actions.DELETE.id, path: 'foo'});
@@ -82,7 +84,8 @@ limitations under the License.
actions._open(); actions._open();
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(actions.$$('li [data-id="restore"]')); MockInteractions.tap(actions.shadowRoot
.querySelector('li [data-id="restore"]'));
assert.isTrue(fileActionHandler.called); assert.isTrue(fileActionHandler.called);
assert.deepEqual(fileActionHandler.lastCall.args[0].detail, assert.deepEqual(fileActionHandler.lastCall.args[0].detail,
{action: GrEditConstants.Actions.RESTORE.id, path: 'foo'}); {action: GrEditConstants.Actions.RESTORE.id, path: 'foo'});
@@ -94,7 +97,8 @@ limitations under the License.
actions._open(); actions._open();
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(actions.$$('li [data-id="rename"]')); MockInteractions.tap(actions.shadowRoot
.querySelector('li [data-id="rename"]'));
assert.isTrue(fileActionHandler.called); assert.isTrue(fileActionHandler.called);
assert.deepEqual(fileActionHandler.lastCall.args[0].detail, assert.deepEqual(fileActionHandler.lastCall.args[0].detail,
{action: GrEditConstants.Actions.RENAME.id, path: 'foo'}); {action: GrEditConstants.Actions.RENAME.id, path: 'foo'});

View File

@@ -470,7 +470,7 @@
_handleAccountDetailUpdate(e) { _handleAccountDetailUpdate(e) {
this.$.mainHeader.reload(); this.$.mainHeader.reload();
if (this.params.view === Gerrit.Nav.View.SETTINGS) { if (this.params.view === Gerrit.Nav.View.SETTINGS) {
this.$$('gr-settings-view').reloadAccountDetail(); this.shadowRoot.querySelector('gr-settings-view').reloadAccountDetail();
} }
} }

View File

@@ -70,13 +70,16 @@ limitations under the License.
const element = fixture('basic'); const element = fixture('basic');
flush(() => { flush(() => {
assert.isTrue(attachedStub.called); assert.isTrue(attachedStub.called);
const pluginCommand = element.$$('gr-plugin-repo-command'); const pluginCommand = element.shadowRoot
.querySelector('gr-plugin-repo-command');
assert.isOk(pluginCommand); assert.isOk(pluginCommand);
const command = pluginCommand.$$('gr-repo-command'); const command = pluginCommand.shadowRoot
.querySelector('gr-repo-command');
assert.isOk(command); assert.isOk(command);
assert.equal(command.title, 'foo'); assert.equal(command.title, 'foo');
assert.isFalse(tapStub.called); assert.isFalse(tapStub.called);
MockInteractions.tap(command.$$('gr-button')); MockInteractions.tap(command.shadowRoot
.querySelector('gr-button'));
assert.isTrue(tapStub.called); assert.isTrue(tapStub.called);
done(); done();
}); });

View File

@@ -72,11 +72,13 @@ limitations under the License.
const element = fixture('basic'); const element = fixture('basic');
flush(() => { flush(() => {
const [menuItemEl, itemEl] = element; const [menuItemEl, itemEl] = element;
const menuItem = menuItemEl.$$('gr-settings-menu-item'); const menuItem = menuItemEl.shadowRoot
.querySelector('gr-settings-menu-item');
assert.isOk(menuItem); assert.isOk(menuItem);
assert.equal(menuItem.title, 'foo'); assert.equal(menuItem.title, 'foo');
assert.equal(menuItem.href, '#x/testplugin/bar'); assert.equal(menuItem.href, '#x/testplugin/bar');
const item = itemEl.$$('gr-settings-item'); const item = itemEl.shadowRoot
.querySelector('gr-settings-item');
assert.isOk(item); assert.isOk(item);
assert.equal(item.title, 'foo'); assert.equal(item.title, 'foo');
assert.equal(item.anchor, 'x/testplugin/bar'); assert.equal(item.anchor, 'x/testplugin/bar');

View File

@@ -66,7 +66,8 @@ limitations under the License.
}); });
test('renders', () => { test('renders', () => {
const rows = element.$$('tbody').querySelectorAll('tr'); const rows = element.shadowRoot
.querySelector('tbody').querySelectorAll('tr');
let tds; let tds;
// The `+ 1` is for the number column, which isn't included in the change // The `+ 1` is for the number column, which isn't included in the change
@@ -79,7 +80,8 @@ limitations under the License.
}); });
test('hide item', () => { test('hide item', () => {
const checkbox = element.$$('table tr:nth-child(2) input'); const checkbox = element.shadowRoot
.querySelector('table tr:nth-child(2) input');
const isChecked = checkbox.checked; const isChecked = checkbox.checked;
const displayedLength = element.displayedColumns.length; const displayedLength = element.displayedColumns.length;
assert.isTrue(isChecked); assert.isTrue(isChecked);
@@ -100,11 +102,13 @@ limitations under the License.
'Updated', 'Updated',
]); ]);
flushAsynchronousOperations(); flushAsynchronousOperations();
const checkbox = element.$$('table tr:nth-child(2) input'); const checkbox = element.shadowRoot
.querySelector('table tr:nth-child(2) input');
const isChecked = checkbox.checked; const isChecked = checkbox.checked;
const displayedLength = element.displayedColumns.length; const displayedLength = element.displayedColumns.length;
assert.isFalse(isChecked); assert.isFalse(isChecked);
assert.equal(element.$$('table').style.display, ''); assert.equal(element.shadowRoot
.querySelector('table').style.display, '');
MockInteractions.tap(checkbox); MockInteractions.tap(checkbox);
flushAsynchronousOperations(); flushAsynchronousOperations();
@@ -116,7 +120,8 @@ limitations under the License.
test('_getDisplayedColumns', () => { test('_getDisplayedColumns', () => {
assert.deepEqual(element._getDisplayedColumns(), columns); assert.deepEqual(element._getDisplayedColumns(), columns);
MockInteractions.tap( MockInteractions.tap(
element.$$('.checkboxContainer input[name=Assignee]')); element.shadowRoot
.querySelector('.checkboxContainer input[name=Assignee]'));
assert.deepEqual(element._getDisplayedColumns(), assert.deepEqual(element._getDisplayedColumns(),
columns.filter(c => c !== 'Assignee')); columns.filter(c => c !== 'Assignee'));
}); });
@@ -126,12 +131,14 @@ limitations under the License.
sandbox.stub(element, '_handleTargetClick'); sandbox.stub(element, '_handleTargetClick');
MockInteractions.tap( MockInteractions.tap(
element.$$('table tr:first-of-type .checkboxContainer')); element.shadowRoot
.querySelector('table tr:first-of-type .checkboxContainer'));
assert.isTrue(element._handleNumberCheckboxClick.calledOnce); assert.isTrue(element._handleNumberCheckboxClick.calledOnce);
assert.isFalse(element._handleTargetClick.called); assert.isFalse(element._handleTargetClick.called);
MockInteractions.tap( MockInteractions.tap(
element.$$('table tr:last-of-type .checkboxContainer')); element.shadowRoot
.querySelector('table tr:last-of-type .checkboxContainer'));
assert.isTrue(element._handleNumberCheckboxClick.calledOnce); assert.isTrue(element._handleNumberCheckboxClick.calledOnce);
assert.isTrue(element._handleTargetClick.calledOnce); assert.isTrue(element._handleTargetClick.calledOnce);
}); });
@@ -140,12 +147,14 @@ limitations under the License.
sandbox.spy(element, '_handleNumberCheckboxClick'); sandbox.spy(element, '_handleNumberCheckboxClick');
MockInteractions MockInteractions
.tap(element.$$('.checkboxContainer input[name=number]')); .tap(element.shadowRoot
.querySelector('.checkboxContainer input[name=number]'));
assert.isTrue(element._handleNumberCheckboxClick.calledOnce); assert.isTrue(element._handleNumberCheckboxClick.calledOnce);
assert.isTrue(element.showNumber); assert.isTrue(element.showNumber);
MockInteractions MockInteractions
.tap(element.$$('.checkboxContainer input[name=number]')); .tap(element.shadowRoot
.querySelector('.checkboxContainer input[name=number]'));
assert.isTrue(element._handleNumberCheckboxClick.calledTwice); assert.isTrue(element._handleNumberCheckboxClick.calledTwice);
assert.isFalse(element.showNumber); assert.isFalse(element.showNumber);
}); });
@@ -154,7 +163,8 @@ limitations under the License.
sandbox.spy(element, '_handleTargetClick'); sandbox.spy(element, '_handleTargetClick');
assert.include(element.displayedColumns, 'Assignee'); assert.include(element.displayedColumns, 'Assignee');
MockInteractions MockInteractions
.tap(element.$$('.checkboxContainer input[name=Assignee]')); .tap(element.shadowRoot
.querySelector('.checkboxContainer input[name=Assignee]'));
assert.isTrue(element._handleTargetClick.calledOnce); assert.isTrue(element._handleTargetClick.calledOnce);
assert.notInclude(element.displayedColumns, 'Assignee'); assert.notInclude(element.displayedColumns, 'Assignee');
}); });

View File

@@ -57,7 +57,8 @@ limitations under the License.
}); });
test('renders', () => { test('renders', () => {
const rows = element.$$('table').querySelectorAll('tbody tr'); const rows = element.shadowRoot
.querySelector('table').querySelectorAll('tbody tr');
assert.equal(rows.length, 3); assert.equal(rows.length, 3);
@@ -75,7 +76,8 @@ limitations under the License.
test('edit preferred', () => { test('edit preferred', () => {
const preferredChangedSpy = sinon.spy(element, '_handlePreferredChange'); const preferredChangedSpy = sinon.spy(element, '_handlePreferredChange');
const radios = element.$$('table').querySelectorAll('input[type=radio]'); const radios = element.shadowRoot
.querySelector('table').querySelectorAll('input[type=radio]');
assert.isFalse(element.hasUnsavedChanges); assert.isFalse(element.hasUnsavedChanges);
assert.isNotOk(element._newPreferred); assert.isNotOk(element._newPreferred);
@@ -97,7 +99,8 @@ limitations under the License.
}); });
test('delete email', () => { test('delete email', () => {
const buttons = element.$$('table').querySelectorAll('gr-button'); const buttons = element.shadowRoot
.querySelector('table').querySelectorAll('gr-button');
assert.isFalse(element.hasUnsavedChanges); assert.isFalse(element.hasUnsavedChanges);
assert.isNotOk(element._newPreferred); assert.isNotOk(element._newPreferred);
@@ -119,7 +122,8 @@ limitations under the License.
sinon.stub(element.$.restAPI, 'deleteAccountEmail'); sinon.stub(element.$.restAPI, 'deleteAccountEmail');
const setPreferredStub = sinon.stub(element.$.restAPI, const setPreferredStub = sinon.stub(element.$.restAPI,
'setPreferredAccountEmail'); 'setPreferredAccountEmail');
const rows = element.$$('table').querySelectorAll('tbody tr'); const rows = element.shadowRoot
.querySelector('table').querySelectorAll('tbody tr');
assert.isFalse(element.hasUnsavedChanges); assert.isFalse(element.hasUnsavedChanges);
assert.isNotOk(element._newPreferred); assert.isNotOk(element._newPreferred);

View File

@@ -55,8 +55,10 @@ limitations under the License.
const selector = 'tr:nth-child(' + (index + 1) + ') .move' + const selector = 'tr:nth-child(' + (index + 1) + ') .move' +
direction + 'Button'; direction + 'Button';
const button = const button =
element.$$('tbody').querySelector(selector) element.shadowRoot
.$$('paper-button'); .querySelector('tbody').querySelector(selector)
.shadowRoot
.querySelector('paper-button');
MockInteractions.tap(button); MockInteractions.tap(button);
} }
@@ -73,7 +75,8 @@ limitations under the License.
}); });
test('renders', () => { test('renders', () => {
const rows = element.$$('tbody').querySelectorAll('tr'); const rows = element.shadowRoot
.querySelector('tbody').querySelectorAll('tr');
let tds; let tds;
assert.equal(rows.length, menu.length); assert.equal(rows.length, menu.length);
@@ -149,17 +152,21 @@ limitations under the License.
['first name', 'second name', 'third name']); ['first name', 'second name', 'third name']);
// Tap the delete button for the middle item. // Tap the delete button for the middle item.
MockInteractions.tap(element.$$('tbody') MockInteractions.tap(element.shadowRoot
.querySelector('tbody')
.querySelector('tr:nth-child(2) .remove-button') .querySelector('tr:nth-child(2) .remove-button')
.$$('paper-button')); .shadowRoot
.querySelector('paper-button'));
assertMenuNamesEqual(element, ['first name', 'third name']); assertMenuNamesEqual(element, ['first name', 'third name']);
// Delete remaining items. // Delete remaining items.
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
MockInteractions.tap(element.$$('tbody') MockInteractions.tap(element.shadowRoot
.querySelector('tbody')
.querySelector('tr:first-child .remove-button') .querySelector('tr:first-child .remove-button')
.$$('paper-button')); .shadowRoot
.querySelector('paper-button'));
} }
assertMenuNamesEqual(element, []); assertMenuNamesEqual(element, []);

View File

@@ -84,7 +84,8 @@ limitations under the License.
}); });
test('renders', () => { test('renders', () => {
const rows = element.$$('table').querySelectorAll('tbody tr'); const rows = element.shadowRoot
.querySelector('table').querySelectorAll('tbody tr');
assert.equal(rows.length, 4); assert.equal(rows.length, 4);
function getKeysOfRow(row) { function getKeysOfRow(row) {
@@ -200,12 +201,14 @@ limitations under the License.
test('_handleRemoveProject', () => { test('_handleRemoveProject', () => {
assert.equal(element._projectsToRemove, 0); assert.equal(element._projectsToRemove, 0);
const button = element.$$('table tbody tr:nth-child(2) gr-button'); const button = element.shadowRoot
.querySelector('table tbody tr:nth-child(2) gr-button');
MockInteractions.tap(button); MockInteractions.tap(button);
flushAsynchronousOperations(); flushAsynchronousOperations();
const rows = element.$$('table tbody').querySelectorAll('tr'); const rows = element.shadowRoot
.querySelector('table tbody').querySelectorAll('tr');
assert.equal(rows.length, 3); assert.equal(rows.length, 3);
assert.equal(element._projectsToRemove.length, 1); assert.equal(element._projectsToRemove.length, 1);

View File

@@ -166,7 +166,8 @@ limitations under the License.
test('status text should not have tooltip', () => { test('status text should not have tooltip', () => {
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.deepEqual(element.$$('gr-limited-text').title, ''); assert.deepEqual(element.shadowRoot
.querySelector('gr-limited-text').title, '');
}); });
test('status text should honor the name length and total length', () => { test('status text should honor the name length and total length', () => {

View File

@@ -54,7 +54,8 @@ limitations under the License.
test('action event', done => { test('action event', done => {
element.show(); element.show();
element._actionCallback = done; element._actionCallback = done;
MockInteractions.tap(element.$$('.action')); MockInteractions.tap(element.shadowRoot
.querySelector('.action'));
}); });
}); });
</script> </script>

View File

@@ -371,7 +371,8 @@ limitations under the License.
test('_focused flag properly triggered', done => { test('_focused flag properly triggered', done => {
flush(() => { flush(() => {
assert.isFalse(element._focused); assert.isFalse(element._focused);
const input = element.$$('paper-input').inputElement; const input = element.shadowRoot
.querySelector('paper-input').inputElement;
MockInteractions.focus(input); MockInteractions.focus(input);
assert.isTrue(element._focused); assert.isTrue(element._focused);
done(); done();
@@ -380,11 +381,13 @@ limitations under the License.
test('search icon shows with showSearchIcon property', done => { test('search icon shows with showSearchIcon property', done => {
flush(() => { flush(() => {
assert.equal(getComputedStyle(element.$$('iron-icon')).display, assert.equal(getComputedStyle(element.shadowRoot
'none'); .querySelector('iron-icon')).display,
'none');
element.showSearchIcon = true; element.showSearchIcon = true;
assert.notEqual(getComputedStyle(element.$$('iron-icon')).display, assert.notEqual(getComputedStyle(element.shadowRoot
'none'); .querySelector('iron-icon')).display,
'none');
done(); done();
}); });
}); });
@@ -517,7 +520,8 @@ limitations under the License.
assert.isFalse(element.$.suggestions.isHidden); assert.isFalse(element.$.suggestions.isHidden);
MockInteractions.pressAndReleaseKeyOn( MockInteractions.pressAndReleaseKeyOn(
element.$.suggestions.$$('li:first-child'), 9, null, 'tab'); element.$.suggestions.shadowRoot
.querySelector('li:first-child'), 9, null, 'tab');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(commitSpy.called); assert.isFalse(commitSpy.called);
assert.isFalse(element._focused); assert.isFalse(element._focused);
@@ -533,7 +537,8 @@ limitations under the License.
assert.isFalse(element.$.suggestions.isHidden); assert.isFalse(element.$.suggestions.isHidden);
MockInteractions.pressAndReleaseKeyOn( MockInteractions.pressAndReleaseKeyOn(
element.$.suggestions.$$('li:first-child'), 9, null, 'tab'); element.$.suggestions.shadowRoot
.querySelector('li:first-child'), 9, null, 'tab');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(commitSpy.called); assert.isTrue(commitSpy.called);
@@ -546,7 +551,8 @@ limitations under the License.
element._suggestions = [{name: 'first suggestion'}]; element._suggestions = [{name: 'first suggestion'}];
Polymer.dom.flush(); Polymer.dom.flush();
assert.isFalse(element.$.suggestions.isHidden); assert.isFalse(element.$.suggestions.isHidden);
MockInteractions.tap(element.$.suggestions.$$('li:first-child')); MockInteractions.tap(element.$.suggestions.shadowRoot
.querySelector('li:first-child'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(focusSpy.called); assert.isFalse(focusSpy.called);

View File

@@ -61,13 +61,17 @@ limitations under the License.
}); });
test('disabled is set by disabled or loading', () => { test('disabled is set by disabled or loading', () => {
assert.isFalse(element.$$('paper-button').disabled); assert.isFalse(element.shadowRoot
.querySelector('paper-button').disabled);
element.disabled = true; element.disabled = true;
assert.isTrue(element.$$('paper-button').disabled); assert.isTrue(element.shadowRoot
.querySelector('paper-button').disabled);
element.disabled = false; element.disabled = false;
assert.isFalse(element.$$('paper-button').disabled); assert.isFalse(element.shadowRoot
.querySelector('paper-button').disabled);
element.loading = true; element.loading = true;
assert.isTrue(element.$$('paper-button').disabled); assert.isTrue(element.shadowRoot
.querySelector('paper-button').disabled);
}); });
test('tabindex should be -1 if disabled', () => { test('tabindex should be -1 if disabled', () => {

View File

@@ -50,12 +50,14 @@ limitations under the License.
test('star visibility states', () => { test('star visibility states', () => {
element.set('change.starred', true); element.set('change.starred', true);
let icon = element.$$('iron-icon'); let icon = element.shadowRoot
.querySelector('iron-icon');
assert.isTrue(icon.classList.contains('active')); assert.isTrue(icon.classList.contains('active'));
assert.equal(icon.icon, 'gr-icons:star'); assert.equal(icon.icon, 'gr-icons:star');
element.set('change.starred', false); element.set('change.starred', false);
icon = element.$$('iron-icon'); icon = element.shadowRoot
.querySelector('iron-icon');
assert.isFalse(icon.classList.contains('active')); assert.isFalse(icon.classList.contains('active'));
assert.equal(icon.icon, 'gr-icons:star-border'); assert.equal(icon.icon, 'gr-icons:star-border');
}); });
@@ -66,7 +68,8 @@ limitations under the License.
done(); done();
}); });
element.set('change.starred', false); element.set('change.starred', false);
MockInteractions.tap(element.$$('button')); MockInteractions.tap(element.shadowRoot
.querySelector('button'));
}); });
test('unstarring', done => { test('unstarring', done => {
@@ -75,7 +78,8 @@ limitations under the License.
done(); done();
}); });
element.set('change.starred', true); element.set('change.starred', true);
MockInteractions.tap(element.$$('button')); MockInteractions.tap(element.shadowRoot
.querySelector('button'));
}); });
}); });
</script> </script>

View File

@@ -63,7 +63,8 @@ limitations under the License.
test('WIP', () => { test('WIP', () => {
element.status = 'WIP'; element.status = 'WIP';
assert.equal(element.$$('.chip').innerText, 'Work in Progress'); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, 'Work in Progress');
assert.equal(element.tooltipText, WIP_TOOLTIP); assert.equal(element.tooltipText, WIP_TOOLTIP);
assert.isTrue(element.classList.contains('wip')); assert.isTrue(element.classList.contains('wip'));
}); });
@@ -71,7 +72,8 @@ limitations under the License.
test('WIP flat', () => { test('WIP flat', () => {
element.flat = true; element.flat = true;
element.status = 'WIP'; element.status = 'WIP';
assert.equal(element.$$('.chip').innerText, 'WIP'); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, 'WIP');
assert.isDefined(element.tooltipText); assert.isDefined(element.tooltipText);
assert.isTrue(element.classList.contains('wip')); assert.isTrue(element.classList.contains('wip'));
assert.isTrue(element.hasAttribute('flat')); assert.isTrue(element.hasAttribute('flat'));
@@ -79,42 +81,48 @@ limitations under the License.
test('merged', () => { test('merged', () => {
element.status = 'Merged'; element.status = 'Merged';
assert.equal(element.$$('.chip').innerText, element.status); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, element.status);
assert.equal(element.tooltipText, ''); assert.equal(element.tooltipText, '');
assert.isTrue(element.classList.contains('merged')); assert.isTrue(element.classList.contains('merged'));
}); });
test('abandoned', () => { test('abandoned', () => {
element.status = 'Abandoned'; element.status = 'Abandoned';
assert.equal(element.$$('.chip').innerText, element.status); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, element.status);
assert.equal(element.tooltipText, ''); assert.equal(element.tooltipText, '');
assert.isTrue(element.classList.contains('abandoned')); assert.isTrue(element.classList.contains('abandoned'));
}); });
test('merge conflict', () => { test('merge conflict', () => {
element.status = 'Merge Conflict'; element.status = 'Merge Conflict';
assert.equal(element.$$('.chip').innerText, element.status); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, element.status);
assert.equal(element.tooltipText, MERGE_CONFLICT_TOOLTIP); assert.equal(element.tooltipText, MERGE_CONFLICT_TOOLTIP);
assert.isTrue(element.classList.contains('merge-conflict')); assert.isTrue(element.classList.contains('merge-conflict'));
}); });
test('private', () => { test('private', () => {
element.status = 'Private'; element.status = 'Private';
assert.equal(element.$$('.chip').innerText, element.status); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, element.status);
assert.equal(element.tooltipText, PRIVATE_TOOLTIP); assert.equal(element.tooltipText, PRIVATE_TOOLTIP);
assert.isTrue(element.classList.contains('private')); assert.isTrue(element.classList.contains('private'));
}); });
test('active', () => { test('active', () => {
element.status = 'Active'; element.status = 'Active';
assert.equal(element.$$('.chip').innerText, element.status); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, element.status);
assert.equal(element.tooltipText, ''); assert.equal(element.tooltipText, '');
assert.isTrue(element.classList.contains('active')); assert.isTrue(element.classList.contains('active'));
}); });
test('ready to submit', () => { test('ready to submit', () => {
element.status = 'Ready to submit'; element.status = 'Ready to submit';
assert.equal(element.$$('.chip').innerText, element.status); assert.equal(element.shadowRoot
.querySelector('.chip').innerText, element.status);
assert.equal(element.tooltipText, ''); assert.equal(element.tooltipText, '');
assert.isTrue(element.classList.contains('ready-to-submit')); assert.isTrue(element.classList.contains('ready-to-submit'));
}); });

View File

@@ -202,7 +202,8 @@ limitations under the License.
test('optionally show file path', () => { test('optionally show file path', () => {
// Path info doesn't exist when showFilePath is false. Because it's in a // Path info doesn't exist when showFilePath is false. Because it's in a
// dom-if it is not yet in the dom. // dom-if it is not yet in the dom.
assert.isNotOk(element.$$('.pathInfo')); assert.isNotOk(element.shadowRoot
.querySelector('.pathInfo'));
sandbox.stub(Gerrit.Nav, 'getUrlForDiffById'); sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
element.changeNum = 123; element.changeNum = 123;
@@ -212,9 +213,11 @@ limitations under the License.
element.lineNum = 5; element.lineNum = 5;
element.showFilePath = true; element.showFilePath = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isOk(element.$$('.pathInfo')); assert.isOk(element.shadowRoot
assert.notEqual(getComputedStyle(element.$$('.pathInfo')).display, .querySelector('.pathInfo'));
'none'); assert.notEqual(getComputedStyle(element.shadowRoot
.querySelector('.pathInfo')).display,
'none');
assert.isTrue(Gerrit.Nav.getUrlForDiffById.lastCall.calledWithExactly( assert.isTrue(Gerrit.Nav.getUrlForDiffById.lastCall.calledWithExactly(
element.changeNum, element.projectName, element.path, element.changeNum, element.projectName, element.path,
element.patchNum, null, element.lineNum)); element.patchNum, null, element.lineNum));
@@ -276,7 +279,8 @@ limitations under the License.
}); });
test('reply', () => { test('reply', () => {
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
const reportStub = sandbox.stub(element.$.reporting, const reportStub = sandbox.stub(element.$.reporting,
'recordDraftInteraction'); 'recordDraftInteraction');
assert.ok(commentEl); assert.ok(commentEl);
@@ -293,7 +297,8 @@ limitations under the License.
}); });
test('quote reply', () => { test('quote reply', () => {
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
const reportStub = sandbox.stub(element.$.reporting, const reportStub = sandbox.stub(element.$.reporting,
'recordDraftInteraction'); 'recordDraftInteraction');
assert.ok(commentEl); assert.ok(commentEl);
@@ -324,7 +329,8 @@ limitations under the License.
}]; }];
flushAsynchronousOperations(); flushAsynchronousOperations();
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
assert.ok(commentEl); assert.ok(commentEl);
const quoteBtn = element.$.quoteBtn; const quoteBtn = element.$.quoteBtn;
@@ -345,7 +351,8 @@ limitations under the License.
element.changeNum = '42'; element.changeNum = '42';
element.patchNum = '1'; element.patchNum = '1';
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
assert.ok(commentEl); assert.ok(commentEl);
const ackBtn = element.$.ackBtn; const ackBtn = element.$.ackBtn;
@@ -366,7 +373,8 @@ limitations under the License.
'recordDraftInteraction'); 'recordDraftInteraction');
element.changeNum = '42'; element.changeNum = '42';
element.patchNum = '1'; element.patchNum = '1';
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
assert.ok(commentEl); assert.ok(commentEl);
const doneBtn = element.$.doneBtn; const doneBtn = element.$.doneBtn;
@@ -386,12 +394,14 @@ limitations under the License.
element.changeNum = '42'; element.changeNum = '42';
element.patchNum = '1'; element.patchNum = '1';
element.path = '/path/to/file.txt'; element.path = '/path/to/file.txt';
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
assert.ok(commentEl); assert.ok(commentEl);
const saveOrDiscardStub = sandbox.stub(); const saveOrDiscardStub = sandbox.stub();
element.addEventListener('thread-changed', saveOrDiscardStub); element.addEventListener('thread-changed', saveOrDiscardStub);
element.$$('gr-comment')._fireSave(); element.shadowRoot
.querySelector('gr-comment')._fireSave();
flush(() => { flush(() => {
assert.isTrue(saveOrDiscardStub.called); assert.isTrue(saveOrDiscardStub.called);
@@ -407,7 +417,8 @@ limitations under the License.
test('please fix', done => { test('please fix', done => {
element.changeNum = '42'; element.changeNum = '42';
element.patchNum = '1'; element.patchNum = '1';
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
assert.ok(commentEl); assert.ok(commentEl);
commentEl.addEventListener('create-fix-comment', () => { commentEl.addEventListener('create-fix-comment', () => {
const drafts = element._orderedComments.filter(c => c.__draft == true); const drafts = element._orderedComments.filter(c => c.__draft == true);
@@ -558,7 +569,8 @@ limitations under the License.
}); });
test('comment-update', () => { test('comment-update', () => {
const commentEl = element.$$('gr-comment'); const commentEl = element.shadowRoot
.querySelector('gr-comment');
const updatedComment = { const updatedComment = {
id: element.comments[0].id, id: element.comments[0].id,
foo: 'bar', foo: 'bar',

View File

@@ -433,7 +433,7 @@
this.$.container.classList.toggle('editing', editing); this.$.container.classList.toggle('editing', editing);
if (this.comment && this.comment.id) { if (this.comment && this.comment.id) {
this.$$('.cancel').hidden = !editing; this.shadowRoot.querySelector('.cancel').hidden = !editing;
} }
if (this.comment) { if (this.comment) {
this.comment.__editing = this.editing; this.comment.__editing = this.editing;

View File

@@ -81,34 +81,41 @@ limitations under the License.
test('collapsible comments', () => { test('collapsible comments', () => {
// When a comment (not draft) is loaded, it should be collapsed // When a comment (not draft) is loaded, it should be collapsed
assert.isTrue(element.collapsed); assert.isTrue(element.collapsed);
assert.isFalse(isVisible(element.$$('gr-formatted-text')), assert.isFalse(isVisible(element.shadowRoot
'gr-formatted-text is not visible'); .querySelector('gr-formatted-text')),
assert.isFalse(isVisible(element.$$('.actions')), 'gr-formatted-text is not visible');
'actions are not visible'); assert.isFalse(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are not visible');
assert.isNotOk(element.textarea, 'textarea is not visible'); assert.isNotOk(element.textarea, 'textarea is not visible');
// The header middle content is only visible when comments are collapsed. // The header middle content is only visible when comments are collapsed.
// It shows the message in a condensed way, and limits to a single line. // It shows the message in a condensed way, and limits to a single line.
assert.isTrue(isVisible(element.$$('.collapsedContent')), assert.isTrue(isVisible(element.shadowRoot
'header middle content is visible'); .querySelector('.collapsedContent')),
'header middle content is visible');
// When the header row is clicked, the comment should expand // When the header row is clicked, the comment should expand
MockInteractions.tap(element.$.header); MockInteractions.tap(element.$.header);
assert.isFalse(element.collapsed); assert.isFalse(element.collapsed);
assert.isTrue(isVisible(element.$$('gr-formatted-text')), assert.isTrue(isVisible(element.shadowRoot
'gr-formatted-text is visible'); .querySelector('gr-formatted-text')),
assert.isTrue(isVisible(element.$$('.actions')), 'gr-formatted-text is visible');
'actions are visible'); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are visible');
assert.isNotOk(element.textarea, 'textarea is not visible'); assert.isNotOk(element.textarea, 'textarea is not visible');
assert.isFalse(isVisible(element.$$('.collapsedContent')), assert.isFalse(isVisible(element.shadowRoot
'header middle content is not visible'); .querySelector('.collapsedContent')),
'header middle content is not visible');
}); });
test('clicking on date link fires event', () => { test('clicking on date link fires event', () => {
element.side = 'PARENT'; element.side = 'PARENT';
const stub = sinon.stub(); const stub = sinon.stub();
element.addEventListener('comment-anchor-tap', stub); element.addEventListener('comment-anchor-tap', stub);
const dateEl = element.$$('.date'); const dateEl = element.shadowRoot
.querySelector('.date');
assert.ok(dateEl); assert.ok(dateEl);
MockInteractions.tap(dateEl); MockInteractions.tap(dateEl);
@@ -168,23 +175,29 @@ limitations under the License.
test('comment expand and collapse', () => { test('comment expand and collapse', () => {
element.collapsed = true; element.collapsed = true;
assert.isFalse(isVisible(element.$$('gr-formatted-text')), assert.isFalse(isVisible(element.shadowRoot
'gr-formatted-text is not visible'); .querySelector('gr-formatted-text')),
assert.isFalse(isVisible(element.$$('.actions')), 'gr-formatted-text is not visible');
'actions are not visible'); assert.isFalse(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are not visible');
assert.isNotOk(element.textarea, 'textarea is not visible'); assert.isNotOk(element.textarea, 'textarea is not visible');
assert.isTrue(isVisible(element.$$('.collapsedContent')), assert.isTrue(isVisible(element.shadowRoot
'header middle content is visible'); .querySelector('.collapsedContent')),
'header middle content is visible');
element.collapsed = false; element.collapsed = false;
assert.isFalse(element.collapsed); assert.isFalse(element.collapsed);
assert.isTrue(isVisible(element.$$('gr-formatted-text')), assert.isTrue(isVisible(element.shadowRoot
'gr-formatted-text is visible'); .querySelector('gr-formatted-text')),
assert.isTrue(isVisible(element.$$('.actions')), 'gr-formatted-text is visible');
'actions are visible'); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are visible');
assert.isNotOk(element.textarea, 'textarea is not visible'); assert.isNotOk(element.textarea, 'textarea is not visible');
assert.isFalse(isVisible(element.$$('.collapsedContent')), assert.isFalse(isVisible(element.shadowRoot
'header middle content is is not visible'); .querySelector('.collapsedContent')),
'header middle content is is not visible');
}); });
suite('while editing', () => { suite('while editing', () => {
@@ -253,14 +266,16 @@ limitations under the License.
}); });
test('delete comment button for non-admins is hidden', () => { test('delete comment button for non-admins is hidden', () => {
element._isAdmin = false; element._isAdmin = false;
assert.isFalse(element.$$('.action.delete') assert.isFalse(element.shadowRoot
.querySelector('.action.delete')
.classList.contains('showDeleteButtons')); .classList.contains('showDeleteButtons'));
}); });
test('delete comment button for admins with draft is hidden', () => { test('delete comment button for admins with draft is hidden', () => {
element._isAdmin = false; element._isAdmin = false;
element.draft = true; element.draft = true;
assert.isFalse(element.$$('.action.delete') assert.isFalse(element.shadowRoot
.querySelector('.action.delete')
.classList.contains('showDeleteButtons')); .classList.contains('showDeleteButtons'));
}); });
@@ -271,9 +286,11 @@ limitations under the License.
element.changeNum = 42; element.changeNum = 42;
element.patchNum = 0xDEADBEEF; element.patchNum = 0xDEADBEEF;
element._isAdmin = true; element._isAdmin = true;
assert.isTrue(element.$$('.action.delete') assert.isTrue(element.shadowRoot
.querySelector('.action.delete')
.classList.contains('showDeleteButtons')); .classList.contains('showDeleteButtons'));
MockInteractions.tap(element.$$('.action.delete')); MockInteractions.tap(element.shadowRoot
.querySelector('.action.delete'));
flush(() => { flush(() => {
element.confirmDeleteOverlay.open.lastCall.returnValue.then(() => { element.confirmDeleteOverlay.open.lastCall.returnValue.then(() => {
const dialog = const dialog =
@@ -336,7 +353,8 @@ limitations under the License.
test('edit reports interaction', () => { test('edit reports interaction', () => {
const reportStub = sandbox.stub(element.$.reporting, const reportStub = sandbox.stub(element.$.reporting,
'recordDraftInteraction'); 'recordDraftInteraction');
MockInteractions.tap(element.$$('.edit')); MockInteractions.tap(element.shadowRoot
.querySelector('.edit'));
assert.isTrue(reportStub.calledOnce); assert.isTrue(reportStub.calledOnce);
}); });
@@ -344,7 +362,8 @@ limitations under the License.
const reportStub = sandbox.stub(element.$.reporting, const reportStub = sandbox.stub(element.$.reporting,
'recordDraftInteraction'); 'recordDraftInteraction');
element.draft = true; element.draft = true;
MockInteractions.tap(element.$$('.discard')); MockInteractions.tap(element.shadowRoot
.querySelector('.discard'));
assert.isTrue(reportStub.calledOnce); assert.isTrue(reportStub.calledOnce);
}); });
}); });
@@ -400,77 +419,110 @@ limitations under the License.
test('button visibility states', () => { test('button visibility states', () => {
element.showActions = false; element.showActions = false;
assert.isTrue(element.$$('.humanActions').hasAttribute('hidden')); assert.isTrue(element.shadowRoot
assert.isTrue(element.$$('.robotActions').hasAttribute('hidden')); .querySelector('.humanActions').hasAttribute('hidden'));
assert.isTrue(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
element.showActions = true; element.showActions = true;
assert.isFalse(element.$$('.humanActions').hasAttribute('hidden')); assert.isFalse(element.shadowRoot
assert.isTrue(element.$$('.robotActions').hasAttribute('hidden')); .querySelector('.humanActions').hasAttribute('hidden'));
assert.isTrue(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
element.draft = true; element.draft = true;
assert.isTrue(isVisible(element.$$('.edit')), 'edit is visible'); assert.isTrue(isVisible(element.shadowRoot
assert.isTrue(isVisible(element.$$('.discard')), 'discard is visible'); .querySelector('.edit')), 'edit is visible');
assert.isFalse(isVisible(element.$$('.save')), 'save is not visible'); assert.isTrue(isVisible(element.shadowRoot
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible'); .querySelector('.discard')), 'discard is visible');
assert.isTrue(isVisible(element.$$('.resolve')), 'resolve is visible'); assert.isFalse(isVisible(element.shadowRoot
assert.isFalse(element.$$('.humanActions').hasAttribute('hidden')); .querySelector('.save')), 'save is not visible');
assert.isTrue(element.$$('.robotActions').hasAttribute('hidden')); assert.isFalse(isVisible(element.shadowRoot
.querySelector('.cancel')), 'cancel is not visible');
assert.isTrue(isVisible(element.shadowRoot
.querySelector('.resolve')), 'resolve is visible');
assert.isFalse(element.shadowRoot
.querySelector('.humanActions').hasAttribute('hidden'));
assert.isTrue(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
element.editing = true; element.editing = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(isVisible(element.$$('.edit')), 'edit is not visible'); assert.isFalse(isVisible(element.shadowRoot
assert.isFalse(isVisible(element.$$('.discard')), 'discard not visible'); .querySelector('.edit')), 'edit is not visible');
assert.isTrue(isVisible(element.$$('.save')), 'save is visible'); assert.isFalse(isVisible(element.shadowRoot
assert.isTrue(isVisible(element.$$('.cancel')), 'cancel is visible'); .querySelector('.discard')), 'discard not visible');
assert.isTrue(isVisible(element.$$('.resolve')), 'resolve is visible'); assert.isTrue(isVisible(element.shadowRoot
assert.isFalse(element.$$('.humanActions').hasAttribute('hidden')); .querySelector('.save')), 'save is visible');
assert.isTrue(element.$$('.robotActions').hasAttribute('hidden')); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.cancel')), 'cancel is visible');
assert.isTrue(isVisible(element.shadowRoot
.querySelector('.resolve')), 'resolve is visible');
assert.isFalse(element.shadowRoot
.querySelector('.humanActions').hasAttribute('hidden'));
assert.isTrue(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
element.draft = false; element.draft = false;
element.editing = false; element.editing = false;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(isVisible(element.$$('.edit')), 'edit is not visible'); assert.isFalse(isVisible(element.shadowRoot
assert.isFalse(isVisible(element.$$('.discard')), .querySelector('.edit')), 'edit is not visible');
'discard is not visible'); assert.isFalse(isVisible(element.shadowRoot
assert.isFalse(isVisible(element.$$('.save')), 'save is not visible'); .querySelector('.discard')),
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is not visible'); 'discard is not visible');
assert.isFalse(element.$$('.humanActions').hasAttribute('hidden')); assert.isFalse(isVisible(element.shadowRoot
assert.isTrue(element.$$('.robotActions').hasAttribute('hidden')); .querySelector('.save')), 'save is not visible');
assert.isFalse(isVisible(element.shadowRoot
.querySelector('.cancel')), 'cancel is not visible');
assert.isFalse(element.shadowRoot
.querySelector('.humanActions').hasAttribute('hidden'));
assert.isTrue(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
element.comment.id = 'foo'; element.comment.id = 'foo';
element.draft = true; element.draft = true;
element.editing = true; element.editing = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(isVisible(element.$$('.cancel')), 'cancel is visible'); assert.isTrue(isVisible(element.shadowRoot
assert.isFalse(element.$$('.humanActions').hasAttribute('hidden')); .querySelector('.cancel')), 'cancel is visible');
assert.isTrue(element.$$('.robotActions').hasAttribute('hidden')); assert.isFalse(element.shadowRoot
.querySelector('.humanActions').hasAttribute('hidden'));
assert.isTrue(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
// Delete button is not hidden by default // Delete button is not hidden by default
assert.isFalse(element.shadowRoot.querySelector('#deleteBtn').hidden); assert.isFalse(element.shadowRoot.querySelector('#deleteBtn').hidden);
element.isRobotComment = true; element.isRobotComment = true;
element.draft = true; element.draft = true;
assert.isTrue(element.$$('.humanActions').hasAttribute('hidden')); assert.isTrue(element.shadowRoot
assert.isFalse(element.$$('.robotActions').hasAttribute('hidden')); .querySelector('.humanActions').hasAttribute('hidden'));
assert.isFalse(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
// It is not expected to see Robot comment drafts, but if they appear, // It is not expected to see Robot comment drafts, but if they appear,
// they will behave the same as non-drafts. // they will behave the same as non-drafts.
element.draft = false; element.draft = false;
assert.isTrue(element.$$('.humanActions').hasAttribute('hidden')); assert.isTrue(element.shadowRoot
assert.isFalse(element.$$('.robotActions').hasAttribute('hidden')); .querySelector('.humanActions').hasAttribute('hidden'));
assert.isFalse(element.shadowRoot
.querySelector('.robotActions').hasAttribute('hidden'));
// A robot comment with run ID should display plain text. // A robot comment with run ID should display plain text.
element.set(['comment', 'robot_run_id'], 'text'); element.set(['comment', 'robot_run_id'], 'text');
element.editing = false; element.editing = false;
element.collapsed = false; element.collapsed = false;
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(element.$$('.robotRun.link').textContent === 'Run Details'); assert.isTrue(element.shadowRoot
.querySelector('.robotRun.link').textContent === 'Run Details');
// A robot comment with run ID and url should display a link. // A robot comment with run ID and url should display a link.
element.set(['comment', 'url'], '/path/to/run'); element.set(['comment', 'url'], '/path/to/run');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.notEqual(getComputedStyle(element.$$('.robotRun.link')).display, assert.notEqual(getComputedStyle(element.shadowRoot
'none'); .querySelector('.robotRun.link')).display,
'none');
// Delete button is hidden for robot comments // Delete button is hidden for robot comments
assert.isTrue(element.shadowRoot.querySelector('#deleteBtn').hidden); assert.isTrue(element.shadowRoot.querySelector('#deleteBtn').hidden);
@@ -478,60 +530,77 @@ limitations under the License.
test('collapsible drafts', () => { test('collapsible drafts', () => {
assert.isTrue(element.collapsed); assert.isTrue(element.collapsed);
assert.isFalse(isVisible(element.$$('gr-formatted-text')), assert.isFalse(isVisible(element.shadowRoot
'gr-formatted-text is not visible'); .querySelector('gr-formatted-text')),
assert.isFalse(isVisible(element.$$('.actions')), 'gr-formatted-text is not visible');
'actions are not visible'); assert.isFalse(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are not visible');
assert.isNotOk(element.textarea, 'textarea is not visible'); assert.isNotOk(element.textarea, 'textarea is not visible');
assert.isTrue(isVisible(element.$$('.collapsedContent')), assert.isTrue(isVisible(element.shadowRoot
'header middle content is visible'); .querySelector('.collapsedContent')),
'header middle content is visible');
MockInteractions.tap(element.$.header); MockInteractions.tap(element.$.header);
assert.isFalse(element.collapsed); assert.isFalse(element.collapsed);
assert.isTrue(isVisible(element.$$('gr-formatted-text')), assert.isTrue(isVisible(element.shadowRoot
'gr-formatted-text is visible'); .querySelector('gr-formatted-text')),
assert.isTrue(isVisible(element.$$('.actions')), 'gr-formatted-text is visible');
'actions are visible'); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are visible');
assert.isNotOk(element.textarea, 'textarea is not visible'); assert.isNotOk(element.textarea, 'textarea is not visible');
assert.isFalse(isVisible(element.$$('.collapsedContent')), assert.isFalse(isVisible(element.shadowRoot
'header middle content is is not visible'); .querySelector('.collapsedContent')),
'header middle content is is not visible');
// When the edit button is pressed, should still see the actions // When the edit button is pressed, should still see the actions
// and also textarea // and also textarea
MockInteractions.tap(element.$$('.edit')); MockInteractions.tap(element.shadowRoot
.querySelector('.edit'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isFalse(element.collapsed); assert.isFalse(element.collapsed);
assert.isFalse(isVisible(element.$$('gr-formatted-text')), assert.isFalse(isVisible(element.shadowRoot
'gr-formatted-text is not visible'); .querySelector('gr-formatted-text')),
assert.isTrue(isVisible(element.$$('.actions')), 'gr-formatted-text is not visible');
'actions are visible'); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are visible');
assert.isTrue(isVisible(element.textarea), 'textarea is visible'); assert.isTrue(isVisible(element.textarea), 'textarea is visible');
assert.isFalse(isVisible(element.$$('.collapsedContent')), assert.isFalse(isVisible(element.shadowRoot
'header middle content is not visible'); .querySelector('.collapsedContent')),
'header middle content is not visible');
// When toggle again, everything should be hidden except for textarea // When toggle again, everything should be hidden except for textarea
// and header middle content should be visible // and header middle content should be visible
MockInteractions.tap(element.$.header); MockInteractions.tap(element.$.header);
assert.isTrue(element.collapsed); assert.isTrue(element.collapsed);
assert.isFalse(isVisible(element.$$('gr-formatted-text')), assert.isFalse(isVisible(element.shadowRoot
'gr-formatted-text is not visible'); .querySelector('gr-formatted-text')),
assert.isFalse(isVisible(element.$$('.actions')), 'gr-formatted-text is not visible');
'actions are not visible'); assert.isFalse(isVisible(element.shadowRoot
assert.isFalse(isVisible(element.$$('gr-textarea')), .querySelector('.actions')),
'textarea is not visible'); 'actions are not visible');
assert.isTrue(isVisible(element.$$('.collapsedContent')), assert.isFalse(isVisible(element.shadowRoot
'header middle content is visible'); .querySelector('gr-textarea')),
'textarea is not visible');
assert.isTrue(isVisible(element.shadowRoot
.querySelector('.collapsedContent')),
'header middle content is visible');
// When toggle again, textarea should remain open in the state it was // When toggle again, textarea should remain open in the state it was
// before // before
MockInteractions.tap(element.$.header); MockInteractions.tap(element.$.header);
assert.isFalse(isVisible(element.$$('gr-formatted-text')), assert.isFalse(isVisible(element.shadowRoot
'gr-formatted-text is not visible'); .querySelector('gr-formatted-text')),
assert.isTrue(isVisible(element.$$('.actions')), 'gr-formatted-text is not visible');
'actions are visible'); assert.isTrue(isVisible(element.shadowRoot
.querySelector('.actions')),
'actions are visible');
assert.isTrue(isVisible(element.textarea), 'textarea is visible'); assert.isTrue(isVisible(element.textarea), 'textarea is visible');
assert.isFalse(isVisible(element.$$('.collapsedContent')), assert.isFalse(isVisible(element.shadowRoot
'header middle content is not visible'); .querySelector('.collapsedContent')),
'header middle content is not visible');
}); });
test('robot comment layout', () => { test('robot comment layout', () => {
@@ -547,37 +616,45 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
let runIdMessage; let runIdMessage;
runIdMessage = element.$$('.runIdMessage'); runIdMessage = element.shadowRoot
.querySelector('.runIdMessage');
assert.isFalse(runIdMessage.hidden); assert.isFalse(runIdMessage.hidden);
const runDetailsLink = element.$$('.robotRunLink'); const runDetailsLink = element.shadowRoot
.querySelector('.robotRunLink');
assert.isTrue(runDetailsLink.href.indexOf(element.comment.url) !== -1); assert.isTrue(runDetailsLink.href.indexOf(element.comment.url) !== -1);
const robotServiceName = element.$$('.authorName'); const robotServiceName = element.shadowRoot
.querySelector('.authorName');
assert.isTrue(robotServiceName.textContent === 'happy_robot_id'); assert.isTrue(robotServiceName.textContent === 'happy_robot_id');
const authorName = element.$$('.robotId'); const authorName = element.shadowRoot
.querySelector('.robotId');
assert.isTrue(authorName.innerText === 'Happy Robot'); assert.isTrue(authorName.innerText === 'Happy Robot');
element.collapsed = true; element.collapsed = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
runIdMessage = element.$$('.runIdMessage'); runIdMessage = element.shadowRoot
.querySelector('.runIdMessage');
assert.isTrue(runIdMessage.hidden); assert.isTrue(runIdMessage.hidden);
}); });
test('draft creation/cancellation', done => { test('draft creation/cancellation', done => {
assert.isFalse(element.editing); assert.isFalse(element.editing);
MockInteractions.tap(element.$$('.edit')); MockInteractions.tap(element.shadowRoot
.querySelector('.edit'));
assert.isTrue(element.editing); assert.isTrue(element.editing);
element._messageText = ''; element._messageText = '';
const eraseMessageDraftSpy = sandbox.spy(element, '_eraseDraftComment'); const eraseMessageDraftSpy = sandbox.spy(element, '_eraseDraftComment');
// Save should be disabled on an empty message. // Save should be disabled on an empty message.
let disabled = element.$$('.save').hasAttribute('disabled'); let disabled = element.shadowRoot
.querySelector('.save').hasAttribute('disabled');
assert.isTrue(disabled, 'save button should be disabled.'); assert.isTrue(disabled, 'save button should be disabled.');
element._messageText = ' '; element._messageText = ' ';
disabled = element.$$('.save').hasAttribute('disabled'); disabled = element.shadowRoot
.querySelector('.save').hasAttribute('disabled');
assert.isTrue(disabled, 'save button should be disabled.'); assert.isTrue(disabled, 'save button should be disabled.');
const updateStub = sinon.stub(); const updateStub = sinon.stub();
@@ -592,7 +669,8 @@ limitations under the License.
done(); done();
} }
}); });
MockInteractions.tap(element.$$('.cancel')); MockInteractions.tap(element.shadowRoot
.querySelector('.cancel'));
element.flushDebouncer('fire-update'); element.flushDebouncer('fire-update');
element._messageText = ''; element._messageText = '';
flushAsynchronousOperations(); flushAsynchronousOperations();
@@ -695,7 +773,8 @@ limitations under the License.
const cancelDebounce = sandbox.stub(element, 'cancelDebouncer'); const cancelDebounce = sandbox.stub(element, 'cancelDebouncer');
element.draft = true; element.draft = true;
MockInteractions.tap(element.$$('.edit')); MockInteractions.tap(element.shadowRoot
.querySelector('.edit'));
element._messageText = 'good news, everyone!'; element._messageText = 'good news, everyone!';
element.flushDebouncer('fire-update'); element.flushDebouncer('fire-update');
element.flushDebouncer('store'); element.flushDebouncer('store');
@@ -709,7 +788,8 @@ limitations under the License.
assert.isTrue(fireStub.calledOnce, assert.isTrue(fireStub.calledOnce,
'No events should fire for text editing'); 'No events should fire for text editing');
MockInteractions.tap(element.$$('.save')); MockInteractions.tap(element.shadowRoot
.querySelector('.save'));
assert.isTrue(element.disabled, assert.isTrue(element.disabled,
'Element should be disabled when creating draft.'); 'Element should be disabled when creating draft.');
@@ -737,10 +817,12 @@ limitations under the License.
assert.equal(draft.message, 'saved!'); assert.equal(draft.message, 'saved!');
assert.isFalse(element.editing); assert.isFalse(element.editing);
}).then(() => { }).then(() => {
MockInteractions.tap(element.$$('.edit')); MockInteractions.tap(element.shadowRoot
.querySelector('.edit'));
element._messageText = 'Youll be delivering a package to Chapek 9, ' + element._messageText = 'Youll be delivering a package to Chapek 9, ' +
'a world where humans are killed on sight.'; 'a world where humans are killed on sight.';
MockInteractions.tap(element.$$('.save')); MockInteractions.tap(element.shadowRoot
.querySelector('.save'));
assert.isTrue(element.disabled, assert.isTrue(element.disabled,
'Element should be disabled when updating draft.'); 'Element should be disabled when updating draft.');
@@ -760,17 +842,20 @@ limitations under the License.
element.showActions = true; element.showActions = true;
element.draft = true; element.draft = true;
MockInteractions.tap(element.$.header); MockInteractions.tap(element.$.header);
MockInteractions.tap(element.$$('.edit')); MockInteractions.tap(element.shadowRoot
.querySelector('.edit'));
element._messageText = 'good news, everyone!'; element._messageText = 'good news, everyone!';
element.flushDebouncer('fire-update'); element.flushDebouncer('fire-update');
element.flushDebouncer('store'); element.flushDebouncer('store');
element.disabled = true; element.disabled = true;
MockInteractions.tap(element.$$('.save')); MockInteractions.tap(element.shadowRoot
.querySelector('.save'));
assert.isFalse(saveStub.called); assert.isFalse(saveStub.called);
element.disabled = false; element.disabled = false;
MockInteractions.tap(element.$$('.save')); MockInteractions.tap(element.shadowRoot
.querySelector('.save'));
assert.isTrue(saveStub.calledOnce); assert.isTrue(saveStub.calledOnce);
}); });
@@ -781,15 +866,18 @@ limitations under the License.
assert.isFalse(save.called); assert.isFalse(save.called);
done(); done();
}); });
MockInteractions.tap(element.$$('.resolve input')); MockInteractions.tap(element.shadowRoot
.querySelector('.resolve input'));
}); });
test('resolved comment state indicated by checkbox', () => { test('resolved comment state indicated by checkbox', () => {
sandbox.stub(element, 'save'); sandbox.stub(element, 'save');
element.comment = {unresolved: false}; element.comment = {unresolved: false};
assert.isTrue(element.$$('.resolve input').checked); assert.isTrue(element.shadowRoot
.querySelector('.resolve input').checked);
element.comment = {unresolved: true}; element.comment = {unresolved: true};
assert.isFalse(element.$$('.resolve input').checked); assert.isFalse(element.shadowRoot
.querySelector('.resolve input').checked);
}); });
test('resolved checkbox saves with tap when !editing', () => { test('resolved checkbox saves with tap when !editing', () => {
@@ -797,12 +885,15 @@ limitations under the License.
const save = sandbox.stub(element, 'save'); const save = sandbox.stub(element, 'save');
element.comment = {unresolved: false}; element.comment = {unresolved: false};
assert.isTrue(element.$$('.resolve input').checked); assert.isTrue(element.shadowRoot
.querySelector('.resolve input').checked);
element.comment = {unresolved: true}; element.comment = {unresolved: true};
assert.isFalse(element.$$('.resolve input').checked); assert.isFalse(element.shadowRoot
.querySelector('.resolve input').checked);
assert.isFalse(save.called); assert.isFalse(save.called);
MockInteractions.tap(element.$.resolvedCheckbox); MockInteractions.tap(element.$.resolvedCheckbox);
assert.isTrue(element.$$('.resolve input').checked); assert.isTrue(element.shadowRoot
.querySelector('.resolve input').checked);
assert.isTrue(save.called); assert.isTrue(save.called);
}); });
@@ -881,7 +972,8 @@ limitations under the License.
element.comments = [element.comment]; element.comments = [element.comment];
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('.fix')); MockInteractions.tap(element.shadowRoot
.querySelector('.fix'));
}); });
test('do not show Please Fix button if human reply exists', () => { test('do not show Please Fix button if human reply exists', () => {
@@ -955,7 +1047,8 @@ limitations under the License.
]; ];
element.comment = element.comments[0]; element.comment = element.comments[0];
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNull(element.$$('robotActions gr-button')); assert.isNull(element.shadowRoot
.querySelector('robotActions gr-button'));
}); });
test('show Please Fix if no human reply', () => { test('show Please Fix if no human reply', () => {
@@ -1016,7 +1109,8 @@ limitations under the License.
]; ];
element.comment = element.comments[0]; element.comment = element.comments[0];
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isNotNull(element.$$('.robotActions gr-button')); assert.isNotNull(element.shadowRoot
.querySelector('.robotActions gr-button'));
}); });
test('_handleShowFix fires open-fix-preview event', done => { test('_handleShowFix fires open-fix-preview event', done => {
@@ -1028,7 +1122,8 @@ limitations under the License.
element.isRobotComment = true; element.isRobotComment = true;
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('.show-fix')); MockInteractions.tap(element.shadowRoot
.querySelector('.show-fix'));
}); });
}); });

View File

@@ -56,7 +56,8 @@ limitations under the License.
test('copy to clipboard', () => { test('copy to clipboard', () => {
const clipboardSpy = sandbox.spy(element, '_copyToClipboard'); const clipboardSpy = sandbox.spy(element, '_copyToClipboard');
const copyBtn = element.$$('.copyToClipboard'); const copyBtn = element.shadowRoot
.querySelector('.copyToClipboard');
MockInteractions.tap(copyBtn); MockInteractions.tap(copyBtn);
assert.isTrue(clipboardSpy.called); assert.isTrue(clipboardSpy.called);
}); });
@@ -64,7 +65,8 @@ limitations under the License.
test('focusOnCopy', () => { test('focusOnCopy', () => {
element.focusOnCopy(); element.focusOnCopy();
assert.deepEqual(Polymer.dom(element.root).activeElement, assert.deepEqual(Polymer.dom(element.root).activeElement,
element.$$('.copyToClipboard')); element.shadowRoot
.querySelector('.copyToClipboard'));
}); });
test('_handleInputClick', () => { test('_handleInputClick', () => {

View File

@@ -70,7 +70,8 @@ limitations under the License.
sandbox.useFakeTimers(normalizedDate(nowStr).getTime()); sandbox.useFakeTimers(normalizedDate(nowStr).getTime());
element.dateStr = dateStr; element.dateStr = dateStr;
flush(() => { flush(() => {
const span = element.$$('span'); const span = element.shadowRoot
.querySelector('span');
assert.equal(span.textContent.trim(), expected); assert.equal(span.textContent.trim(), expected);
assert.equal(element.title, expectedTooltip); assert.equal(element.title, expectedTooltip);
element.showDateAndTime = true; element.showDateAndTime = true;

View File

@@ -55,24 +55,28 @@ limitations under the License.
element.addEventListener('confirm', handler); element.addEventListener('confirm', handler);
element.addEventListener('cancel', handler); element.addEventListener('cancel', handler);
MockInteractions.tap(element.$$('gr-button[primary]')); MockInteractions.tap(element.shadowRoot
MockInteractions.tap(element.$$('gr-button:not([primary])')); .querySelector('gr-button[primary]'));
MockInteractions.tap(element.shadowRoot
.querySelector('gr-button:not([primary])'));
}); });
test('confirmOnEnter', () => { test('confirmOnEnter', () => {
element.confirmOnEnter = false; element.confirmOnEnter = false;
const handleConfirmStub = sandbox.stub(element, '_handleConfirm'); const handleConfirmStub = sandbox.stub(element, '_handleConfirm');
const handleKeydownSpy = sandbox.spy(element, '_handleKeydown'); const handleKeydownSpy = sandbox.spy(element, '_handleKeydown');
MockInteractions.pressAndReleaseKeyOn(element.$$('main'), MockInteractions.pressAndReleaseKeyOn(element.shadowRoot
13, null, 'enter'); .querySelector('main'),
13, null, 'enter');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(handleKeydownSpy.called); assert.isTrue(handleKeydownSpy.called);
assert.isFalse(handleConfirmStub.called); assert.isFalse(handleConfirmStub.called);
element.confirmOnEnter = true; element.confirmOnEnter = true;
MockInteractions.pressAndReleaseKeyOn(element.$$('main'), MockInteractions.pressAndReleaseKeyOn(element.shadowRoot
13, null, 'enter'); .querySelector('main'),
13, null, 'enter');
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.isTrue(handleConfirmStub.called); assert.isTrue(handleConfirmStub.called);

View File

@@ -53,7 +53,7 @@
} }
focusOnCopy() { focusOnCopy() {
this.$$('gr-shell-command').focusOnCopy(); this.shadowRoot.querySelector('gr-shell-command').focusOnCopy();
} }
_getLoggedIn() { _getLoggedIn() {

View File

@@ -79,24 +79,30 @@ limitations under the License.
}); });
test('focusOnCopy', () => { test('focusOnCopy', () => {
const focusStub = sandbox.stub(element.$$('gr-shell-command'), const focusStub = sandbox.stub(element.shadowRoot
'focusOnCopy'); .querySelector('gr-shell-command'),
'focusOnCopy');
element.focusOnCopy(); element.focusOnCopy();
assert.isTrue(focusStub.called); assert.isTrue(focusStub.called);
}); });
test('element visibility', () => { test('element visibility', () => {
assert.isFalse(isHidden(element.$$('paper-tabs'))); assert.isFalse(isHidden(element.shadowRoot
assert.isFalse(isHidden(element.$$('.commands'))); .querySelector('paper-tabs')));
assert.isFalse(isHidden(element.shadowRoot
.querySelector('.commands')));
element.schemes = []; element.schemes = [];
assert.isTrue(isHidden(element.$$('paper-tabs'))); assert.isTrue(isHidden(element.shadowRoot
assert.isTrue(isHidden(element.$$('.commands'))); .querySelector('paper-tabs')));
assert.isTrue(isHidden(element.shadowRoot
.querySelector('.commands')));
}); });
test('tab selection', done => { test('tab selection', done => {
assert.equal(element.$.downloadTabs.selected, '0'); assert.equal(element.$.downloadTabs.selected, '0');
MockInteractions.tap(element.$$('[data-scheme="ssh"]')); MockInteractions.tap(element.shadowRoot
.querySelector('[data-scheme="ssh"]'));
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(element.selectedScheme, 'ssh'); assert.equal(element.selectedScheme, 'ssh');
assert.equal(element.$.downloadTabs.selected, '2'); assert.equal(element.$.downloadTabs.selected, '2');
@@ -137,7 +143,8 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
const repoTab = element.$$('paper-tab[data-scheme="repo"]'); const repoTab = element.shadowRoot
.querySelector('paper-tab[data-scheme="repo"]');
MockInteractions.tap(repoTab); MockInteractions.tap(repoTab);

View File

@@ -94,7 +94,8 @@ limitations under the License.
mobileText: 'Mobile Text 3', mobileText: 'Mobile Text 3',
}, },
]; ];
assert.equal(element.$$('paper-listbox').selected, element.value); assert.equal(element.shadowRoot
.querySelector('paper-listbox').selected, element.value);
assert.equal(element.text, 'Button Text 2'); assert.equal(element.text, 'Button Text 2');
flush(() => { flush(() => {
const items = Polymer.dom(element.root).querySelectorAll('paper-item'); const items = Polymer.dom(element.root).querySelectorAll('paper-item');

View File

@@ -129,7 +129,8 @@ limitations under the License.
element.addEventListener('tap-item-foo', fooTapped); element.addEventListener('tap-item-foo', fooTapped);
element.addEventListener('tap-item', tapped); element.addEventListener('tap-item', tapped);
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('.itemAction')); MockInteractions.tap(element.shadowRoot
.querySelector('.itemAction'));
assert.isTrue(fooTapped.called); assert.isTrue(fooTapped.called);
assert.isTrue(tapped.called); assert.isTrue(tapped.called);
assert.deepEqual(tapped.lastCall.args[0].detail, item0); assert.deepEqual(tapped.lastCall.args[0].detail, item0);
@@ -144,7 +145,8 @@ limitations under the License.
element.addEventListener('tap-item-foo', stub); element.addEventListener('tap-item-foo', stub);
element.addEventListener('tap-item', tapped); element.addEventListener('tap-item', tapped);
flushAsynchronousOperations(); flushAsynchronousOperations();
MockInteractions.tap(element.$$('.itemAction')); MockInteractions.tap(element.shadowRoot
.querySelector('.itemAction'));
assert.isFalse(stub.called); assert.isFalse(stub.called);
assert.isFalse(tapped.called); assert.isFalse(tapped.called);
}); });

View File

@@ -80,7 +80,7 @@
} }
focusTextarea() { focusTextarea() {
this.$$('iron-autogrow-textarea').textarea.focus(); this.shadowRoot.querySelector('iron-autogrow-textarea').textarea.focus();
} }
_newContentChanged(newContent, oldContent) { _newContentChanged(newContent, oldContent) {

View File

@@ -57,14 +57,16 @@ limitations under the License.
assert.equal(e.detail.content, 'foo'); assert.equal(e.detail.content, 'foo');
done(); done();
}); });
MockInteractions.tap(element.$$('gr-button[primary]')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button[primary]'));
}); });
test('cancel event', done => { test('cancel event', done => {
element.addEventListener('editable-content-cancel', () => { element.addEventListener('editable-content-cancel', () => {
done(); done();
}); });
MockInteractions.tap(element.$$('gr-button:not([primary])')); MockInteractions.tap(element.shadowRoot
.querySelector('gr-button:not([primary])'));
}); });
test('enabling editing keeps old content', () => { test('enabling editing keeps old content', () => {
@@ -96,12 +98,14 @@ limitations under the License.
}); });
test('save button is disabled initially', () => { test('save button is disabled initially', () => {
assert.isTrue(element.$$('gr-button[primary]').disabled); assert.isTrue(element.shadowRoot
.querySelector('gr-button[primary]').disabled);
}); });
test('save button is enabled when content changes', () => { test('save button is enabled when content changes', () => {
element._newContent = 'new content'; element._newContent = 'new content';
assert.isFalse(element.$$('gr-button[primary]').disabled); assert.isFalse(element.shadowRoot
.querySelector('gr-button[primary]').disabled);
}); });
}); });

View File

@@ -67,7 +67,8 @@ limitations under the License.
element = fixture('basic'); element = fixture('basic');
elementNoPlaceholder = fixture('no-placeholder'); elementNoPlaceholder = fixture('no-placeholder');
label = element.$$('label'); label = element.shadowRoot
.querySelector('label');
sandbox = sinon.sandbox.create(); sandbox = sinon.sandbox.create();
flush(() => { flush(() => {
// In Polymer 2 inputElement isn't nativeInput anymore // In Polymer 2 inputElement isn't nativeInput anymore
@@ -226,7 +227,8 @@ limitations under the License.
setup(() => { setup(() => {
element = fixture('read-only'); element = fixture('read-only');
label = element.$$('label'); label = element.shadowRoot
.querySelector('label');
}); });
test('disallows edit when read-only', () => { test('disallows edit when read-only', () => {

View File

@@ -128,14 +128,17 @@ breaking changes to gr-change-actions wont be noticed.
const handler = sinon.spy(); const handler = sinon.spy();
changeActions.addTapListener(key, handler); changeActions.addTapListener(key, handler);
flush(() => { flush(() => {
MockInteractions.tap(element.$$('[data-action-key="' + key + '"]')); MockInteractions.tap(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
assert(handler.calledOnce); assert(handler.calledOnce);
changeActions.removeTapListener(key, handler); changeActions.removeTapListener(key, handler);
MockInteractions.tap(element.$$('[data-action-key="' + key + '"]')); MockInteractions.tap(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
assert(handler.calledOnce); assert(handler.calledOnce);
changeActions.remove(key); changeActions.remove(key);
flush(() => { flush(() => {
assert.isNull(element.$$('[data-action-key="' + key + '"]')); assert.isNull(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
done(); done();
}); });
}); });
@@ -144,7 +147,8 @@ breaking changes to gr-change-actions wont be noticed.
test('action button properties', done => { test('action button properties', done => {
const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!'); const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!');
flush(() => { flush(() => {
const button = element.$$('[data-action-key="' + key + '"]'); const button = element.shadowRoot
.querySelector('[data-action-key="' + key + '"]');
assert.isOk(button); assert.isOk(button);
assert.equal(button.getAttribute('data-label'), 'Bork!'); assert.equal(button.getAttribute('data-label'), 'Bork!');
assert.isNotOk(button.disabled); assert.isNotOk(button.disabled);
@@ -166,13 +170,15 @@ breaking changes to gr-change-actions wont be noticed.
test('hide action buttons', done => { test('hide action buttons', done => {
const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!'); const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!');
flush(() => { flush(() => {
const button = element.$$('[data-action-key="' + key + '"]'); const button = element.shadowRoot
.querySelector('[data-action-key="' + key + '"]');
assert.isOk(button); assert.isOk(button);
assert.isFalse(button.hasAttribute('hidden')); assert.isFalse(button.hasAttribute('hidden'));
changeActions.setActionHidden( changeActions.setActionHidden(
changeActions.ActionType.REVISION, key, true); changeActions.ActionType.REVISION, key, true);
flush(() => { flush(() => {
const button = element.$$('[data-action-key="' + key + '"]'); const button = element.shadowRoot
.querySelector('[data-action-key="' + key + '"]');
assert.isNotOk(button); assert.isNotOk(button);
done(); done();
}); });
@@ -183,11 +189,13 @@ breaking changes to gr-change-actions wont be noticed.
const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!'); const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!');
flush(() => { flush(() => {
assert.isTrue(element.$.moreActions.hidden); assert.isTrue(element.$.moreActions.hidden);
assert.isOk(element.$$('[data-action-key="' + key + '"]')); assert.isOk(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
changeActions.setActionOverflow( changeActions.setActionOverflow(
changeActions.ActionType.REVISION, key, true); changeActions.ActionType.REVISION, key, true);
flush(() => { flush(() => {
assert.isNotOk(element.$$('[data-action-key="' + key + '"]')); assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
assert.isFalse(element.$.moreActions.hidden); assert.isFalse(element.$.moreActions.hidden);
assert.strictEqual(element.$.moreActions.items[0].name, 'Bork!'); assert.strictEqual(element.$.moreActions.items[0].name, 'Bork!');
done(); done();

View File

@@ -82,7 +82,8 @@ limitations under the License.
test('_computeCanDeleteVote', () => { test('_computeCanDeleteVote', () => {
element.mutable = false; element.mutable = false;
const button = element.$$('gr-button'); const button = element.shadowRoot
.querySelector('gr-button');
assert.isTrue(isHidden(button)); assert.isTrue(isHidden(button));
element.change.removable_reviewers = [element.account]; element.change.removable_reviewers = [element.account];
element.mutable = true; element.mutable = true;
@@ -97,7 +98,8 @@ limitations under the License.
element.change.removable_reviewers = [element.account]; element.change.removable_reviewers = [element.account];
element.change.labels.test.recommended = {_account_id: 1}; element.change.labels.test.recommended = {_account_id: 1};
element.mutable = true; element.mutable = true;
const button = element.$$('gr-button'); const button = element.shadowRoot
.querySelector('gr-button');
MockInteractions.tap(button); MockInteractions.tap(button);
assert.isTrue(button.disabled); assert.isTrue(button.disabled);
return deleteResponse.then(() => { return deleteResponse.then(() => {
@@ -223,11 +225,14 @@ limitations under the License.
test('placeholder', () => { test('placeholder', () => {
element.labelInfo = {}; element.labelInfo = {};
assert.isFalse(isHidden(element.$$('.placeholder'))); assert.isFalse(isHidden(element.shadowRoot
.querySelector('.placeholder')));
element.labelInfo = {all: []}; element.labelInfo = {all: []};
assert.isFalse(isHidden(element.$$('.placeholder'))); assert.isFalse(isHidden(element.shadowRoot
.querySelector('.placeholder')));
element.labelInfo = {all: [{value: 1}]}; element.labelInfo = {all: [{value: 1}]};
assert.isTrue(isHidden(element.$$('.placeholder'))); assert.isTrue(isHidden(element.shadowRoot
.querySelector('.placeholder')));
}); });
}); });
</script> </script>

View File

@@ -357,7 +357,8 @@ limitations under the License.
const links = Polymer.dom(element.root).querySelectorAll('a'); const links = Polymer.dom(element.root).querySelectorAll('a');
assert.equal(links.length, 2); assert.equal(links.length, 2);
assert.equal(element.$$('span').textContent, '- B: 123, 45'); assert.equal(element.shadowRoot
.querySelector('span').textContent, '- B: 123, 45');
assert.equal(links[0].href, 'ftp://foo/123'); assert.equal(links[0].href, 'ftp://foo/123');
assert.equal(links[0].textContent, '123'); assert.equal(links[0].textContent, '123');

View File

@@ -39,7 +39,10 @@
} }
get nativeSelect() { get nativeSelect() {
return this.$$('select'); // gr-select is not a shadow component
// TODO(taoalpha): maybe we should convert
// it into a shadow dom component instead
return this.querySelector('select');
} }
_updateValue() { _updateValue() {

View File

@@ -31,7 +31,7 @@
} }
focusOnCopy() { focusOnCopy() {
this.$$('gr-copy-clipboard').focusOnCopy(); this.shadowRoot.querySelector('gr-copy-clipboard').focusOnCopy();
} }
} }

View File

@@ -54,8 +54,9 @@ limitations under the License.
}); });
test('focusOnCopy', () => { test('focusOnCopy', () => {
const focusStub = sandbox.stub(element.$$('gr-copy-clipboard'), const focusStub = sandbox.stub(element.shadowRoot
'focusOnCopy'); .querySelector('gr-copy-clipboard'),
'focusOnCopy');
element.focusOnCopy(); element.focusOnCopy();
assert.isTrue(focusStub.called); assert.isTrue(focusStub.called);
}); });

View File

@@ -51,14 +51,18 @@ limitations under the License.
}); });
test('the correct arrow is displayed', () => { test('the correct arrow is displayed', () => {
assert.equal(getComputedStyle(element.$$('.arrowPositionBelow')).display, assert.equal(getComputedStyle(element.shadowRoot
'none'); .querySelector('.arrowPositionBelow')).display,
assert.notEqual(getComputedStyle(element.$$('.arrowPositionAbove')) 'none');
assert.notEqual(getComputedStyle(element.shadowRoot
.querySelector('.arrowPositionAbove'))
.display, 'none'); .display, 'none');
element.positionBelow = true; element.positionBelow = true;
assert.notEqual(getComputedStyle(element.$$('.arrowPositionBelow')) assert.notEqual(getComputedStyle(element.shadowRoot
.querySelector('.arrowPositionBelow'))
.display, 'none'); .display, 'none');
assert.equal(getComputedStyle(element.$$('.arrowPositionAbove')) assert.equal(getComputedStyle(element.shadowRoot
.querySelector('.arrowPositionAbove'))
.display, 'none'); .display, 'none');
}); });
}); });