1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Simplify test setup by removing option for global overrides (#7302)

* Remove option to doGeneralOverrides and do it always

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Override telemetry by default to optimize and simplify testing

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Simplify more usages of getDiForUnitTesting

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix code style

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

---------

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2023-03-07 19:23:57 +02:00 committed by GitHub
parent 8fa92c06ea
commit 0d480917cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
95 changed files with 165 additions and 161 deletions

View File

@ -67,7 +67,7 @@ describe("cluster-store", () => {
let writeFileSyncAndReturnPath: (filePath: string, contents: string) => string;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(directoryForTempInjectable, () => "/some-temp-directory");

View File

@ -17,7 +17,7 @@ describe("create resource stack tests", () => {
let cluster: KubernetesCluster;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
cluster = {
getId: () => "test-cluster",
} as any;

View File

@ -43,7 +43,7 @@ describe("HotbarStore", () => {
let loggerMock: jest.Mocked<Logger>;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
testCluster = getMockCatalogEntity({
apiVersion: "v1",

View File

@ -21,7 +21,7 @@ describe("user store tests", () => {
let di: DiContainer;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(writeFileInjectable, () => () => Promise.resolve());
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");

View File

@ -12,7 +12,7 @@ describe("kubernetesClusterCategory", () => {
let kubernetesClusterCategory: KubernetesClusterCategory;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
kubernetesClusterCategory = di.inject(kubernetesClusterCategoryInjectable);
});

View File

@ -20,7 +20,7 @@ describe("requestNamespaceListPermissions", () => {
let requestNamespaceListPermissions: RequestNamespaceListPermissionsFor;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
requestNamespaceListPermissions = di.inject(requestNamespaceListPermissionsForInjectable);
});

View File

@ -12,7 +12,7 @@ import { pipeline } from "@ogre-tools/fp";
describe("verify-that-all-routes-have-component", () => {
it("verify that routes have route component", () => {
const rendererDi = getDiForUnitTesting({ doGeneralOverrides: true });
const rendererDi = getDiForUnitTesting();
rendererDi.override(clusterStoreInjectable, () => ({
getById: () => null,

View File

@ -15,7 +15,7 @@ describe("InitializableState tests", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
});
describe("when created", () => {

View File

@ -37,7 +37,7 @@ describe("ApiManager", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -15,7 +15,7 @@ describe("DeploymentApi", () => {
let kubeJsonApi: jest.Mocked<KubeJsonApi>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(storesAndApisCanBeCreatedInjectable, () => true);
kubeJsonApi = {

View File

@ -30,7 +30,7 @@ describe("KubeApi", () => {
let di: DiContainer;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
fetchMock = asyncFn();
di.override(fetchInjectable, () => fetchMock);

View File

@ -42,7 +42,7 @@ describe("createKubeApiForRemoteCluster", () => {
let fetchMock: AsyncFnMock<Fetch>;
beforeEach(async () => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");
@ -145,7 +145,7 @@ describe("KubeApi", () => {
let di: DiContainer;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -15,7 +15,7 @@ describe("StatefulSetApi", () => {
let kubeJsonApi: jest.Mocked<KubeJsonApi>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(storesAndApisCanBeCreatedInjectable, () => true);
kubeJsonApi = {

View File

@ -18,7 +18,7 @@ describe("with-error-logging", () => {
let logErrorMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
logErrorMock = jest.fn();
@ -116,7 +116,7 @@ describe("with-error-logging", () => {
let logErrorMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
logErrorMock = jest.fn();

View File

@ -14,7 +14,7 @@ describe("with orphan promise, when called", () => {
let logErrorMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
logErrorMock = jest.fn();

View File

@ -23,7 +23,7 @@ describe("ExtensionLoader", () => {
let updateExtensionStateMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(currentlyInClusterFrameInjectable, () => false);

View File

@ -32,7 +32,7 @@ describe("ExtensionDiscovery", () => {
let homeDirectoryPath: string;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(installExtensionInjectable, () => () => Promise.resolve());

View File

@ -18,7 +18,7 @@ describe("ensure-hashed-directory-for-extension", () => {
let registeredExtensions: ObservableMap<string, string>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
ensureDirMock = jest.fn();

View File

@ -23,6 +23,8 @@ describe("check-for-platform-updates", () => {
beforeEach(() => {
const di = getDiForUnitTesting();
di.unoverride(checkForPlatformUpdatesInjectable);
checkForUpdatesMock = asyncFn();
electronUpdaterFake = {

View File

@ -26,6 +26,8 @@ describe("download-platform-update", () => {
beforeEach(() => {
di = getDiForUnitTesting();
di.unoverride(downloadPlatformUpdateInjectable);
downloadUpdateMock = asyncFn();
electronUpdaterOnMock = jest.fn();
electronUpdaterOffMock = jest.fn();

View File

@ -37,9 +37,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
let unixShellEnv: ReturnType<ComputeUnixShellEnvironment>;
beforeEach(() => {
di = getDiForUnitTesting({
doGeneralOverrides: true,
});
di = getDiForUnitTesting();
spawnMock = jest.fn().mockImplementation((spawnfile, spawnargs) => {
shellStdin = new MemoryStream();

View File

@ -9,12 +9,15 @@ import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
import telemetryWhiteListForFunctionsInjectable from "./renderer/telemetry-white-list-for-functions.injectable";
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
import logErrorInjectable from "../../common/log-error.injectable";
import telemetryDecoratorInjectable from "./renderer/telemetry-decorator.injectable";
describe("emit-telemetry-from-specific-function-calls", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.unoverride(telemetryDecoratorInjectable);
});
describe("given a telemetry white-list for injectables which instantiate a function", () => {

View File

@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { identity } from "lodash/fp";
import { getGlobalOverride } from "../../../common/test-utils/get-global-override";
import telemetryDecoratorInjectable from "./telemetry-decorator.injectable";
export default getGlobalOverride(telemetryDecoratorInjectable, () => ({
decorate: identity,
}));

View File

@ -31,7 +31,7 @@ describe("create clusters", () => {
beforeEach(() => {
jest.clearAllMocks();
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
const clusterServerUrl = "https://192.168.64.3:8443";
di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");

View File

@ -53,7 +53,7 @@ describe("ContextHandler", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(createKubeAuthProxyInjectable, () => ({} as any));
createContextHandler = di.inject(createContextHandlerInjectable);

View File

@ -39,7 +39,7 @@ describe("kube auth proxy tests", () => {
let getBasenameOfPath: GetBasenameOfPath;
beforeEach(async () => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(directoryForTempInjectable, () => "/some-directory-for-temp");

View File

@ -46,7 +46,7 @@ describe("kubeconfig manager tests", () => {
let ensureServerMock: AsyncFnMock<() => Promise<void>>;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForTempInjectable, () => "/some-directory-for-temp");
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");

View File

@ -11,7 +11,7 @@ describe("static-file-route", () => {
let handleStaticFileRoute: Route<Buffer, "/{path*}">;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
handleStaticFileRoute = di.inject(staticFileRouteInjectable);
});

View File

@ -11,7 +11,9 @@ describe("get-electron-app-path", () => {
let getElectronAppPath: (name: string) => string;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: false });
const di = getDiForUnitTesting();
di.unoverride(getElectronAppPathInjectable);
const appStub = {
name: "some-app-name",

View File

@ -43,7 +43,7 @@ describe("kubeconfig-sync.source tests", () => {
let di: DiContainer;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(directoryForTempInjectable, () => "/some-directory-for-temp");

View File

@ -65,7 +65,7 @@ describe("CatalogEntityRegistry", () => {
});
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
entityRegistry = di.inject(catalogEntityRegistryInjectable);
});

View File

@ -24,7 +24,7 @@ describe("detect-cluster-metadata", () => {
let cluster: Cluster;
beforeEach(async () => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
const lastSeenDetectMock = jest.fn().mockReturnValue(Promise.resolve({ value: "some-time-stamp", accuracy: 100 }));
const nodeCountDetectMock = jest.fn().mockReturnValue(Promise.resolve({ value: 42, accuracy: 100 }));

View File

@ -33,11 +33,7 @@ import {
} from "../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
const {
doGeneralOverrides = false,
} = opts;
export function getDiForUnitTesting() {
const di = createContainer("main");
registerMobX(di);
@ -56,7 +52,6 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
}
});
if (doGeneralOverrides) {
for (const globalOverridePath of global.injectablePaths.main.globalOverridePaths) {
const globalOverride = require(globalOverridePath).default as GlobalOverride;
@ -82,7 +77,6 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
on: jest.fn(),
} as never;
});
}
return di;
}

View File

@ -16,7 +16,7 @@ describe("Helm Service tests", () => {
let getActiveHelmRepositoriesMock: jest.Mock<Promise<AsyncResult<HelmRepo[]>>>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
getActiveHelmRepositoriesMock = jest.fn();

View File

@ -21,7 +21,7 @@ describe("exec-file-with-input", () => {
};
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.unoverride(execFileWithInputInjectable);

View File

@ -21,7 +21,7 @@ describe("get helm release resources", () => {
let execFileWithStreamInputMock: AsyncFnMock<ExecFileWithInput>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
execHelmMock = asyncFn();
execFileWithStreamInputMock = asyncFn();

View File

@ -37,7 +37,7 @@ describe("protocol router tests", () => {
let broadcastMessageMock: jest.Mock;
beforeEach(async () => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(pathExistsInjectable, () => () => { throw new Error("tried call pathExists without override"); });
di.override(pathExistsSyncInjectable, () => () => { throw new Error("tried call pathExistsSync without override"); });

View File

@ -28,7 +28,7 @@ describe("router", () => {
beforeEach(async () => {
routeHandlerMock = asyncFn();
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(parseRequestInjectable, () => () => Promise.resolve({
payload: "some-payload",

View File

@ -26,9 +26,7 @@ describe("technical unit tests for local shell sessions", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({
doGeneralOverrides: true,
});
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");
di.override(buildVersionInjectable, () => ({

View File

@ -15,7 +15,7 @@ describe("enlist message channel listener in main", () => {
let offMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
onMock = jest.fn();
offMock = jest.fn();

View File

@ -26,7 +26,7 @@ describe("enlist request channel listener in main", () => {
let offMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
handleMock = jest.fn();
offMock = jest.fn();

View File

@ -15,7 +15,7 @@ describe("message-to-channel", () => {
let sendToWindowMock: jest.Mock;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
sendToWindowMock = jest.fn();

View File

@ -20,7 +20,7 @@ describe("technical: resolve-system-proxy-from-electron", () => {
let actualPromise: Promise<string>;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
logErrorMock = jest.fn();
di.override(logErrorInjectable, () => logErrorMock);

View File

@ -80,7 +80,7 @@ describe("CatalogEntityRegistry", () => {
let catalogCategoryRegistry: CatalogCategoryRegistry;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
entityRegistry = di.inject(catalogEntityRegistryInjectable);
catalogCategoryRegistry = di.inject(catalogCategoryRegistryInjectable);

View File

@ -18,7 +18,7 @@ describe("WebsocketApi tests", () => {
let api: TestWebSocketApi;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
api = new TestWebSocketApi({
defaultParams: di.inject(defaultWebsocketApiParamsInjectable),

View File

@ -31,7 +31,7 @@ describe("CatalogAddButton", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -70,7 +70,7 @@ describe("CatalogEntityStore", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
});
describe("getTotalCount", () => {

View File

@ -44,7 +44,7 @@ describe("Custom Category Columns", () => {
let getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(hotbarStoreInjectable, () => ({}));
di.override(currentlyInClusterFrameInjectable, () => false);

View File

@ -16,7 +16,7 @@ describe("Custom Category Views", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
});
it("should order items correctly over all extensions", () => {

View File

@ -39,7 +39,7 @@ describe("<HpaDetails/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -20,7 +20,7 @@ jest.mock("../../kube-object-meta/kube-object-meta", () => ({
describe("SecretDetails tests", () => {
it("should show the visibility toggle when the secret value is ''", () => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
const render = renderFor(di);
di.override(directoryForUserDataInjectable, () => "/some-user-data");

View File

@ -15,7 +15,7 @@ describe("<CustomResourceDetails />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -39,7 +39,7 @@ describe("Extensions", () => {
let downloadBinary: jest.MockedFunction<DownloadBinary>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
di.override(directoryForDownloadsInjectable, () => "some-directory-for-downloads");

View File

@ -48,7 +48,7 @@ describe("<NamespaceSelectFilter />", () => {
let cleanup: Disposer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.unoverride(subscribeStoresInjectable);
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");

View File

@ -105,7 +105,7 @@ describe("NamespaceStore", () => {
let namespaceStore: NamespaceStore;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -106,7 +106,7 @@ describe("<NamespaceTreeView />", () => {
let render: DiRender;
beforeEach(async () => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(hierarchicalNamespacesInjectable, () => [
acmeGroup,

View File

@ -15,7 +15,7 @@ describe("NetworkPolicyDetails", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -27,7 +27,7 @@ describe("ClusterRoleBindingDialog tests", () => {
let openClusterRoleBindingDialog: OpenClusterRoleBindingDialog;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -24,7 +24,7 @@ describe("RoleBindingDialog tests", () => {
let openRoleBindingDialog: OpenRoleBindingDialog;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -23,7 +23,7 @@ describe("<Welcome/>", () => {
let welcomeBannersStub: WelcomeBannerRegistration[];
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(currentlyInClusterFrameInjectable, () => false);

View File

@ -88,7 +88,7 @@ describe("<DeploymentScaleDialog />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(storesAndApisCanBeCreatedInjectable, () => true);

View File

@ -21,7 +21,7 @@ describe("<ContainerEnv />", () => {
let configMapStore: jest.Mocked<Pick<ConfigMapStore, "load" | "getByName">>;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
secretStore = ({
load: jest.fn().mockImplementation(async () => {

View File

@ -32,7 +32,7 @@ describe("<PodTolerations />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForLensLocalStorageInjectable, () => "some-directory-for-lens-local-storage" );

View File

@ -16,7 +16,7 @@ describe("<CephFs />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);

View File

@ -81,7 +81,7 @@ describe("<ReplicaSetScaleDialog />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(storesAndApisCanBeCreatedInjectable, () => true);

View File

@ -92,7 +92,7 @@ describe("<StatefulSetScaleDialog />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(storesAndApisCanBeCreatedInjectable, () => true);

View File

@ -121,7 +121,7 @@ describe("CronJob Store tests", () => {
let cronJobStore: CronJobStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -138,7 +138,7 @@ describe("DaemonSet Store tests", () => {
let daemonSetStore: DaemonSetStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -210,7 +210,7 @@ describe("Deployment Store tests", () => {
let deploymentStore: DeploymentStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -175,7 +175,7 @@ describe("Job Store tests", () => {
let jobStore: JobStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -121,7 +121,7 @@ describe("Pod Store tests", () => {
let podStore: PodStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -138,7 +138,7 @@ describe("ReplicaSet Store tests", () => {
let replicaSetStore: ReplicaSetStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -138,7 +138,7 @@ describe("StatefulSet Store tests", () => {
let statefulSetStore: StatefulSetStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -14,7 +14,7 @@ describe("<Avatar/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -21,7 +21,7 @@ describe("ClusterLocalTerminalSettings", () => {
let statMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
showErrorNotificationMock = jest.fn();

View File

@ -22,7 +22,7 @@ describe("DockStore", () => {
let dockStore: DockStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(hostedClusterIdInjectable, () => "some-cluster-id");
di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");

View File

@ -107,7 +107,7 @@ describe("<LogResourceSelector />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
const { ensureDirSync } = di.inject(fsInjectable);

View File

@ -63,7 +63,7 @@ describe("LogSearch tests", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -15,7 +15,7 @@ describe("<ToBottom/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -14,7 +14,7 @@ describe("<DrawerParamToggler />", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
result = render((

View File

@ -30,7 +30,7 @@ describe("<HotbarRemoveCommand />", () => {
let render: DiRender;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(storesAndApisCanBeCreatedInjectable, () => true);
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");

View File

@ -28,7 +28,7 @@ describe("kube-object-list-layout", () => {
let podStore: PodStore;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-user-store-path");
di.override(directoryForKubeConfigsInjectable, () => "/some-kube-configs");

View File

@ -32,7 +32,7 @@ describe("kube-object-menu", () => {
let render: DiRender;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
runInAction(() => {
di.register(

View File

@ -34,7 +34,7 @@ describe("<SidebarCluster/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(hotbarStoreInjectable, () => ({
isAddedToActive: () => {},

View File

@ -34,7 +34,7 @@ describe("<TopBar/>", () => {
let toggleMaximizeWindow: jest.MockedFunction<() => void>;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.override(rendererExtensionsInjectable, () => computed(() => []));
di.override(openAppContextMenuInjectable, () => openAppContextMenu = jest.fn());

View File

@ -10,7 +10,9 @@ describe("get-editor-height-from-lines-number", () => {
let getEditorHeightFromLinesNumber: (linesCount: number) => number;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: false });
const di = getDiForUnitTesting();
di.unoverride(getEditorHeightFromLinesCountInjectable);
getEditorHeightFromLinesNumber = di.inject(getEditorHeightFromLinesCountInjectable);
});

View File

@ -17,7 +17,7 @@ describe("<RenderDelay/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);

View File

@ -25,7 +25,7 @@ describe("<ScrollSpy/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});
@ -107,7 +107,7 @@ describe("<TreeView/> dataTree inside <ScrollSpy/>", () => {
let render: DiRender;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
render = renderFor(di);
});

View File

@ -20,7 +20,7 @@ describe("<Select />", () => {
let render: DiRender;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
render = renderFor(di);
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");

View File

@ -168,9 +168,7 @@ interface Environment {
}
export const getApplicationBuilder = () => {
const mainDi = getMainDi({
doGeneralOverrides: true,
});
const mainDi = getMainDi();
runInAction(() => {
registerFeature(
@ -236,7 +234,7 @@ export const getApplicationBuilder = () => {
const createElectronWindowFake: CreateElectronWindow = (configuration) => {
const windowId = configuration.id;
const windowDi = getRendererDi({ doGeneralOverrides: true });
const windowDi = getRendererDi();
overrideForWindow(windowDi, windowId);
overrideFsWithFakes(windowDi);

View File

@ -32,7 +32,7 @@ describe("<ClusterFrame />", () => {
let cluster: Cluster;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
render = () => testingLibraryRender((
<DiContextProvider value={{ di }}>
<Router history={di.inject(historyInjectable)}>

View File

@ -24,11 +24,7 @@ import {
} from "@ogre-tools/injectable-extension-for-mobx";
import { registerInjectableReact } from "@ogre-tools/injectable-react";
export const getDiForUnitTesting = (
opts: { doGeneralOverrides?: boolean } = {},
) => {
const { doGeneralOverrides = false } = opts;
export const getDiForUnitTesting = () => {
const environment = "renderer";
const di = createContainer(environment);
@ -49,7 +45,6 @@ export const getDiForUnitTesting = (
}
});
if (doGeneralOverrides) {
for (const globalOverridePath of global.injectablePaths.renderer.globalOverridePaths) {
const globalOverride = require(globalOverridePath).default as GlobalOverride;
@ -76,7 +71,6 @@ export const getDiForUnitTesting = (
di.override(requestFromChannelInjectable, () => () => Promise.resolve(undefined as never));
getOverrideFsWithFakes()(di);
}
return di;
};

View File

@ -18,7 +18,7 @@ describe("search store tests", () => {
let searchStore: SearchStore;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
di.override(directoryForUserDataInjectable, () => "/some-directory-for-user-data");

View File

@ -20,7 +20,7 @@ describe("renderer/utils/StorageHelper", () => {
let createStorageHelper: CreateStorageHelper;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
createStorageHelper = di.inject(createStorageHelperInjectable);
});

View File

@ -15,7 +15,7 @@ describe("enlist message channel listener in renderer", () => {
let offMock: jest.Mock;
beforeEach(() => {
const di = getDiForUnitTesting({ doGeneralOverrides: true });
const di = getDiForUnitTesting();
onMock = jest.fn();
offMock = jest.fn();