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