mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Convert runMany and runManySync to use injectManyWithMeta + move to seperate package (#7244)
* Convert runMany and runManySync to use injectManyWithMeta Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup type errors due to new Runnable requirements Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add documentation for verifyRunnablesAreDAG Signed-off-by: Sebastian Malton <sebastian@malton.name> * Simplify convertToWithIdWith Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move all utility functions to separate package Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move testing utilities to separate package Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move run-many and run-many-sync to separate package Signed-off-by: Sebastian Malton <sebastian@malton.name> * Replace all internal uses of utilities with new packages Signed-off-by: Sebastian Malton <sebastian@malton.name> * Use new @k8slens/run-many package in core Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add dep to open-lens Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup uses of @k8slens/test-utils Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup getGlobalOverride Signed-off-by: Sebastian Malton <sebastian@malton.name> * Move tests to new package too Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix type errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup uses of AsyncResult and autoBind Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fixup remaining import issues Signed-off-by: Sebastian Malton <sebastian@malton.name> * Finial fixups to fix build Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Revert moving "testUsingFakeTime" to separate package - This fixes tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix integration tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix unit test failing due to spelling fix Signed-off-by: Sebastian Malton <sebastian@malton.name> --------- Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
ad9bafe2a5
commit
2789bcebcb
754 files changed
+2715
-2752
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ import type { DownloadPlatformUpdate } from "./main/download-update/download-pla
|
||||
import downloadPlatformUpdateInjectable from "./main/download-update/download-platform-update/download-platform-update.injectable";
|
||||
import quitAndInstallUpdateInjectable from "./main/quit-and-install-update.injectable";
|
||||
import periodicalCheckForUpdatesInjectable from "./child-features/periodical-checking-of-updates/main/periodical-check-for-updates.injectable";
|
||||
import { advanceFakeTime, testUsingFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import { advanceFakeTime, testUsingFakeTime } from "../../test-utils/use-fake-time";
|
||||
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
|
||||
import getBuildVersionInjectable from "../../main/vars/build-version/get-build-version.injectable";
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import type { ApplicationBuilder } from "../../../../renderer/components/test-ut
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable";
|
||||
import quitAndInstallUpdateInjectable from "../../main/quit-and-install-update.injectable";
|
||||
import { advanceFakeTime, testUsingFakeTime } from "../../../../common/test-utils/use-fake-time";
|
||||
import { testUsingFakeTime, advanceFakeTime } from "../../../../test-utils/use-fake-time";
|
||||
|
||||
function daysToMilliseconds(days: number) {
|
||||
return Math.round(days * 24 * 60 * 60 * 1000);
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import styles from "./styles.module.scss";
|
||||
import type { HTMLAttributes } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { Menu, MenuItem } from "../../../../../../../renderer/components/menu";
|
||||
import { cssNames } from "../../../../../../../renderer/utils";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import type { IconProps } from "../../../../../../../renderer/components/icon";
|
||||
import { Icon } from "../../../../../../../renderer/components/icon";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
|
||||
+1
-1
@@ -14,11 +14,11 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { fireEvent } from "@testing-library/react";
|
||||
import { advanceFakeTime, testUsingFakeTime } from "../../../../common/test-utils/use-fake-time";
|
||||
import quitAndInstallUpdateInjectable from "../../main/quit-and-install-update.injectable";
|
||||
import timeAfterUpdateMustBeInstalledInjectable from "./renderer/force-update-modal/time-after-update-must-be-installed.injectable";
|
||||
import secondsAfterInstallStartsInjectable from "./renderer/force-update-modal/seconds-after-install-starts.injectable";
|
||||
import forceUpdateModalRootFrameComponentInjectable from "./renderer/force-update-modal/force-update-modal-root-frame-component.injectable";
|
||||
import { testUsingFakeTime, advanceFakeTime } from "../../../../test-utils/use-fake-time";
|
||||
|
||||
const TIME_AFTER_UPDATE_MUST_BE_INSTALLED = 1000;
|
||||
const TIME_AFTER_INSTALL_STARTS = 5 * 1000;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { computed } from "mobx";
|
||||
import { getGlobalOverride } from "../../../../../../common/test-utils/get-global-override";
|
||||
import { getGlobalOverride } from "@k8slens/test-utils";
|
||||
import forceUpdateModalRootFrameComponentInjectable from "./force-update-modal-root-frame-component.injectable";
|
||||
|
||||
export default getGlobalOverride(
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable";
|
||||
import { getGlobalOverride } from "../../../../../common/test-utils/get-global-override";
|
||||
import { getGlobalOverride } from "@k8slens/test-utils";
|
||||
|
||||
export default getGlobalOverride(periodicalCheckForUpdatesInjectable, () => ({
|
||||
start: () => {},
|
||||
|
||||
+9
-12
@@ -10,19 +10,16 @@ import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||
const startCheckingForUpdatesInjectable = getInjectable({
|
||||
id: "start-checking-for-updates",
|
||||
|
||||
instantiate: (di) => {
|
||||
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
|
||||
const updatingIsEnabled = di.inject(updatingIsEnabledInjectable);
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
|
||||
const updatingIsEnabled = di.inject(updatingIsEnabledInjectable);
|
||||
|
||||
return {
|
||||
id: "start-checking-for-updates",
|
||||
run: () => {
|
||||
if (updatingIsEnabled && !periodicalCheckForUpdates.started) {
|
||||
periodicalCheckForUpdates.start();
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
if (updatingIsEnabled && !periodicalCheckForUpdates.started) {
|
||||
periodicalCheckForUpdates.start();
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||
});
|
||||
|
||||
+10
-13
@@ -4,25 +4,22 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable";
|
||||
import { beforeQuitOfBackEndInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token";
|
||||
import { beforeQuitOfBackEndInjectionToken } from "../../../../../main/start-main-application/runnable-tokens/phases";
|
||||
|
||||
const stopCheckingForUpdatesInjectable = getInjectable({
|
||||
id: "stop-checking-for-updates",
|
||||
|
||||
instantiate: (di) => {
|
||||
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const periodicalCheckForUpdates = di.inject(periodicalCheckForUpdatesInjectable);
|
||||
|
||||
return {
|
||||
id: "stop-checking-for-updates",
|
||||
run: () => {
|
||||
if (periodicalCheckForUpdates.started) {
|
||||
periodicalCheckForUpdates.stop();
|
||||
}
|
||||
if (periodicalCheckForUpdates.started) {
|
||||
periodicalCheckForUpdates.stop();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
},
|
||||
return undefined;
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: beforeQuitOfBackEndInjectionToken,
|
||||
});
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/fea
|
||||
import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable";
|
||||
import periodicalCheckForUpdatesInjectable from "./main/periodical-check-for-updates.injectable";
|
||||
import { advanceFakeTime, testUsingFakeTime } from "../../../../common/test-utils/use-fake-time";
|
||||
import { testUsingFakeTime, advanceFakeTime } from "../../../../test-utils/use-fake-time";
|
||||
|
||||
const ENOUGH_TIME = 1000 * 60 * 60 * 2;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import type { DownloadPlatformUpdate } from "./main/download-update/download-pla
|
||||
import downloadPlatformUpdateInjectable from "./main/download-update/download-platform-update/download-platform-update.injectable";
|
||||
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
|
||||
import processCheckingForUpdatesInjectable from "./main/process-checking-for-updates.injectable";
|
||||
import { testUsingFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import { testUsingFakeTime } from "../../test-utils/use-fake-time";
|
||||
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
|
||||
|
||||
describe("installing update", () => {
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import checkForPlatformUpdatesInjectable from "./check-for-platform-updates.injectable";
|
||||
import { getGlobalOverrideForFunction } from "../../../../../common/test-utils/get-global-override-for-function";
|
||||
import { getGlobalOverrideForFunction } from "@k8slens/test-utils";
|
||||
|
||||
export default getGlobalOverrideForFunction(checkForPlatformUpdatesInjectable);
|
||||
+2
-2
@@ -10,9 +10,9 @@ import type { AppUpdater, UpdateCheckResult } from "electron-updater";
|
||||
import type { CheckForPlatformUpdates } from "./check-for-platform-updates.injectable";
|
||||
import checkForPlatformUpdatesInjectable from "./check-for-platform-updates.injectable";
|
||||
import type { UpdateChannel, ReleaseChannel } from "../../../common/update-channels";
|
||||
import { getPromiseStatus } from "../../../../../common/test-utils/get-promise-status";
|
||||
import { getPromiseStatus } from "@k8slens/test-utils";
|
||||
import loggerInjectable from "../../../../../common/logger.injectable";
|
||||
import { noop } from "../../../../../common/utils";
|
||||
import { noop } from "@k8slens/utilities";
|
||||
|
||||
describe("check-for-platform-updates", () => {
|
||||
let checkForPlatformUpdates: CheckForPlatformUpdates;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getGlobalOverrideForFunction } from "../../../../../common/test-utils/get-global-override-for-function";
|
||||
import { getGlobalOverrideForFunction } from "@k8slens/test-utils";
|
||||
import downloadPlatformUpdateInjectable from "./download-platform-update.injectable";
|
||||
|
||||
export default getGlobalOverrideForFunction(downloadPlatformUpdateInjectable);
|
||||
+2
-2
@@ -9,10 +9,10 @@ import downloadPlatformUpdateInjectable from "./download-platform-update.injecta
|
||||
import type { AppUpdater } from "electron-updater";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
import { getPromiseStatus } from "../../../../../common/test-utils/get-promise-status";
|
||||
import { getPromiseStatus } from "@k8slens/test-utils";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import loggerInjectable from "../../../../../common/logger.injectable";
|
||||
import { noop } from "../../../../../common/utils";
|
||||
import { noop } from "@k8slens/utilities";
|
||||
|
||||
describe("download-platform-update", () => {
|
||||
let downloadPlatformUpdate: DownloadPlatformUpdate;
|
||||
|
||||
+14
-17
@@ -11,25 +11,22 @@ import buildVersionInjectable from "../../../main/vars/build-version/build-versi
|
||||
const emitCurrentVersionToAnalyticsInjectable = getInjectable({
|
||||
id: "emit-current-version-to-analytics",
|
||||
|
||||
instantiate: (di) => {
|
||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||
const buildVersion = di.inject(buildVersionInjectable);
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||
const buildVersion = di.inject(buildVersionInjectable);
|
||||
|
||||
return {
|
||||
id: "emit-current-version-to-analytics",
|
||||
run: () => {
|
||||
emitAppEvent({
|
||||
name: "app",
|
||||
action: "current-version",
|
||||
emitAppEvent({
|
||||
name: "app",
|
||||
action: "current-version",
|
||||
|
||||
params: {
|
||||
version: buildVersion.get(),
|
||||
currentDateTime: getCurrentDateTime(),
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
params: {
|
||||
version: buildVersion.get(),
|
||||
currentDateTime: getCurrentDateTime(),
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: afterApplicationIsLoadedInjectionToken,
|
||||
});
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getGlobalOverride } from "../../../../../common/test-utils/get-global-override";
|
||||
import { getGlobalOverride } from "@k8slens/test-utils";
|
||||
import publishIsConfiguredInjectable from "./publish-is-configured.injectable";
|
||||
|
||||
export default getGlobalOverride(publishIsConfiguredInjectable, () => false);
|
||||
+6
-9
@@ -9,16 +9,13 @@ import watchIfUpdateShouldHappenOnQuitInjectable from "./watch-if-update-should-
|
||||
const startWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({
|
||||
id: "start-watching-if-update-should-happen-on-quit",
|
||||
|
||||
instantiate: (di) => {
|
||||
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
|
||||
|
||||
return {
|
||||
id: "start-watching-if-update-should-happen-on-quit",
|
||||
run: () => {
|
||||
watchIfUpdateShouldHappenOnQuit.start();
|
||||
},
|
||||
};
|
||||
},
|
||||
watchIfUpdateShouldHappenOnQuit.start();
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: onLoadOfApplicationInjectionToken,
|
||||
});
|
||||
|
||||
+9
-8
@@ -4,19 +4,20 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import watchIfUpdateShouldHappenOnQuitInjectable from "./watch-if-update-should-happen-on-quit.injectable";
|
||||
import { beforeQuitOfBackEndInjectionToken } from "../../../../main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token";
|
||||
import { beforeQuitOfBackEndInjectionToken } from "../../../../main/start-main-application/runnable-tokens/phases";
|
||||
|
||||
const stopWatchingIfUpdateShouldHappenOnQuitInjectable = getInjectable({
|
||||
id: "stop-watching-if-update-should-happen-on-quit",
|
||||
|
||||
instantiate: (di) => {
|
||||
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const watchIfUpdateShouldHappenOnQuit = di.inject(watchIfUpdateShouldHappenOnQuitInjectable);
|
||||
|
||||
return {
|
||||
id: "stop-watching-if-update-should-happen-on-quit",
|
||||
run: () => void watchIfUpdateShouldHappenOnQuit.stop(),
|
||||
};
|
||||
},
|
||||
watchIfUpdateShouldHappenOnQuit.stop();
|
||||
|
||||
return undefined;
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: beforeQuitOfBackEndInjectionToken,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user