Manually updating some tests before run conversion script

Some tests don't work correctly after polymer-modulizer conversion and
must be updated. Changes are small and it is easier to make changes
manually than to automate such changes.

The change has the following updates:
* gr-comment-api-mock_test.js doesn't wait for HTMLImportsLoaded event
  anymore.
* gr-app_test.html loads gr-app.html statically with <link ...> tag
  (instead of dynamic loading with document.head.appendChild(...).
  polymer-modulizer converts the link tag to 'import' statement.
* Remove waiting and call someAction() immediately in tests:
     readyToTest().then(() => { someAction(); })
* Update some script src path. Without these updates
  web-component-tester fails after conversion

The change makes some tests unstable, so gerrit-ci can fail on this
change. Tests will become stable after conversion to es6-modules.

Change-Id: Ieceb498bff0fc3398e82ab8647efa819cdd50448
This commit is contained in:
Dmitrii Filippov 2020-03-11 13:04:10 +01:00
parent 31f655eb15
commit 23505e90b6
13 changed files with 83 additions and 76 deletions

View File

@ -17,7 +17,6 @@
(function() {
'use strict';
window.addEventListener('HTMLImportsLoaded', () => {
class CommentApiMock extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@ -52,5 +51,4 @@
}
customElements.define(CommentApiMock.is, CommentApiMock);
});
})();

View File

@ -25,13 +25,7 @@ limitations under the License.
<script src="/bower_components/web-component-tester/browser.js"></script>
<script src="../test/test-pre-setup.js"></script>
<link rel="import" href="../test/common-test-setup.html"/>
<script>
const link = document.createElement('link');
link.setAttribute('rel', 'import');
link.setAttribute('href', 'gr-app.html');
document.head.appendChild(link);
</script>
<link rel="import" href="gr-app.html"/>
<script>void(0);</script>
@ -84,7 +78,7 @@ limitations under the License.
sandbox.restore();
});
appElement = () => element.$['app-element'];
const appElement = () => element.$['app-element'];
test('reporting', () => {
assert.isTrue(appElement().$.reporting.appStarted.calledOnce);

View File

@ -31,7 +31,6 @@ limitations under the License.
<dom-element id="some-element">
<script>
readyToTest().then(() => {
Polymer({
is: 'some-element',
properties: {
@ -41,7 +40,6 @@ limitations under the License.
},
},
});
});
</script>
</dom-element>

View File

@ -31,7 +31,6 @@ limitations under the License.
<dom-element id="some-element">
<script>
readyToTest().then(() => {
Polymer({
is: 'some-element',
@ -46,7 +45,6 @@ limitations under the License.
Gerrit.FireBehavior,
],
});
});
</script>
</dom-element>

View File

@ -45,7 +45,6 @@ limitations under the License.
element = fixture('basic');
sandbox = sinon.sandbox.create();
sandbox.stub(document.body, 'appendChild');
sandbox.stub(Polymer, 'importHref');
});
teardown(() => {

View File

@ -41,9 +41,7 @@ limitations under the License.
<div id="barfoo">some test module</div>
</template>
<script>
readyToTest().then(() => {
Polymer({is: 'gr-user-test-popup'});
});
</script>
</dom-module>

View File

@ -35,9 +35,7 @@ limitations under the License.
<div id="wrapper"></div>
</template>
<script>
readyToTest().then(() => {
Polymer({is: 'gr-style-test-element'});
});
</script>
</dom-module>

View File

@ -25,7 +25,13 @@ limitations under the License.
<script src="/bower_components/web-component-tester/browser.js"></script>
<script src="../../../test/test-pre-setup.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="/bower_components/iron-test-helpers/mock-interactions.js"></script>
<!-- Can't use absolute path below for mock-interaction.js.
Web component tester(wct) has a built-in http server and it serves "/components" directory (which is
actually /node_modules directory). Also, wct patches some files to load modules from /components.
With the absolute path, browser tries to load dom-module from 2 different places (/component/... and
/node_modules/...) though this is actually the same file. This leads to a run-time error.
-->
<script src="../../../node_modules/iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="gr-editable-content.html">

View File

@ -25,7 +25,13 @@ limitations under the License.
<script src="/bower_components/web-component-tester/browser.js"></script>
<script src="../../../test/test-pre-setup.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="/bower_components/iron-test-helpers/mock-interactions.js"></script>
<!-- Can't use absolute path below for mock-interaction.js.
Web component tester(wct) has a built-in http server and it serves "/components" directory (which is
actually /node_modules directory). Also, wct patches some files to load modules from /components.
With the absolute path, browser tries to load dom-module from 2 different places (/component/... and
/node_modules/...) though this is actually the same file. This leads to a run-time error.
-->
<script src="../../../node_modules/iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="gr-editable-label.html">

View File

@ -25,7 +25,13 @@ limitations under the License.
<script src="/bower_components/web-component-tester/browser.js"></script>
<script src="../../../test/test-pre-setup.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="/bower_components/iron-test-helpers/mock-interactions.js"></script>
<!-- Can't use absolute path below for mock-interaction.js.
Web component tester(wct) has a built-in http server and it serves "/components" directory (which is
actually /node_modules directory). Also, wct patches some files to load modules from /components.
With the absolute path, browser tries to load dom-module from 2 different places (/component/... and
/node_modules/...) though this is actually the same file. This leads to a run-time error.
-->
<script src="../../../node_modules/iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="gr-hovercard.html">

View File

@ -25,7 +25,13 @@ limitations under the License.
<script src="/bower_components/web-component-tester/browser.js"></script>
<script src="../../../test/test-pre-setup.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="/bower_components/iron-test-helpers/mock-interactions.js"></script>
<!-- Can't use absolute path below for mock-interaction.js.
Web component tester(wct) has a built-in http server and it serves "/components" directory (which is
actually /node_modules directory). Also, wct patches some files to load modules from /components.
With the absolute path, browser tries to load dom-module from 2 different places (/component/... and
/node_modules/...) though this is actually the same file. This leads to a run-time error.
-->
<script src="../../../node_modules/iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="gr-linked-chip.html">

View File

@ -26,7 +26,7 @@ limitations under the License.
<script src="../../../test/test-pre-setup.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="gr-etag-decorator.js"></script>
<link rel="import" href="./gr-etag-decorator.html">
<script>
suite('gr-etag-decorator', async () => {

View File

@ -19,8 +19,8 @@ limitations under the License.
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Elements Test Runner</title>
<meta charset="utf-8">
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="/bower_components/web-component-tester/browser.js"></script>
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
<script src="/node_modules/web-component-tester/browser.js"></script>
<style>
/* Prevent horizontal scrolling on page.
New version of web-component-tester creates very narrow iframe */