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

Add global override for component observing current time for causing … (#5814)

This commit is contained in:
Janne Savolainen 2022-07-08 19:54:23 +03:00 committed by GitHub
parent 30880276d7
commit 63bd783803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-t
import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable";
import timeAfterUpdateMustBeInstalledInjectable from "../../renderer/application-update/force-update-modal/time-after-update-must-be-installed.injectable";
import secondsAfterInstallStartsInjectable from "../../renderer/application-update/force-update-modal/seconds-after-install-starts.injectable";
import forceUpdateModalRootFrameComponentInjectable from "../../renderer/application-update/force-update-modal/force-update-modal-root-frame-component.injectable";
const TIME_AFTER_UPDATE_MUST_BE_INSTALLED = 1000;
const TIME_AFTER_INSTALL_STARTS = 5 * 1000;
@ -35,6 +36,9 @@ describe("force user to update when too long since update was downloaded", () =>
applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
rendererDi.unoverride(forceUpdateModalRootFrameComponentInjectable);
rendererDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable);
checkForPlatformUpdatesMock = asyncFn();
mainDi.override(checkForPlatformUpdatesInjectable, () => checkForPlatformUpdatesMock);

View File

@ -18,7 +18,6 @@ import processCheckingForUpdatesInjectable from "../../main/application-update/c
import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable";
import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time";
function daysToMilliseconds(days: number) {
return Math.round(days * 24 * 60 * 60 * 1000);
}

View File

@ -31,6 +31,9 @@ const forceUpdateModalRootFrameComponentInjectable = getInjectable({
},
injectionToken: rootFrameChildComponentInjectionToken,
// Note: Globally overridden because it observes the current time which can cause long running tests
causesSideEffects: true,
});
export default forceUpdateModalRootFrameComponentInjectable;

View File

@ -69,6 +69,7 @@ import kubeObjectDetailsClusterFrameChildComponentInjectable from "./components/
import kubeconfigDialogClusterFrameChildComponentInjectable from "./components/kubeconfig-dialog/kubeconfig-dialog-cluster-frame-child-component.injectable";
import portForwardDialogClusterFrameChildComponentInjectable from "./port-forward/port-forward-dialog-cluster-frame-child-component.injectable";
import setupSystemCaInjectable from "./frames/root-frame/setup-system-ca.injectable";
import forceUpdateModalRootFrameComponentInjectable from "./application-update/force-update-modal/force-update-modal-root-frame-component.injectable";
export const getDiForUnitTesting = (opts: { doGeneralOverrides?: boolean } = {}) => {
const {
@ -119,6 +120,12 @@ export const getDiForUnitTesting = (opts: { doGeneralOverrides?: boolean } = {})
shouldRender: computed(() => false),
}));
di.override(forceUpdateModalRootFrameComponentInjectable, () => ({
id: "force-update-modal",
Component: () => null,
shouldRender: computed(() => false),
}));
// TODO: Remove side-effects and shared global state
const clusterFrameChildComponentInjectables: Injectable<any, any, any>[] = [
commandContainerClusterFrameChildComponentInjectable,