mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: Only show Update Channel preferences when applicable
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a0953df4b1
commit
43cedae7b0
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "./main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "./child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
import type { CheckForPlatformUpdates } from "./main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
|
||||
@ -15,7 +15,7 @@ import type { ShowMessagePopup } from "../../../../main/electron-app/features/sh
|
||||
import electronUpdaterIsActiveInjectable
|
||||
from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable
|
||||
from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
from "../../child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
|
||||
describe("installing update using application menu", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
|
||||
@ -7,7 +7,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import applicationMenuItemInjectionToken from "../../../../application-menu/main/menu-items/application-menu-item-injection-token";
|
||||
import processCheckingForUpdatesInjectable from "../../../main/process-checking-for-updates.injectable";
|
||||
import showApplicationWindowInjectable from "../../../../../main/start-main-application/lens-window/show-application-window.injectable";
|
||||
import updatingIsEnabledInjectable from "../../../main/updating-is-enabled/updating-is-enabled.injectable";
|
||||
import updatingIsEnabledInjectable from "../../updating-is-enabled/main/updating-is-enabled.injectable";
|
||||
import isMacInjectable from "../../../../../common/vars/is-mac.injectable";
|
||||
import showMessagePopupInjectable from "../../../../../main/electron-app/features/show-message-popup.injectable";
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import type { CheckForPlatformUpdates } from "../../main/check-for-updates/check
|
||||
import checkForPlatformUpdatesInjectable from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import type { DownloadPlatformUpdate } from "../../main/download-update/download-platform-update/download-platform-update.injectable";
|
||||
import downloadPlatformUpdateInjectable from "../../main/download-update/download-platform-update/download-platform-update.injectable";
|
||||
import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "../../child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
|
||||
@ -6,7 +6,7 @@ import { getApplicationBuilder } from "../../../../renderer/components/test-util
|
||||
import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "../../child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import type { CheckForPlatformUpdates } from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import checkForPlatformUpdatesInjectable from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import updatingIsEnabledInjectable from "../../../../main/updating-is-enabled/updating-is-enabled.injectable";
|
||||
import updatingIsEnabledInjectable from "../../../updating-is-enabled/main/updating-is-enabled.injectable";
|
||||
import { trayMenuItemInjectionToken } from "../../../../../../main/tray/tray-menu-item/tray-menu-item-injection-token";
|
||||
import showApplicationWindowInjectable from "../../../../../../main/start-main-application/lens-window/show-application-window.injectable";
|
||||
import discoveredUpdateVersionInjectable from "../../../../common/discovered-update-version.injectable";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import periodicalCheckForUpdatesInjectable from "./periodical-check-for-updates.injectable";
|
||||
import updatingIsEnabledInjectable from "../../../main/updating-is-enabled/updating-is-enabled.injectable";
|
||||
import updatingIsEnabledInjectable from "../../updating-is-enabled/main/updating-is-enabled.injectable";
|
||||
import { afterApplicationIsLoadedInjectionToken } from "@k8slens/application";
|
||||
|
||||
const startCheckingForUpdatesInjectable = getInjectable({
|
||||
|
||||
@ -6,7 +6,7 @@ import type { ApplicationBuilder } from "../../../../renderer/components/test-ut
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "../../child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import processCheckingForUpdatesInjectable from "../../main/process-checking-for-updates.injectable";
|
||||
import periodicalCheckForUpdatesInjectable from "./main/periodical-check-for-updates.injectable";
|
||||
import { testUsingFakeTime, advanceFakeTime } from "../../../../test-utils/use-fake-time";
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { preferenceItemInjectionToken } from "../../../../../preferences/renderer/preference-items/preference-item-injection-token";
|
||||
import { updatingIsEnabledInitializable } from "../../../updating-is-enabled/common/token";
|
||||
import { UpdateChannel } from "./update-channel";
|
||||
|
||||
const updateChannelPreferenceBlockInjectable = getInjectable({
|
||||
@ -15,6 +16,7 @@ const updateChannelPreferenceBlockInjectable = getInjectable({
|
||||
parentId: "application-page",
|
||||
orderNumber: 50,
|
||||
Component: UpdateChannel,
|
||||
isShown: di.inject(updatingIsEnabledInitializable.stateToken),
|
||||
}),
|
||||
|
||||
injectionToken: preferenceItemInjectionToken,
|
||||
|
||||
@ -7,7 +7,7 @@ import { getApplicationBuilder } from "../../../../renderer/components/test-util
|
||||
import quitAndInstallUpdateInjectable from "../../main/quit-and-install-update.injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "../../child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import type { CheckForPlatformUpdates } from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import checkForPlatformUpdatesInjectable from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { RequestChannel } from "@k8slens/messaging";
|
||||
import { getInitializable } from "../../../../../common/initializable-state/create";
|
||||
|
||||
export const updatingIsEnabledChannel: RequestChannel<void, boolean> = {
|
||||
id: "updating-is-enabled",
|
||||
};
|
||||
|
||||
export const updatingIsEnabledInitializable = getInitializable<boolean>("updating-is-enabled");
|
||||
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { updatingIsEnabledChannel, updatingIsEnabledInitializable } from "../common/token";
|
||||
|
||||
const updatingIsEnabledChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
channel: updatingIsEnabledChannel,
|
||||
id: "foobar",
|
||||
getHandler: (di) => {
|
||||
const updatingIsEnabled = di.inject(updatingIsEnabledInitializable.stateToken);
|
||||
|
||||
return () => updatingIsEnabled;
|
||||
},
|
||||
});
|
||||
|
||||
export default updatingIsEnabledChannelListenerInjectable;
|
||||
@ -3,7 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import electronUpdaterIsActiveInjectable from "../../../../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import { updatingIsEnabledInitializable } from "../common/token";
|
||||
import publishIsConfiguredInjectable from "./publish-is-configured.injectable";
|
||||
|
||||
const updatingIsEnabledInjectable = getInjectable({
|
||||
@ -15,6 +16,7 @@ const updatingIsEnabledInjectable = getInjectable({
|
||||
|
||||
return electronUpdaterIsActive && publishIsConfigured;
|
||||
},
|
||||
injectionToken: updatingIsEnabledInitializable.stateToken,
|
||||
});
|
||||
|
||||
export default updatingIsEnabledInjectable;
|
||||
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { getInjectablesForInitializable } from "../../../../../common/initializable-state/create";
|
||||
import { updatingIsEnabledChannel, updatingIsEnabledInitializable } from "../common/token";
|
||||
|
||||
export const {
|
||||
stateInjectable,
|
||||
initializationInjectable,
|
||||
} = getInjectablesForInitializable({
|
||||
token: updatingIsEnabledInitializable,
|
||||
init: async (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return requestFromChannel(updatingIsEnabledChannel);
|
||||
},
|
||||
phase: onLoadOfApplicationInjectionToken,
|
||||
});
|
||||
@ -5,7 +5,7 @@
|
||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "./main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "./child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
import type { CheckForPlatformUpdates } from "./main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { GetSingleElement } from "@k8slens/react-testing-library-discovery";
|
||||
import { getSingleElement } from "@k8slens/react-testing-library-discovery";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import navigateToPreferencesInjectable from "../preferences/common/navigate-to-preferences.injectable";
|
||||
import updatingIsEnabledInjectable from "./child-features/updating-is-enabled/main/updating-is-enabled.injectable";
|
||||
|
||||
describe("hiding Update Channel preference with updating is not enabled", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
let result: RenderResult;
|
||||
let getElement: GetSingleElement;
|
||||
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.mainDi.override(updatingIsEnabledInjectable, () => false);
|
||||
|
||||
result = await builder.render();
|
||||
|
||||
getElement = getSingleElement(() => result);
|
||||
builder.navigateWith(navigateToPreferencesInjectable);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(result.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows the application settings", () => {
|
||||
expect(getElement("preference-page", "application-page").discovered).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not show the update channel preference", () => {
|
||||
expect(() => getElement("preference-item", "update-channel")).toThrowError(`Couldn't find HTML-element with attribute "data-preference-item-test" with value "update-channel".`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("showing Update Channel preference with updating is enabled", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
let result: RenderResult;
|
||||
let getElement: GetSingleElement;
|
||||
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.mainDi.override(updatingIsEnabledInjectable, () => true);
|
||||
|
||||
result = await builder.render();
|
||||
|
||||
getElement = getSingleElement(() => result);
|
||||
builder.navigateWith(navigateToPreferencesInjectable);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(result.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows the application settings", () => {
|
||||
expect(getElement("preference-page", "application-page").discovered).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does show the update channel preference", () => {
|
||||
expect(getElement("preference-item", "update-channel").discovered).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@ -7,7 +7,7 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
|
||||
import quitAndInstallUpdateInjectable from "./main/quit-and-install-update.injectable";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable";
|
||||
import publishIsConfiguredInjectable from "./main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
|
||||
import publishIsConfiguredInjectable from "./child-features/updating-is-enabled/main/publish-is-configured.injectable";
|
||||
import type { CheckForPlatformUpdates } from "./main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import checkForPlatformUpdatesInjectable from "./main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
|
||||
import type { AsyncFnMock } from "@async-fn/jest";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user