From 7ddaa7544d02bf4e0ad5429c8caf8564ffa71a8c Mon Sep 17 00:00:00 2001 From: Iku-turso Date: Fri, 2 Sep 2022 09:21:53 +0300 Subject: [PATCH] Adapt existing code and tests to presence of telemetry Signed-off-by: Iku-turso --- .../app-event-bus.global-override-for-injectable.ts | 8 ++++++++ src/common/app-event-bus/app-event-bus.injectable.ts | 1 + .../catalog-entities/__tests__/kubernetes-cluster.test.ts | 2 +- .../utils/with-error-logging/with-error-logging.test.ts | 4 ++-- .../analytics-for-installing-update.test.ts | 4 +++- .../resolve-system-proxy-from-electron.test.ts | 2 +- .../api/__tests__/catalog-entity-registry.test.ts | 2 +- .../components/+catalog/__tests__/custom-columns.test.ts | 2 +- .../components/+catalog/__tests__/custom-views.test.ts | 2 +- 9 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 src/common/app-event-bus/app-event-bus.global-override-for-injectable.ts diff --git a/src/common/app-event-bus/app-event-bus.global-override-for-injectable.ts b/src/common/app-event-bus/app-event-bus.global-override-for-injectable.ts new file mode 100644 index 0000000000..2cdd21c919 --- /dev/null +++ b/src/common/app-event-bus/app-event-bus.global-override-for-injectable.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getGlobalOverride } from "../test-utils/get-global-override"; +import emitEventInjectable from "./emit-event.injectable"; + +export default getGlobalOverride(emitEventInjectable, () => () => {}); diff --git a/src/common/app-event-bus/app-event-bus.injectable.ts b/src/common/app-event-bus/app-event-bus.injectable.ts index 31ed3dd3a1..d707ec9fc3 100644 --- a/src/common/app-event-bus/app-event-bus.injectable.ts +++ b/src/common/app-event-bus/app-event-bus.injectable.ts @@ -9,6 +9,7 @@ const appEventBusInjectable = getInjectable({ id: "app-event-bus", instantiate: () => appEventBus, causesSideEffects: true, + decorable: false, }); export default appEventBusInjectable; diff --git a/src/common/catalog-entities/__tests__/kubernetes-cluster.test.ts b/src/common/catalog-entities/__tests__/kubernetes-cluster.test.ts index d681713a80..b2814f9785 100644 --- a/src/common/catalog-entities/__tests__/kubernetes-cluster.test.ts +++ b/src/common/catalog-entities/__tests__/kubernetes-cluster.test.ts @@ -12,7 +12,7 @@ describe("kubernetesClusterCategory", () => { let kubernetesClusterCategory: KubernetesClusterCategory; beforeEach(() => { - const di = getDiForUnitTesting(); + const di = getDiForUnitTesting({ doGeneralOverrides: true }); kubernetesClusterCategory = di.inject(kubernetesClusterCategoryInjectable); }); diff --git a/src/common/utils/with-error-logging/with-error-logging.test.ts b/src/common/utils/with-error-logging/with-error-logging.test.ts index 05526c64c9..b14b7278e9 100644 --- a/src/common/utils/with-error-logging/with-error-logging.test.ts +++ b/src/common/utils/with-error-logging/with-error-logging.test.ts @@ -19,7 +19,7 @@ describe("with-error-logging", () => { let decorated: (a: string, b: string) => number | undefined; beforeEach(() => { - const di = getDiForUnitTesting(); + const di = getDiForUnitTesting({ doGeneralOverrides: true }); loggerStub = { error: jest.fn(), @@ -119,7 +119,7 @@ describe("with-error-logging", () => { let toBeDecorated: AsyncFnMock; beforeEach(() => { - const di = getDiForUnitTesting(); + const di = getDiForUnitTesting({ doGeneralOverrides: true }); loggerStub = { error: jest.fn(), diff --git a/src/features/application-update/analytics-for-installing-update.test.ts b/src/features/application-update/analytics-for-installing-update.test.ts index 7f451b0076..60523c5e49 100644 --- a/src/features/application-update/analytics-for-installing-update.test.ts +++ b/src/features/application-update/analytics-for-installing-update.test.ts @@ -19,6 +19,7 @@ import quitAndInstallUpdateInjectable from "../../main/application-update/quit-a import appVersionInjectable from "../../common/vars/app-version.injectable"; import periodicalCheckForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable"; import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time"; +import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable"; describe("analytics for installing update", () => { let builder: ApplicationBuilder; @@ -51,6 +52,8 @@ describe("analytics for installing update", () => { mainDi.override(publishIsConfiguredInjectable, () => true); + mainDi.unoverride(emitEventInjectable); + const eventBus = mainDi.inject(appEventBusInjectable); eventBus.addListener(analyticsListenerMock); @@ -65,7 +68,6 @@ describe("analytics for installing update", () => { mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable); await builder.render(); - }); it("sends event to analytics for being checked periodically", () => { diff --git a/src/main/utils/resolve-system-proxy/resolve-system-proxy-from-electron.test.ts b/src/main/utils/resolve-system-proxy/resolve-system-proxy-from-electron.test.ts index 9c395dca5b..a80a05a7cf 100644 --- a/src/main/utils/resolve-system-proxy/resolve-system-proxy-from-electron.test.ts +++ b/src/main/utils/resolve-system-proxy/resolve-system-proxy-from-electron.test.ts @@ -20,7 +20,7 @@ describe("technical: resolve-system-proxy-from-electron", () => { let actualPromise: Promise; beforeEach(() => { - di = getDiForUnitTesting(); + di = getDiForUnitTesting({ doGeneralOverrides: true }); logErrorMock = jest.fn(); di.override(logErrorInjectable, () => logErrorMock); diff --git a/src/renderer/api/__tests__/catalog-entity-registry.test.ts b/src/renderer/api/__tests__/catalog-entity-registry.test.ts index 08dacb8f5a..7092650e5a 100644 --- a/src/renderer/api/__tests__/catalog-entity-registry.test.ts +++ b/src/renderer/api/__tests__/catalog-entity-registry.test.ts @@ -80,7 +80,7 @@ describe("CatalogEntityRegistry", () => { let catalogCategoryRegistry: CatalogCategoryRegistry; beforeEach(() => { - const di = getDiForUnitTesting(); + const di = getDiForUnitTesting({ doGeneralOverrides: true }); entityRegistry = di.inject(catalogEntityRegistryInjectable); catalogCategoryRegistry = di.inject(catalogCategoryRegistryInjectable); diff --git a/src/renderer/components/+catalog/__tests__/custom-columns.test.ts b/src/renderer/components/+catalog/__tests__/custom-columns.test.ts index 83b564566b..d689e8f812 100644 --- a/src/renderer/components/+catalog/__tests__/custom-columns.test.ts +++ b/src/renderer/components/+catalog/__tests__/custom-columns.test.ts @@ -43,7 +43,7 @@ describe("Custom Category Columns", () => { let di: DiContainer; beforeEach(() => { - di = getDiForUnitTesting(); + di = getDiForUnitTesting({ doGeneralOverrides: true }); di.override(hotbarStoreInjectable, () => ({})); }); diff --git a/src/renderer/components/+catalog/__tests__/custom-views.test.ts b/src/renderer/components/+catalog/__tests__/custom-views.test.ts index 8bd996505e..8a8f7fa39d 100644 --- a/src/renderer/components/+catalog/__tests__/custom-views.test.ts +++ b/src/renderer/components/+catalog/__tests__/custom-views.test.ts @@ -16,7 +16,7 @@ describe("Custom Category Views", () => { let di: DiContainer; beforeEach(() => { - di = getDiForUnitTesting(); + di = getDiForUnitTesting({ doGeneralOverrides: true }); }); it("should order items correctly over all extensions", () => {