mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Split root and cluster frames in smaller pieces (#5737)
* Make root frame child components comply with open closed principle and include it in the behavioural unit tests Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make cluster frame child components comply with open closed principle and include it in behavioural unit tests Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove duplication Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Simplify test Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make a component more determistic in unit tests Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Mock uninterested, non-deterministic third party library in unit tests Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Optimize registration of injectables in unit tests to make tests faster Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Update snapshots Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove import time side-effect causing memory leak Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
1a9fa699c9
commit
14d5a1c3cc
66 files changed
+48472
-35711
No files matched your search
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import glob from "glob";
|
||||
import { kebabCase, memoize, noop } from "lodash/fp";
|
||||
import { kebabCase, memoize, noop, chunk } from "lodash/fp";
|
||||
import type { DiContainer, Injectable } from "@ogre-tools/injectable";
|
||||
import { createContainer } from "@ogre-tools/injectable";
|
||||
import { Environments, setLegacyGlobalDiForExtensionApi } from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||
@@ -99,6 +99,7 @@ import updateHelmReleaseInjectable from "./helm/helm-service/update-helm-release
|
||||
import waitUntilBundledExtensionsAreLoadedInjectable from "./start-main-application/lens-window/application-window/wait-until-bundled-extensions-are-loaded.injectable";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import electronInjectable from "./utils/resolve-system-proxy/electron.injectable";
|
||||
import type { HotbarStore } from "../common/hotbars/store";
|
||||
|
||||
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
|
||||
const {
|
||||
@@ -111,15 +112,13 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
|
||||
|
||||
setLegacyGlobalDiForExtensionApi(di, Environments.main);
|
||||
|
||||
for (const filePath of getInjectableFilePaths()) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const injectableInstance = require(filePath).default;
|
||||
const filePaths = getInjectableFilePaths();
|
||||
|
||||
di.register({
|
||||
...injectableInstance,
|
||||
aliases: [injectableInstance, ...(injectableInstance.aliases || [])],
|
||||
});
|
||||
}
|
||||
const injectables = filePaths.map(filePath => require(filePath).default);
|
||||
|
||||
chunk(100)(injectables).forEach(chunkInjectables => {
|
||||
di.register(...chunkInjectables);
|
||||
});
|
||||
|
||||
di.preventSideEffects();
|
||||
|
||||
@@ -127,7 +126,13 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
|
||||
di.override(electronInjectable, () => ({}));
|
||||
di.override(waitUntilBundledExtensionsAreLoadedInjectable, () => async () => {});
|
||||
di.override(getRandomIdInjectable, () => () => "some-irrelevant-random-id");
|
||||
di.override(hotbarStoreInjectable, () => ({ load: () => {} }));
|
||||
|
||||
di.override(hotbarStoreInjectable, () => ({
|
||||
load: () => {},
|
||||
getActive: () => ({ name: "some-hotbar", items: [] }),
|
||||
getDisplayIndex: () => "0",
|
||||
}) as unknown as HotbarStore);
|
||||
|
||||
di.override(userStoreInjectable, () => ({ startMainReactions: () => {}, extensionRegistryUrl: { customUrl: "some-custom-url" }}) as UserStore);
|
||||
di.override(extensionsStoreInjectable, () => ({ isEnabled: (opts) => (void opts, false) }) as ExtensionsStore);
|
||||
di.override(clusterStoreInjectable, () => ({ provideInitialFromMain: () => {}, getById: (id) => (void id, {}) as Cluster }) as ClusterStore);
|
||||
|
||||
Reference in new issue
Block a user