Fix tests for M80

As of M80(chrome version >= 80), chrome removed the
native htmlImports support, tho we have the polyfill
from webcomponents, the loading of html changed from
sync to async which cause a lot test to fail in M80.

The fix is introducing a util method `readyToTest` which
wait until htmlImports finished before running any tests.

Updated some tests to have only one top suite per test so
we only need one `readyToTest` and also multiple `readyToTest`
actually affect tests' stub functionality.

Tested locally with `npm run test` on all passed tests and also
with manual failure to make sure the updated tests can still
catch any errors if have.

Bug: Issue 12294
Change-Id: Ib0c464f8ff9f36a401e6c3b249e6bb6d68ee6e2f
This commit is contained in:
Tao Zhou
2020-02-07 13:30:34 +01:00
parent 5d89999293
commit 4f10d777d9
212 changed files with 8255 additions and 7768 deletions

View File

@@ -23,11 +23,13 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="async-foreach-behavior.html">
<script>
suite('async-foreach-behavior tests', () => {
suite('async-foreach-behavior tests', async () => {
await readyToTest();
test('loops over each item', () => {
const fn = sinon.stub().returns(Promise.resolve());
return Gerrit.AsyncForeachBehavior.asyncForeach([1, 2, 3], fn)

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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>
/** @type {string} */
@@ -45,7 +46,8 @@ limitations under the License.
</test-fixture>
<script>
suite('base-url-behavior tests', () => {
suite('base-url-behavior tests', async () => {
await readyToTest();
let element;
// eslint-disable-next-line no-unused-vars
let overlay;

View File

@@ -17,6 +17,7 @@ limitations under the License.
<!-- Polymer included for the html import polyfill. -->
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<title>docs-url-behavior</title>
@@ -33,7 +34,8 @@ limitations under the License.
</test-fixture>
<script>
suite('docs-url-behavior tests', () => {
suite('docs-url-behavior tests', async () => {
await readyToTest();
let element;
suiteSetup(() => {

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="dom-util-behavior.html">
@@ -40,7 +41,8 @@ limitations under the License.
</test-fixture>
<script>
suite('dom-util-behavior tests', () => {
suite('dom-util-behavior tests', async () => {
await readyToTest();
let element;
let divs;

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-access-behavior.html">
@@ -33,7 +34,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-access-behavior tests', () => {
suite('gr-access-behavior tests', async () => {
await readyToTest();
let element;
suiteSetup(() => {

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-admin-nav-behavior.html">
@@ -33,7 +34,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-admin-nav-behavior tests', () => {
suite('gr-admin-nav-behavior tests', async () => {
await readyToTest();
let element;
let sandbox;
let capabilityStub;

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-change-table-behavior.html">
@@ -41,7 +42,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-change-table-behavior tests', () => {
suite('gr-change-table-behavior tests', async () => {
await readyToTest();
let element;
// eslint-disable-next-line no-unused-vars
let overlay;

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-display-name-behavior.html">
@@ -33,7 +34,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-display-name-behavior tests', () => {
suite('gr-display-name-behavior tests', async () => {
await readyToTest();
let element;
// eslint-disable-next-line no-unused-vars
const config = {

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-list-view-behavior.html">
@@ -33,7 +34,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-list-view-behavior tests', () => {
suite('gr-list-view-behavior tests', async () => {
await readyToTest();
let element;
// eslint-disable-next-line no-unused-vars
let overlay;

View File

@@ -17,6 +17,7 @@ limitations under the License.
<!-- Polymer included for the html import polyfill. -->
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<title>gr-patch-set-behavior</title>
@@ -25,7 +26,8 @@ limitations under the License.
<link rel="import" href="gr-patch-set-behavior.html">
<script>
suite('gr-patch-set-behavior tests', () => {
suite('gr-patch-set-behavior tests', async () => {
await readyToTest();
test('getRevisionByPatchNum', () => {
const get = Gerrit.PatchSetBehavior.getRevisionByPatchNum;
const revisions = [

View File

@@ -17,6 +17,7 @@ limitations under the License.
<!-- Polymer included for the html import polyfill. -->
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<title>gr-path-list-behavior</title>
@@ -25,7 +26,8 @@ limitations under the License.
<link rel="import" href="gr-path-list-behavior.html">
<script>
suite('gr-path-list-behavior tests', () => {
suite('gr-path-list-behavior tests', async () => {
await readyToTest();
test('special sort', () => {
const sort = Gerrit.PathListBehavior.specialFilePathCompare;
const testFiles = [

View File

@@ -22,6 +22,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-tooltip-behavior.html">
@@ -34,7 +35,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-tooltip-behavior tests', () => {
suite('gr-tooltip-behavior tests', async () => {
await readyToTest();
let element;
let sandbox;

View File

@@ -22,6 +22,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="gr-url-encoding-behavior.html">
@@ -34,7 +35,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-url-encoding-behavior tests', () => {
suite('gr-url-encoding-behavior tests', async () => {
await readyToTest();
let element;
let sandbox;

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="keyboard-shortcut-behavior.html">
@@ -41,7 +42,8 @@ limitations under the License.
</test-fixture>
<script>
suite('keyboard-shortcut-behavior tests', () => {
suite('keyboard-shortcut-behavior tests', async () => {
await readyToTest();
const kb = window.Gerrit.KeyboardShortcutBinder;
let element;

View File

@@ -23,6 +23,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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>
/** @type {string} */
@@ -47,7 +48,8 @@ limitations under the License.
</test-fixture>
<script>
suite('rest-client-behavior tests', () => {
suite('rest-client-behavior tests', async () => {
await readyToTest();
let element;
// eslint-disable-next-line no-unused-vars
let overlay;

View File

@@ -22,6 +22,7 @@ limitations under the License.
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<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"/>
<link rel="import" href="safe-types-behavior.html">
@@ -34,7 +35,8 @@ limitations under the License.
</test-fixture>
<script>
suite('gr-tooltip-behavior tests', () => {
suite('gr-tooltip-behavior tests', async () => {
await readyToTest();
let element;
let sandbox;