Move PluginEndpoints to be on PluginLoader
Additionally, get rid of the reset functionality for PluginLoader as
this is automatically done by the fact that we recreate all dependencies
on each test run
Release-Notes: skip
Change-Id: I6a82ff3771eeda0b2b56eeb20581492c19eefc84
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
index b4ef453..d9982b1 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
@@ -17,7 +17,6 @@
import '../../shared/gr-tooltip-content/gr-tooltip-content';
import {navigationToken} from '../../core/gr-navigation/gr-navigation';
import {getDisplayName} from '../../../utils/display-name-util';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {getAppContext} from '../../../services/app-context';
import {truncatePath} from '../../../utils/path-list-util';
import {changeStatuses} from '../../../utils/change-util';
@@ -142,9 +141,10 @@
this.getPluginLoader()
.awaitPluginsLoaded()
.then(() => {
- this.dynamicCellEndpoints = getPluginEndpoints().getDynamicEndpoints(
- 'change-list-item-cell'
- );
+ this.dynamicCellEndpoints =
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-list-item-cell'
+ );
});
this.addEventListener('click', this.onItemClick);
}
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
index 50f2c02..4c43da5 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
@@ -10,7 +10,6 @@
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
import {getAppContext} from '../../../services/app-context';
import {navigationToken} from '../../core/gr-navigation/gr-navigation';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {GrCursorManager} from '../../shared/gr-cursor-manager/gr-cursor-manager';
import {
AccountInfo,
@@ -185,7 +184,9 @@
.awaitPluginsLoaded()
.then(() => {
this.dynamicHeaderEndpoints =
- getPluginEndpoints().getDynamicEndpoints('change-list-header');
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-list-header'
+ );
});
}
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
index 9db339be..50bb9d9 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
@@ -46,7 +46,6 @@
import {GrEndpointDecorator} from '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
import {
queryAndAssert,
- resetPlugins,
stubRestApi,
waitUntilCalled,
} from '../../../test/test-utils';
@@ -951,17 +950,12 @@
suite('plugin endpoints', () => {
setup(async () => {
- resetPlugins();
element = await fixture(html`<gr-change-metadata></gr-change-metadata>`);
element.change = createParsedChange();
element.revision = createRevision();
await element.updateComplete;
});
- teardown(() => {
- resetPlugins();
- });
-
test('endpoint params', async () => {
interface MetadataGrEndpointDecorator extends GrEndpointDecorator {
plugin: PluginApi;
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index c6d86a7..ab10850e 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -42,7 +42,6 @@
windowLocationReload,
} from '../../../utils/dom-util';
import {navigationToken} from '../../core/gr-navigation/gr-navigation';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {RevisionInfo as RevisionInfoClass} from '../../shared/revision-info/revision-info';
import {
ChangeStatus,
@@ -809,9 +808,13 @@
.awaitPluginsLoaded()
.then(() => {
this.pluginTabsHeaderEndpoints =
- getPluginEndpoints().getDynamicEndpoints('change-view-tab-header');
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-view-tab-header'
+ );
this.pluginTabsContentEndpoints =
- getPluginEndpoints().getDynamicEndpoints('change-view-tab-content');
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-view-tab-content'
+ );
if (
this.pluginTabsContentEndpoints.length !==
this.pluginTabsHeaderEndpoints.length
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
index 5fbbe35..8f9eca9 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -17,7 +17,6 @@
Tab,
} from '../../../constants/constants';
import {GrEditConstants} from '../../edit/gr-edit-constants';
-import {_testOnly_resetEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {navigationToken} from '../../core/gr-navigation/gr-navigation';
import {PluginApi} from '../../../api/plugin';
import {
@@ -338,8 +337,6 @@
];
setup(async () => {
- // Since pluginEndpoints are global, must reset state.
- _testOnly_resetEndpoints();
setUrlStub = sinon.stub(testResolver(navigationToken), 'setUrl');
stubRestApi('getConfig').returns(
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index 5ef8c9d..6ba51cca 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -21,7 +21,6 @@
import {FilesExpandedState} from '../gr-file-list-constants';
import {diffFilePaths, pluralize} from '../../../utils/string-util';
import {navigationToken} from '../../core/gr-navigation/gr-navigation';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {getAppContext} from '../../../services/app-context';
import {
DiffViewMode,
@@ -828,23 +827,26 @@
this.getPluginLoader()
.awaitPluginsLoaded()
.then(() => {
- this.dynamicHeaderEndpoints = getPluginEndpoints().getDynamicEndpoints(
- 'change-view-file-list-header'
- );
- this.dynamicContentEndpoints = getPluginEndpoints().getDynamicEndpoints(
- 'change-view-file-list-content'
- );
+ this.dynamicHeaderEndpoints =
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-view-file-list-header'
+ );
+ this.dynamicContentEndpoints =
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-view-file-list-content'
+ );
this.dynamicPrependedHeaderEndpoints =
- getPluginEndpoints().getDynamicEndpoints(
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
'change-view-file-list-header-prepend'
);
this.dynamicPrependedContentEndpoints =
- getPluginEndpoints().getDynamicEndpoints(
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
'change-view-file-list-content-prepend'
);
- this.dynamicSummaryEndpoints = getPluginEndpoints().getDynamicEndpoints(
- 'change-view-file-list-summary'
- );
+ this.dynamicSummaryEndpoints =
+ this.getPluginLoader().pluginEndPoints.getDynamicEndpoints(
+ 'change-view-file-list-summary'
+ );
if (
this.dynamicHeaderEndpoints.length !==
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
index 4e82df3..676a468 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
@@ -22,7 +22,6 @@
import {
query,
queryAndAssert,
- resetPlugins,
stubRestApi,
waitEventLoop,
} from '../../../test/test-utils';
@@ -647,16 +646,11 @@
let element: GrRelatedChangesList;
setup(async () => {
- resetPlugins();
element = await fixture(
html`<gr-related-changes-list></gr-related-changes-list>`
);
});
- teardown(() => {
- resetPlugins();
- });
-
test('endpoint params', async () => {
element.change = {...createParsedChange(), labels: {}};
interface RelatedChangesListGrEndpointDecorator
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.ts
index aacf9ed..25e3e51 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.ts
@@ -7,7 +7,6 @@
import './gr-reply-dialog';
import {
queryAndAssert,
- resetPlugins,
stubRestApi,
waitEventLoop,
} from '../../../test/test-utils';
@@ -82,10 +81,6 @@
await element.updateComplete;
});
- teardown(() => {
- resetPlugins();
- });
-
test('submit blocked when invalid email is supplied to ccs', async () => {
const sendStub = sinon.stub(element, 'send').returns(Promise.resolve());
@@ -101,7 +96,6 @@
});
test('lgtm plugin', async () => {
- resetPlugins();
window.Gerrit.install(
plugin => {
const replyApi = plugin.changeReply();
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
index d0b4328..d5fc9f8 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator.ts
@@ -5,10 +5,7 @@
*/
import {html, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';
-import {
- getPluginEndpoints,
- ModuleInfo,
-} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
+import {ModuleInfo} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {PluginApi} from '../../../api/plugin';
import {HookApi, PluginElement} from '../../../api/hook';
import {getAppContext} from '../../../services/app-context';
@@ -48,12 +45,17 @@
override connectedCallback() {
super.connectedCallback();
assertIsDefined(this.name);
- getPluginEndpoints().onNewEndpoint(this.name, this.initModule);
+ this.getPluginLoader().pluginEndPoints.onNewEndpoint(
+ this.name,
+ this.initModule
+ );
this.getPluginLoader()
.awaitPluginsLoaded()
.then(() => {
assertIsDefined(this.name);
- const modules = getPluginEndpoints().getDetails(this.name);
+ const modules = this.getPluginLoader().pluginEndPoints.getDetails(
+ this.name
+ );
for (const module of modules) {
this.initModule(module);
}
@@ -65,7 +67,10 @@
domHook.handleInstanceDetached(el);
}
assertIsDefined(this.name);
- getPluginEndpoints().onDetachedEndpoint(this.name, this.initModule);
+ this.getPluginLoader().pluginEndPoints.onDetachedEndpoint(
+ this.name,
+ this.initModule
+ );
super.disconnectedCallback();
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.ts b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.ts
index 687b4aa..57888fa 100644
--- a/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-endpoint-decorator/gr-endpoint-decorator_test.ts
@@ -8,11 +8,7 @@
import '../gr-endpoint-param/gr-endpoint-param';
import '../gr-endpoint-slot/gr-endpoint-slot';
import {fixture, html, assert} from '@open-wc/testing';
-import {
- mockPromise,
- queryAndAssert,
- resetPlugins,
-} from '../../../test/test-utils';
+import {mockPromise, queryAndAssert} from '../../../test/test-utils';
import {GrEndpointDecorator} from './gr-endpoint-decorator';
import {PluginApi} from '../../../api/plugin';
import {GrEndpointParam} from '../gr-endpoint-param/gr-endpoint-param';
@@ -29,7 +25,6 @@
let banana: GrEndpointDecorator;
setup(async () => {
- resetPlugins();
container = await fixture(
html`<div>
<gr-endpoint-decorator name="first">
@@ -104,10 +99,6 @@
await replacementHookPromise;
});
- teardown(() => {
- resetPlugins();
- });
-
test('imports plugin-provided modules into endpoints', () => {
const endpoints = Array.from(
container.querySelectorAll('gr-endpoint-decorator')
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
index 0079e02..5a0e8df 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style.ts
@@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
import {updateStyles} from '@polymer/polymer/lib/mixins/element-mixin';
-import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
import {LitElement, html, PropertyValues} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import {pluginLoaderToken} from '../../shared/gr-js-api-interface/gr-plugin-loader';
@@ -64,7 +63,9 @@
}
private importAndApply() {
- const moduleNames = getPluginEndpoints().getModules(this.name);
+ const moduleNames = this.getPluginLoader().pluginEndPoints.getModules(
+ this.name
+ );
for (const name of moduleNames) {
this.applyStyle(name);
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.ts b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.ts
index f2f00fa..6c0e789 100644
--- a/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-external-style/gr-external-style_test.ts
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import '../../../test/common-test-setup';
-import {mockPromise, MockPromise, resetPlugins} from '../../../test/test-utils';
+import {mockPromise, MockPromise} from '../../../test/test-utils';
import './gr-external-style';
import {GrExternalStyle} from './gr-external-style';
import {PluginApi} from '../../../api/plugin';
@@ -16,7 +16,7 @@
const TEST_URL = 'http://some.com/plugins/url.js';
let element: GrExternalStyle;
- let plugin: PluginApi;
+ let plugin: PluginApi | undefined;
let pluginsLoaded: MockPromise<void>;
let applyStyleSpy: sinon.SinonSpy;
@@ -47,7 +47,7 @@
const lateRegister = async () => {
installPlugin();
await createElement();
- plugin.registerStyleModule('foo', 'some-module');
+ plugin!.registerStyleModule('foo', 'some-module');
};
/**
@@ -55,7 +55,7 @@
*/
const earlyRegister = async () => {
installPlugin();
- plugin.registerStyleModule('foo', 'some-module');
+ plugin!.registerStyleModule('foo', 'some-module');
await createElement();
};
@@ -67,7 +67,7 @@
});
teardown(() => {
- resetPlugins();
+ plugin = undefined;
document.body
.querySelectorAll('custom-style')
.forEach(style => style.remove());
@@ -83,7 +83,7 @@
test('does not double apply', async () => {
await earlyRegister();
await element.updateComplete;
- plugin.registerStyleModule('foo', 'some-module');
+ plugin!.registerStyleModule('foo', 'some-module');
await element.updateComplete;
const stylesApplied = element.stylesApplied.filter(
name => name === 'some-module'
@@ -99,7 +99,7 @@
test('removes old custom-style if name is changed', async () => {
installPlugin();
- plugin.registerStyleModule('bar', 'some-module');
+ plugin!.registerStyleModule('bar', 'some-module');
await earlyRegister();
await element.updateComplete;
let customStyles = document.body.querySelectorAll('custom-style');
@@ -117,7 +117,7 @@
test('can apply more than one style', async () => {
await earlyRegister();
await element.updateComplete;
- plugin.registerStyleModule('foo', 'some-module2');
+ plugin!.registerStyleModule('foo', 'some-module2');
pluginsLoaded.resolve();
await element.updateComplete;
assert.strictEqual(element.stylesApplied.length, 2);
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.ts
index e91ddee..ae93977 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.ts
@@ -5,12 +5,7 @@
*/
import '../../../test/common-test-setup';
import '../../change/gr-change-actions/gr-change-actions';
-import {
- query,
- queryAll,
- queryAndAssert,
- resetPlugins,
-} from '../../../test/test-utils';
+import {query, queryAll, queryAndAssert} from '../../../test/test-utils';
import {GrChangeActions} from '../../change/gr-change-actions/gr-change-actions';
import {fixture, html, assert} from '@open-wc/testing';
import {PluginApi} from '../../../api/plugin';
@@ -33,7 +28,6 @@
suite('early init', () => {
setup(async () => {
- resetPlugins();
window.Gerrit.install(
p => {
plugin = p;
@@ -49,10 +43,6 @@
`);
});
- teardown(() => {
- resetPlugins();
- });
-
test('does not throw', () => {
assert.doesNotThrow(() => {
changeActions.add(ActionType.CHANGE, 'foo');
@@ -62,7 +52,6 @@
suite('normal init', () => {
setup(async () => {
- resetPlugins();
element = await fixture<GrChangeActions>(html`
<gr-change-actions></gr-change-actions>
`);
@@ -80,10 +69,6 @@
testResolver(pluginLoaderToken).loadPlugins([]);
});
- teardown(() => {
- resetPlugins();
- });
-
test('property existence', () => {
const properties = ['ActionType', 'ChangeActions', 'RevisionActions'];
for (const p of properties) {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
index 76b3c15..af744c6 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints.ts
@@ -165,13 +165,3 @@
);
}
}
-
-let pluginEndpoints = new GrPluginEndpoints();
-
-// To avoid mutable-exports, we don't want to export above variable directly
-export function getPluginEndpoints() {
- return pluginEndpoints;
-}
-export function _testOnly_resetEndpoints() {
- pluginEndpoints = new GrPluginEndpoints();
-}
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.ts
index 15e19e6..2ef86ed 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-endpoints_test.ts
@@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
import '../../../test/common-test-setup';
-import {resetPlugins} from '../../../test/test-utils';
import './gr-js-api-interface';
import {GrPluginEndpoints} from './gr-plugin-endpoints';
import {PluginApi} from '../../../api/plugin';
@@ -70,10 +69,6 @@
});
});
- teardown(() => {
- resetPlugins();
- });
-
test('getDetails all', () => {
assert.deepEqual(instance.getDetails('my-endpoint'), [
{
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
index f5bfe65..b2894a7 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
@@ -11,7 +11,7 @@
} from './gr-api-utils';
import {Plugin} from './gr-public-js-api';
import {getBaseUrl} from '../../../utils/url-util';
-import {getPluginEndpoints} from './gr-plugin-endpoints';
+import {GrPluginEndpoints} from './gr-plugin-endpoints';
import {PluginApi} from '../../../api/plugin';
import {ReportingService} from '../../../services/gr-reporting/gr-reporting';
import {fireAlert} from '../../../utils/event-util';
@@ -106,6 +106,8 @@
public readonly pluginsModel: PluginsModel;
+ public pluginEndPoints: GrPluginEndpoints;
+
constructor(
private readonly reportingService: ReportingService,
private readonly restApiService: RestApiService
@@ -115,19 +117,10 @@
this.reportingService
);
this.pluginsModel = new PluginsModel();
+ this.pluginEndPoints = new GrPluginEndpoints();
}
- reset() {
- this.pluginListLoaded = false;
- this.plugins = new Map<string, PluginObject>();
- this.loadingPromise = null;
- this.loadingResolver = null;
- this.instanceId = undefined;
- }
-
- finalize() {
- this.reset();
- }
+ finalize() {}
/**
* Use the plugin name or use the full url if not recognized.
@@ -226,7 +219,8 @@
this.jsApiService,
this.reportingService,
this.restApiService,
- this.pluginsModel
+ this.pluginsModel,
+ this.pluginEndPoints
);
}
try {
@@ -252,7 +246,7 @@
private checkIfCompleted() {
if (this.arePluginsLoaded()) {
- getPluginEndpoints().setPluginsReady();
+ this.pluginEndPoints.setPluginsReady();
if (this.loadingResolver) {
this.loadingResolver();
this.loadingResolver = null;
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.ts
index fb8d67d..acce236 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader_test.ts
@@ -14,7 +14,6 @@
import {EventType} from '../../../types/events';
import {assert} from '@open-wc/testing';
import {getAppContext} from '../../../services/app-context';
-import {_testOnly_resetEndpoints} from './gr-plugin-endpoints';
suite('gr-plugin-loader tests', () => {
let plugin: PluginApi;
@@ -43,7 +42,6 @@
teardown(() => {
clock.restore();
- _testOnly_resetEndpoints();
});
test('reuse plugin for install calls', () => {
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
index 89b67c5..6e638bd 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-public-js-api.ts
@@ -13,7 +13,7 @@
import {GrAnnotationActionsInterface} from './gr-annotation-actions-js-api';
import {GrEventHelper} from '../../plugins/gr-event-helper/gr-event-helper';
import {GrPluginRestApi} from './gr-plugin-rest-api';
-import {getPluginEndpoints} from './gr-plugin-endpoints';
+import {GrPluginEndpoints} from './gr-plugin-endpoints';
import {getPluginNameFromUrl, send} from './gr-api-utils';
import {GrReportingJsApi} from './gr-reporting-js-api';
import {EventType, PluginApi, TargetElement} from '../../../api/plugin';
@@ -68,7 +68,8 @@
private readonly jsApi: JsApiService,
private readonly report: ReportingService,
private readonly restApiService: RestApiService,
- private readonly pluginsModel: PluginsModel
+ private readonly pluginsModel: PluginsModel,
+ private readonly pluginEndpoints: GrPluginEndpoints
) {
this.domHooks = new GrDomHooksManager(this);
@@ -96,7 +97,7 @@
`The deprecated plugin API 'registerStyleModule()' was called with parameters '${endpoint}' and '${moduleName}'.`
);
this.report.trackApi(this, 'plugin', 'registerStyleModule');
- getPluginEndpoints().registerModule(this, {
+ this.pluginEndpoints.registerModule(this, {
endpoint,
type: EndpointType.STYLE,
moduleName,
@@ -148,7 +149,7 @@
const slot = options?.slot ?? '';
const domHook = this.domHooks.getDomHook<T>(endpoint, moduleName);
moduleName = moduleName || domHook.getModuleName();
- getPluginEndpoints().registerModule(this, {
+ this.pluginEndpoints.registerModule(this, {
slot,
endpoint,
type,
diff --git a/polygerrit-ui/app/test/test-utils.ts b/polygerrit-ui/app/test/test-utils.ts
index 387cf4e..6ab0924 100644
--- a/polygerrit-ui/app/test/test-utils.ts
+++ b/polygerrit-ui/app/test/test-utils.ts
@@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
import '../types/globals';
-import {_testOnly_resetEndpoints} from '../elements/shared/gr-js-api-interface/gr-plugin-endpoints';
import {getAppContext} from '../services/app-context';
import {RestApiService} from '../services/gr-rest-api/gr-rest-api';
import {SinonSpy, SinonStub} from 'sinon';
@@ -15,8 +14,6 @@
import {Observable} from 'rxjs';
import {filter, take, timeout} from 'rxjs/operators';
import {assert} from '@open-wc/testing';
-import {testResolver} from './common-test-setup';
-import {pluginLoaderToken} from '../elements/shared/gr-js-api-interface/gr-plugin-loader';
export {query, queryAll, queryAndAssert} from '../utils/common-util';
export interface MockPromise<T> extends Promise<T> {
@@ -48,14 +45,6 @@
return getComputedStyle(el).getPropertyValue('display') !== 'none';
}
-// Provide reset plugins function to clear installed plugins between tests.
-export const resetPlugins = () => {
- _testOnly_resetEndpoints();
- const pluginLoader = testResolver(pluginLoaderToken);
- pluginLoader.reset();
- pluginLoader.loadPlugins([]);
-};
-
export type CleanupCallback = () => void;
const cleanups: CleanupCallback[] = [];