mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Linter fixes
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
4d852b9e02
commit
a0bd4c003a
@ -1,6 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import type { AsyncFnMock } from "@async-fn/jest";
|
import type { AsyncFnMock } from "@async-fn/jest";
|
||||||
import asyncFn from "@async-fn/jest";
|
import asyncFn from "@async-fn/jest";
|
||||||
import { act, RenderResult } from "@testing-library/react";
|
import type { RenderResult } from "@testing-library/react";
|
||||||
|
import { act } from "@testing-library/react";
|
||||||
import type { CheckForPlatformUpdates } from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
import type { CheckForPlatformUpdates } from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||||
import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||||
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||||
@ -67,7 +72,7 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
rendererDi.permitSideEffects(closeWindowInjectable);
|
rendererDi.permitSideEffects(closeWindowInjectable);
|
||||||
rendererDi.permitSideEffects(maximizeWindowInjectable);
|
rendererDi.permitSideEffects(maximizeWindowInjectable);
|
||||||
rendererDi.permitSideEffects(toggleMaximizeWindowInjectable);
|
rendererDi.permitSideEffects(toggleMaximizeWindowInjectable);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when started", () => {
|
describe("when started", () => {
|
||||||
@ -109,13 +114,13 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
const button = rendered.queryByTestId("update-button");
|
const button = rendered.queryByTestId("update-button");
|
||||||
|
|
||||||
expect(button).toBeInTheDocument();
|
expect(button).toBeInTheDocument();
|
||||||
})
|
});
|
||||||
|
|
||||||
it("has soft emotional indication in the button", () => {
|
it("has soft emotional indication in the button", () => {
|
||||||
const button = rendered.getByTestId("update-button");
|
const button = rendered.getByTestId("update-button");
|
||||||
|
|
||||||
expect(button).toHaveAttribute("data-warning-level", "light")
|
expect(button).toHaveAttribute("data-warning-level", "light");
|
||||||
})
|
});
|
||||||
|
|
||||||
describe("when button is clicked", () => {
|
describe("when button is clicked", () => {
|
||||||
it("shows dropdown with update item", () => {
|
it("shows dropdown with update item", () => {
|
||||||
@ -124,7 +129,7 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
act(() => button?.click());
|
act(() => button?.click());
|
||||||
|
|
||||||
expect(rendered.getByTestId("update-lens-menu-item")).toBeInTheDocument();
|
expect(rendered.getByTestId("update-lens-menu-item")).toBeInTheDocument();
|
||||||
})
|
});
|
||||||
|
|
||||||
it("when selected update now, restarts the application to update", () => {
|
it("when selected update now, restarts the application to update", () => {
|
||||||
const button = rendered.queryByTestId("update-button");
|
const button = rendered.queryByTestId("update-button");
|
||||||
@ -136,7 +141,7 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
act(() => updateMenuItem?.click());
|
act(() => updateMenuItem?.click());
|
||||||
|
|
||||||
expect(restartAndInstallUpdate).toBeCalled();
|
expect(restartAndInstallUpdate).toBeCalled();
|
||||||
})
|
});
|
||||||
|
|
||||||
describe("when dropdown closed without clicking update item", () => {
|
describe("when dropdown closed without clicking update item", () => {
|
||||||
it("does not restart the application to update", async () => {
|
it("does not restart the application to update", async () => {
|
||||||
@ -147,46 +152,46 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
act(() => button?.click());
|
act(() => button?.click());
|
||||||
|
|
||||||
expect(restartAndInstallUpdate).not.toBeCalled();
|
expect(restartAndInstallUpdate).not.toBeCalled();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
describe("given just enough time passes for medium update encouragement", () => {
|
describe("given just enough time passes for medium update encouragement", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
})
|
});
|
||||||
|
|
||||||
it("has medium emotional indication in the button", () => {
|
it("has medium emotional indication in the button", () => {
|
||||||
const button = rendered.getByTestId("update-button");
|
const button = rendered.getByTestId("update-button");
|
||||||
|
|
||||||
jest.advanceTimersByTime(daysToMilliseconds(22));
|
jest.advanceTimersByTime(daysToMilliseconds(22));
|
||||||
|
|
||||||
expect(button).toHaveAttribute("data-warning-level", "medium")
|
expect(button).toHaveAttribute("data-warning-level", "medium");
|
||||||
})
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
describe("given just enough time passes for severe update encouragement", () => {
|
describe("given just enough time passes for severe update encouragement", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
})
|
});
|
||||||
|
|
||||||
it("has severe emotional indication in the button", () => {
|
it("has severe emotional indication in the button", () => {
|
||||||
const button = rendered.getByTestId("update-button");
|
const button = rendered.getByTestId("update-button");
|
||||||
|
|
||||||
jest.advanceTimersByTime(daysToMilliseconds(26));
|
jest.advanceTimersByTime(daysToMilliseconds(26));
|
||||||
|
|
||||||
expect(button).toHaveAttribute("data-warning-level", "high")
|
expect(button).toHaveAttribute("data-warning-level", "high");
|
||||||
})
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { MessageChannel, messageChannelInjectionToken } from "../../utils/channel/message-channel-injection-token";
|
import type { MessageChannel } from "../../utils/channel/message-channel-injection-token";
|
||||||
|
import { messageChannelInjectionToken } from "../../utils/channel/message-channel-injection-token";
|
||||||
|
|
||||||
export type RestartAndInstallUpdateChannel = MessageChannel;
|
export type RestartAndInstallUpdateChannel = MessageChannel;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import createSyncBoxInjectable from "../../utils/sync-box/create-sync-box.injectable";
|
import createSyncBoxInjectable from "../../utils/sync-box/create-sync-box.injectable";
|
||||||
import { syncBoxInjectionToken } from "../../utils/sync-box/sync-box-injection-token";
|
import { syncBoxInjectionToken } from "../../utils/sync-box/sync-box-injection-token";
|
||||||
@ -9,12 +13,12 @@ const updateWarningLevelInjectable = getInjectable({
|
|||||||
const createSyncBox = di.inject(createSyncBoxInjectable);
|
const createSyncBox = di.inject(createSyncBoxInjectable);
|
||||||
|
|
||||||
return createSyncBox<"light" | "medium" | "high" | "">(
|
return createSyncBox<"light" | "medium" | "high" | "">(
|
||||||
"update-warning-level",
|
"update-warning-level",
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: syncBoxInjectionToken,
|
injectionToken: syncBoxInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default updateWarningLevelInjectable;
|
export default updateWarningLevelInjectable;
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
|
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
|
||||||
import setUpdateWarningLevelInjectable from "./set-update-warning-level.injectable";
|
import setUpdateWarningLevelInjectable from "./set-update-warning-level.injectable";
|
||||||
@ -26,4 +30,4 @@ const periodicalCheckForUpdateWarningInjectable = getInjectable({
|
|||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default periodicalCheckForUpdateWarningInjectable;
|
export default periodicalCheckForUpdateWarningInjectable;
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
|
import updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
|
||||||
|
|
||||||
@ -9,8 +13,8 @@ const setUpdateDownloadedDateInjectable = getInjectable({
|
|||||||
|
|
||||||
return (date: Date) => {
|
return (date: Date) => {
|
||||||
downloadedDate.set(date);
|
downloadedDate.set(date);
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default setUpdateDownloadedDateInjectable;
|
export default setUpdateDownloadedDateInjectable;
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
|
import updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
|
||||||
import { UpdateWarningLevelCalculator } from "./update-warning-level-calculator";
|
import { UpdateWarningLevelCalculator } from "./update-warning-level-calculator";
|
||||||
@ -12,9 +16,10 @@ const setUpdateWarningLevelInjectable = getInjectable({
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const newLevel = new UpdateWarningLevelCalculator(updateDownloadedDate.value.get()).get();
|
const newLevel = new UpdateWarningLevelCalculator(updateDownloadedDate.value.get()).get();
|
||||||
|
|
||||||
updateWarningLevel.set(newLevel);
|
updateWarningLevel.set(newLevel);
|
||||||
}
|
};
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default setUpdateWarningLevelInjectable;
|
export default setUpdateWarningLevelInjectable;
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token";
|
import { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token";
|
||||||
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import createSyncBoxInjectable from "../../../common/utils/sync-box/create-sync-box.injectable";
|
import createSyncBoxInjectable from "../../../common/utils/sync-box/create-sync-box.injectable";
|
||||||
import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token";
|
import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token";
|
||||||
@ -9,12 +13,12 @@ const updateDownloadedDateInjectable = getInjectable({
|
|||||||
const createSyncBox = di.inject(createSyncBoxInjectable);
|
const createSyncBox = di.inject(createSyncBoxInjectable);
|
||||||
|
|
||||||
return createSyncBox<Date | null>(
|
return createSyncBox<Date | null>(
|
||||||
"update-downloaded-date",
|
"update-downloaded-date",
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: syncBoxInjectionToken,
|
injectionToken: syncBoxInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default updateDownloadedDateInjectable;
|
export default updateDownloadedDateInjectable;
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
type WarningLevel = "high" | "medium" | "light" | "";
|
type WarningLevel = "high" | "medium" | "light" | "";
|
||||||
|
|
||||||
export class UpdateWarningLevelCalculator {
|
export class UpdateWarningLevelCalculator {
|
||||||
private onceADay = 1000 * 60 * 60 * 24;
|
private onceADay = 1000 * 60 * 60 * 24;
|
||||||
private level: WarningLevel = "";
|
private level: WarningLevel = "";
|
||||||
|
|
||||||
constructor (private updateDownloadedDate: Date | null) {
|
constructor(private updateDownloadedDate: Date | null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
get(): WarningLevel {
|
get(): WarningLevel {
|
||||||
@ -48,4 +50,4 @@ export class UpdateWarningLevelCalculator {
|
|||||||
this.level = "light";
|
this.level = "light";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import restartAndInstallUpdateChannel from "../../../common/application-update/update-warning-level/restart-and-install-update-channel.injectable";
|
import restartAndInstallUpdateChannel from "../../../common/application-update/update-warning-level/restart-and-install-update-channel.injectable";
|
||||||
import messageToChannelInjectable from "../../utils/channel/message-to-channel.injectable";
|
import messageToChannelInjectable from "../../utils/channel/message-to-channel.injectable";
|
||||||
@ -15,4 +19,4 @@ const restartAndInstallUpdateInjectable = getInjectable({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default restartAndInstallUpdateInjectable;
|
export default restartAndInstallUpdateInjectable;
|
||||||
|
|||||||
@ -14,7 +14,8 @@ import { Icon } from "../icon";
|
|||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level/update-warning-level.injectable";
|
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level/update-warning-level.injectable";
|
||||||
import { computed, IComputedValue } from "mobx";
|
import type { IComputedValue } from "mobx";
|
||||||
|
import { computed } from "mobx";
|
||||||
import restartAndInstallUpdateInjectable from "./restart-and-install-update.injectable";
|
import restartAndInstallUpdateInjectable from "./restart-and-install-update.injectable";
|
||||||
|
|
||||||
interface UpdateButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
interface UpdateButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user