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

Make Runnable and RunnableSync require ids

- Allows for better error messages related to mismatched runAfter's so
  that mismatched injection tokens are easy to fix

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-09-01 10:57:01 -04:00
parent 38ca06fc80
commit f178cf05eb
71 changed files with 139 additions and 38 deletions

View File

@ -25,13 +25,19 @@ describe("runManyFor", () => {
const someInjectable = getInjectable({
id: "some-injectable",
instantiate: () => ({ run: () => runMock("some-call") }),
instantiate: () => ({
id: "some-injectable",
run: () => runMock("some-call"),
}),
injectionToken: someInjectionTokenForRunnables,
});
const someOtherInjectable = getInjectable({
id: "some-other-injectable",
instantiate: () => ({ run: () => runMock("some-other-call") }),
instantiate: () => ({
id: "some-other-injectable",
run: () => runMock("some-other-call"),
}),
injectionToken: someInjectionTokenForRunnables,
});
@ -79,6 +85,7 @@ describe("runManyFor", () => {
id: "some-injectable-1",
instantiate: (di) => ({
id: "some-injectable-1",
run: () => runMock("third-level-run"),
runAfter: di.inject(someInjectable2),
}),
@ -90,6 +97,7 @@ describe("runManyFor", () => {
id: "some-injectable-2",
instantiate: (di) => ({
id: "some-injectable-2",
run: () => runMock("second-level-run"),
runAfter: di.inject(someInjectable3),
}),
@ -99,7 +107,10 @@ describe("runManyFor", () => {
const someInjectable3 = getInjectable({
id: "some-injectable-3",
instantiate: () => ({ run: () => runMock("first-level-run") }),
instantiate: () => ({
id: "some-injectable-3",
run: () => runMock("first-level-run"),
}),
injectionToken: someInjectionTokenForRunnables,
});
@ -186,6 +197,7 @@ describe("runManyFor", () => {
id: "some-runnable-1",
instantiate: (di) => ({
id: "some-runnable-1",
run: () => runMock("some-runnable-1"),
runAfter: di.inject(someOtherInjectable),
}),
@ -197,6 +209,7 @@ describe("runManyFor", () => {
id: "some-runnable-2",
instantiate: () => ({
id: "some-runnable-2",
run: () => runMock("some-runnable-2"),
}),
@ -232,6 +245,7 @@ describe("runManyFor", () => {
id: "some-runnable-1",
instantiate: () => ({
id: "some-runnable-1",
run: (parameter) => runMock("run-of-some-runnable-1", parameter),
}),
@ -242,6 +256,7 @@ describe("runManyFor", () => {
id: "some-runnable-2",
instantiate: () => ({
id: "some-runnable-2",
run: (parameter) => runMock("run-of-some-runnable-2", parameter),
}),

View File

@ -11,8 +11,9 @@ import { filter, forEach, map, tap } from "lodash/fp";
import { throwWithIncorrectHierarchyFor } from "./throw-with-incorrect-hierarchy-for";
export interface Runnable<TParameter = void> {
id: string;
run: Run<TParameter>;
runAfter?: this;
runAfter?: Runnable<TParameter>;
}
type Run<Param> = (parameter: Param) => Promise<void> | void;

View File

@ -21,13 +21,19 @@ describe("runManySyncFor", () => {
const someInjectable = getInjectable({
id: "some-injectable",
instantiate: () => ({ run: () => runMock("some-call") }),
instantiate: () => ({
id: "some-injectable",
run: () => runMock("some-call"),
}),
injectionToken: someInjectionTokenForRunnables,
});
const someOtherInjectable = getInjectable({
id: "some-other-injectable",
instantiate: () => ({ run: () => runMock("some-other-call") }),
instantiate: () => ({
id: "some-other-injectable",
run: () => runMock("some-other-call"),
}),
injectionToken: someInjectionTokenForRunnables,
});
@ -62,6 +68,7 @@ describe("runManySyncFor", () => {
id: "some-injectable-1",
instantiate: (di) => ({
id: "some-injectable-1",
run: () => runMock("third-level-run"),
runAfter: di.inject(someInjectable2),
}),
@ -73,6 +80,7 @@ describe("runManySyncFor", () => {
id: "some-injectable-2",
instantiate: (di) => ({
id: "some-injectable-2",
run: () => runMock("second-level-run"),
runAfter: di.inject(someInjectable3),
}),
@ -82,7 +90,10 @@ describe("runManySyncFor", () => {
const someInjectable3 = getInjectable({
id: "some-injectable-3",
instantiate: () => ({ run: () => runMock("first-level-run") }),
instantiate: () => ({
id: "some-injectable-3",
run: () => runMock("first-level-run"),
}),
injectionToken: someInjectionTokenForRunnables,
});
@ -115,6 +126,7 @@ describe("runManySyncFor", () => {
id: "some-runnable-1",
instantiate: (di) => ({
id: "some-runnable-1",
run: () => runMock("some-runnable-1"),
runAfter: di.inject(someOtherInjectable),
}),
@ -126,6 +138,7 @@ describe("runManySyncFor", () => {
id: "some-runnable-2",
instantiate: () => ({
id: "some-runnable-2",
run: () => runMock("some-runnable-2"),
}),
@ -161,6 +174,7 @@ describe("runManySyncFor", () => {
id: "some-runnable-1",
instantiate: () => ({
id: "some-runnable-1",
run: (parameter) => runMock("run-of-some-runnable-1", parameter),
}),
@ -171,6 +185,7 @@ describe("runManySyncFor", () => {
id: "some-runnable-2",
instantiate: () => ({
id: "some-runnable-2",
run: (parameter) => runMock("run-of-some-runnable-2", parameter),
}),

View File

@ -3,17 +3,15 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { pipeline } from "@ogre-tools/fp";
import type {
DiContainerForInjection,
InjectionToken,
} from "@ogre-tools/injectable";
import type { DiContainerForInjection, InjectionToken } from "@ogre-tools/injectable";
import { filter, forEach, map, tap } from "lodash/fp";
import type { Runnable } from "./run-many-for";
import { throwWithIncorrectHierarchyFor } from "./throw-with-incorrect-hierarchy-for";
export interface RunnableSync<TParameter = void> {
id: string;
run: RunSync<TParameter>;
runAfter?: this;
runAfter?: RunnableSync<TParameter>;
}
type RunSync<Param> = (parameter: Param) => void;

View File

@ -5,12 +5,10 @@
import type { Runnable } from "./run-many-for";
import type { RunnableSync } from "./run-many-sync-for";
export const throwWithIncorrectHierarchyFor =
(allRunnables: Runnable<any>[] | RunnableSync<any>[]) =>
(runnable: Runnable<any> | RunnableSync<any>) => {
if (runnable.runAfter && !allRunnables.includes(runnable.runAfter)) {
throw new Error(
"Tried to run runnable after other runnable which does not same injection token.",
);
}
};
export const throwWithIncorrectHierarchyFor = (allRunnables: Runnable<any>[] | RunnableSync<any>[]) => (
(runnable: Runnable<any> | RunnableSync<any>) => {
if (runnable.runAfter && !allRunnables.includes(runnable.runAfter)) {
throw new Error(`Tried to run runnable "${runnable.id}" after the runnable "${runnable.runAfter.id}" which does not same injection token.`);
}
}
);

View File

@ -27,6 +27,7 @@ const setupAppPathsInjectable = getInjectable({
const joinPaths = di.inject(joinPathsInjectable);
return {
id: "setup-app-paths",
run: () => {
if (directoryForIntegrationTesting) {
setElectronAppPath("appData", directoryForIntegrationTesting);

View File

@ -16,6 +16,7 @@ const emitCurrentVersionToAnalyticsInjectable = getInjectable({
const buildVersion = di.inject(buildVersionInjectable);
return {
id: "emit-current-version-to-analytics",
run: () => {
emitEvent({
name: "app",

View File

@ -15,6 +15,7 @@ const startCheckingForUpdatesInjectable = getInjectable({
const updatingIsEnabled = di.inject(updatingIsEnabledInjectable);
return {
id: "start-checking-for-updates",
run: async () => {
if (updatingIsEnabled && !periodicalCheckForUpdates.started) {
await periodicalCheckForUpdates.start();

View File

@ -13,6 +13,7 @@ const stopCheckingForUpdatesInjectable = getInjectable({
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
return {
id: "stop-checking-for-updates",
run: async () => {
if (periodicalCheckForUpdates.started) {
await periodicalCheckForUpdates.stop();

View File

@ -13,6 +13,7 @@ const startWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
return {
id: "start-watching-if-update-should-happen-on-quit",
run: () => {
watchIfUpdateShouldHappenOnQuit.start();
},

View File

@ -13,6 +13,7 @@ const stopWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
return {
id: "stop-watching-if-update-should-happen-on-quit",
run: () => {
watchIfUpdateShouldHappenOnQuit.stop();
},

View File

@ -13,6 +13,7 @@ const startCatalogSyncInjectable = getInjectable({
const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable);
return {
id: "start-catalog-sync",
run: async () => {
if (!catalogSyncToRenderer.started) {
await catalogSyncToRenderer.start();

View File

@ -13,6 +13,7 @@ const stopCatalogSyncInjectable = getInjectable({
const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable);
return {
id: "stop-catalog-sync",
run: async () => {
if (catalogSyncToRenderer.started) {
await catalogSyncToRenderer.stop();

View File

@ -12,6 +12,7 @@ const initializeClusterManagerInjectable = getInjectable({
const clusterManager = di.inject(clusterManagerInjectable);
return {
id: "initialize-cluster-manager",
run: () => {
clusterManager.init();
},

View File

@ -13,6 +13,7 @@ const cleanUpDeepLinkingInjectable = getInjectable({
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
return {
id: "clean-up-deep-linking",
run: () => {
lensProtocolRouterMain.cleanup();
},

View File

@ -16,6 +16,7 @@ const hideDockForLastClosedWindowInjectable = getInjectable({
const getVisibleWindows = di.inject(getVisibleWindowsInjectable);
return {
id: "hide-dock-when-there-are-no-windows",
run: () => {
const visibleWindows = getVisibleWindows();

View File

@ -13,6 +13,7 @@ const showDockForFirstOpenedWindowInjectable = getInjectable({
const app = di.inject(electronAppInjectable);
return {
id: "show-dock-for-first-opened-window",
run: () => {
app.dock?.show();
},

View File

@ -15,6 +15,7 @@ const enforceSingleApplicationInstanceInjectable = getInjectable({
const exitApp = di.inject(exitAppInjectable);
return {
id: "enforce-single-application-instance",
run: () => {
if (!requestSingleInstanceLock()) {
exitApp();

View File

@ -15,6 +15,7 @@ const setupApplicationNameInjectable = getInjectable({
const appName = di.inject(appNameInjectable);
return {
id: "setup-application-name",
run: () => {
app.setName(appName);
},

View File

@ -26,6 +26,7 @@ const setupDeepLinkingInjectable = getInjectable({
);
return {
id: "setup-deep-linking",
run: async () => {
logger.info(`📟 Setting protocol client for lens://`);

View File

@ -13,6 +13,7 @@ const setupDeveloperToolsInDevelopmentEnvironmentInjectable = getInjectable({
const logger = di.inject(loggerInjectable);
return {
id: "setup-developer-tools-in-development-environment",
run: () => {
if (process.env.NODE_ENV !== "development") {
return;

View File

@ -15,6 +15,7 @@ const setupDeviceShutdownInjectable = getInjectable({
const exitApp = di.inject(exitAppInjectable);
return {
id: "setup-device-shutdown",
run: () => {
powerMonitor.on("shutdown", async () => {
exitApp();

View File

@ -36,6 +36,7 @@ const setupIpcMainHandlersInjectable = getInjectable({
const clustersThatAreBeingDeleted = di.inject(clustersThatAreBeingDeletedInjectable);
return {
id: "setup-ipc-main-handlers",
run: () => {
logger.debug("[APP-MAIN] initializing ipc main handlers");

View File

@ -17,6 +17,7 @@ const setupMainWindowVisibilityAfterActivationInjectable = getInjectable({
const logger = di.inject(loggerInjectable);
return {
id: "setup-main-window-visibility-after-activation",
run: () => {
app.on("activate", async (_, windowIsVisible) => {
logger.info("APP:ACTIVATE", { hasVisibleWindows: windowIsVisible });

View File

@ -15,6 +15,7 @@ const setupRunnablesAfterWindowIsOpenedInjectable = getInjectable({
const afterWindowIsOpened = runManyFor(di)(afterWindowIsOpenedInjectionToken);
return {
id: "setup-runnables-after-window-is-opened",
run: () => {
const app = di.inject(electronAppInjectable);

View File

@ -26,6 +26,7 @@ const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
);
return {
id: "setup-closing-of-application",
run: () => {
const app = di.inject(electronAppInjectable);

View File

@ -219,7 +219,10 @@ const overrideRunnablesHavingSideEffects = (di: DiContainer) => {
startCatalogSyncInjectable,
startKubeConfigSyncInjectable,
].forEach((injectable) => {
di.override(injectable, () => ({ run: () => {} }));
di.override(injectable, () => ({
id: injectable.id,
run: () => {},
}));
});
};
@ -231,18 +234,20 @@ const overrideOperatingSystem = (di: DiContainer) => {
};
const overrideElectronFeatures = (di: DiContainer) => {
di.override(setupMainWindowVisibilityAfterActivationInjectable, () => ({
run: () => {},
}));
[
setupMainWindowVisibilityAfterActivationInjectable,
setupDeviceShutdownInjectable,
setupDeepLinkingInjectable,
setupApplicationNameInjectable,
setupRunnablesBeforeClosingOfApplicationInjectable,
].forEach((injectable) => {
di.override(injectable, () => ({
id: injectable.id,
run: () => {},
}));
});
di.override(setupDeviceShutdownInjectable, () => ({
run: () => {},
}));
di.override(setupDeepLinkingInjectable, () => ({ run: () => {} }));
di.override(exitAppInjectable, () => () => {});
di.override(setupApplicationNameInjectable, () => ({ run: () => {} }));
di.override(setupRunnablesBeforeClosingOfApplicationInjectable, () => ({ run: () => {} }));
di.override(getCommandLineSwitchInjectable, () => () => "irrelevant");
di.override(requestSingleInstanceLockInjectable, () => () => true);
di.override(disableHardwareAccelerationInjectable, () => () => {});

View File

@ -15,6 +15,7 @@ const startApplicationMenuInjectable = getInjectable({
);
return {
id: "start-application-menu",
run: async () => {
await applicationMenu.start();
},

View File

@ -15,6 +15,7 @@ const stopApplicationMenuInjectable = getInjectable({
);
return {
id: "stop-application-menu",
run: async () => {
await applicationMenu.stop();
},

View File

@ -14,6 +14,7 @@ const setupListenerForCurrentClusterFrameInjectable = getInjectable({
id: "setup-listener-for-current-cluster-frame",
instantiate: (di) => ({
id: "setup-listener-for-current-cluster-frame",
run: () => {
const currentClusterFrameState = di.inject(currentClusterFrameClusterIdStateInjectable);

View File

@ -10,6 +10,7 @@ const cleanUpShellSessionsInjectable = getInjectable({
id: "clean-up-shell-sessions",
instantiate: () => ({
id: "clean-up-shell-sessions",
run: () => {
ShellSession.cleanup();
},

View File

@ -13,6 +13,7 @@ const emitCloseToEventBusInjectable = getInjectable({
const appEventBus = di.inject(appEventBusInjectable);
return {
id: "emit-close-to-event-bus",
run: () => {
appEventBus.emit({ name: "app", action: "close" });
},

View File

@ -13,6 +13,7 @@ const emitServiceStartToEventBusInjectable = getInjectable({
const appEventBus = di.inject(appEventBusInjectable);
return {
id: "emit-service-start-to-event-bus",
run: () => {
appEventBus.emit({ name: "service", action: "start" });
},

View File

@ -14,6 +14,7 @@ const flagRendererAsLoadedInjectable = getInjectable({
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
return {
id: "flag-renderer-as-loaded",
run: () => {
runInAction(() => {
// Todo: remove this kludge which enables out-of-place temporal dependency.

View File

@ -14,6 +14,7 @@ const flagRendererAsNotLoadedInjectable = getInjectable({
const lensProtocolRouterMain = di.inject(lensProtocolRouterMainInjectable);
return {
id: "stop-deep-linking",
run: () => {
runInAction(() => {
// Todo: remove this kludge which enables out-of-place temporal dependency.

View File

@ -21,6 +21,7 @@ const initializeExtensionsInjectable = getInjectable({
const showErrorPopup = di.inject(showErrorPopupInjectable);
return {
id: "initialize-extensions",
run: async () => {
logger.info("🧩 Initializing extensions");

View File

@ -14,6 +14,7 @@ const addKubeconfigSyncAsEntitySourceInjectable = getInjectable({
const entityRegistry = di.inject(catalogEntityRegistryInjectable);
return {
id: "add-kubeconfig-sync-as-entity-source",
run: () => {
entityRegistry.addComputedSource("kubeconfig-sync", kubeConfigSyncManager.source);
},

View File

@ -18,6 +18,7 @@ const startKubeConfigSyncInjectable = getInjectable({
const ensureDir = di.inject(ensureDirInjectable);
return {
id: "start-kubeconfig-sync",
run: async () => {
await ensureDir(directoryForKubeConfigs);

View File

@ -13,6 +13,7 @@ const stopKubeConfigSyncInjectable = getInjectable({
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
return {
id: "stop-kube-config-sync",
run: () => {
kubeConfigSyncManager.stopSync();
},

View File

@ -18,6 +18,7 @@ const setupDetectorRegistryInjectable = getInjectable({
const detectorRegistry = di.inject(detectorRegistryInjectable);
return {
id: "setup-detector-registry",
run: () => {
detectorRegistry
.add(ClusterIdDetector)

View File

@ -15,6 +15,7 @@ const setupHardwareAccelerationInjectable = getInjectable({
const disableHardwareAcceleration = di.inject(disableHardwareAccelerationInjectable);
return {
id: "setup-hardware-acceleration",
run: () => {
if (hardwareAccelerationShouldBeDisabled) {
disableHardwareAcceleration();

View File

@ -11,6 +11,7 @@ const setupHotbarStoreInjectable = getInjectable({
id: "setup-hotbar-store",
instantiate: (di) => ({
id: "setup-hotbar-store",
run: () => {
const hotbarStore = di.inject(hotbarStoreInjectable);

View File

@ -10,6 +10,7 @@ const setupImmerInjectable = getInjectable({
id: "setup-immer",
instantiate: () => ({
id: "setup-immer",
run: () => {
// Docs: https://immerjs.github.io/immer/
// Required in `utils/storage-helper.ts`

View File

@ -26,6 +26,7 @@ const setupLensProxyInjectable = getInjectable({
const buildVersion = di.inject(buildVersionInjectable);
return {
id: "setup-lens-proxy",
run: async () => {
try {
logger.info("🔌 Starting LensProxy");

View File

@ -10,6 +10,7 @@ const setupMobxInjectable = getInjectable({
id: "setup-mobx",
instantiate: () => ({
id: "setup-mobx",
run: () => {
// Docs: https://mobx.js.org/configuration.html
Mobx.configure({

View File

@ -18,6 +18,7 @@ const setupPrometheusRegistryInjectable = getInjectable({
const prometheusProviderRegistry = di.inject(prometheusProviderRegistryInjectable);
return {
id: "setup-prometheus-registry",
run: () => {
prometheusProviderRegistry
.registerProvider(new PrometheusLens())

View File

@ -13,6 +13,7 @@ const setupProxyEnvInjectable = getInjectable({
const getCommandLineSwitch = di.inject(getCommandLineSwitchInjectable);
return {
id: "setup-proxy-env",
run: () => {
const switchValue = getCommandLineSwitch("proxy-server");

View File

@ -13,6 +13,7 @@ const setupReactionsInUserStoreInjectable = getInjectable({
const userStore = di.inject(userStoreInjectable);
return {
id: "setup-reactions-in-user-store",
run: () => {
userStore.startMainReactions();
},

View File

@ -20,6 +20,7 @@ const setupShellInjectable = getInjectable({
const electronApp = di.inject(electronAppInjectable);
return {
id: "setup-shell",
run: async () => {
logger.info("🐚 Syncing shell environment");

View File

@ -15,6 +15,7 @@ const setupSyncingOfGeneralCatalogEntitiesInjectable = getInjectable({
);
return {
id: "setup-syncing-of-general-catalog-entities",
run: () => {
syncGeneralCatalogEntities();
},

View File

@ -13,6 +13,7 @@ const setupSyncingOfWeblinksInjectable = getInjectable({
const syncWeblinks = di.inject(syncWeblinksInjectable);
return {
id: "setup-syncing-of-weblinks",
run: () => {
syncWeblinks();
},

View File

@ -10,6 +10,7 @@ const setupSystemCaInjectable = getInjectable({
id: "setup-system-ca",
instantiate: () => ({
id: "setup-system-ca",
run: async () => {
await injectSystemCAs();
},

View File

@ -13,6 +13,7 @@ const stopClusterManagerInjectable = getInjectable({
const clusterManager = di.inject(clusterManagerInjectable);
return {
id: "stop-cluster-manager",
run: () => {
clusterManager.stop();
},

View File

@ -13,6 +13,7 @@ const startBroadcastingThemeChangeInjectable = getInjectable({
const broadcastThemeChange = di.inject(broadcastThemeChangeInjectable);
return {
id: "start-broadcasting-theme-change",
run: async () => {
await broadcastThemeChange.start();
},

View File

@ -13,6 +13,7 @@ const stopBroadcastingThemeChangeInjectable = getInjectable({
const broadcastThemeChange = di.inject(broadcastThemeChangeInjectable);
return {
id: "stop-broadcasting-theme-change",
run: async () => {
await broadcastThemeChange.stop();
},

View File

@ -13,6 +13,7 @@ const startSyncingThemeFromOperatingSystemInjectable = getInjectable({
const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable);
return {
id: "start-syncing-theme-from-operating-system",
run: async () => {
await syncTheme.start();
},

View File

@ -13,6 +13,7 @@ const stopSyncingThemeFromOperatingSystemInjectable = getInjectable({
const syncTheme = di.inject(syncThemeFromOperatingSystemInjectable);
return {
id: "stop-syncing-theme-from-operating-system",
run: async () => {
await syncTheme.stop();
},

View File

@ -13,6 +13,7 @@ const startTrayInjectable = getInjectable({
const electronTray = di.inject(electronTrayInjectable);
return {
id: "start-tray",
run: () => {
electronTray.start();
},

View File

@ -14,6 +14,7 @@ const stopTrayInjectable = getInjectable({
const electronTray = di.inject(electronTrayInjectable);
return {
id: "stop-tray",
run: () => {
electronTray.stop();
},

View File

@ -14,6 +14,7 @@ const startReactiveTrayMenuIconInjectable = getInjectable({
const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable);
return {
id: "start-reactive-tray-menu-icon",
run: async () => {
await reactiveTrayMenuIcon.start();
},

View File

@ -13,6 +13,7 @@ const stopReactiveTrayMenuIconInjectable = getInjectable({
const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable);
return {
id: "stop-reactive-tray-menu-icon",
run: async () => {
await reactiveTrayMenuIcon.stop();
},

View File

@ -14,6 +14,7 @@ const startReactiveTrayMenuItemsInjectable = getInjectable({
const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable);
return {
id: "start-reactive-tray-menu-items",
run: async () => {
await reactiveTrayMenuItems.start();
},

View File

@ -13,6 +13,7 @@ const stopReactiveTrayMenuItemsInjectable = getInjectable({
const reactiveTrayMenuItems = di.inject(reactiveTrayMenuItemsInjectable);
return {
id: "stop-reactive-tray-menu-items",
run: async () => {
await reactiveTrayMenuItems.stop();
},

View File

@ -13,6 +13,7 @@ const startListeningOfChannelsInjectable = getInjectable({
const listeningOfChannels = di.inject(listeningOfChannelsInjectable);
return {
id: "start-listening-of-channels-main",
run: async () => {
await listeningOfChannels.start();
},

View File

@ -11,6 +11,7 @@ const setupOnApiErrorListenersInjectable = getInjectable({
id: "setup-on-api-error-listeners",
instantiate: () => ({
id: "setup-on-api-error-listeners",
run: () => {
apiBase?.onError.addListener(onApiError);
},

View File

@ -17,6 +17,7 @@ const setupAppPathsInjectable = getInjectable({
const appPathsState = di.inject(appPathsStateInjectable);
return {
id: "setup-app-paths",
run: async () => {
const appPaths = await requestFromChannel(
appPathsChannel,

View File

@ -16,6 +16,7 @@ const startTopbarStateSyncInjectable = getInjectable({
const ipcRenderer = di.inject(ipcRendererInjectable);
return {
id: "start-topbar-state-sync",
run: () => {
ipcRenderer.on("history:can-go-back", action((event, canGoBack: boolean) => {
state.prevEnabled = canGoBack;

View File

@ -10,6 +10,7 @@ const setupSystemCaInjectable = getInjectable({
id: "setup-system-ca",
instantiate: () => ({
id: "setup-system-ca",
run: async () => {
await injectSystemCAs();
},

View File

@ -104,9 +104,17 @@ export const getDiForUnitTesting = (
di.override(getRandomIdInjectable, () => () => "some-irrelevant-random-id");
di.override(platformInjectable, () => "darwin");
di.override(startTopbarStateSyncInjectable, () => ({
run: () => {},
}));
[
startTopbarStateSyncInjectable,
setupSystemCaInjectable,
setupOnApiErrorListenersInjectable,
].forEach((injectable) => {
di.override(injectable, () => ({
id: injectable.id,
run: () => {},
}));
});
di.override(terminalSpawningPoolInjectable, () => document.createElement("div"));
di.override(hostedClusterIdInjectable, () => undefined);
@ -180,9 +188,6 @@ export const getDiForUnitTesting = (
di.override(fileSystemProvisionerStoreInjectable, () => ({}) as FileSystemProvisionerStore);
di.override(setupSystemCaInjectable, () => ({ run: () => {} }));
di.override(setupOnApiErrorListenersInjectable, () => ({ run: () => {} }));
di.override(defaultShellInjectable, () => "some-default-shell");
di.override(userStoreInjectable, () => ({

View File

@ -13,6 +13,7 @@ const startListeningOfChannelsInjectable = getInjectable({
const listeningOfChannels = di.inject(listeningOfChannelsInjectable);
return {
id: "start-listening-of-channels-renderer",
run: async () => {
await listeningOfChannels.start();
},

View File

@ -25,6 +25,7 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
di.inject(createSyncBoxStateInjectable, syncBox.id).set(state);
return {
id: "provide-initial-values-for-sync-boxes",
run: async () => {
const initialValues = await requestFromChannel(syncBoxInitialValueChannel);