Cleanup Gerrit global variable from tests and types
Change-Id: I70d8fcd68a8c7982f0ebbb9242f9cf4455fac86f
This commit is contained in:
@@ -165,7 +165,6 @@ module.exports = {
|
|||||||
// You must not add anything new in this list!
|
// You must not add anything new in this list!
|
||||||
// Instead export variables from modules
|
// Instead export variables from modules
|
||||||
// TODO(dmfilippov): Remove global variables from polygerrit
|
// TODO(dmfilippov): Remove global variables from polygerrit
|
||||||
"Gerrit": "readonly",
|
|
||||||
"GrReporting": "readonly",
|
"GrReporting": "readonly",
|
||||||
// Global variables from 3rd party libraries.
|
// Global variables from 3rd party libraries.
|
||||||
// You should not add anything in this list, always try to import
|
// You should not add anything in this list, always try to import
|
||||||
@@ -212,6 +211,13 @@ module.exports = {
|
|||||||
"HTMLImports": "readonly",
|
"HTMLImports": "readonly",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"files": ["samples/**/*.js", "**/test/plugin.html"],
|
||||||
|
"globals": {
|
||||||
|
// Settings for samples. You can add globals here if you want to use it
|
||||||
|
"Gerrit": "readonly",
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"files": ["test/functional/**/*.js", "wct.conf.js", "template_test.js"],
|
"files": ["test/functional/**/*.js", "wct.conf.js", "template_test.js"],
|
||||||
// Settings for functional tests. These scripts are node scripts.
|
// Settings for functional tests. These scripts are node scripts.
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ import './gr-change-metadata.js';
|
|||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {resetPlugins} from '../../../test/test-utils.js';
|
import {resetPlugins} from '../../../test/test-utils.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-change-metadata integration tests', () => {
|
suite('gr-change-metadata integration tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -142,7 +142,7 @@ suite('gr-change-metadata integration tests', () => {
|
|||||||
let plugin;
|
let plugin;
|
||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
Gerrit.install(p => plugin = p, '0.1',
|
pluginApi.install(p => plugin = p, '0.1',
|
||||||
new URL('test/plugin.html?' + Math.random(),
|
new URL('test/plugin.html?' + Math.random(),
|
||||||
window.location.href).toString());
|
window.location.href).toString());
|
||||||
sandbox.stub(pluginLoader, 'arePluginsLoaded').returns(true);
|
sandbox.stub(pluginLoader, 'arePluginsLoaded').returns(true);
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ import '../../core/gr-router/gr-router.js';
|
|||||||
import './gr-change-metadata.js';
|
import './gr-change-metadata.js';
|
||||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-change-metadata tests', () => {
|
suite('gr-change-metadata tests', () => {
|
||||||
let element;
|
let element;
|
||||||
@@ -754,7 +754,7 @@ suite('gr-change-metadata tests', () => {
|
|||||||
element.revision = {};
|
element.revision = {};
|
||||||
let hookEl;
|
let hookEl;
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(
|
pluginApi.install(
|
||||||
p => {
|
p => {
|
||||||
plugin = p;
|
plugin = p;
|
||||||
plugin.hook('change-metadata-item').getLastAttached()
|
plugin.hook('change-metadata-item').getLastAttached()
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ import {_testOnly_resetEndpoints} from '../../shared/gr-js-api-interface/gr-plug
|
|||||||
import {util} from '../../../scripts/util.js';
|
import {util} from '../../../scripts/util.js';
|
||||||
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-change-view tests', () => {
|
suite('gr-change-view tests', () => {
|
||||||
const kb = KeyboardShortcutBinder;
|
const kb = KeyboardShortcutBinder;
|
||||||
@@ -315,7 +315,7 @@ suite('gr-change-view tests', () => {
|
|||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
sandbox.stub(element.$.actions, 'reload').returns(Promise.resolve());
|
sandbox.stub(element.$.actions, 'reload').returns(Promise.resolve());
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
Gerrit.install(
|
pluginApi.install(
|
||||||
plugin => {
|
plugin => {
|
||||||
plugin.registerDynamicCustomComponent(
|
plugin.registerDynamicCustomComponent(
|
||||||
'change-view-tab-header',
|
'change-view-tab-header',
|
||||||
@@ -2223,7 +2223,7 @@ suite('gr-change-view tests', () => {
|
|||||||
element._selectedRevision = {};
|
element._selectedRevision = {};
|
||||||
let hookEl;
|
let hookEl;
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(
|
pluginApi.install(
|
||||||
p => {
|
p => {
|
||||||
plugin = p;
|
plugin = p;
|
||||||
plugin.hook('change-view-integration').getLastAttached()
|
plugin.hook('change-view-integration').getLastAttached()
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ import './gr-reply-dialog.js';
|
|||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {resetPlugins} from '../../../test/test-utils.js';
|
import {resetPlugins} from '../../../test/test-utils.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
_testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-reply-dialog tests', () => {
|
suite('gr-reply-dialog tests', () => {
|
||||||
let element;
|
let element;
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ void (0);
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import './gr-error-manager.js';
|
import './gr-error-manager.js';
|
||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
_testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-error-manager tests', () => {
|
suite('gr-error-manager tests', () => {
|
||||||
let element;
|
let element;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-admin-api tests', () => {
|
suite('gr-admin-api tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -39,7 +39,7 @@ suite('gr-admin-api tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
adminApi = plugin.admin();
|
adminApi = plugin.admin();
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||||
import {GrDomHook, GrDomHooksManager} from './gr-dom-hooks.js';
|
import {GrDomHook, GrDomHooksManager} from './gr-dom-hooks.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-dom-hooks tests', () => {
|
suite('gr-dom-hooks tests', () => {
|
||||||
const PUBLIC_METHODS =[
|
const PUBLIC_METHODS =[
|
||||||
@@ -55,7 +55,7 @@ suite('gr-dom-hooks tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
instance = new GrDomHooksManager(plugin);
|
instance = new GrDomHooksManager(plugin);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ import '../gr-endpoint-param/gr-endpoint-param.js';
|
|||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {resetPlugins} from '../../../test/test-utils.js';
|
import {resetPlugins} from '../../../test/test-utils.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-endpoint-decorator', () => {
|
suite('gr-endpoint-decorator', () => {
|
||||||
let container;
|
let container;
|
||||||
@@ -65,7 +65,7 @@ suite('gr-endpoint-decorator', () => {
|
|||||||
});
|
});
|
||||||
resetPlugins();
|
resetPlugins();
|
||||||
container = fixture('basic');
|
container = fixture('basic');
|
||||||
Gerrit.install(p => plugin = p, '0.1',
|
pluginApi.install(p => plugin = p, '0.1',
|
||||||
'http://some/plugin/url.html');
|
'http://some/plugin/url.html');
|
||||||
// Decoration
|
// Decoration
|
||||||
decorationHook = plugin.registerCustomComponent('first', 'some-module');
|
decorationHook = plugin.registerCustomComponent('first', 'some-module');
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import './gr-external-style.js';
|
import './gr-external-style.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-external-style integration tests', () => {
|
suite('gr-external-style integration tests', () => {
|
||||||
const TEST_URL = 'http://some/plugin/url.html';
|
const TEST_URL = 'http://some/plugin/url.html';
|
||||||
@@ -47,7 +47,7 @@ suite('gr-external-style integration tests', () => {
|
|||||||
|
|
||||||
const installPlugin = () => {
|
const installPlugin = () => {
|
||||||
if (plugin) { return; }
|
if (plugin) { return; }
|
||||||
Gerrit.install(p => {
|
pluginApi.install(p => {
|
||||||
plugin = p;
|
plugin = p;
|
||||||
}, '0.1', TEST_URL);
|
}, '0.1', TEST_URL);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ import '../../../test/common-test-setup.js';
|
|||||||
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {GrPopupInterface} from './gr-popup-interface.js';
|
import {GrPopupInterface} from './gr-popup-interface.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
suite('gr-popup-interface tests', () => {
|
suite('gr-popup-interface tests', () => {
|
||||||
let container;
|
let container;
|
||||||
let instance;
|
let instance;
|
||||||
@@ -58,7 +58,7 @@ suite('gr-popup-interface tests', () => {
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
container = fixture('container');
|
container = fixture('container');
|
||||||
sandbox.stub(plugin, 'hook').returns({
|
sandbox.stub(plugin, 'hook').returns({
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-repo-api tests', () => {
|
suite('gr-repo-api tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -46,7 +46,7 @@ suite('gr-repo-api tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
repoApi = plugin.project();
|
repoApi = plugin.project();
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-settings-api tests', () => {
|
suite('gr-settings-api tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -48,7 +48,7 @@ suite('gr-settings-api tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
settingsApi = plugin.settings();
|
settingsApi = plugin.settings();
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ import '../../../test/common-test-setup.js';
|
|||||||
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
import '../../shared/gr-js-api-interface/gr-js-api-interface.js';
|
||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-styles-api tests', () => {
|
suite('gr-styles-api tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -52,7 +52,7 @@ suite('gr-styles-api tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
stylesApi = plugin.styles();
|
stylesApi = plugin.styles();
|
||||||
@@ -81,7 +81,7 @@ suite('gr-styles-api tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
stylesApi = plugin.styles();
|
stylesApi = plugin.styles();
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
import '../gr-endpoint-decorator/gr-endpoint-decorator.js';
|
||||||
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
import {pluginLoader} from '../../shared/gr-js-api-interface/gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../../shared/gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-theme-api tests', () => {
|
suite('gr-theme-api tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -47,7 +47,7 @@ suite('gr-theme-api tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
theme = plugin.theme();
|
theme = plugin.theme();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../gr-js-api-interface/gr-js-api-interface.js';
|
import '../gr-js-api-interface/gr-js-api-interface.js';
|
||||||
import {EventEmitter} from './gr-event-interface.js';
|
import {EventEmitter} from './gr-event-interface.js';
|
||||||
import {initGerritPluginApi} from '../gr-js-api-interface/gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from '../gr-js-api-interface/gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-event-interface tests', () => {
|
suite('gr-event-interface tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -50,46 +50,46 @@ suite('gr-event-interface tests', () => {
|
|||||||
suite('test on Gerrit', () => {
|
suite('test on Gerrit', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
fixture('basic');
|
fixture('basic');
|
||||||
Gerrit.removeAllListeners();
|
pluginApi.removeAllListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('communicate between plugin and Gerrit', done => {
|
test('communicate between plugin and Gerrit', done => {
|
||||||
const eventName = 'test-plugin-event';
|
const eventName = 'test-plugin-event';
|
||||||
let p;
|
let p;
|
||||||
Gerrit.on(eventName, e => {
|
pluginApi.on(eventName, e => {
|
||||||
assert.equal(e.value, 'test');
|
assert.equal(e.value, 'test');
|
||||||
assert.equal(e.plugin, p);
|
assert.equal(e.plugin, p);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
Gerrit.install(plugin => {
|
pluginApi.install(plugin => {
|
||||||
p = plugin;
|
p = plugin;
|
||||||
Gerrit.emit(eventName, {value: 'test', plugin});
|
pluginApi.emit(eventName, {value: 'test', plugin});
|
||||||
}, '0.1',
|
}, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('listen on events from core', done => {
|
test('listen on events from core', done => {
|
||||||
const eventName = 'test-plugin-event';
|
const eventName = 'test-plugin-event';
|
||||||
Gerrit.on(eventName, e => {
|
pluginApi.on(eventName, e => {
|
||||||
assert.equal(e.value, 'test');
|
assert.equal(e.value, 'test');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
Gerrit.emit(eventName, {value: 'test'});
|
pluginApi.emit(eventName, {value: 'test'});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('communicate across plugins', done => {
|
test('communicate across plugins', done => {
|
||||||
const eventName = 'test-plugin-event';
|
const eventName = 'test-plugin-event';
|
||||||
Gerrit.install(plugin => {
|
pluginApi.install(plugin => {
|
||||||
Gerrit.on(eventName, e => {
|
pluginApi.on(eventName, e => {
|
||||||
assert.equal(e.plugin.getPluginName(), 'testB');
|
assert.equal(e.plugin.getPluginName(), 'testB');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, '0.1',
|
}, '0.1',
|
||||||
'http://test.com/plugins/testA/static/testA.js');
|
'http://test.com/plugins/testA/static/testA.js');
|
||||||
|
|
||||||
Gerrit.install(plugin => {
|
pluginApi.install(plugin => {
|
||||||
Gerrit.emit(eventName, {plugin});
|
pluginApi.emit(eventName, {plugin});
|
||||||
}, '0.1',
|
}, '0.1',
|
||||||
'http://test.com/plugins/testB/static/testB.js');
|
'http://test.com/plugins/testB/static/testB.js');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import '../../../test/common-test-setup.js';
|
|||||||
import './gr-js-api-interface.js';
|
import './gr-js-api-interface.js';
|
||||||
import {GrAnnotation} from '../../diff/gr-diff-highlight/gr-annotation.js';
|
import {GrAnnotation} from '../../diff/gr-diff-highlight/gr-annotation.js';
|
||||||
import {GrAnnotationActionsContext} from './gr-annotation-actions-context.js';
|
import {GrAnnotationActionsContext} from './gr-annotation-actions-context.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-annotation-actions-context tests', () => {
|
suite('gr-annotation-actions-context tests', () => {
|
||||||
let instance;
|
let instance;
|
||||||
@@ -47,7 +47,7 @@ suite('gr-annotation-actions-context tests', () => {
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
|
|
||||||
const str = 'lorem ipsum blah blah';
|
const str = 'lorem ipsum blah blah';
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ limitations under the License.
|
|||||||
<script type="module">
|
<script type="module">
|
||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../../change/gr-change-actions/gr-change-actions.js';
|
import '../../change/gr-change-actions/gr-change-actions.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-annotation-actions-js-api tests', () => {
|
suite('gr-annotation-actions-js-api tests', () => {
|
||||||
let annotationActions;
|
let annotationActions;
|
||||||
@@ -48,7 +48,7 @@ suite('gr-annotation-actions-js-api tests', () => {
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
annotationActions = plugin.annotationApi();
|
annotationActions = plugin.annotationApi();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ import '../../change/gr-change-actions/gr-change-actions.js';
|
|||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {resetPlugins} from '../../../test/test-utils.js';
|
import {resetPlugins} from '../../../test/test-utils.js';
|
||||||
import {pluginLoader} from './gr-plugin-loader.js';
|
import {pluginLoader} from './gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-js-api-interface tests', () => {
|
suite('gr-js-api-interface tests', () => {
|
||||||
let element;
|
let element;
|
||||||
@@ -59,7 +59,7 @@ suite('gr-js-api-interface tests', () => {
|
|||||||
suite('early init', () => {
|
suite('early init', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
resetPlugins();
|
resetPlugins();
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
// Mimic all plugins loaded.
|
// Mimic all plugins loaded.
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
@@ -86,7 +86,7 @@ suite('gr-js-api-interface tests', () => {
|
|||||||
sinon.stub(element, '_editStatusChanged');
|
sinon.stub(element, '_editStatusChanged');
|
||||||
element.change = {};
|
element.change = {};
|
||||||
element._hasKnownChainState = false;
|
element._hasKnownChainState = false;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
changeActions = plugin.changeActions();
|
changeActions = plugin.changeActions();
|
||||||
// Mimic all plugins loaded.
|
// Mimic all plugins loaded.
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ breaking changes to gr-reply-dialog won’t be noticed.
|
|||||||
<script type="module">
|
<script type="module">
|
||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import '../../change/gr-reply-dialog/gr-reply-dialog.js';
|
import '../../change/gr-reply-dialog/gr-reply-dialog.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-change-reply-js-api tests', () => {
|
suite('gr-change-reply-js-api tests', () => {
|
||||||
let element;
|
let element;
|
||||||
@@ -61,7 +61,7 @@ suite('gr-change-reply-js-api tests', () => {
|
|||||||
|
|
||||||
suite('early init', () => {
|
suite('early init', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
changeReply = plugin.changeReply();
|
changeReply = plugin.changeReply();
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
@@ -93,7 +93,7 @@ suite('gr-change-reply-js-api tests', () => {
|
|||||||
suite('normal init', () => {
|
suite('normal init', () => {
|
||||||
setup(() => {
|
setup(() => {
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
changeReply = plugin.changeReply();
|
changeReply = plugin.changeReply();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ export function initGerritPluginApi() {
|
|||||||
pluginLoader.installPreloadedPlugins();
|
pluginLoader.installPreloadedPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function _testOnly_initGerritPluginApi() {
|
||||||
|
initGerritPluginApi();
|
||||||
|
return window.Gerrit;
|
||||||
|
}
|
||||||
|
|
||||||
export function deprecatedDelete(url, opt_callback) {
|
export function deprecatedDelete(url, opt_callback) {
|
||||||
console.warn('.delete() is deprecated! Use plugin.restApi().delete()');
|
console.warn('.delete() is deprecated! Use plugin.restApi().delete()');
|
||||||
return getRestAPI().send('DELETE', url)
|
return getRestAPI().send('DELETE', url)
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ import '../../../test/common-test-setup.js';
|
|||||||
import './gr-js-api-interface.js';
|
import './gr-js-api-interface.js';
|
||||||
import {pluginLoader} from './gr-plugin-loader.js';
|
import {pluginLoader} from './gr-plugin-loader.js';
|
||||||
import {resetPlugins} from '../../../test/test-utils.js';
|
import {resetPlugins} from '../../../test/test-utils.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-gerrit tests', () => {
|
suite('gr-gerrit tests', () => {
|
||||||
let element;
|
let element;
|
||||||
@@ -74,7 +74,7 @@ suite('gr-gerrit tests', () => {
|
|||||||
'isPluginEnabled',
|
'isPluginEnabled',
|
||||||
(...args) => stubFn(...args)
|
(...args) => stubFn(...args)
|
||||||
);
|
);
|
||||||
Gerrit._isPluginEnabled('test_plugin');
|
pluginApi._isPluginEnabled('test_plugin');
|
||||||
assert.isTrue(stubFn.calledWith('test_plugin'));
|
assert.isTrue(stubFn.calledWith('test_plugin'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ suite('gr-gerrit tests', () => {
|
|||||||
'isPluginLoaded',
|
'isPluginLoaded',
|
||||||
(...args) => stubFn(...args)
|
(...args) => stubFn(...args)
|
||||||
);
|
);
|
||||||
Gerrit._isPluginLoaded('test_plugin');
|
pluginApi._isPluginLoaded('test_plugin');
|
||||||
assert.isTrue(stubFn.calledWith('test_plugin'));
|
assert.isTrue(stubFn.calledWith('test_plugin'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ suite('gr-gerrit tests', () => {
|
|||||||
'isPluginPreloaded',
|
'isPluginPreloaded',
|
||||||
(...args) => stubFn(...args)
|
(...args) => stubFn(...args)
|
||||||
);
|
);
|
||||||
Gerrit._isPluginPreloaded('test_plugin');
|
pluginApi._isPluginPreloaded('test_plugin');
|
||||||
assert.isTrue(stubFn.calledWith('test_plugin'));
|
assert.isTrue(stubFn.calledWith('test_plugin'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ import {GrSettingsApi} from '../../plugins/gr-settings-api/gr-settings-api.js';
|
|||||||
import {GrPluginActionContext} from './gr-plugin-action-context.js';
|
import {GrPluginActionContext} from './gr-plugin-action-context.js';
|
||||||
import {PLUGIN_LOADING_TIMEOUT_MS} from './gr-api-utils.js';
|
import {PLUGIN_LOADING_TIMEOUT_MS} from './gr-api-utils.js';
|
||||||
import {pluginLoader} from './gr-plugin-loader.js';
|
import {pluginLoader} from './gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-js-api-interface tests', () => {
|
suite('gr-js-api-interface tests', () => {
|
||||||
let element;
|
let element;
|
||||||
@@ -71,7 +71,7 @@ suite('gr-js-api-interface tests', () => {
|
|||||||
});
|
});
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
errorStub = sandbox.stub(console, 'error');
|
errorStub = sandbox.stub(console, 'error');
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
pluginLoader.loadPlugins([]);
|
pluginLoader.loadPlugins([]);
|
||||||
});
|
});
|
||||||
@@ -91,7 +91,7 @@ suite('gr-js-api-interface tests', () => {
|
|||||||
|
|
||||||
test('url for preloaded plugin without ASSETS_PATH', () => {
|
test('url for preloaded plugin without ASSETS_PATH', () => {
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'preloaded:testpluginB');
|
'preloaded:testpluginB');
|
||||||
assert.equal(plugin.url(),
|
assert.equal(plugin.url(),
|
||||||
`${window.location.origin}/plugins/testpluginB/`);
|
`${window.location.origin}/plugins/testpluginB/`);
|
||||||
@@ -103,7 +103,7 @@ suite('gr-js-api-interface tests', () => {
|
|||||||
const oldAssetsPath = window.ASSETS_PATH;
|
const oldAssetsPath = window.ASSETS_PATH;
|
||||||
window.ASSETS_PATH = 'http://test.com';
|
window.ASSETS_PATH = 'http://test.com';
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'preloaded:testpluginC');
|
'preloaded:testpluginC');
|
||||||
assert.equal(plugin.url(), `${window.ASSETS_PATH}/plugins/testpluginC/`);
|
assert.equal(plugin.url(), `${window.ASSETS_PATH}/plugins/testpluginC/`);
|
||||||
assert.equal(plugin.url('/static/test.js'),
|
assert.equal(plugin.url('/static/test.js'),
|
||||||
@@ -388,7 +388,7 @@ suite('gr-js-api-interface tests', () => {
|
|||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox.stub(BaseUrlBehavior, 'getBaseUrl').returns('/r');
|
sandbox.stub(BaseUrlBehavior, 'getBaseUrl').returns('/r');
|
||||||
|
|
||||||
Gerrit.install(p => { baseUrlPlugin = p; }, '0.1',
|
pluginApi.install(p => { baseUrlPlugin = p; }, '0.1',
|
||||||
'http://test.com/r/plugins/baseurlplugin/static/test.js');
|
'http://test.com/r/plugins/baseurlplugin/static/test.js');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ import '../../../test/common-test-setup.js';
|
|||||||
import './gr-js-api-interface.js';
|
import './gr-js-api-interface.js';
|
||||||
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
|
||||||
import {GrPluginActionContext} from './gr-plugin-action-context.js';
|
import {GrPluginActionContext} from './gr-plugin-action-context.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-plugin-action-context tests', () => {
|
suite('gr-plugin-action-context tests', () => {
|
||||||
let instance;
|
let instance;
|
||||||
@@ -46,7 +46,7 @@ suite('gr-plugin-action-context tests', () => {
|
|||||||
|
|
||||||
setup(() => {
|
setup(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
instance = new GrPluginActionContext(plugin);
|
instance = new GrPluginActionContext(plugin);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ import '../../../test/common-test-setup.js';
|
|||||||
import './gr-js-api-interface.js';
|
import './gr-js-api-interface.js';
|
||||||
import {GrPluginEndpoints} from './gr-plugin-endpoints.js';
|
import {GrPluginEndpoints} from './gr-plugin-endpoints.js';
|
||||||
import {pluginLoader} from './gr-plugin-loader.js';
|
import {pluginLoader} from './gr-plugin-loader.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-plugin-endpoints tests', () => {
|
suite('gr-plugin-endpoints tests', () => {
|
||||||
let sandbox;
|
let sandbox;
|
||||||
@@ -44,11 +44,11 @@ suite('gr-plugin-endpoints tests', () => {
|
|||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
domHook = {};
|
domHook = {};
|
||||||
instance = new GrPluginEndpoints();
|
instance = new GrPluginEndpoints();
|
||||||
Gerrit.install(p => { pluginFoo = p; }, '0.1',
|
pluginApi.install(p => { pluginFoo = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/foo.html');
|
'http://test.com/plugins/testplugin/static/foo.html');
|
||||||
instance.registerModule(
|
instance.registerModule(
|
||||||
pluginFoo, 'a-place', 'decorate', 'foo-module', domHook);
|
pluginFoo, 'a-place', 'decorate', 'foo-module', domHook);
|
||||||
Gerrit.install(p => { pluginBar = p; }, '0.1',
|
pluginApi.install(p => { pluginBar = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/bar.html');
|
'http://test.com/plugins/testplugin/static/bar.html');
|
||||||
instance.registerModule(
|
instance.registerModule(
|
||||||
pluginBar, 'a-place', 'style', 'bar-module', domHook);
|
pluginBar, 'a-place', 'style', 'bar-module', domHook);
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ import {PRELOADED_PROTOCOL, PLUGIN_LOADING_TIMEOUT_MS} from './gr-api-utils.js';
|
|||||||
import {pluginLoader} from './gr-plugin-loader.js';
|
import {pluginLoader} from './gr-plugin-loader.js';
|
||||||
import {resetPlugins} from '../../../test/test-utils.js';
|
import {resetPlugins} from '../../../test/test-utils.js';
|
||||||
import {_testOnly_flushPreinstalls} from './gr-gerrit.js';
|
import {_testOnly_flushPreinstalls} from './gr-gerrit.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-plugin-loader tests', () => {
|
suite('gr-plugin-loader tests', () => {
|
||||||
let plugin;
|
let plugin;
|
||||||
@@ -72,11 +72,11 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('reuse plugin for install calls', () => {
|
test('reuse plugin for install calls', () => {
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1',
|
pluginApi.install(p => { plugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
|
|
||||||
let otherPlugin;
|
let otherPlugin;
|
||||||
Gerrit.install(p => { otherPlugin = p; }, '0.1',
|
pluginApi.install(p => { otherPlugin = p; }, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
assert.strictEqual(plugin, otherPlugin);
|
assert.strictEqual(plugin, otherPlugin);
|
||||||
});
|
});
|
||||||
@@ -93,7 +93,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
|
|
||||||
test('versioning', () => {
|
test('versioning', () => {
|
||||||
const callback = sandbox.spy();
|
const callback = sandbox.spy();
|
||||||
Gerrit.install(callback, '0.0pre-alpha');
|
pluginApi.install(callback, '0.0pre-alpha');
|
||||||
assert(callback.notCalled);
|
assert(callback.notCalled);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
|
|
||||||
test('plugins installed successfully', done => {
|
test('plugins installed successfully', done => {
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => void 0, undefined, url);
|
pluginApi.install(() => void 0, undefined, url);
|
||||||
});
|
});
|
||||||
const pluginsLoadedStub = sandbox.stub();
|
const pluginsLoadedStub = sandbox.stub();
|
||||||
stub('gr-reporting', {
|
stub('gr-reporting', {
|
||||||
@@ -148,7 +148,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
|
|
||||||
test('isPluginEnabled and isPluginLoaded', done => {
|
test('isPluginEnabled and isPluginLoaded', done => {
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => void 0, undefined, url);
|
pluginApi.install(() => void 0, undefined, url);
|
||||||
});
|
});
|
||||||
const pluginsLoadedStub = sandbox.stub();
|
const pluginsLoadedStub = sandbox.stub();
|
||||||
stub('gr-reporting', {
|
stub('gr-reporting', {
|
||||||
@@ -185,7 +185,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
document.addEventListener('show-alert', alertStub);
|
document.addEventListener('show-alert', alertStub);
|
||||||
|
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => {
|
pluginApi.install(() => {
|
||||||
if (url === plugins[0]) {
|
if (url === plugins[0]) {
|
||||||
throw new Error('failed');
|
throw new Error('failed');
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
document.addEventListener('show-alert', alertStub);
|
document.addEventListener('show-alert', alertStub);
|
||||||
|
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => {
|
pluginApi.install(() => {
|
||||||
if (url === plugins[0]) {
|
if (url === plugins[0]) {
|
||||||
throw new Error('failed');
|
throw new Error('failed');
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
document.addEventListener('show-alert', alertStub);
|
document.addEventListener('show-alert', alertStub);
|
||||||
|
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => {
|
pluginApi.install(() => {
|
||||||
throw new Error('failed');
|
throw new Error('failed');
|
||||||
}, undefined, url);
|
}, undefined, url);
|
||||||
});
|
});
|
||||||
@@ -284,7 +284,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
document.addEventListener('show-alert', alertStub);
|
document.addEventListener('show-alert', alertStub);
|
||||||
|
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => {
|
pluginApi.install(() => {
|
||||||
}, url === plugins[0] ? '' : 'alpha', url);
|
}, url === plugins[0] ? '' : 'alpha', url);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
|
|
||||||
test('multiple assets for same plugin installed successfully', done => {
|
test('multiple assets for same plugin installed successfully', done => {
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => void 0, undefined, url);
|
pluginApi.install(() => void 0, undefined, url);
|
||||||
});
|
});
|
||||||
const pluginsLoadedStub = sandbox.stub();
|
const pluginsLoadedStub = sandbox.stub();
|
||||||
stub('gr-reporting', {
|
stub('gr-reporting', {
|
||||||
@@ -498,7 +498,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
sandbox.stub(pluginLoader, '_loadJsPlugin', url => {
|
||||||
Gerrit.install(() => pluginCallback(url), undefined, url);
|
pluginApi.install(() => pluginCallback(url), undefined, url);
|
||||||
});
|
});
|
||||||
|
|
||||||
pluginLoader.loadPlugins(plugins);
|
pluginLoader.loadPlugins(plugins);
|
||||||
@@ -559,7 +559,7 @@ suite('gr-plugin-loader tests', () => {
|
|||||||
|
|
||||||
test('installing preloaded plugin', () => {
|
test('installing preloaded plugin', () => {
|
||||||
let plugin;
|
let plugin;
|
||||||
Gerrit.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
|
pluginApi.install(p => { plugin = p; }, '0.1', 'preloaded:foo');
|
||||||
assert.strictEqual(plugin.getPluginName(), 'foo');
|
assert.strictEqual(plugin.getPluginName(), 'foo');
|
||||||
assert.strictEqual(plugin.url('/some/thing.html'),
|
assert.strictEqual(plugin.url('/some/thing.html'),
|
||||||
`${window.location.origin}/plugins/foo/some/thing.html`);
|
`${window.location.origin}/plugins/foo/some/thing.html`);
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ limitations under the License.
|
|||||||
import '../../../test/common-test-setup.js';
|
import '../../../test/common-test-setup.js';
|
||||||
import './gr-js-api-interface.js';
|
import './gr-js-api-interface.js';
|
||||||
import {GrPluginRestApi} from './gr-plugin-rest-api.js';
|
import {GrPluginRestApi} from './gr-plugin-rest-api.js';
|
||||||
import {initGerritPluginApi} from './gr-gerrit.js';
|
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
|
||||||
|
|
||||||
initGerritPluginApi();
|
const pluginApi = _testOnly_initGerritPluginApi();
|
||||||
|
|
||||||
suite('gr-plugin-rest-api tests', () => {
|
suite('gr-plugin-rest-api tests', () => {
|
||||||
let instance;
|
let instance;
|
||||||
@@ -54,7 +54,7 @@ suite('gr-plugin-rest-api tests', () => {
|
|||||||
a[k] = (...args) => restApiStub[k](...args);
|
a[k] = (...args) => restApiStub[k](...args);
|
||||||
return a;
|
return a;
|
||||||
}, {}));
|
}, {}));
|
||||||
Gerrit.install(p => {}, '0.1',
|
pluginApi.install(p => {}, '0.1',
|
||||||
'http://test.com/plugins/testplugin/static/test.js');
|
'http://test.com/plugins/testplugin/static/test.js');
|
||||||
instance = new GrPluginRestApi();
|
instance = new GrPluginRestApi();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ export const CoverageType = {
|
|||||||
NOT_INSTRUMENTED: 'NOT_INSTRUMENTED',
|
NOT_INSTRUMENTED: 'NOT_INSTRUMENTED',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Gerrit = window.Gerrit || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
* start_line: number,
|
* start_line: number,
|
||||||
|
|||||||
Reference in New Issue
Block a user