Fix polymer 2 tests

Bug: Issue 10930
Change-Id: Ie19714c66ec4941de816976761abac1faa534386
This commit is contained in:
Dmitrii Filippov
2019-09-25 15:00:27 +02:00
parent 05e30a3aba
commit 9bdc58185b
2 changed files with 23 additions and 3 deletions

View File

@@ -267,7 +267,15 @@ limitations under the License.
element.path = 'some/path';
element.projectName = 'Some project';
const threadEls = threads.map(
thread => element._createThreadElement(thread));
thread => {
const threadEl = element._createThreadElement(thread);
// Polymer 2 doesn't fire ready events and doesn't execute
// observers if element is not added to the Dom.
// See https://github.com/Polymer/old-docs-site/issues/2322
// and https://github.com/Polymer/polymer/issues/4526
element._attachThreadElement(threadEl);
return threadEl;
});
assert.equal(threadEls.length, 2);
assert.equal(threadEls[0].rootId, 4711);
assert.equal(threadEls[1].rootId, 42);

View File

@@ -24,7 +24,13 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="/bower_components/web-component-tester/browser.js"></script>
<link rel="import" href="../test/common-test-setup.html"/>
<link rel="import" href="gr-app.html">
<script>
const link = document.createElement('link');
link.setAttribute('rel', 'import');
link.setAttribute('href', window.POLYMER2 ? 'gr-app-p2.html' : 'gr-app.html');
document.head.appendChild(link);
</script>
<script>void(0);</script>
@@ -34,6 +40,12 @@ limitations under the License.
</template>
</test-fixture>
<test-fixture id="basic-p2">
<template>
<gr-app-p2 id="app"></gr-app-p2>
</template>
</test-fixture>
<script>
suite('gr-app tests', () => {
let sandbox;
@@ -68,7 +80,7 @@ limitations under the License.
probePath() { return Promise.resolve(42); },
});
element = fixture('basic');
element = fixture(window.POLYMER2 ? 'basic-p2' : 'basic');
flush(done);
});