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:
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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(() => {
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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(() => {
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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 = {
|
||||
|
@@ -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;
|
||||
|
@@ -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 = [
|
||||
|
@@ -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 = [
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-section.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-access-section tests', () => {
|
||||
suite('gr-access-section tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -25,6 +25,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-group-list.html">
|
||||
@@ -54,7 +55,8 @@ limitations under the License.
|
||||
};
|
||||
};
|
||||
|
||||
suite('gr-admin-group-list tests', () => {
|
||||
suite('gr-admin-group-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let groups;
|
||||
let sandbox;
|
||||
|
@@ -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-view.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-admin-view tests', () => {
|
||||
suite('gr-admin-view tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-delete-item-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-delete-item-dialog tests', () => {
|
||||
suite('gr-confirm-delete-item-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-create-change-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-change-dialog tests', () => {
|
||||
suite('gr-create-change-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-create-group-dialog.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-group-dialog tests', () => {
|
||||
suite('gr-create-group-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
const GROUP_NAME = 'test-group';
|
||||
|
@@ -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-create-pointer-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-pointer-dialog tests', () => {
|
||||
suite('gr-create-pointer-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-create-repo-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-repo-dialog tests', () => {
|
||||
suite('gr-create-repo-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-group-audit-log.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-group-audit-log tests', () => {
|
||||
suite('gr-group-audit-log tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-group-members.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-group-members tests', () => {
|
||||
suite('gr-group-members tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let groups;
|
||||
|
@@ -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-group.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-group tests', () => {
|
||||
suite('gr-group tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let groupStub;
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-permission.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-permission tests', () => {
|
||||
suite('gr-permission tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-plugin-config-array-editor.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-plugin-config-array-editor tests', () => {
|
||||
suite('gr-plugin-config-array-editor tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let dispatchStub;
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-plugin-list.html">
|
||||
|
||||
@@ -50,7 +51,8 @@ limitations under the License.
|
||||
return plugin;
|
||||
};
|
||||
|
||||
suite('gr-plugin-list tests', () => {
|
||||
suite('gr-plugin-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let plugins;
|
||||
let sandbox;
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-repo-access.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo-access tests', () => {
|
||||
suite('gr-repo-access tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let repoStub;
|
||||
|
@@ -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-repo-command.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo-command tests', () => {
|
||||
suite('gr-repo-command tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-repo-commands.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo-commands tests', () => {
|
||||
suite('gr-repo-commands tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let repoStub;
|
||||
|
@@ -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-repo-dashboards.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo-dashboards tests', () => {
|
||||
suite('gr-repo-dashboards tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-repo-detail-list.html">
|
||||
|
||||
@@ -69,495 +70,498 @@ limitations under the License.
|
||||
};
|
||||
};
|
||||
|
||||
suite('Branches', () => {
|
||||
let element;
|
||||
let branches;
|
||||
let sandbox;
|
||||
suite('gr-repo-detail-list', async () => {
|
||||
await readyToTest();
|
||||
suite('Branches', () => {
|
||||
let element;
|
||||
let branches;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
element.detailType = 'branches';
|
||||
counter = 0;
|
||||
sandbox.stub(page, 'show');
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
suite('list of repo branches', () => {
|
||||
setup(done => {
|
||||
branches = [{
|
||||
ref: 'HEAD',
|
||||
revision: 'master',
|
||||
}].concat(_.times(25, branchGenerator));
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoBranches(num, project, offset) {
|
||||
return Promise.resolve(branches);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'branches',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
element.detailType = 'branches';
|
||||
counter = 0;
|
||||
sandbox.stub(page, 'show');
|
||||
});
|
||||
|
||||
test('test for branch in the list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[2].ref, 'refs/heads/test2');
|
||||
done();
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
suite('list of repo branches', () => {
|
||||
setup(done => {
|
||||
branches = [{
|
||||
ref: 'HEAD',
|
||||
revision: 'master',
|
||||
}].concat(_.times(25, branchGenerator));
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoBranches(num, project, offset) {
|
||||
return Promise.resolve(branches);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'branches',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
});
|
||||
|
||||
test('test for branch in the list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[2].ref, 'refs/heads/test2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test for web links in the branches list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[2].web_links[0].url,
|
||||
'https://git.example.org/branch/test;refs/heads/test2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test for refs/heads/ being striped from ref', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._stripRefs(element._items[2].ref,
|
||||
element.detailType), 'test2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
|
||||
test('Edit HEAD button not admin', done => {
|
||||
sandbox.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
|
||||
sandbox.stub(element.$.restAPI, 'getRepoAccess').returns(
|
||||
Promise.resolve({
|
||||
test: {is_owner: false},
|
||||
}));
|
||||
element._determineIfOwner('test').then(() => {
|
||||
assert.equal(element._isOwner, false);
|
||||
assert.equal(getComputedStyle(Polymer.dom(element.root)
|
||||
.querySelector('.revisionNoEditing')).display, 'inline');
|
||||
assert.equal(getComputedStyle(Polymer.dom(element.root)
|
||||
.querySelector('.revisionEdit')).display, 'none');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('Edit HEAD button admin', done => {
|
||||
const saveBtn = Polymer.dom(element.root).querySelector('.saveBtn');
|
||||
const cancelBtn = Polymer.dom(element.root).querySelector('.cancelBtn');
|
||||
const editBtn = Polymer.dom(element.root).querySelector('.editBtn');
|
||||
const revisionNoEditing = Polymer.dom(element.root)
|
||||
.querySelector('.revisionNoEditing');
|
||||
const revisionWithEditing = Polymer.dom(element.root)
|
||||
.querySelector('.revisionWithEditing');
|
||||
|
||||
sandbox.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
|
||||
sandbox.stub(element.$.restAPI, 'getRepoAccess').returns(
|
||||
Promise.resolve({
|
||||
test: {is_owner: true},
|
||||
}));
|
||||
sandbox.stub(element, '_handleSaveRevision');
|
||||
element._determineIfOwner('test').then(() => {
|
||||
assert.equal(element._isOwner, true);
|
||||
// The revision container for non-editing enabled row is not visible.
|
||||
assert.equal(getComputedStyle(revisionNoEditing).display, 'none');
|
||||
|
||||
// The revision container for editing enabled row is visible.
|
||||
assert.notEqual(getComputedStyle(Polymer.dom(element.root)
|
||||
.querySelector('.revisionEdit')).display, 'none');
|
||||
|
||||
// The revision and edit button are visible.
|
||||
assert.notEqual(getComputedStyle(revisionWithEditing).display,
|
||||
'none');
|
||||
assert.notEqual(getComputedStyle(editBtn).display, 'none');
|
||||
|
||||
// The input, cancel, and save buttons are not visible.
|
||||
const hiddenElements = Polymer.dom(element.root)
|
||||
.querySelectorAll('.canEdit .editItem');
|
||||
|
||||
for (const item of hiddenElements) {
|
||||
assert.equal(getComputedStyle(item).display, 'none');
|
||||
}
|
||||
|
||||
MockInteractions.tap(editBtn);
|
||||
flushAsynchronousOperations();
|
||||
// The revision and edit button are not visible.
|
||||
assert.equal(getComputedStyle(revisionWithEditing).display, 'none');
|
||||
assert.equal(getComputedStyle(editBtn).display, 'none');
|
||||
|
||||
// The input, cancel, and save buttons are not visible.
|
||||
for (item of hiddenElements) {
|
||||
assert.notEqual(getComputedStyle(item).display, 'none');
|
||||
}
|
||||
|
||||
// The revised ref was set correctly
|
||||
assert.equal(element._revisedRef, 'master');
|
||||
|
||||
assert.isFalse(saveBtn.disabled);
|
||||
|
||||
// Delete the ref.
|
||||
element._revisedRef = '';
|
||||
assert.isTrue(saveBtn.disabled);
|
||||
|
||||
// Change the ref to something else
|
||||
element._revisedRef = 'newRef';
|
||||
element._repo = 'test';
|
||||
assert.isFalse(saveBtn.disabled);
|
||||
|
||||
// Save button calls handleSave. since this is stubbed, the edit
|
||||
// section remains open.
|
||||
MockInteractions.tap(saveBtn);
|
||||
assert.isTrue(element._handleSaveRevision.called);
|
||||
|
||||
// When cancel is tapped, the edit secion closes.
|
||||
MockInteractions.tap(cancelBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
// The revision and edit button are visible.
|
||||
assert.notEqual(getComputedStyle(revisionWithEditing).display,
|
||||
'none');
|
||||
assert.notEqual(getComputedStyle(editBtn).display, 'none');
|
||||
|
||||
// The input, cancel, and save buttons are not visible.
|
||||
for (const item of hiddenElements) {
|
||||
assert.equal(getComputedStyle(item).display, 'none');
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_handleSaveRevision with invalid rev', done => {
|
||||
const event = {model: {set: sandbox.stub()}};
|
||||
element._isEditing = true;
|
||||
sandbox.stub(element.$.restAPI, 'setRepoHead').returns(
|
||||
Promise.resolve({
|
||||
status: 400,
|
||||
})
|
||||
);
|
||||
|
||||
element._setRepoHead('test', 'newRef', event).then(() => {
|
||||
assert.isTrue(element._isEditing);
|
||||
assert.isFalse(event.model.set.called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_handleSaveRevision with valid rev', done => {
|
||||
const event = {model: {set: sandbox.stub()}};
|
||||
element._isEditing = true;
|
||||
sandbox.stub(element.$.restAPI, 'setRepoHead').returns(
|
||||
Promise.resolve({
|
||||
status: 200,
|
||||
})
|
||||
);
|
||||
|
||||
element._setRepoHead('test', 'newRef', event).then(() => {
|
||||
assert.isFalse(element._isEditing);
|
||||
assert.isTrue(event.model.set.called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test _computeItemName', () => {
|
||||
assert.deepEqual(element._computeItemName('branches'), 'Branch');
|
||||
assert.deepEqual(element._computeItemName('tags'), 'Tag');
|
||||
});
|
||||
});
|
||||
|
||||
test('test for web links in the branches list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[2].web_links[0].url,
|
||||
'https://git.example.org/branch/test;refs/heads/test2');
|
||||
done();
|
||||
suite('list with less then 25 branches', () => {
|
||||
setup(done => {
|
||||
branches = _.times(25, branchGenerator);
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoBranches(num, repo, offset) {
|
||||
return Promise.resolve(branches);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'branches',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
});
|
||||
|
||||
test('test for refs/heads/ being striped from ref', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._stripRefs(element._items[2].ref,
|
||||
element.detailType), 'test2');
|
||||
done();
|
||||
suite('filter', () => {
|
||||
test('_paramsChanged', done => {
|
||||
sandbox.stub(
|
||||
element.$.restAPI,
|
||||
'getRepoBranches',
|
||||
() => Promise.resolve(branches));
|
||||
const params = {
|
||||
detail: 'branches',
|
||||
repo: 'test',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params).then(() => {
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[1],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[2],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[3],
|
||||
25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getRepoBranches',
|
||||
(filter, repo, reposBranchesPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
|
||||
test('Edit HEAD button not admin', done => {
|
||||
sandbox.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
|
||||
sandbox.stub(element.$.restAPI, 'getRepoAccess').returns(
|
||||
Promise.resolve({
|
||||
test: {is_owner: false},
|
||||
}));
|
||||
element._determineIfOwner('test').then(() => {
|
||||
assert.equal(element._isOwner, false);
|
||||
assert.equal(getComputedStyle(Polymer.dom(element.root)
|
||||
.querySelector('.revisionNoEditing')).display, 'inline');
|
||||
assert.equal(getComputedStyle(Polymer.dom(element.root)
|
||||
.querySelector('.revisionEdit')).display, 'none');
|
||||
done();
|
||||
});
|
||||
});
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Edit HEAD button admin', done => {
|
||||
const saveBtn = Polymer.dom(element.root).querySelector('.saveBtn');
|
||||
const cancelBtn = Polymer.dom(element.root).querySelector('.cancelBtn');
|
||||
const editBtn = Polymer.dom(element.root).querySelector('.editBtn');
|
||||
const revisionNoEditing = Polymer.dom(element.root)
|
||||
.querySelector('.revisionNoEditing');
|
||||
const revisionWithEditing = Polymer.dom(element.root)
|
||||
.querySelector('.revisionWithEditing');
|
||||
|
||||
sandbox.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
|
||||
sandbox.stub(element.$.restAPI, 'getRepoAccess').returns(
|
||||
Promise.resolve({
|
||||
test: {is_owner: true},
|
||||
}));
|
||||
sandbox.stub(element, '_handleSaveRevision');
|
||||
element._determineIfOwner('test').then(() => {
|
||||
assert.equal(element._isOwner, true);
|
||||
// The revision container for non-editing enabled row is not visible.
|
||||
assert.equal(getComputedStyle(revisionNoEditing).display, 'none');
|
||||
|
||||
// The revision container for editing enabled row is visible.
|
||||
assert.notEqual(getComputedStyle(Polymer.dom(element.root)
|
||||
.querySelector('.revisionEdit')).display, 'none');
|
||||
|
||||
// The revision and edit button are visible.
|
||||
assert.notEqual(getComputedStyle(revisionWithEditing).display,
|
||||
'none');
|
||||
assert.notEqual(getComputedStyle(editBtn).display, 'none');
|
||||
|
||||
// The input, cancel, and save buttons are not visible.
|
||||
const hiddenElements = Polymer.dom(element.root)
|
||||
.querySelectorAll('.canEdit .editItem');
|
||||
|
||||
for (const item of hiddenElements) {
|
||||
assert.equal(getComputedStyle(item).display, 'none');
|
||||
}
|
||||
|
||||
MockInteractions.tap(editBtn);
|
||||
flushAsynchronousOperations();
|
||||
// The revision and edit button are not visible.
|
||||
assert.equal(getComputedStyle(revisionWithEditing).display, 'none');
|
||||
assert.equal(getComputedStyle(editBtn).display, 'none');
|
||||
|
||||
// The input, cancel, and save buttons are not visible.
|
||||
for (item of hiddenElements) {
|
||||
assert.notEqual(getComputedStyle(item).display, 'none');
|
||||
}
|
||||
|
||||
// The revised ref was set correctly
|
||||
assert.equal(element._revisedRef, 'master');
|
||||
|
||||
assert.isFalse(saveBtn.disabled);
|
||||
|
||||
// Delete the ref.
|
||||
element._revisedRef = '';
|
||||
assert.isTrue(saveBtn.disabled);
|
||||
|
||||
// Change the ref to something else
|
||||
element._revisedRef = 'newRef';
|
||||
element._repo = 'test';
|
||||
assert.isFalse(saveBtn.disabled);
|
||||
|
||||
// Save button calls handleSave. since this is stubbed, the edit
|
||||
// section remains open.
|
||||
MockInteractions.tap(saveBtn);
|
||||
assert.isTrue(element._handleSaveRevision.called);
|
||||
|
||||
// When cancel is tapped, the edit secion closes.
|
||||
MockInteractions.tap(cancelBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
// The revision and edit button are visible.
|
||||
assert.notEqual(getComputedStyle(revisionWithEditing).display,
|
||||
'none');
|
||||
assert.notEqual(getComputedStyle(editBtn).display, 'none');
|
||||
|
||||
// The input, cancel, and save buttons are not visible.
|
||||
for (const item of hiddenElements) {
|
||||
assert.equal(getComputedStyle(item).display, 'none');
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_handleSaveRevision with invalid rev', done => {
|
||||
const event = {model: {set: sandbox.stub()}};
|
||||
element._isEditing = true;
|
||||
sandbox.stub(element.$.restAPI, 'setRepoHead').returns(
|
||||
Promise.resolve({
|
||||
status: 400,
|
||||
})
|
||||
);
|
||||
|
||||
element._setRepoHead('test', 'newRef', event).then(() => {
|
||||
assert.isTrue(element._isEditing);
|
||||
assert.isFalse(event.model.set.called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_handleSaveRevision with valid rev', done => {
|
||||
const event = {model: {set: sandbox.stub()}};
|
||||
element._isEditing = true;
|
||||
sandbox.stub(element.$.restAPI, 'setRepoHead').returns(
|
||||
Promise.resolve({
|
||||
status: 200,
|
||||
})
|
||||
);
|
||||
|
||||
element._setRepoHead('test', 'newRef', event).then(() => {
|
||||
assert.isFalse(element._isEditing);
|
||||
assert.isTrue(event.model.set.called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test _computeItemName', () => {
|
||||
assert.deepEqual(element._computeItemName('branches'), 'Branch');
|
||||
assert.deepEqual(element._computeItemName('tags'), 'Tag');
|
||||
});
|
||||
});
|
||||
|
||||
suite('list with less then 25 branches', () => {
|
||||
setup(done => {
|
||||
branches = _.times(25, branchGenerator);
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoBranches(num, repo, offset) {
|
||||
return Promise.resolve(branches);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'branches',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
});
|
||||
|
||||
suite('filter', () => {
|
||||
test('_paramsChanged', done => {
|
||||
sandbox.stub(
|
||||
element.$.restAPI,
|
||||
'getRepoBranches',
|
||||
() => Promise.resolve(branches));
|
||||
const params = {
|
||||
detail: 'branches',
|
||||
repo: 'test',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params).then(() => {
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[1],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[2],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[3],
|
||||
25);
|
||||
done();
|
||||
const params = {
|
||||
detail: 'branches',
|
||||
repo: 'test',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getRepoBranches',
|
||||
(filter, repo, reposBranchesPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
suite('Tags', () => {
|
||||
let element;
|
||||
let tags;
|
||||
let sandbox;
|
||||
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
const params = {
|
||||
detail: 'branches',
|
||||
repo: 'test',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Tags', () => {
|
||||
let element;
|
||||
let tags;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
element.detailType = 'tags';
|
||||
counter = 0;
|
||||
sandbox.stub(page, 'show');
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('_computeMessage', () => {
|
||||
let message = 'v2.15-rc1↵-----BEGIN PGP SIGNATURE-----↵Version: GnuPG v' +
|
||||
'1↵↵iQIcBAABAgAGBQJZ27O7AAoJEF/XxZqaEoiMy6kQAMoQCpGr3J6JITI4BVWsr7QM↵xy' +
|
||||
'EcWH5YPUko5EPTbkABHmaVyFmKGkuIQdn6c+NIbqJOk+5XT4oUyRSo1T569HPJ↵3kyxEJi' +
|
||||
'T1ryvp5BIHwdvHx58fjw1+YkiWLZuZq1FFkUYqnWTYCrkv7Fok98pdOmV↵CL1Hgugi5uK8' +
|
||||
'/kxf1M7+Nv6piaZ140pwSb1h6QdAjaZVfaBCnoxlG4LRUqHvEYay↵f4QYgFT67auHIGkZ4' +
|
||||
'moUcsp2Du/1jSsCWL/CPwjPFGbbckVAjLCMT9yD3NKwpEZF↵pfsiZyHI9dL0M+QjVrM+RD' +
|
||||
'HwIIJwra8R0IMkDlQ6MDrFlKNqNBbo588S6UPrm71L↵YuiwWlcrK9ZIybxT6LzbR65Rvez' +
|
||||
'DSitQ+xeIfpZE19/X6BCnvlARLE8k/tC2JksI↵lEZi7Lf3FQdIcwwyt98tJkS9HX9v9jbC' +
|
||||
'5QXifnoj3Li8tHSLuQ1dJCxHQiis6ojI↵OWUFkm0IHBXVNHA2dqYBdM+pL12mlI3wp6Ica' +
|
||||
'4cdEVDwzu+j1xnVSFUa+d+Y2xJF↵7mytuyhHiKG4hm+zbhMv6WD8Q3FoDsJZeLY99l0hYQ' +
|
||||
'SnnkMduFVroIs45pAs8gUA↵RvYla8mm9w/543IJAPzzFarPVLSsSyQ7tJl3UBzjKRNH/rX' +
|
||||
'W+F22qyWD1zyHPUIR↵C00ItmwlAvveImYKpQAH↵=L+K9↵-----END PGP SIGNATURE---' +
|
||||
'--';
|
||||
assert.equal(element._computeMessage(message), 'v2.15-rc1↵');
|
||||
message = 'v2.15-rc1';
|
||||
assert.equal(element._computeMessage(message), 'v2.15-rc1');
|
||||
});
|
||||
|
||||
suite('list of repo tags', () => {
|
||||
setup(done => {
|
||||
tags = _.times(26, tagGenerator);
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoTags(num, repo, offset) {
|
||||
return Promise.resolve(tags);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
element.detailType = 'tags';
|
||||
counter = 0;
|
||||
sandbox.stub(page, 'show');
|
||||
});
|
||||
|
||||
test('test for tag in the list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[1].ref, 'refs/tags/test2');
|
||||
done();
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('_computeMessage', () => {
|
||||
let message = 'v2.15-rc1↵-----BEGIN PGP SIGNATURE-----↵Version: GnuPG v' +
|
||||
'1↵↵iQIcBAABAgAGBQJZ27O7AAoJEF/XxZqaEoiMy6kQAMoQCpGr3J6JITI4BVWsr7QM↵xy' +
|
||||
'EcWH5YPUko5EPTbkABHmaVyFmKGkuIQdn6c+NIbqJOk+5XT4oUyRSo1T569HPJ↵3kyxEJi' +
|
||||
'T1ryvp5BIHwdvHx58fjw1+YkiWLZuZq1FFkUYqnWTYCrkv7Fok98pdOmV↵CL1Hgugi5uK8' +
|
||||
'/kxf1M7+Nv6piaZ140pwSb1h6QdAjaZVfaBCnoxlG4LRUqHvEYay↵f4QYgFT67auHIGkZ4' +
|
||||
'moUcsp2Du/1jSsCWL/CPwjPFGbbckVAjLCMT9yD3NKwpEZF↵pfsiZyHI9dL0M+QjVrM+RD' +
|
||||
'HwIIJwra8R0IMkDlQ6MDrFlKNqNBbo588S6UPrm71L↵YuiwWlcrK9ZIybxT6LzbR65Rvez' +
|
||||
'DSitQ+xeIfpZE19/X6BCnvlARLE8k/tC2JksI↵lEZi7Lf3FQdIcwwyt98tJkS9HX9v9jbC' +
|
||||
'5QXifnoj3Li8tHSLuQ1dJCxHQiis6ojI↵OWUFkm0IHBXVNHA2dqYBdM+pL12mlI3wp6Ica' +
|
||||
'4cdEVDwzu+j1xnVSFUa+d+Y2xJF↵7mytuyhHiKG4hm+zbhMv6WD8Q3FoDsJZeLY99l0hYQ' +
|
||||
'SnnkMduFVroIs45pAs8gUA↵RvYla8mm9w/543IJAPzzFarPVLSsSyQ7tJl3UBzjKRNH/rX' +
|
||||
'W+F22qyWD1zyHPUIR↵C00ItmwlAvveImYKpQAH↵=L+K9↵-----END PGP SIGNATURE---' +
|
||||
'--';
|
||||
assert.equal(element._computeMessage(message), 'v2.15-rc1↵');
|
||||
message = 'v2.15-rc1';
|
||||
assert.equal(element._computeMessage(message), 'v2.15-rc1');
|
||||
});
|
||||
|
||||
suite('list of repo tags', () => {
|
||||
setup(done => {
|
||||
tags = _.times(26, tagGenerator);
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoTags(num, repo, offset) {
|
||||
return Promise.resolve(tags);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
});
|
||||
|
||||
test('test for tag in the list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[1].ref, 'refs/tags/test2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test for tag message in the list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[1].message, 'Annotated tag');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test for tagger in the tag list', done => {
|
||||
const tagger = {
|
||||
name: 'Test User',
|
||||
email: 'test.user@gmail.com',
|
||||
date: '2017-09-19 14:54:00.000000000',
|
||||
tz: 540,
|
||||
};
|
||||
flush(() => {
|
||||
assert.deepEqual(element._items[1].tagger, tagger);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test for web links in the tags list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[1].web_links[0].url,
|
||||
'https://git.example.org/tag/test;refs/tags/test2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('test for refs/tags/ being striped from ref', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._stripRefs(element._items[1].ref,
|
||||
element.detailType), 'test2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
|
||||
test('_computeHideTagger', () => {
|
||||
const testObject1 = {
|
||||
tagger: 'test',
|
||||
};
|
||||
assert.equal(element._computeHideTagger(testObject1), '');
|
||||
|
||||
assert.equal(element._computeHideTagger(undefined), 'hide');
|
||||
});
|
||||
});
|
||||
|
||||
test('test for tag message in the list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[1].message, 'Annotated tag');
|
||||
done();
|
||||
suite('list with less then 25 tags', () => {
|
||||
setup(done => {
|
||||
tags = _.times(25, tagGenerator);
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoTags(num, project, offset) {
|
||||
return Promise.resolve(tags);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
});
|
||||
|
||||
test('test for tagger in the tag list', done => {
|
||||
const tagger = {
|
||||
name: 'Test User',
|
||||
email: 'test.user@gmail.com',
|
||||
date: '2017-09-19 14:54:00.000000000',
|
||||
tz: 540,
|
||||
};
|
||||
flush(() => {
|
||||
assert.deepEqual(element._items[1].tagger, tagger);
|
||||
done();
|
||||
suite('filter', () => {
|
||||
test('_paramsChanged', done => {
|
||||
sandbox.stub(
|
||||
element.$.restAPI,
|
||||
'getRepoTags',
|
||||
() => Promise.resolve(tags));
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params).then(() => {
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[1],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[2],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[3],
|
||||
25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('test for web links in the tags list', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._items[1].web_links[0].url,
|
||||
'https://git.example.org/tag/test;refs/tags/test2');
|
||||
done();
|
||||
suite('create new', () => {
|
||||
test('_handleCreateClicked called when create-click fired', () => {
|
||||
sandbox.stub(element, '_handleCreateClicked');
|
||||
element.$$('gr-list-view').fire('create-clicked');
|
||||
assert.isTrue(element._handleCreateClicked.called);
|
||||
});
|
||||
|
||||
test('_handleCreateClicked opens modal', () => {
|
||||
const openStub = sandbox.stub(element.$.createOverlay, 'open');
|
||||
element._handleCreateClicked();
|
||||
assert.isTrue(openStub.called);
|
||||
});
|
||||
|
||||
test('_handleCreateItem called when confirm fired', () => {
|
||||
sandbox.stub(element, '_handleCreateItem');
|
||||
element.$.createDialog.fire('confirm');
|
||||
assert.isTrue(element._handleCreateItem.called);
|
||||
});
|
||||
|
||||
test('_handleCloseCreate called when cancel fired', () => {
|
||||
sandbox.stub(element, '_handleCloseCreate');
|
||||
element.$.createDialog.fire('cancel');
|
||||
assert.isTrue(element._handleCloseCreate.called);
|
||||
});
|
||||
});
|
||||
|
||||
test('test for refs/tags/ being striped from ref', done => {
|
||||
flush(() => {
|
||||
assert.equal(element._stripRefs(element._items[1].ref,
|
||||
element.detailType), 'test2');
|
||||
done();
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getRepoTags',
|
||||
(filter, repo, reposTagsPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params);
|
||||
});
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
test('test _computeHideDeleteClass', () => {
|
||||
assert.deepEqual(element._computeHideDeleteClass(true, false), 'show');
|
||||
assert.deepEqual(element._computeHideDeleteClass(false, true), 'show');
|
||||
assert.deepEqual(element._computeHideDeleteClass(false, false), '');
|
||||
});
|
||||
|
||||
test('_computeHideTagger', () => {
|
||||
const testObject1 = {
|
||||
tagger: 'test',
|
||||
};
|
||||
assert.equal(element._computeHideTagger(testObject1), '');
|
||||
|
||||
assert.equal(element._computeHideTagger(undefined), 'hide');
|
||||
});
|
||||
});
|
||||
|
||||
suite('list with less then 25 tags', () => {
|
||||
setup(done => {
|
||||
tags = _.times(25, tagGenerator);
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getRepoTags(num, project, offset) {
|
||||
return Promise.resolve(tags);
|
||||
},
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
};
|
||||
|
||||
element._paramsChanged(params).then(() => { flush(done); });
|
||||
});
|
||||
|
||||
test('_shownItems', () => {
|
||||
assert.equal(element._shownItems.length, 25);
|
||||
});
|
||||
});
|
||||
|
||||
suite('filter', () => {
|
||||
test('_paramsChanged', done => {
|
||||
sandbox.stub(
|
||||
element.$.restAPI,
|
||||
'getRepoTags',
|
||||
() => Promise.resolve(tags));
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params).then(() => {
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[1],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[2],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[3],
|
||||
25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('create new', () => {
|
||||
test('_handleCreateClicked called when create-click fired', () => {
|
||||
sandbox.stub(element, '_handleCreateClicked');
|
||||
element.$$('gr-list-view').fire('create-clicked');
|
||||
assert.isTrue(element._handleCreateClicked.called);
|
||||
});
|
||||
|
||||
test('_handleCreateClicked opens modal', () => {
|
||||
const openStub = sandbox.stub(element.$.createOverlay, 'open');
|
||||
element._handleCreateClicked();
|
||||
assert.isTrue(openStub.called);
|
||||
});
|
||||
|
||||
test('_handleCreateItem called when confirm fired', () => {
|
||||
sandbox.stub(element, '_handleCreateItem');
|
||||
element.$.createDialog.fire('confirm');
|
||||
assert.isTrue(element._handleCreateItem.called);
|
||||
});
|
||||
|
||||
test('_handleCloseCreate called when cancel fired', () => {
|
||||
sandbox.stub(element, '_handleCloseCreate');
|
||||
element.$.createDialog.fire('cancel');
|
||||
assert.isTrue(element._handleCloseCreate.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getRepoTags',
|
||||
(filter, repo, reposTagsPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params);
|
||||
});
|
||||
});
|
||||
|
||||
test('test _computeHideDeleteClass', () => {
|
||||
assert.deepEqual(element._computeHideDeleteClass(true, false), 'show');
|
||||
assert.deepEqual(element._computeHideDeleteClass(false, true), 'show');
|
||||
assert.deepEqual(element._computeHideDeleteClass(false, false), '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-repo-list.html">
|
||||
|
||||
@@ -50,7 +51,8 @@ limitations under the License.
|
||||
};
|
||||
};
|
||||
|
||||
suite('gr-repo-list tests', () => {
|
||||
suite('gr-repo-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let repos;
|
||||
let sandbox;
|
||||
|
@@ -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-repo-plugin-config.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo-plugin-config tests', () => {
|
||||
suite('gr-repo-plugin-config tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-repo.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo tests', () => {
|
||||
suite('gr-repo tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let repoStub;
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-rule-editor.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-rule-editor tests', () => {
|
||||
suite('gr-rule-editor tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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 src="../../../scripts/util.js"></script>
|
||||
|
||||
@@ -37,7 +38,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-change-list-item tests', () => {
|
||||
suite('gr-change-list-item tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -24,6 +24,7 @@ limitations under the License.
|
||||
<script src="/bower_components/page/page.js"></script>
|
||||
<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-list-view.html">
|
||||
|
||||
@@ -39,7 +40,8 @@ limitations under the License.
|
||||
const CHANGE_ID = 'IcA3dAB3edAB9f60B8dcdA6ef71A75980e4B7127';
|
||||
const COMMIT_HASH = '12345678';
|
||||
|
||||
suite('gr-change-list-view tests', () => {
|
||||
suite('gr-change-list-view tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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 src="/bower_components/page/page.js"></script>
|
||||
|
||||
@@ -43,7 +44,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-change-list basic tests', () => {
|
||||
suite('gr-change-list basic tests', async () => {
|
||||
await readyToTest();
|
||||
// Define keybindings before attaching other fixtures.
|
||||
const kb = window.Gerrit.KeyboardShortcutBinder;
|
||||
kb.bindShortcut(kb.Shortcut.CURSOR_NEXT_CHANGE, 'j');
|
||||
@@ -431,192 +433,192 @@ limitations under the License.
|
||||
assert.isNotOk(element.$$(elementClass));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('dashboard queries', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
suite('dashboard queries', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
});
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
});
|
||||
|
||||
teardown(() => { sandbox.restore(); });
|
||||
teardown(() => { sandbox.restore(); });
|
||||
|
||||
test('query without age and limit unchanged', () => {
|
||||
const query = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), query);
|
||||
});
|
||||
test('query without age and limit unchanged', () => {
|
||||
const query = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), query);
|
||||
});
|
||||
|
||||
test('query with age and limit', () => {
|
||||
const query = 'status:closed age:1week limit:10 owner:me';
|
||||
const expectedQuery = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
test('query with age and limit', () => {
|
||||
const query = 'status:closed age:1week limit:10 owner:me';
|
||||
const expectedQuery = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
|
||||
test('query with age', () => {
|
||||
const query = 'status:closed age:1week owner:me';
|
||||
const expectedQuery = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
test('query with age', () => {
|
||||
const query = 'status:closed age:1week owner:me';
|
||||
const expectedQuery = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
|
||||
test('query with limit', () => {
|
||||
const query = 'status:closed limit:10 owner:me';
|
||||
const expectedQuery = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
test('query with limit', () => {
|
||||
const query = 'status:closed limit:10 owner:me';
|
||||
const expectedQuery = 'status:closed owner:me';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
|
||||
test('query with age as value and not key', () => {
|
||||
const query = 'status:closed random:age';
|
||||
const expectedQuery = 'status:closed random:age';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
test('query with age as value and not key', () => {
|
||||
const query = 'status:closed random:age';
|
||||
const expectedQuery = 'status:closed random:age';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
|
||||
test('query with limit as value and not key', () => {
|
||||
const query = 'status:closed random:limit';
|
||||
const expectedQuery = 'status:closed random:limit';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
test('query with limit as value and not key', () => {
|
||||
const query = 'status:closed random:limit';
|
||||
const expectedQuery = 'status:closed random:limit';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
|
||||
test('query with -age key', () => {
|
||||
const query = 'status:closed -age:1week';
|
||||
const expectedQuery = 'status:closed';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
});
|
||||
|
||||
suite('gr-change-list sections', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
});
|
||||
|
||||
teardown(() => { sandbox.restore(); });
|
||||
|
||||
test('keyboard shortcuts', done => {
|
||||
element.selectedIndex = 0;
|
||||
element.sections = [
|
||||
{
|
||||
results: [
|
||||
{_number: 0},
|
||||
{_number: 1},
|
||||
{_number: 2},
|
||||
],
|
||||
},
|
||||
{
|
||||
results: [
|
||||
{_number: 3},
|
||||
{_number: 4},
|
||||
{_number: 5},
|
||||
],
|
||||
},
|
||||
{
|
||||
results: [
|
||||
{_number: 6},
|
||||
{_number: 7},
|
||||
{_number: 8},
|
||||
],
|
||||
},
|
||||
];
|
||||
flushAsynchronousOperations();
|
||||
Polymer.RenderStatus.afterNextRender(element, () => {
|
||||
const elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||
'gr-change-list-item');
|
||||
assert.equal(elementItems.length, 9);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
|
||||
const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||
assert.equal(element.selectedIndex, 2);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
assert.deepEqual(navStub.lastCall.args[0], {_number: 2},
|
||||
'Should navigate to /c/2/');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
assert.deepEqual(navStub.lastCall.args[0], {_number: 1},
|
||||
'Should navigate to /c/1/');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
assert.equal(element.selectedIndex, 4);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
assert.deepEqual(navStub.lastCall.args[0], {_number: 4},
|
||||
'Should navigate to /c/4/');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
|
||||
const change = element._changeForIndex(element.selectedIndex);
|
||||
assert.equal(change.reviewed, true,
|
||||
'Should mark change as reviewed');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
|
||||
assert.equal(change.reviewed, false,
|
||||
'Should mark change as unreviewed');
|
||||
done();
|
||||
test('query with -age key', () => {
|
||||
const query = 'status:closed -age:1week';
|
||||
const expectedQuery = 'status:closed';
|
||||
assert.deepEqual(element._processQuery(query), expectedQuery);
|
||||
});
|
||||
});
|
||||
|
||||
test('highlight attribute is updated correctly', () => {
|
||||
element.changes = [
|
||||
{
|
||||
_number: 0,
|
||||
status: 'NEW',
|
||||
owner: {_account_id: 0},
|
||||
},
|
||||
{
|
||||
_number: 1,
|
||||
status: 'ABANDONED',
|
||||
owner: {_account_id: 0},
|
||||
},
|
||||
];
|
||||
element.account = {_account_id: 42};
|
||||
flushAsynchronousOperations();
|
||||
let items = element._getListItems();
|
||||
assert.equal(items.length, 2);
|
||||
assert.isFalse(items[0].hasAttribute('highlight'));
|
||||
assert.isFalse(items[1].hasAttribute('highlight'));
|
||||
suite('gr-change-list sections', () => {
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
// Assign all issues to the user, but only the first one is highlighted
|
||||
// because the second one is abandoned.
|
||||
element.set(['changes', 0, 'assignee'], {_account_id: 12});
|
||||
element.set(['changes', 1, 'assignee'], {_account_id: 12});
|
||||
element.account = {_account_id: 12};
|
||||
flushAsynchronousOperations();
|
||||
items = element._getListItems();
|
||||
assert.isTrue(items[0].hasAttribute('highlight'));
|
||||
assert.isFalse(items[1].hasAttribute('highlight'));
|
||||
});
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
element = fixture('basic');
|
||||
});
|
||||
|
||||
test('_computeItemHighlight gives false for null account', () => {
|
||||
assert.isFalse(
|
||||
element._computeItemHighlight(null, {assignee: {_account_id: 42}}));
|
||||
});
|
||||
teardown(() => { sandbox.restore(); });
|
||||
|
||||
test('_computeItemAbsoluteIndex', () => {
|
||||
sandbox.stub(element, '_computeLabelNames');
|
||||
element.sections = [
|
||||
{results: new Array(1)},
|
||||
{results: new Array(2)},
|
||||
{results: new Array(3)},
|
||||
];
|
||||
test('keyboard shortcuts', done => {
|
||||
element.selectedIndex = 0;
|
||||
element.sections = [
|
||||
{
|
||||
results: [
|
||||
{_number: 0},
|
||||
{_number: 1},
|
||||
{_number: 2},
|
||||
],
|
||||
},
|
||||
{
|
||||
results: [
|
||||
{_number: 3},
|
||||
{_number: 4},
|
||||
{_number: 5},
|
||||
],
|
||||
},
|
||||
{
|
||||
results: [
|
||||
{_number: 6},
|
||||
{_number: 7},
|
||||
{_number: 8},
|
||||
],
|
||||
},
|
||||
];
|
||||
flushAsynchronousOperations();
|
||||
Polymer.RenderStatus.afterNextRender(element, () => {
|
||||
const elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||
'gr-change-list-item');
|
||||
assert.equal(elementItems.length, 9);
|
||||
|
||||
assert.equal(element._computeItemAbsoluteIndex(0, 0), 0);
|
||||
// Out of range but no matter.
|
||||
assert.equal(element._computeItemAbsoluteIndex(0, 1), 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
|
||||
assert.equal(element._computeItemAbsoluteIndex(1, 0), 1);
|
||||
assert.equal(element._computeItemAbsoluteIndex(1, 1), 2);
|
||||
assert.equal(element._computeItemAbsoluteIndex(1, 2), 3);
|
||||
assert.equal(element._computeItemAbsoluteIndex(2, 0), 3);
|
||||
assert.equal(element._computeItemAbsoluteIndex(3, 0), 6);
|
||||
const navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||
assert.equal(element.selectedIndex, 2);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
assert.deepEqual(navStub.lastCall.args[0], {_number: 2},
|
||||
'Should navigate to /c/2/');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
assert.deepEqual(navStub.lastCall.args[0], {_number: 1},
|
||||
'Should navigate to /c/1/');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
assert.equal(element.selectedIndex, 4);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
assert.deepEqual(navStub.lastCall.args[0], {_number: 4},
|
||||
'Should navigate to /c/4/');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
|
||||
const change = element._changeForIndex(element.selectedIndex);
|
||||
assert.equal(change.reviewed, true,
|
||||
'Should mark change as reviewed');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
|
||||
assert.equal(change.reviewed, false,
|
||||
'Should mark change as unreviewed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('highlight attribute is updated correctly', () => {
|
||||
element.changes = [
|
||||
{
|
||||
_number: 0,
|
||||
status: 'NEW',
|
||||
owner: {_account_id: 0},
|
||||
},
|
||||
{
|
||||
_number: 1,
|
||||
status: 'ABANDONED',
|
||||
owner: {_account_id: 0},
|
||||
},
|
||||
];
|
||||
element.account = {_account_id: 42};
|
||||
flushAsynchronousOperations();
|
||||
let items = element._getListItems();
|
||||
assert.equal(items.length, 2);
|
||||
assert.isFalse(items[0].hasAttribute('highlight'));
|
||||
assert.isFalse(items[1].hasAttribute('highlight'));
|
||||
|
||||
// Assign all issues to the user, but only the first one is highlighted
|
||||
// because the second one is abandoned.
|
||||
element.set(['changes', 0, 'assignee'], {_account_id: 12});
|
||||
element.set(['changes', 1, 'assignee'], {_account_id: 12});
|
||||
element.account = {_account_id: 12};
|
||||
flushAsynchronousOperations();
|
||||
items = element._getListItems();
|
||||
assert.isTrue(items[0].hasAttribute('highlight'));
|
||||
assert.isFalse(items[1].hasAttribute('highlight'));
|
||||
});
|
||||
|
||||
test('_computeItemHighlight gives false for null account', () => {
|
||||
assert.isFalse(
|
||||
element._computeItemHighlight(null, {assignee: {_account_id: 42}}));
|
||||
});
|
||||
|
||||
test('_computeItemAbsoluteIndex', () => {
|
||||
sandbox.stub(element, '_computeLabelNames');
|
||||
element.sections = [
|
||||
{results: new Array(1)},
|
||||
{results: new Array(2)},
|
||||
{results: new Array(3)},
|
||||
];
|
||||
|
||||
assert.equal(element._computeItemAbsoluteIndex(0, 0), 0);
|
||||
// Out of range but no matter.
|
||||
assert.equal(element._computeItemAbsoluteIndex(0, 1), 1);
|
||||
|
||||
assert.equal(element._computeItemAbsoluteIndex(1, 0), 1);
|
||||
assert.equal(element._computeItemAbsoluteIndex(1, 1), 2);
|
||||
assert.equal(element._computeItemAbsoluteIndex(1, 2), 3);
|
||||
assert.equal(element._computeItemAbsoluteIndex(2, 0), 3);
|
||||
assert.equal(element._computeItemAbsoluteIndex(3, 0), 6);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -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 src="../../../scripts/util.js"></script>
|
||||
|
||||
@@ -37,7 +38,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-change-help tests', () => {
|
||||
suite('gr-create-change-help tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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-create-commands-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-create-commands-dialog tests', () => {
|
||||
suite('gr-create-commands-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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-dashboard-view.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-dashboard-view tests', () => {
|
||||
suite('gr-dashboard-view tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let paramsChangedPromise;
|
||||
|
@@ -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-repo-header.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-repo-header tests', () => {
|
||||
suite('gr-repo-header tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-user-header.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-user-header tests', () => {
|
||||
suite('gr-user-header tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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="../../plugins/gr-plugin-host/gr-plugin-host.html">
|
||||
<link rel="import" href="gr-change-metadata.html">
|
||||
@@ -42,7 +43,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-change-metadata integration tests', () => {
|
||||
suite('gr-change-metadata integration tests', async () => {
|
||||
await readyToTest();
|
||||
let sandbox;
|
||||
let element;
|
||||
|
||||
|
@@ -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="../../core/gr-router/gr-router.html">
|
||||
<link rel="import" href="gr-change-metadata.html">
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-change-metadata tests', () => {
|
||||
suite('gr-change-metadata tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-requirements.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-change-metadata tests', () => {
|
||||
suite('gr-change-metadata tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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 src="/bower_components/page/page.js"></script>
|
||||
|
||||
@@ -44,7 +45,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-change-view tests', () => {
|
||||
suite('gr-change-view tests', async () => {
|
||||
await readyToTest();
|
||||
const kb = window.Gerrit.KeyboardShortcutBinder;
|
||||
kb.bindShortcut(kb.Shortcut.SEND_REPLY, 'ctrl+enter');
|
||||
kb.bindShortcut(kb.Shortcut.REFRESH_CHANGE, 'shift+r');
|
||||
|
@@ -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-comment-list.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-comment-list tests', () => {
|
||||
suite('gr-comment-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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="../../core/gr-router/gr-router.html">
|
||||
<link rel="import" href="gr-commit-info.html">
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-commit-info tests', () => {
|
||||
suite('gr-commit-info tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-abandon-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-abandon-dialog tests', () => {
|
||||
suite('gr-confirm-abandon-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-cherrypick-conflict-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-cherrypick-conflict-dialog tests', () => {
|
||||
suite('gr-confirm-cherrypick-conflict-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-cherrypick-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-cherrypick-dialog tests', () => {
|
||||
suite('gr-confirm-cherrypick-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-move-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-move-dialog tests', () => {
|
||||
suite('gr-confirm-move-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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-confirm-rebase-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-rebase-dialog tests', () => {
|
||||
suite('gr-confirm-rebase-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-revert-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-revert-dialog tests', () => {
|
||||
suite('gr-confirm-revert-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-confirm-revert-submission-dialog.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-confirm-revert-submission-dialog tests', () => {
|
||||
suite('gr-confirm-revert-submission-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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 src="/bower_components/page/page.js"></script>
|
||||
|
||||
@@ -37,7 +38,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-file-list-header tests', () => {
|
||||
suite('gr-file-list-header tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-download-dialog.html">
|
||||
|
||||
@@ -119,7 +120,8 @@ limitations under the License.
|
||||
};
|
||||
}
|
||||
|
||||
suite('gr-download-dialog', () => {
|
||||
suite('gr-download-dialog', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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 src="/bower_components/page/page.js"></script>
|
||||
|
||||
@@ -43,7 +44,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-file-list-header tests', () => {
|
||||
suite('gr-file-list-header tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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-included-in-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-included-in-dialog', () => {
|
||||
suite('gr-included-in-dialog', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -24,6 +24,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-label-score-row.html">
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-label-row-score tests', () => {
|
||||
suite('gr-label-row-score tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-label-scores.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-label-scores tests', () => {
|
||||
suite('gr-label-scores tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-message.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-message tests', () => {
|
||||
suite('gr-message tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(done => {
|
||||
|
@@ -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="../../diff/gr-comment-api/gr-comment-api.html">
|
||||
|
||||
@@ -70,7 +71,8 @@ limitations under the License.
|
||||
randomMessage(opt_params));
|
||||
};
|
||||
|
||||
suite('gr-messages-list tests', () => {
|
||||
suite('gr-messages-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let messages;
|
||||
let sandbox;
|
||||
@@ -132,483 +134,485 @@ limitations under the License.
|
||||
],
|
||||
};
|
||||
|
||||
setup(() => {
|
||||
stub('gr-rest-api-interface', {
|
||||
getConfig() { return Promise.resolve({}); },
|
||||
getLoggedIn() { return Promise.resolve(false); },
|
||||
getDiffComments() { return Promise.resolve(comments); },
|
||||
getDiffRobotComments() { return Promise.resolve({}); },
|
||||
getDiffDrafts() { return Promise.resolve({}); },
|
||||
suite('basic tests', () => {
|
||||
setup(() => {
|
||||
stub('gr-rest-api-interface', {
|
||||
getConfig() { return Promise.resolve({}); },
|
||||
getLoggedIn() { return Promise.resolve(false); },
|
||||
getDiffComments() { return Promise.resolve(comments); },
|
||||
getDiffRobotComments() { return Promise.resolve({}); },
|
||||
getDiffDrafts() { return Promise.resolve({}); },
|
||||
});
|
||||
sandbox = sinon.sandbox.create();
|
||||
messages = _.times(3, randomMessage);
|
||||
// Element must be wrapped in an element with direct access to the
|
||||
// comment API.
|
||||
commentApiWrapper = fixture('basic');
|
||||
element = commentApiWrapper.$.messagesList;
|
||||
loadCommentSpy = sandbox.spy(commentApiWrapper.$.commentAPI, 'loadAll');
|
||||
element.messages = messages;
|
||||
|
||||
// Stub methods on the changeComments object after changeComments has
|
||||
// been initialized.
|
||||
return commentApiWrapper.loadComments();
|
||||
});
|
||||
sandbox = sinon.sandbox.create();
|
||||
messages = _.times(3, randomMessage);
|
||||
// Element must be wrapped in an element with direct access to the
|
||||
// comment API.
|
||||
commentApiWrapper = fixture('basic');
|
||||
element = commentApiWrapper.$.messagesList;
|
||||
loadCommentSpy = sandbox.spy(commentApiWrapper.$.commentAPI, 'loadAll');
|
||||
element.messages = messages;
|
||||
|
||||
// Stub methods on the changeComments object after changeComments has
|
||||
// been initialized.
|
||||
return commentApiWrapper.loadComments();
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('show some old messages', () => {
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
element.messages = _.times(26, randomMessage);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
assert.equal(getMessages().length, 20);
|
||||
assert.equal(element.$.incrementMessagesBtn.innerText.toUpperCase()
|
||||
.trim(), 'SHOW 5 MORE');
|
||||
MockInteractions.tap(element.$.incrementMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(getMessages().length, 25);
|
||||
assert.equal(element.$.incrementMessagesBtn.innerText.toUpperCase()
|
||||
.trim(), 'SHOW 1 MORE');
|
||||
MockInteractions.tap(element.$.incrementMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
assert.equal(getMessages().length, 26);
|
||||
});
|
||||
|
||||
test('show all old messages', () => {
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
element.messages = _.times(26, randomMessage);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
assert.equal(getMessages().length, 20);
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW ALL 6 MESSAGES');
|
||||
MockInteractions.tap(element.$.oldMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(getMessages().length, 26);
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
});
|
||||
|
||||
test('message count respects automated', () => {
|
||||
element.messages = _.times(10, randomAutomated)
|
||||
.concat(_.times(11, randomMessage));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW 1 MESSAGE');
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
});
|
||||
|
||||
test('message count still respects non-automated on toggle', () => {
|
||||
element.messages = _.times(10, randomMessage)
|
||||
.concat(_.times(11, randomAutomated));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW 1 MESSAGE');
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW 1 MESSAGE');
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
});
|
||||
|
||||
test('show all messages respects expand', () => {
|
||||
element.messages = _.times(10, randomAutomated)
|
||||
.concat(_.times(11, randomMessage));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages')); // Expand all.
|
||||
flushAsynchronousOperations();
|
||||
|
||||
let messages = getMessages();
|
||||
assert.equal(messages.length, 20);
|
||||
for (const message of messages) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
|
||||
MockInteractions.tap(element.$.oldMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
messages = getMessages();
|
||||
assert.equal(messages.length, 21);
|
||||
for (const message of messages) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
});
|
||||
|
||||
test('show all messages respects collapse', () => {
|
||||
element.messages = _.times(10, randomAutomated)
|
||||
.concat(_.times(11, randomMessage));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages')); // Expand all.
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages')); // Collapse all.
|
||||
flushAsynchronousOperations();
|
||||
|
||||
let messages = getMessages();
|
||||
assert.equal(messages.length, 20);
|
||||
for (const message of messages) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
|
||||
MockInteractions.tap(element.$.oldMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
messages = getMessages();
|
||||
assert.equal(messages.length, 21);
|
||||
for (const message of messages) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
});
|
||||
|
||||
test('expand/collapse all', () => {
|
||||
let allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
message._expanded = false;
|
||||
}
|
||||
MockInteractions.tap(allMessageEls[1]);
|
||||
assert.isTrue(allMessageEls[1]._expanded);
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
});
|
||||
|
||||
test('expand/collapse from external keypress', () => {
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
let allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
|
||||
// Expand/collapse all text also changes.
|
||||
assert.equal(element.shadowRoot
|
||||
.querySelector('#collapse-messages').textContent.trim(),
|
||||
'Collapse all');
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
// Expand/collapse all text also changes.
|
||||
assert.equal(element.shadowRoot
|
||||
.querySelector('#collapse-messages').textContent.trim(),
|
||||
'Expand all');
|
||||
});
|
||||
|
||||
test('hide messages does not appear when no automated messages', () => {
|
||||
assert.isOk(element.shadowRoot
|
||||
.querySelector('#automatedMessageToggleContainer[hidden]'));
|
||||
});
|
||||
|
||||
test('scroll to message', () => {
|
||||
const allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
message.set('message.expanded', false);
|
||||
}
|
||||
|
||||
const scrollToStub = sandbox.stub(window, 'scrollTo');
|
||||
const highlightStub = sandbox.stub(element, '_highlightEl');
|
||||
|
||||
element.scrollToMessage('invalid');
|
||||
|
||||
for (const message of allMessageEls) {
|
||||
assert.isFalse(message._expanded,
|
||||
'expected gr-message to not be expanded');
|
||||
}
|
||||
|
||||
const messageID = messages[1].id;
|
||||
element.scrollToMessage(messageID);
|
||||
assert.isTrue(
|
||||
element.$$('[data-message-id="' + messageID + '"]')._expanded);
|
||||
|
||||
assert.isTrue(scrollToStub.calledOnce);
|
||||
assert.isTrue(highlightStub.calledOnce);
|
||||
});
|
||||
|
||||
test('scroll to message offscreen', () => {
|
||||
const scrollToStub = sandbox.stub(window, 'scrollTo');
|
||||
const highlightStub = sandbox.stub(element, '_highlightEl');
|
||||
element.messages = _.times(25, randomMessage);
|
||||
flushAsynchronousOperations();
|
||||
assert.isFalse(scrollToStub.called);
|
||||
assert.isFalse(highlightStub.called);
|
||||
|
||||
const messageID = element.messages[1].id;
|
||||
element.scrollToMessage(messageID);
|
||||
assert.isTrue(scrollToStub.calledOnce);
|
||||
assert.isTrue(highlightStub.calledOnce);
|
||||
assert.equal(element._visibleMessages.length, 24);
|
||||
assert.isTrue(
|
||||
element.$$('[data-message-id="' + messageID + '"]')._expanded);
|
||||
});
|
||||
|
||||
test('messages', () => {
|
||||
const messages = [].concat(
|
||||
randomMessage(),
|
||||
{
|
||||
_index: 5,
|
||||
_revision_number: 4,
|
||||
message: 'Uploaded patch set 4.',
|
||||
date: '2016-09-28 13:36:33.000000000',
|
||||
author,
|
||||
id: '8c19ccc949c6d482b061be6a28e10782abf0e7af',
|
||||
},
|
||||
{
|
||||
_index: 6,
|
||||
_revision_number: 4,
|
||||
message: 'Patch Set 4:\n\n(6 comments)',
|
||||
date: '2016-09-28 13:36:33.000000000',
|
||||
author,
|
||||
id: 'e7bfdbc842f6b6d8064bc68e0f52b673f40c0ca5',
|
||||
}
|
||||
);
|
||||
element.messages = messages;
|
||||
const isAuthor = function(author, message) {
|
||||
return message.author._account_id === author._account_id;
|
||||
};
|
||||
const isMarvin = isAuthor.bind(null, author);
|
||||
flushAsynchronousOperations();
|
||||
const messageElements = getMessages();
|
||||
assert.equal(messageElements.length, messages.length);
|
||||
assert.deepEqual(messageElements[1].message, messages[1]);
|
||||
assert.deepEqual(messageElements[2].message, messages[2]);
|
||||
assert.deepEqual(messageElements[1].comments.file1,
|
||||
comments.file1.filter(isMarvin));
|
||||
assert.deepEqual(messageElements[1].comments.file2,
|
||||
comments.file2.filter(isMarvin));
|
||||
assert.deepEqual(messageElements[2].comments, {});
|
||||
});
|
||||
|
||||
test('messages without author do not throw', () => {
|
||||
const messages = [{
|
||||
_index: 5,
|
||||
_revision_number: 4,
|
||||
message: 'Uploaded patch set 4.',
|
||||
date: '2016-09-28 13:36:33.000000000',
|
||||
id: '8c19ccc949c6d482b061be6a28e10782abf0e7af',
|
||||
}];
|
||||
element.messages = messages;
|
||||
flushAsynchronousOperations();
|
||||
const messageEls = getMessages();
|
||||
assert.equal(messageEls.length, 1);
|
||||
assert.equal(messageEls[0].message.message, messages[0].message);
|
||||
});
|
||||
|
||||
test('hide increment text if increment >= total remaining', () => {
|
||||
// Test with stubbed return values, as _numRemaining and _getDelta have
|
||||
// their own tests.
|
||||
sandbox.stub(element, '_getDelta').returns(5);
|
||||
const remainingStub = sandbox.stub(element, '_numRemaining').returns(6);
|
||||
assert.isFalse(element._computeIncrementHidden(null, null, null));
|
||||
remainingStub.restore();
|
||||
|
||||
sandbox.stub(element, '_numRemaining').returns(4);
|
||||
assert.isTrue(element._computeIncrementHidden(null, null, null));
|
||||
});
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
suite('gr-messages-list automate tests', () => {
|
||||
let element;
|
||||
let messages;
|
||||
let sandbox;
|
||||
let commentApiWrapper;
|
||||
|
||||
test('show some old messages', () => {
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
element.messages = _.times(26, randomMessage);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
assert.equal(getMessages().length, 20);
|
||||
assert.equal(element.$.incrementMessagesBtn.innerText.toUpperCase()
|
||||
.trim(), 'SHOW 5 MORE');
|
||||
MockInteractions.tap(element.$.incrementMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(getMessages().length, 25);
|
||||
assert.equal(element.$.incrementMessagesBtn.innerText.toUpperCase()
|
||||
.trim(), 'SHOW 1 MORE');
|
||||
MockInteractions.tap(element.$.incrementMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
assert.equal(getMessages().length, 26);
|
||||
});
|
||||
|
||||
test('show all old messages', () => {
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
element.messages = _.times(26, randomMessage);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
assert.equal(getMessages().length, 20);
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW ALL 6 MESSAGES');
|
||||
MockInteractions.tap(element.$.oldMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(getMessages().length, 26);
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
});
|
||||
|
||||
test('message count respects automated', () => {
|
||||
element.messages = _.times(10, randomAutomated)
|
||||
.concat(_.times(11, randomMessage));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW 1 MESSAGE');
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isTrue(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
});
|
||||
|
||||
test('message count still respects non-automated on toggle', () => {
|
||||
element.messages = _.times(10, randomMessage)
|
||||
.concat(_.times(11, randomAutomated));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW 1 MESSAGE');
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.equal(element.$.oldMessagesBtn.innerText.toUpperCase(),
|
||||
'SHOW 1 MESSAGE');
|
||||
assert.isFalse(element.$.messageControlsContainer.hasAttribute('hidden'));
|
||||
});
|
||||
|
||||
test('show all messages respects expand', () => {
|
||||
element.messages = _.times(10, randomAutomated)
|
||||
.concat(_.times(11, randomMessage));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages')); // Expand all.
|
||||
flushAsynchronousOperations();
|
||||
|
||||
let messages = getMessages();
|
||||
assert.equal(messages.length, 20);
|
||||
for (const message of messages) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
|
||||
MockInteractions.tap(element.$.oldMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
messages = getMessages();
|
||||
assert.equal(messages.length, 21);
|
||||
for (const message of messages) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
});
|
||||
|
||||
test('show all messages respects collapse', () => {
|
||||
element.messages = _.times(10, randomAutomated)
|
||||
.concat(_.times(11, randomMessage));
|
||||
flushAsynchronousOperations();
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages')); // Expand all.
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages')); // Collapse all.
|
||||
flushAsynchronousOperations();
|
||||
|
||||
let messages = getMessages();
|
||||
assert.equal(messages.length, 20);
|
||||
for (const message of messages) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
|
||||
MockInteractions.tap(element.$.oldMessagesBtn);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
messages = getMessages();
|
||||
assert.equal(messages.length, 21);
|
||||
for (const message of messages) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
});
|
||||
|
||||
test('expand/collapse all', () => {
|
||||
let allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
message._expanded = false;
|
||||
}
|
||||
MockInteractions.tap(allMessageEls[1]);
|
||||
assert.isTrue(allMessageEls[1]._expanded);
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
});
|
||||
|
||||
test('expand/collapse from external keypress', () => {
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
let allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isTrue(message._expanded);
|
||||
}
|
||||
|
||||
// Expand/collapse all text also changes.
|
||||
assert.equal(element.shadowRoot
|
||||
.querySelector('#collapse-messages').textContent.trim(),
|
||||
'Collapse all');
|
||||
|
||||
MockInteractions.tap(element.shadowRoot
|
||||
.querySelector('#collapse-messages'));
|
||||
allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
assert.isFalse(message._expanded);
|
||||
}
|
||||
// Expand/collapse all text also changes.
|
||||
assert.equal(element.shadowRoot
|
||||
.querySelector('#collapse-messages').textContent.trim(),
|
||||
'Expand all');
|
||||
});
|
||||
|
||||
test('hide messages does not appear when no automated messages', () => {
|
||||
assert.isOk(element.shadowRoot
|
||||
.querySelector('#automatedMessageToggleContainer[hidden]'));
|
||||
});
|
||||
|
||||
test('scroll to message', () => {
|
||||
const allMessageEls = getMessages();
|
||||
for (const message of allMessageEls) {
|
||||
message.set('message.expanded', false);
|
||||
}
|
||||
|
||||
const scrollToStub = sandbox.stub(window, 'scrollTo');
|
||||
const highlightStub = sandbox.stub(element, '_highlightEl');
|
||||
|
||||
element.scrollToMessage('invalid');
|
||||
|
||||
for (const message of allMessageEls) {
|
||||
assert.isFalse(message._expanded,
|
||||
'expected gr-message to not be expanded');
|
||||
}
|
||||
|
||||
const messageID = messages[1].id;
|
||||
element.scrollToMessage(messageID);
|
||||
assert.isTrue(
|
||||
element.$$('[data-message-id="' + messageID + '"]')._expanded);
|
||||
|
||||
assert.isTrue(scrollToStub.calledOnce);
|
||||
assert.isTrue(highlightStub.calledOnce);
|
||||
});
|
||||
|
||||
test('scroll to message offscreen', () => {
|
||||
const scrollToStub = sandbox.stub(window, 'scrollTo');
|
||||
const highlightStub = sandbox.stub(element, '_highlightEl');
|
||||
element.messages = _.times(25, randomMessage);
|
||||
flushAsynchronousOperations();
|
||||
assert.isFalse(scrollToStub.called);
|
||||
assert.isFalse(highlightStub.called);
|
||||
|
||||
const messageID = element.messages[1].id;
|
||||
element.scrollToMessage(messageID);
|
||||
assert.isTrue(scrollToStub.calledOnce);
|
||||
assert.isTrue(highlightStub.calledOnce);
|
||||
assert.equal(element._visibleMessages.length, 24);
|
||||
assert.isTrue(
|
||||
element.$$('[data-message-id="' + messageID + '"]')._expanded);
|
||||
});
|
||||
|
||||
test('messages', () => {
|
||||
const messages = [].concat(
|
||||
randomMessage(),
|
||||
{
|
||||
_index: 5,
|
||||
_revision_number: 4,
|
||||
message: 'Uploaded patch set 4.',
|
||||
date: '2016-09-28 13:36:33.000000000',
|
||||
author,
|
||||
id: '8c19ccc949c6d482b061be6a28e10782abf0e7af',
|
||||
},
|
||||
{
|
||||
_index: 6,
|
||||
_revision_number: 4,
|
||||
message: 'Patch Set 4:\n\n(6 comments)',
|
||||
date: '2016-09-28 13:36:33.000000000',
|
||||
author,
|
||||
id: 'e7bfdbc842f6b6d8064bc68e0f52b673f40c0ca5',
|
||||
}
|
||||
);
|
||||
element.messages = messages;
|
||||
const isAuthor = function(author, message) {
|
||||
return message.author._account_id === author._account_id;
|
||||
const getMessages = function() {
|
||||
return Polymer.dom(element.root).querySelectorAll('gr-message');
|
||||
};
|
||||
const getHiddenMessages = function() {
|
||||
return Polymer.dom(element.root).querySelectorAll('gr-message[hidden]');
|
||||
};
|
||||
const isMarvin = isAuthor.bind(null, author);
|
||||
flushAsynchronousOperations();
|
||||
const messageElements = getMessages();
|
||||
assert.equal(messageElements.length, messages.length);
|
||||
assert.deepEqual(messageElements[1].message, messages[1]);
|
||||
assert.deepEqual(messageElements[2].message, messages[2]);
|
||||
assert.deepEqual(messageElements[1].comments.file1,
|
||||
comments.file1.filter(isMarvin));
|
||||
assert.deepEqual(messageElements[1].comments.file2,
|
||||
comments.file2.filter(isMarvin));
|
||||
assert.deepEqual(messageElements[2].comments, {});
|
||||
});
|
||||
|
||||
test('messages without author do not throw', () => {
|
||||
const messages = [{
|
||||
_index: 5,
|
||||
_revision_number: 4,
|
||||
message: 'Uploaded patch set 4.',
|
||||
date: '2016-09-28 13:36:33.000000000',
|
||||
id: '8c19ccc949c6d482b061be6a28e10782abf0e7af',
|
||||
}];
|
||||
element.messages = messages;
|
||||
flushAsynchronousOperations();
|
||||
const messageEls = getMessages();
|
||||
assert.equal(messageEls.length, 1);
|
||||
assert.equal(messageEls[0].message.message, messages[0].message);
|
||||
});
|
||||
const randomMessageReviewer = {
|
||||
reviewer: {},
|
||||
date: '2016-01-13 20:30:33.038000',
|
||||
};
|
||||
|
||||
test('hide increment text if increment >= total remaining', () => {
|
||||
// Test with stubbed return values, as _numRemaining and _getDelta have
|
||||
// their own tests.
|
||||
sandbox.stub(element, '_getDelta').returns(5);
|
||||
const remainingStub = sandbox.stub(element, '_numRemaining').returns(6);
|
||||
assert.isFalse(element._computeIncrementHidden(null, null, null));
|
||||
remainingStub.restore();
|
||||
|
||||
sandbox.stub(element, '_numRemaining').returns(4);
|
||||
assert.isTrue(element._computeIncrementHidden(null, null, null));
|
||||
});
|
||||
});
|
||||
|
||||
suite('gr-messages-list automate tests', () => {
|
||||
let element;
|
||||
let messages;
|
||||
let sandbox;
|
||||
let commentApiWrapper;
|
||||
|
||||
const getMessages = function() {
|
||||
return Polymer.dom(element.root).querySelectorAll('gr-message');
|
||||
};
|
||||
const getHiddenMessages = function() {
|
||||
return Polymer.dom(element.root).querySelectorAll('gr-message[hidden]');
|
||||
};
|
||||
|
||||
const randomMessageReviewer = {
|
||||
reviewer: {},
|
||||
date: '2016-01-13 20:30:33.038000',
|
||||
};
|
||||
|
||||
setup(() => {
|
||||
stub('gr-rest-api-interface', {
|
||||
getConfig() { return Promise.resolve({}); },
|
||||
getLoggedIn() { return Promise.resolve(false); },
|
||||
getDiffComments() { return Promise.resolve({}); },
|
||||
getDiffRobotComments() { return Promise.resolve({}); },
|
||||
getDiffDrafts() { return Promise.resolve({}); },
|
||||
});
|
||||
|
||||
sandbox = sinon.sandbox.create();
|
||||
messages = _.times(2, randomAutomated);
|
||||
messages.push(randomMessageReviewer);
|
||||
|
||||
// Element must be wrapped in an element with direct access to the
|
||||
// comment API.
|
||||
commentApiWrapper = fixture('basic');
|
||||
element = commentApiWrapper.$.messagesList;
|
||||
loadCommentSpy = sandbox.spy(commentApiWrapper.$.commentAPI, 'loadAll');
|
||||
element.messages = messages;
|
||||
|
||||
// Stub methods on the changeComments object after changeComments has
|
||||
// been initialized.
|
||||
return commentApiWrapper.loadComments();
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('hide autogenerated button is not hidden', () => {
|
||||
assert.isNotOk(element.shadowRoot
|
||||
.querySelector('#automatedMessageToggle[hidden]'));
|
||||
});
|
||||
|
||||
test('autogenerated messages are not hidden initially', () => {
|
||||
const allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
// There are no hidden messages.
|
||||
assert.isFalse(!!allHiddenMessageEls.length);
|
||||
});
|
||||
|
||||
test('autogenerated messages hidden after comments only toggle', () => {
|
||||
let allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
element._hideAutomated = false;
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
flushAsynchronousOperations();
|
||||
allMessageEls = getMessages();
|
||||
allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
// Autogenerated messages are now hidden.
|
||||
assert.equal(allHiddenMessageEls.length, allMessageEls.length);
|
||||
});
|
||||
|
||||
test('autogenerated messages not hidden after comments only toggle',
|
||||
() => {
|
||||
let allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
element._hideAutomated = true;
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
// Autogenerated messages are now hidden.
|
||||
assert.isFalse(!!allHiddenMessageEls.length);
|
||||
setup(() => {
|
||||
stub('gr-rest-api-interface', {
|
||||
getConfig() { return Promise.resolve({}); },
|
||||
getLoggedIn() { return Promise.resolve(false); },
|
||||
getDiffComments() { return Promise.resolve({}); },
|
||||
getDiffRobotComments() { return Promise.resolve({}); },
|
||||
getDiffDrafts() { return Promise.resolve({}); },
|
||||
});
|
||||
|
||||
test('_getDelta', () => {
|
||||
let messages = [randomMessage()];
|
||||
assert.equal(element._getDelta([], messages, false), 1);
|
||||
assert.equal(element._getDelta([], messages, true), 1);
|
||||
sandbox = sinon.sandbox.create();
|
||||
messages = _.times(2, randomAutomated);
|
||||
messages.push(randomMessageReviewer);
|
||||
|
||||
messages = _.times(7, randomMessage);
|
||||
assert.equal(element._getDelta([], messages, false), 5);
|
||||
assert.equal(element._getDelta([], messages, true), 5);
|
||||
// Element must be wrapped in an element with direct access to the
|
||||
// comment API.
|
||||
commentApiWrapper = fixture('basic');
|
||||
element = commentApiWrapper.$.messagesList;
|
||||
loadCommentSpy = sandbox.spy(commentApiWrapper.$.commentAPI, 'loadAll');
|
||||
element.messages = messages;
|
||||
|
||||
messages = _.times(4, randomMessage)
|
||||
.concat(_.times(2, randomAutomated))
|
||||
.concat(_.times(3, randomMessage));
|
||||
// Stub methods on the changeComments object after changeComments has
|
||||
// been initialized.
|
||||
return commentApiWrapper.loadComments();
|
||||
});
|
||||
|
||||
const dummyArr = _.times(2, randomMessage);
|
||||
assert.equal(element._getDelta(dummyArr, messages, false), 5);
|
||||
assert.equal(element._getDelta(dummyArr, messages, true), 7);
|
||||
});
|
||||
teardown(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('_getHumanMessages', () => {
|
||||
assert.equal(
|
||||
element._getHumanMessages(_.times(5, randomAutomated)).length, 0);
|
||||
assert.equal(
|
||||
element._getHumanMessages(_.times(5, randomMessage)).length, 5);
|
||||
test('hide autogenerated button is not hidden', () => {
|
||||
assert.isNotOk(element.shadowRoot
|
||||
.querySelector('#automatedMessageToggle[hidden]'));
|
||||
});
|
||||
|
||||
let messages = _.shuffle(_.times(5, randomMessage)
|
||||
.concat(_.times(5, randomAutomated)));
|
||||
messages = element._getHumanMessages(messages);
|
||||
assert.equal(messages.length, 5);
|
||||
assert.isFalse(element._hasAutomatedMessages(messages));
|
||||
});
|
||||
test('autogenerated messages are not hidden initially', () => {
|
||||
const allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
test('initially show only 20 messages', () => {
|
||||
sandbox.stub(element.$.reporting, 'reportInteraction',
|
||||
(eventName, details) => {
|
||||
assert.equal(typeof(eventName), 'string');
|
||||
if (details) {
|
||||
assert.equal(typeof(details), 'object');
|
||||
}
|
||||
// There are no hidden messages.
|
||||
assert.isFalse(!!allHiddenMessageEls.length);
|
||||
});
|
||||
|
||||
test('autogenerated messages hidden after comments only toggle', () => {
|
||||
let allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
element._hideAutomated = false;
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
flushAsynchronousOperations();
|
||||
allMessageEls = getMessages();
|
||||
allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
// Autogenerated messages are now hidden.
|
||||
assert.equal(allHiddenMessageEls.length, allMessageEls.length);
|
||||
});
|
||||
|
||||
test('autogenerated messages not hidden after comments only toggle',
|
||||
() => {
|
||||
let allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
element._hideAutomated = true;
|
||||
MockInteractions.tap(element.$.automatedMessageToggle);
|
||||
allHiddenMessageEls = getHiddenMessages();
|
||||
|
||||
// Autogenerated messages are now hidden.
|
||||
assert.isFalse(!!allHiddenMessageEls.length);
|
||||
});
|
||||
const messages = Array.from(Array(23).keys())
|
||||
.map(() => {
|
||||
return {};
|
||||
});
|
||||
element._processedMessagesChanged(messages);
|
||||
|
||||
assert.equal(element._visibleMessages.length, 20);
|
||||
});
|
||||
test('_getDelta', () => {
|
||||
let messages = [randomMessage()];
|
||||
assert.equal(element._getDelta([], messages, false), 1);
|
||||
assert.equal(element._getDelta([], messages, true), 1);
|
||||
|
||||
test('_computeLabelExtremes', () => {
|
||||
const computeSpy = sandbox.spy(element, '_computeLabelExtremes');
|
||||
messages = _.times(7, randomMessage);
|
||||
assert.equal(element._getDelta([], messages, false), 5);
|
||||
assert.equal(element._getDelta([], messages, true), 5);
|
||||
|
||||
element.labels = null;
|
||||
assert.isTrue(computeSpy.calledOnce);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
messages = _.times(4, randomMessage)
|
||||
.concat(_.times(2, randomAutomated))
|
||||
.concat(_.times(3, randomMessage));
|
||||
|
||||
element.labels = {};
|
||||
assert.isTrue(computeSpy.calledTwice);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
const dummyArr = _.times(2, randomMessage);
|
||||
assert.equal(element._getDelta(dummyArr, messages, false), 5);
|
||||
assert.equal(element._getDelta(dummyArr, messages, true), 7);
|
||||
});
|
||||
|
||||
element.labels = {'my-label': {}};
|
||||
assert.isTrue(computeSpy.calledThrice);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
test('_getHumanMessages', () => {
|
||||
assert.equal(
|
||||
element._getHumanMessages(_.times(5, randomAutomated)).length, 0);
|
||||
assert.equal(
|
||||
element._getHumanMessages(_.times(5, randomMessage)).length, 5);
|
||||
|
||||
element.labels = {'my-label': {values: {}}};
|
||||
assert.equal(computeSpy.callCount, 4);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
let messages = _.shuffle(_.times(5, randomMessage)
|
||||
.concat(_.times(5, randomAutomated)));
|
||||
messages = element._getHumanMessages(messages);
|
||||
assert.equal(messages.length, 5);
|
||||
assert.isFalse(element._hasAutomatedMessages(messages));
|
||||
});
|
||||
|
||||
element.labels = {'my-label': {values: {'-12': {}}}};
|
||||
assert.equal(computeSpy.callCount, 5);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue,
|
||||
{'my-label': {min: -12, max: -12}});
|
||||
test('initially show only 20 messages', () => {
|
||||
sandbox.stub(element.$.reporting, 'reportInteraction',
|
||||
(eventName, details) => {
|
||||
assert.equal(typeof(eventName), 'string');
|
||||
if (details) {
|
||||
assert.equal(typeof(details), 'object');
|
||||
}
|
||||
});
|
||||
const messages = Array.from(Array(23).keys())
|
||||
.map(() => {
|
||||
return {};
|
||||
});
|
||||
element._processedMessagesChanged(messages);
|
||||
|
||||
element.labels = {
|
||||
'my-label': {values: {'-2': {}, '-1': {}, '0': {}, '+1': {}, '+2': {}}},
|
||||
};
|
||||
assert.equal(computeSpy.callCount, 6);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue,
|
||||
{'my-label': {min: -2, max: 2}});
|
||||
assert.equal(element._visibleMessages.length, 20);
|
||||
});
|
||||
|
||||
element.labels = {
|
||||
'my-label': {values: {'-12': {}}},
|
||||
'other-label': {values: {'-1': {}, ' 0': {}, '+1': {}}},
|
||||
};
|
||||
assert.equal(computeSpy.callCount, 7);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {
|
||||
'my-label': {min: -12, max: -12},
|
||||
'other-label': {min: -1, max: 1},
|
||||
test('_computeLabelExtremes', () => {
|
||||
const computeSpy = sandbox.spy(element, '_computeLabelExtremes');
|
||||
|
||||
element.labels = null;
|
||||
assert.isTrue(computeSpy.calledOnce);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
|
||||
element.labels = {};
|
||||
assert.isTrue(computeSpy.calledTwice);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
|
||||
element.labels = {'my-label': {}};
|
||||
assert.isTrue(computeSpy.calledThrice);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
|
||||
element.labels = {'my-label': {values: {}}};
|
||||
assert.equal(computeSpy.callCount, 4);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {});
|
||||
|
||||
element.labels = {'my-label': {values: {'-12': {}}}};
|
||||
assert.equal(computeSpy.callCount, 5);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue,
|
||||
{'my-label': {min: -12, max: -12}});
|
||||
|
||||
element.labels = {
|
||||
'my-label': {values: {'-2': {}, '-1': {}, '0': {}, '+1': {}, '+2': {}}},
|
||||
};
|
||||
assert.equal(computeSpy.callCount, 6);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue,
|
||||
{'my-label': {min: -2, max: 2}});
|
||||
|
||||
element.labels = {
|
||||
'my-label': {values: {'-12': {}}},
|
||||
'other-label': {values: {'-1': {}, ' 0': {}, '+1': {}}},
|
||||
};
|
||||
assert.equal(computeSpy.callCount, 7);
|
||||
assert.deepEqual(computeSpy.lastCall.returnValue, {
|
||||
'my-label': {min: -12, max: -12},
|
||||
'other-label': {min: -1, max: 1},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -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-related-changes-list.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-related-changes-list tests', () => {
|
||||
suite('gr-related-changes-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -24,6 +24,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="../../plugins/gr-plugin-host/gr-plugin-host.html">
|
||||
<link rel="import" href="gr-reply-dialog.html">
|
||||
@@ -43,7 +44,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-reply-dialog tests', () => {
|
||||
suite('gr-reply-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let changeNum;
|
||||
let patchNum;
|
||||
|
@@ -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-reply-dialog.html">
|
||||
|
||||
@@ -54,7 +55,8 @@ limitations under the License.
|
||||
};
|
||||
}
|
||||
|
||||
suite('gr-reply-dialog tests', () => {
|
||||
suite('gr-reply-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let changeNum;
|
||||
let patchNum;
|
||||
|
@@ -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-reviewer-list.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-reviewer-list tests', () => {
|
||||
suite('gr-reviewer-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-thread-list.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-thread-list tests', () => {
|
||||
suite('gr-thread-list tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let threadElements;
|
||||
|
@@ -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-upload-help-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-upload-help-dialog tests', () => {
|
||||
suite('gr-upload-help-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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-account-dropdown.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-account-dropdown tests', () => {
|
||||
suite('gr-account-dropdown tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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-error-dialog.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-error-dialog tests', () => {
|
||||
suite('gr-error-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -35,7 +35,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-error-manager tests', () => {
|
||||
suite('gr-error-manager tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-key-binding-display.html">
|
||||
|
||||
@@ -34,7 +35,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-key-binding-display tests', () => {
|
||||
suite('gr-key-binding-display tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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-keyboard-shortcuts-dialog.html">
|
||||
|
||||
@@ -34,7 +35,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-keyboard-shortcuts-dialog tests', () => {
|
||||
suite('gr-keyboard-shortcuts-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
const kb = window.Gerrit.KeyboardShortcutBinder;
|
||||
let element;
|
||||
|
||||
|
@@ -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-main-header.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-main-header tests', () => {
|
||||
suite('gr-main-header tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -23,10 +23,12 @@ 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>
|
||||
suite('gr-navigation tests', () => {
|
||||
suite('gr-navigation tests', async () => {
|
||||
await readyToTest();
|
||||
test('invalid patch ranges throw exceptions', () => {
|
||||
assert.throw(() => Gerrit.Nav.getUrlForChange('123', undefined, 12));
|
||||
assert.throw(() => Gerrit.Nav.getUrlForDiff('123', 'x.c', undefined, 12));
|
||||
|
@@ -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-reporting.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-reporting tests', () => {
|
||||
suite('gr-reporting tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let clock;
|
||||
|
@@ -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-router.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-router tests', () => {
|
||||
suite('gr-router tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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 src="/bower_components/page/page.js"></script>
|
||||
|
||||
@@ -38,7 +39,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-search-bar tests', () => {
|
||||
suite('gr-search-bar tests', async () => {
|
||||
await readyToTest();
|
||||
const kb = window.Gerrit.KeyboardShortcutBinder;
|
||||
kb.bindShortcut(kb.Shortcut.SEARCH, '/');
|
||||
|
||||
|
@@ -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-smart-search.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-smart-search tests', () => {
|
||||
suite('gr-smart-search tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-app.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-app custom dark theme tests', () => {
|
||||
suite('gr-app custom dark theme tests', async () => {
|
||||
await readyToTest();
|
||||
let sandbox;
|
||||
let element;
|
||||
|
||||
|
@@ -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-app.html">
|
||||
|
||||
@@ -35,7 +36,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-app custom light theme tests', () => {
|
||||
suite('gr-app custom light theme tests', async () => {
|
||||
await readyToTest();
|
||||
let sandbox;
|
||||
let element;
|
||||
|
||||
|
@@ -35,7 +35,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-apply-fix-dialog tests', () => {
|
||||
suite('gr-apply-fix-dialog tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
const ROBOT_COMMENT = {
|
||||
|
@@ -17,38 +17,40 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
class CommentApiMock extends Polymer.GestureEventListeners(
|
||||
Polymer.LegacyElementMixin(
|
||||
Polymer.Element)) {
|
||||
static get is() { return 'comment-api-mock'; }
|
||||
window.addEventListener('HTMLImportsLoaded', () => {
|
||||
class CommentApiMock extends Polymer.GestureEventListeners(
|
||||
Polymer.LegacyElementMixin(
|
||||
Polymer.Element)) {
|
||||
static get is() { return 'comment-api-mock'; }
|
||||
|
||||
static get properties() {
|
||||
return {
|
||||
_changeComments: Object,
|
||||
};
|
||||
static get properties() {
|
||||
return {
|
||||
_changeComments: Object,
|
||||
};
|
||||
}
|
||||
|
||||
loadComments() {
|
||||
return this._reloadComments();
|
||||
}
|
||||
|
||||
/**
|
||||
* For the purposes of the mock, _reloadDrafts is not included because its
|
||||
* response is the same type as reloadComments, just makes less API
|
||||
* requests. Since this is for test purposes/mocked data anyway, keep this
|
||||
* file simpler by just using _reloadComments here instead.
|
||||
*/
|
||||
_reloadDraftsWithCallback(e) {
|
||||
return this._reloadComments().then(() => e.detail.resolve());
|
||||
}
|
||||
|
||||
_reloadComments() {
|
||||
return this.$.commentAPI.loadAll(this._changeNum)
|
||||
.then(comments => {
|
||||
this._changeComments = this.$.commentAPI._changeComments;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadComments() {
|
||||
return this._reloadComments();
|
||||
}
|
||||
|
||||
/**
|
||||
* For the purposes of the mock, _reloadDrafts is not included because its
|
||||
* response is the same type as reloadComments, just makes less API
|
||||
* requests. Since this is for test purposes/mocked data anyway, keep this
|
||||
* file simpler by just using _reloadComments here instead.
|
||||
*/
|
||||
_reloadDraftsWithCallback(e) {
|
||||
return this._reloadComments().then(() => e.detail.resolve());
|
||||
}
|
||||
|
||||
_reloadComments() {
|
||||
return this.$.commentAPI.loadAll(this._changeNum)
|
||||
.then(comments => {
|
||||
this._changeComments = this.$.commentAPI._changeComments;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define(CommentApiMock.is, CommentApiMock);
|
||||
customElements.define(CommentApiMock.is, CommentApiMock);
|
||||
});
|
||||
})();
|
||||
|
@@ -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-comment-api.html">
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-comment-api tests', () => {
|
||||
suite('gr-comment-api tests', async () => {
|
||||
await readyToTest();
|
||||
const PARENT = 'PARENT';
|
||||
|
||||
let element;
|
||||
|
@@ -24,6 +24,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="../gr-diff/gr-diff-line.js"></script>
|
||||
<script src="../../../test/test-pre-setup.js"></script>
|
||||
<link rel="import" href="../../../test/common-test-setup.html"/>
|
||||
|
||||
<link rel="import" href="gr-coverage-layer.html">
|
||||
@@ -37,7 +38,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-coverage-layer', () => {
|
||||
suite('gr-coverage-layer', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
|
||||
setup(() => {
|
||||
|
@@ -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 src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
@@ -34,7 +35,8 @@ limitations under the License.
|
||||
<script>void(0);</script>
|
||||
|
||||
<script>
|
||||
suite('GrDiffBuilderUnified tests', () => {
|
||||
suite('GrDiffBuilderUnified tests', async () => {
|
||||
await readyToTest();
|
||||
let prefs;
|
||||
let outputEl;
|
||||
let diffBuilder;
|
||||
|
@@ -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 src="../../../scripts/util.js"></script>
|
||||
<script src="../gr-diff/gr-diff-line.js"></script>
|
||||
@@ -59,7 +60,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-diff-builder tests', () => {
|
||||
suite('gr-diff-builder tests', async () => {
|
||||
await readyToTest();
|
||||
let prefs;
|
||||
let element;
|
||||
let builder;
|
||||
|
@@ -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 src="../../../scripts/util.js"></script>
|
||||
|
||||
@@ -49,7 +50,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-diff-cursor tests', () => {
|
||||
suite('gr-diff-cursor tests', async () => {
|
||||
await readyToTest();
|
||||
let sandbox;
|
||||
let cursorElement;
|
||||
let diffElement;
|
||||
@@ -387,25 +389,25 @@ limitations under the License.
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('gr-diff-cursor event tests', () => {
|
||||
let sandbox;
|
||||
let someEmptyDiv;
|
||||
suite('gr-diff-cursor event tests', () => {
|
||||
let sandbox;
|
||||
let someEmptyDiv;
|
||||
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
someEmptyDiv = fixture('empty');
|
||||
});
|
||||
|
||||
teardown(() => sandbox.restore());
|
||||
|
||||
test('ready is fired after component is rendered', done => {
|
||||
const cursorElement = document.createElement('gr-diff-cursor');
|
||||
cursorElement.addEventListener('ready', () => {
|
||||
done();
|
||||
setup(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
someEmptyDiv = fixture('empty');
|
||||
});
|
||||
|
||||
teardown(() => sandbox.restore());
|
||||
|
||||
test('ready is fired after component is rendered', done => {
|
||||
const cursorElement = document.createElement('gr-diff-cursor');
|
||||
cursorElement.addEventListener('ready', () => {
|
||||
done();
|
||||
});
|
||||
someEmptyDiv.appendChild(cursorElement);
|
||||
});
|
||||
someEmptyDiv.appendChild(cursorElement);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@@ -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 src="gr-annotation.js"></script>
|
||||
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('annotation', () => {
|
||||
suite('annotation', async () => {
|
||||
await readyToTest();
|
||||
let str;
|
||||
let parent;
|
||||
let textNode;
|
||||
|
@@ -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-diff-highlight.html">
|
||||
|
||||
@@ -147,7 +148,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-diff-highlight', () => {
|
||||
suite('gr-diff-highlight', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
@@ -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-diff-host.html">
|
||||
@@ -36,7 +37,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-diff-host tests', () => {
|
||||
suite('gr-diff-host tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
let getLoggedIn;
|
||||
|
@@ -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 src="/bower_components/page/page.js"></script>
|
||||
<script src="../../../scripts/util.js"></script>
|
||||
@@ -38,7 +39,8 @@ limitations under the License.
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('gr-diff-mode-selector tests', () => {
|
||||
suite('gr-diff-mode-selector tests', async () => {
|
||||
await readyToTest();
|
||||
let element;
|
||||
let sandbox;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user