mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improve documentation of Singleton functions, change to createInstance (#2585)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
33ca6c9c17
commit
b63fdfaff3
@ -59,7 +59,7 @@ describe("empty config", () => {
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
await ClusterStore.getInstanceOrCreate().load();
|
await ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -177,7 +177,7 @@ describe("config with existing clusters", () => {
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -274,7 +274,7 @@ users:
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -316,7 +316,7 @@ describe("pre 2.0 config with an existing cluster", () => {
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -386,7 +386,7 @@ describe("pre 2.6.0 config with a cluster that has arrays in auth config", () =>
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -430,7 +430,7 @@ describe("pre 2.6.0 config with a cluster icon", () => {
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -469,7 +469,7 @@ describe("for a pre 2.7.0-beta.0 config without a workspace", () => {
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -505,7 +505,7 @@ describe("pre 3.6.0-beta.1 config with an existing cluster", () => {
|
|||||||
|
|
||||||
mockFs(mockOpts);
|
mockFs(mockOpts);
|
||||||
|
|
||||||
return ClusterStore.getInstanceOrCreate().load();
|
return ClusterStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { HotbarStore } from "../hotbar-store";
|
|||||||
describe("HotbarStore", () => {
|
describe("HotbarStore", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ClusterStore.resetInstance();
|
ClusterStore.resetInstance();
|
||||||
ClusterStore.getInstanceOrCreate();
|
ClusterStore.createInstance();
|
||||||
|
|
||||||
HotbarStore.resetInstance();
|
HotbarStore.resetInstance();
|
||||||
mockFs({ tmp: { "lens-hotbar-store.json": "{}" } });
|
mockFs({ tmp: { "lens-hotbar-store.json": "{}" } });
|
||||||
@ -17,7 +17,7 @@ describe("HotbarStore", () => {
|
|||||||
|
|
||||||
describe("load", () => {
|
describe("load", () => {
|
||||||
it("loads one hotbar by default", () => {
|
it("loads one hotbar by default", () => {
|
||||||
HotbarStore.getInstanceOrCreate().load();
|
HotbarStore.createInstance().load();
|
||||||
expect(HotbarStore.getInstance().hotbars.length).toEqual(1);
|
expect(HotbarStore.getInstance().hotbars.length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -28,7 +28,7 @@ describe("user store tests", () => {
|
|||||||
UserStore.resetInstance();
|
UserStore.resetInstance();
|
||||||
mockFs({ tmp: { "config.json": "{}", "kube_config": "{}" } });
|
mockFs({ tmp: { "config.json": "{}", "kube_config": "{}" } });
|
||||||
|
|
||||||
(UserStore.getInstanceOrCreate() as any).refreshNewContexts = jest.fn(() => Promise.resolve());
|
(UserStore.createInstance() as any).refreshNewContexts = jest.fn(() => Promise.resolve());
|
||||||
|
|
||||||
return UserStore.getInstance().load();
|
return UserStore.getInstance().load();
|
||||||
});
|
});
|
||||||
@ -102,7 +102,7 @@ describe("user store tests", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return UserStore.getInstanceOrCreate().load();
|
return UserStore.createInstance().load();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@ -1,10 +1,3 @@
|
|||||||
/**
|
|
||||||
* Narrowing class instances to the one.
|
|
||||||
* Use "private" or "protected" modifier for constructor (when overriding) to disallow "new" usage.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* const usersStore: UsersStore = UsersStore.getInstance();
|
|
||||||
*/
|
|
||||||
type StaticThis<T, R extends any[]> = { new(...args: R): T };
|
type StaticThis<T, R extends any[]> = { new(...args: R): T };
|
||||||
|
|
||||||
export class Singleton {
|
export class Singleton {
|
||||||
@ -13,12 +6,28 @@ export class Singleton {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (Singleton.creating.length === 0) {
|
if (Singleton.creating.length === 0) {
|
||||||
throw new TypeError("A singleton class must be created by getInstanceOrCreate()");
|
throw new TypeError("A singleton class must be created by createInstance()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static getInstanceOrCreate<T, R extends any[]>(this: StaticThis<T, R>, ...args: R): T {
|
/**
|
||||||
|
* Creates the single instance of the child class if one was not already created.
|
||||||
|
*
|
||||||
|
* Multiple calls will return the same instance.
|
||||||
|
* Essentially throwing away the arguments to the subsequent calls.
|
||||||
|
*
|
||||||
|
* Note: this is a racy function, if two (or more) calls are racing to call this function
|
||||||
|
* only the first's arguments will be used.
|
||||||
|
* @param this Implicit argument that is the child class type
|
||||||
|
* @param args The constructor arguments for the child class
|
||||||
|
* @returns An instance of the child class
|
||||||
|
*/
|
||||||
|
static createInstance<T, R extends any[]>(this: StaticThis<T, R>, ...args: R): T {
|
||||||
if (!Singleton.instances.has(this)) {
|
if (!Singleton.instances.has(this)) {
|
||||||
|
if (Singleton.creating.length > 0) {
|
||||||
|
throw new TypeError("Cannot create a second singleton while creating a first");
|
||||||
|
}
|
||||||
|
|
||||||
Singleton.creating = this.name;
|
Singleton.creating = this.name;
|
||||||
Singleton.instances.set(this, new this(...args));
|
Singleton.instances.set(this, new this(...args));
|
||||||
Singleton.creating = "";
|
Singleton.creating = "";
|
||||||
@ -27,6 +36,13 @@ export class Singleton {
|
|||||||
return Singleton.instances.get(this) as T;
|
return Singleton.instances.get(this) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instance of the child class that was previously created.
|
||||||
|
* @param this Implicit argument that is the child class type
|
||||||
|
* @param strict If false will return `undefined` instead of throwing when an instance doesn't exist.
|
||||||
|
* Default: `true`
|
||||||
|
* @returns An instance of the child class
|
||||||
|
*/
|
||||||
static getInstance<T, R extends any[]>(this: StaticThis<T, R>, strict = true): T | undefined {
|
static getInstance<T, R extends any[]>(this: StaticThis<T, R>, strict = true): T | undefined {
|
||||||
if (!Singleton.instances.has(this) && strict) {
|
if (!Singleton.instances.has(this) && strict) {
|
||||||
throw new TypeError(`instance of ${this.name} is not created`);
|
throw new TypeError(`instance of ${this.name} is not created`);
|
||||||
@ -35,6 +51,13 @@ export class Singleton {
|
|||||||
return Singleton.instances.get(this) as (T | undefined);
|
return Singleton.instances.get(this) as (T | undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the instance of the child class.
|
||||||
|
*
|
||||||
|
* Note: this doesn't prevent callers of `getInstance` from storing the result in a global.
|
||||||
|
*
|
||||||
|
* There is *no* way in JS or TS to prevent globals like that.
|
||||||
|
*/
|
||||||
static resetInstance() {
|
static resetInstance() {
|
||||||
Singleton.instances.delete(this);
|
Singleton.instances.delete(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ describe("ExtensionDiscovery", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ExtensionDiscovery.resetInstance();
|
ExtensionDiscovery.resetInstance();
|
||||||
ExtensionsStore.resetInstance();
|
ExtensionsStore.resetInstance();
|
||||||
ExtensionsStore.getInstanceOrCreate();
|
ExtensionsStore.createInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("emits add for added extension", async done => {
|
it("emits add for added extension", async done => {
|
||||||
@ -43,7 +43,7 @@ describe("ExtensionDiscovery", () => {
|
|||||||
mockedWatch.mockImplementationOnce(() =>
|
mockedWatch.mockImplementationOnce(() =>
|
||||||
(mockWatchInstance) as any
|
(mockWatchInstance) as any
|
||||||
);
|
);
|
||||||
const extensionDiscovery = ExtensionDiscovery.getInstanceOrCreate();
|
const extensionDiscovery = ExtensionDiscovery.createInstance();
|
||||||
|
|
||||||
// Need to force isLoaded to be true so that the file watching is started
|
// Need to force isLoaded to be true so that the file watching is started
|
||||||
extensionDiscovery.isLoaded = true;
|
extensionDiscovery.isLoaded = true;
|
||||||
@ -83,7 +83,7 @@ describe("ExtensionDiscovery", () => {
|
|||||||
mockedWatch.mockImplementationOnce(() =>
|
mockedWatch.mockImplementationOnce(() =>
|
||||||
(mockWatchInstance) as any
|
(mockWatchInstance) as any
|
||||||
);
|
);
|
||||||
const extensionDiscovery = ExtensionDiscovery.getInstanceOrCreate();
|
const extensionDiscovery = ExtensionDiscovery.createInstance();
|
||||||
|
|
||||||
// Need to force isLoaded to be true so that the file watching is started
|
// Need to force isLoaded to be true so that the file watching is started
|
||||||
extensionDiscovery.isLoaded = true;
|
extensionDiscovery.isLoaded = true;
|
||||||
|
|||||||
@ -110,7 +110,7 @@ describe("ExtensionLoader", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.only("renderer updates extension after ipc broadcast", async (done) => {
|
it.only("renderer updates extension after ipc broadcast", async (done) => {
|
||||||
const extensionLoader = ExtensionLoader.getInstanceOrCreate();
|
const extensionLoader = ExtensionLoader.createInstance();
|
||||||
|
|
||||||
expect(extensionLoader.userExtensions).toMatchInlineSnapshot(`Map {}`);
|
expect(extensionLoader.userExtensions).toMatchInlineSnapshot(`Map {}`);
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ describe("ExtensionLoader", () => {
|
|||||||
// Disable sending events in this test
|
// Disable sending events in this test
|
||||||
(ipcRenderer.on as any).mockImplementation();
|
(ipcRenderer.on as any).mockImplementation();
|
||||||
|
|
||||||
const extensionLoader = ExtensionLoader.getInstanceOrCreate();
|
const extensionLoader = ExtensionLoader.createInstance();
|
||||||
|
|
||||||
await extensionLoader.init();
|
await extensionLoader.init();
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ describe("kube auth proxy tests", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
UserStore.resetInstance();
|
UserStore.resetInstance();
|
||||||
UserStore.getInstanceOrCreate();
|
UserStore.createInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calling exit multiple times shouldn't throw", async () => {
|
it("calling exit multiple times shouldn't throw", async () => {
|
||||||
|
|||||||
@ -62,7 +62,7 @@ if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
|||||||
if (!app.requestSingleInstanceLock()) {
|
if (!app.requestSingleInstanceLock()) {
|
||||||
app.exit();
|
app.exit();
|
||||||
} else {
|
} else {
|
||||||
const lprm = LensProtocolRouterMain.getInstanceOrCreate();
|
const lprm = LensProtocolRouterMain.createInstance();
|
||||||
|
|
||||||
for (const arg of process.argv) {
|
for (const arg of process.argv) {
|
||||||
if (arg.toLowerCase().startsWith("lens://")) {
|
if (arg.toLowerCase().startsWith("lens://")) {
|
||||||
@ -73,7 +73,7 @@ if (!app.requestSingleInstanceLock()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.on("second-instance", (event, argv) => {
|
app.on("second-instance", (event, argv) => {
|
||||||
const lprm = LensProtocolRouterMain.getInstanceOrCreate();
|
const lprm = LensProtocolRouterMain.createInstance();
|
||||||
|
|
||||||
for (const arg of argv) {
|
for (const arg of argv) {
|
||||||
if (arg.toLowerCase().startsWith("lens://")) {
|
if (arg.toLowerCase().startsWith("lens://")) {
|
||||||
@ -98,11 +98,11 @@ app.on("ready", async () => {
|
|||||||
|
|
||||||
registerFileProtocol("static", __static);
|
registerFileProtocol("static", __static);
|
||||||
|
|
||||||
const userStore = UserStore.getInstanceOrCreate();
|
const userStore = UserStore.createInstance();
|
||||||
const clusterStore = ClusterStore.getInstanceOrCreate();
|
const clusterStore = ClusterStore.createInstance();
|
||||||
const hotbarStore = HotbarStore.getInstanceOrCreate();
|
const hotbarStore = HotbarStore.createInstance();
|
||||||
const extensionsStore = ExtensionsStore.getInstanceOrCreate();
|
const extensionsStore = ExtensionsStore.createInstance();
|
||||||
const filesystemStore = FilesystemProvisionerStore.getInstanceOrCreate();
|
const filesystemStore = FilesystemProvisionerStore.createInstance();
|
||||||
|
|
||||||
logger.info("💾 Loading stores");
|
logger.info("💾 Loading stores");
|
||||||
// preload
|
// preload
|
||||||
@ -114,36 +114,35 @@ app.on("ready", async () => {
|
|||||||
filesystemStore.load(),
|
filesystemStore.load(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// find free port
|
|
||||||
let proxyPort;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("🔑 Getting free port for LensProxy server");
|
logger.info("🔑 Getting free port for LensProxy server");
|
||||||
proxyPort = await getFreePort();
|
const proxyPort = await getFreePort();
|
||||||
|
|
||||||
|
// create cluster manager
|
||||||
|
ClusterManager.createInstance(proxyPort);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
dialog.showErrorBox("Lens Error", "Could not find a free port for the cluster proxy");
|
dialog.showErrorBox("Lens Error", "Could not find a free port for the cluster proxy");
|
||||||
app.exit();
|
app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create cluster manager
|
const clusterManager = ClusterManager.getInstance();
|
||||||
ClusterManager.getInstanceOrCreate(proxyPort);
|
|
||||||
|
|
||||||
// run proxy
|
// run proxy
|
||||||
try {
|
try {
|
||||||
logger.info("🔌 Starting LensProxy");
|
logger.info("🔌 Starting LensProxy");
|
||||||
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
||||||
LensProxy.getInstanceOrCreate(proxyPort).listen();
|
LensProxy.createInstance(clusterManager.port).listen();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Could not start proxy (127.0.0:${proxyPort}): ${error?.message}`);
|
logger.error(`Could not start proxy (127.0.0:${clusterManager.port}): ${error?.message}`);
|
||||||
dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${proxyPort}): ${error?.message || "unknown error"}`);
|
dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${clusterManager.port}): ${error?.message || "unknown error"}`);
|
||||||
app.exit();
|
app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test proxy connection
|
// test proxy connection
|
||||||
try {
|
try {
|
||||||
logger.info("🔎 Testing LensProxy connection ...");
|
logger.info("🔎 Testing LensProxy connection ...");
|
||||||
const versionFromProxy = await getAppVersionFromProxyServer(proxyPort);
|
const versionFromProxy = await getAppVersionFromProxyServer(clusterManager.port);
|
||||||
|
|
||||||
if (getAppVersion() !== versionFromProxy) {
|
if (getAppVersion() !== versionFromProxy) {
|
||||||
logger.error(`Proxy server responded with invalid response`);
|
logger.error(`Proxy server responded with invalid response`);
|
||||||
@ -153,9 +152,9 @@ app.on("ready", async () => {
|
|||||||
logger.error("Checking proxy server connection failed", error);
|
logger.error("Checking proxy server connection failed", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const extensionDiscovery = ExtensionDiscovery.getInstanceOrCreate();
|
const extensionDiscovery = ExtensionDiscovery.createInstance();
|
||||||
|
|
||||||
ExtensionLoader.getInstanceOrCreate().init();
|
ExtensionLoader.createInstance().init();
|
||||||
extensionDiscovery.init();
|
extensionDiscovery.init();
|
||||||
|
|
||||||
// Start the app without showing the main window when auto starting on login
|
// Start the app without showing the main window when auto starting on login
|
||||||
@ -163,7 +162,7 @@ app.on("ready", async () => {
|
|||||||
const startHidden = process.argv.includes("--hidden") || (isMac && app.getLoginItemSettings().wasOpenedAsHidden);
|
const startHidden = process.argv.includes("--hidden") || (isMac && app.getLoginItemSettings().wasOpenedAsHidden);
|
||||||
|
|
||||||
logger.info("🖥️ Starting WindowManager");
|
logger.info("🖥️ Starting WindowManager");
|
||||||
const windowManager = WindowManager.getInstanceOrCreate(proxyPort);
|
const windowManager = WindowManager.createInstance(clusterManager.port);
|
||||||
|
|
||||||
installDeveloperTools();
|
installDeveloperTools();
|
||||||
|
|
||||||
|
|||||||
@ -17,10 +17,10 @@ function throwIfDefined(val: any): void {
|
|||||||
|
|
||||||
describe("protocol router tests", () => {
|
describe("protocol router tests", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ExtensionsStore.getInstanceOrCreate();
|
ExtensionsStore.createInstance();
|
||||||
ExtensionLoader.getInstanceOrCreate();
|
ExtensionLoader.createInstance();
|
||||||
|
|
||||||
const lpr = LensProtocolRouterMain.getInstanceOrCreate();
|
const lpr = LensProtocolRouterMain.createInstance();
|
||||||
|
|
||||||
lpr.extensionsLoaded = true;
|
lpr.extensionsLoaded = true;
|
||||||
lpr.rendererLoaded = true;
|
lpr.rendererLoaded = true;
|
||||||
|
|||||||
@ -51,16 +51,16 @@ export async function bootstrap(App: AppComponent) {
|
|||||||
await attachChromeDebugger();
|
await attachChromeDebugger();
|
||||||
rootElem.classList.toggle("is-mac", isMac);
|
rootElem.classList.toggle("is-mac", isMac);
|
||||||
|
|
||||||
ExtensionLoader.getInstanceOrCreate().init();
|
ExtensionLoader.createInstance().init();
|
||||||
ExtensionDiscovery.getInstanceOrCreate().init();
|
ExtensionDiscovery.createInstance().init();
|
||||||
|
|
||||||
const userStore = UserStore.getInstanceOrCreate();
|
const userStore = UserStore.createInstance();
|
||||||
const clusterStore = ClusterStore.getInstanceOrCreate();
|
const clusterStore = ClusterStore.createInstance();
|
||||||
const extensionsStore = ExtensionsStore.getInstanceOrCreate();
|
const extensionsStore = ExtensionsStore.createInstance();
|
||||||
const filesystemStore = FilesystemProvisionerStore.getInstanceOrCreate();
|
const filesystemStore = FilesystemProvisionerStore.createInstance();
|
||||||
const themeStore = ThemeStore.getInstanceOrCreate();
|
const themeStore = ThemeStore.createInstance();
|
||||||
const hotbarStore = HotbarStore.getInstanceOrCreate();
|
const hotbarStore = HotbarStore.createInstance();
|
||||||
const helmRepoManager = HelmRepoManager.getInstanceOrCreate();
|
const helmRepoManager = HelmRepoManager.createInstance();
|
||||||
|
|
||||||
// preload common stores
|
// preload common stores
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@ -42,16 +42,16 @@ describe("Extensions", () => {
|
|||||||
UserStore.resetInstance();
|
UserStore.resetInstance();
|
||||||
ThemeStore.resetInstance();
|
ThemeStore.resetInstance();
|
||||||
|
|
||||||
await UserStore.getInstanceOrCreate().load();
|
await UserStore.createInstance().load();
|
||||||
await ThemeStore.getInstanceOrCreate().init();
|
await ThemeStore.createInstance().init();
|
||||||
|
|
||||||
ExtensionLoader.resetInstance();
|
ExtensionLoader.resetInstance();
|
||||||
ExtensionDiscovery.resetInstance();
|
ExtensionDiscovery.resetInstance();
|
||||||
Extensions.installStates.clear();
|
Extensions.installStates.clear();
|
||||||
|
|
||||||
ExtensionDiscovery.getInstanceOrCreate().uninstallExtension = jest.fn(() => Promise.resolve());
|
ExtensionDiscovery.createInstance().uninstallExtension = jest.fn(() => Promise.resolve());
|
||||||
|
|
||||||
ExtensionLoader.getInstanceOrCreate().addExtension({
|
ExtensionLoader.createInstance().addExtension({
|
||||||
id: "extensionId",
|
id: "extensionId",
|
||||||
manifest: {
|
manifest: {
|
||||||
name: "test",
|
name: "test",
|
||||||
|
|||||||
@ -44,8 +44,8 @@ const getFewPodsTabData = (): LogTabData => {
|
|||||||
|
|
||||||
describe("<LogResourceSelector />", () => {
|
describe("<LogResourceSelector />", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
UserStore.getInstanceOrCreate();
|
UserStore.createInstance();
|
||||||
ThemeStore.getInstanceOrCreate();
|
ThemeStore.createInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const cluster: Cluster = new Cluster({
|
|||||||
|
|
||||||
describe("<MainLayoutHeader />", () => {
|
describe("<MainLayoutHeader />", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ClusterStore.getInstanceOrCreate();
|
ClusterStore.createInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export class LensApp extends React.Component {
|
|||||||
static async init() {
|
static async init() {
|
||||||
catalogEntityRegistry.init();
|
catalogEntityRegistry.init();
|
||||||
ExtensionLoader.getInstance().loadOnClusterManagerRenderer();
|
ExtensionLoader.getInstance().loadOnClusterManagerRenderer();
|
||||||
LensProtocolRouterRenderer.getInstanceOrCreate().init();
|
LensProtocolRouterRenderer.createInstance().init();
|
||||||
bindProtocolAddRouteHandlers();
|
bindProtocolAddRouteHandlers();
|
||||||
|
|
||||||
window.addEventListener("offline", () => broadcastMessage("network:offline"));
|
window.addEventListener("offline", () => broadcastMessage("network:offline"));
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { ClusterStore } from "../../../common/cluster-store";
|
|||||||
|
|
||||||
describe("renderer/utils/StorageHelper", () => {
|
describe("renderer/utils/StorageHelper", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ClusterStore.getInstanceOrCreate();
|
ClusterStore.createInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user