Add karma-runner and convert some tests to run with karma The following changes are included in this change: * karma-runner is added to the polygerrit-ui/package.json file * bazel rule for karma tests is added to the polygerrit-ui/BUILD file * The run_test.sh script is updated - it runs both deprecated web-component-tester(WCT) tests and karma tests * Commands to run separately karma and wct tests are added to the top level package.json file * The common-test-setup-karma.js file adds global functions to replace functionality provided by the WCT * The postinstall step is added to the polygerrit-ui/package.json file to run 'selenium-standalone install' command. Note, that this is not a new command - it runs during the WCT install (see wct-local/scripts/postinstall.js), but sometimes it fails after switching between different branches. Calling it in the postinstall step of polygerrit-ui/package.json improves the situation. Change-Id: Iaf480d22c5553d98eb7607a0e83a86b66f733caa
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js similarity index 97% rename from polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html rename to polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js index 9dab7af..9e6b53a 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.js
@@ -1,45 +1,21 @@ -<!DOCTYPE html> -<!-- -@license -Copyright (C) 2015 The Android Open Source Project +/** + * @license + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> - -<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> -<meta charset="utf-8"> -<title>gr-change-view</title> - -<script src="/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script> - -<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script> -<script src="/components/wct-browser-legacy/browser.js"></script> -<script src="/node_modules/page/page.js"></script> - -<test-fixture id="basic"> - <template> - <gr-change-view></gr-change-view> - </template> -</test-fixture> - -<test-fixture id="blank"> - <template> - <div></div> - </template> -</test-fixture> - -<script type="module"> -import '../../../test/common-test-setup.js'; +import '../../../test/common-test-setup-karma.js'; import '../../edit/gr-edit-constants.js'; import './gr-change-view.js'; import {PrimaryTab, SecondaryTab, ChangeStatus} from '../../../constants/constants.js'; @@ -53,7 +29,10 @@ import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js'; import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js'; +import 'lodash/lodash.js'; + const pluginApi = _testOnly_initGerritPluginApi(); +const fixture = fixtureFromElement('gr-change-view'); suite('gr-change-view tests', () => { const kb = KeyboardShortcutBinder; @@ -314,7 +293,7 @@ getDiffDrafts() { return Promise.resolve({}); }, _fetchSharedCacheURL() { return Promise.resolve({}); }, }); - element = fixture('basic'); + element = fixture.instantiate(); sandbox.stub(element.$.actions, 'reload').returns(Promise.resolve()); pluginLoader.loadPlugins([]); pluginApi.install( @@ -2401,4 +2380,3 @@ }); }); }); -</script>