mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into react-table-with-resizable-columns
This commit is contained in:
commit
5cce219387
3
Makefile
3
Makefile
@ -17,8 +17,7 @@ else
|
||||
endif
|
||||
|
||||
node_modules: yarn.lock
|
||||
yarn install --frozen-lockfile --network-timeout=100000
|
||||
yarn check --verify-tree --integrity
|
||||
yarn install --check-files --frozen-lockfile --network-timeout=100000
|
||||
|
||||
binaries/client: node_modules
|
||||
yarn download:binaries
|
||||
|
||||
11
package.json
11
package.json
@ -207,6 +207,9 @@
|
||||
"role": "Viewer"
|
||||
}
|
||||
},
|
||||
"resolutions": {
|
||||
"@astronautlabs/jsonpath/underscore": "^1.12.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astronautlabs/jsonpath": "^1.1.0",
|
||||
"@hapi/call": "^9.0.0",
|
||||
@ -257,7 +260,7 @@
|
||||
"moment-timezone": "^0.5.34",
|
||||
"monaco-editor": "^0.29.1",
|
||||
"monaco-editor-webpack-plugin": "^5.0.0",
|
||||
"node-fetch": "lensapp/node-fetch#2.x",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-pty": "0.10.1",
|
||||
"npm": "^6.14.17",
|
||||
"p-limit": "^3.1.0",
|
||||
@ -343,7 +346,7 @@
|
||||
"@types/request": "^2.48.7",
|
||||
"@types/request-promise-native": "^1.0.18",
|
||||
"@types/semver": "^7.3.10",
|
||||
"@types/sharp": "^0.30.4",
|
||||
"@types/sharp": "^0.30.5",
|
||||
"@types/spdy": "^3.4.5",
|
||||
"@types/tar": "^4.0.5",
|
||||
"@types/tar-stream": "^2.2.2",
|
||||
@ -399,7 +402,7 @@
|
||||
"node-loader": "^2.0.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"playwright": "^1.24.2",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss": "^8.4.16",
|
||||
"postcss-loader": "^6.2.1",
|
||||
"randomcolor": "^0.6.2",
|
||||
"react-beautiful-dnd": "^13.1.0",
|
||||
@ -413,7 +416,7 @@
|
||||
"sass-loader": "^12.6.0",
|
||||
"sharp": "^0.30.7",
|
||||
"style-loader": "^3.3.1",
|
||||
"tailwindcss": "^3.1.6",
|
||||
"tailwindcss": "^3.1.8",
|
||||
"tar-stream": "^2.2.0",
|
||||
"ts-loader": "^9.3.1",
|
||||
"ts-node": "^10.9.1",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { LensMainExtension } from "../../extensions/lens-main-extension";
|
||||
import type { TrayMenuRegistration } from "../../main/tray/tray-menu-registration";
|
||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import getRandomIdInjectable from "../../common/utils/get-random-id.injectable";
|
||||
|
||||
describe("multiple separators originating from extension", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
mainDi.unoverride(getRandomIdInjectable);
|
||||
mainDi.permitSideEffects(getRandomIdInjectable);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
});
|
||||
|
||||
it("given extension with multiple separators, when extension is enabled, does not throw", () => {
|
||||
const someExtension = new SomeTestExtension({
|
||||
id: "some-extension-id",
|
||||
trayMenus: [{ type: "separator" }, { type: "separator" } ],
|
||||
});
|
||||
|
||||
expect(() => {
|
||||
applicationBuilder.extensions.main.enable(someExtension);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
class SomeTestExtension extends LensMainExtension {
|
||||
constructor({ id, trayMenus }: {
|
||||
id: string;
|
||||
trayMenus: TrayMenuRegistration[];
|
||||
}) {
|
||||
super({
|
||||
id,
|
||||
absolutePath: "irrelevant",
|
||||
isBundled: false,
|
||||
isCompatible: false,
|
||||
isEnabled: false,
|
||||
manifest: { name: id, version: "some-version", engines: { lens: "^5.5.0" }},
|
||||
manifestPath: "irrelevant",
|
||||
});
|
||||
|
||||
this.trayMenus = trayMenus;
|
||||
}
|
||||
}
|
||||
@ -14,15 +14,10 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
|
||||
describe("app-paths", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let rendererDi: DiContainer;
|
||||
let mainDi: DiContainer;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const defaultAppPathsStub: AppPaths = {
|
||||
appData: "some-app-data",
|
||||
@ -43,7 +38,7 @@ describe("app-paths", () => {
|
||||
userData: "some-irrelevant-user-data",
|
||||
};
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(
|
||||
getElectronAppPathInjectable,
|
||||
() =>
|
||||
@ -64,12 +59,18 @@ describe("app-paths", () => {
|
||||
});
|
||||
|
||||
describe("normally", () => {
|
||||
let windowDi: DiContainer;
|
||||
let mainDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
mainDi = builder.mainDi;
|
||||
});
|
||||
|
||||
it("given in renderer, when injecting app paths, returns application specific app paths", () => {
|
||||
const actual = rendererDi.inject(appPathsInjectionToken);
|
||||
const actual = windowDi.inject(appPathsInjectionToken);
|
||||
|
||||
expect(actual).toEqual({
|
||||
appData: "some-app-data",
|
||||
@ -116,19 +117,23 @@ describe("app-paths", () => {
|
||||
});
|
||||
|
||||
describe("when running integration tests", () => {
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(
|
||||
directoryForIntegrationTestingInjectable,
|
||||
() => "some-integration-testing-app-data",
|
||||
);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
it("given in renderer, when injecting path for app data, has integration specific app data path", () => {
|
||||
const { appData, userData } = rendererDi.inject(appPathsInjectionToken);
|
||||
const { appData, userData } = windowDi.inject(appPathsInjectionToken);
|
||||
|
||||
expect({ appData, userData }).toEqual({
|
||||
appData: "some-integration-testing-app-data",
|
||||
@ -137,7 +142,7 @@ describe("app-paths", () => {
|
||||
});
|
||||
|
||||
it("given in main, when injecting path for app data, has integration specific app data path", () => {
|
||||
const { appData, userData } = rendererDi.inject(appPathsInjectionToken);
|
||||
const { appData, userData } = windowDi.inject(appPathsInjectionToken);
|
||||
|
||||
expect({ appData, userData }).toEqual({
|
||||
appData: "some-integration-testing-app-data",
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import clusterStoreInjectable from "./cluster-store.injectable";
|
||||
import type { Cluster } from "../cluster/cluster";
|
||||
import type { ClusterStore } from "./cluster-store";
|
||||
|
||||
export default getGlobalOverride(
|
||||
clusterStoreInjectable,
|
||||
() =>
|
||||
({
|
||||
provideInitialFromMain: () => {},
|
||||
getById: (id) => (void id, {}) as Cluster,
|
||||
} as ClusterStore),
|
||||
);
|
||||
@ -4,13 +4,11 @@
|
||||
*/
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { LensWindow } from "../../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||
import { lensWindowInjectionToken } from "../../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||
import type { MessageToChannel } from "./message-to-channel-injection-token";
|
||||
import { messageToChannelInjectionToken } from "./message-to-channel-injection-token";
|
||||
import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import createLensWindowInjectable from "../../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||
import closeAllWindowsInjectable from "../../../main/start-main-application/lens-window/hide-all-windows/close-all-windows.injectable";
|
||||
import type { LensWindow } from "../../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||
import { messageChannelListenerInjectionToken } from "./message-channel-listener-injection-token";
|
||||
import type { MessageChannel } from "./message-channel-injection-token";
|
||||
import type { RequestFromChannel } from "./request-from-channel-injection-token";
|
||||
@ -30,12 +28,10 @@ describe("channel", () => {
|
||||
let messageListenerInWindowMock: jest.Mock;
|
||||
let mainDi: DiContainer;
|
||||
let messageToChannel: MessageToChannel;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(async () => {
|
||||
const applicationBuilder = getApplicationBuilder();
|
||||
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
const rendererDi = applicationBuilder.dis.rendererDi;
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
messageListenerInWindowMock = jest.fn();
|
||||
|
||||
@ -44,37 +40,34 @@ describe("channel", () => {
|
||||
|
||||
instantiate: (di) => ({
|
||||
channel: di.inject(testMessageChannelInjectable),
|
||||
|
||||
handler: messageListenerInWindowMock,
|
||||
}),
|
||||
|
||||
injectionToken: messageChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
rendererDi.register(testChannelListenerInTestWindowInjectable);
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
|
||||
// Notice how test channel has presence in both DIs, being from common
|
||||
mainDi.register(testMessageChannelInjectable);
|
||||
rendererDi.register(testMessageChannelInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testChannelListenerInTestWindowInjectable);
|
||||
windowDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
|
||||
mainDi = builder.mainDi;
|
||||
|
||||
await builder.startHidden();
|
||||
|
||||
testMessageChannel = mainDi.inject(testMessageChannelInjectable);
|
||||
|
||||
messageToChannel = mainDi.inject(
|
||||
messageToChannelInjectionToken,
|
||||
);
|
||||
|
||||
await applicationBuilder.render();
|
||||
|
||||
const closeAllWindows = mainDi.inject(closeAllWindowsInjectable);
|
||||
|
||||
closeAllWindows();
|
||||
messageToChannel = mainDi.inject(messageToChannelInjectionToken);
|
||||
});
|
||||
|
||||
describe("given window is started", () => {
|
||||
let someWindowFake: LensWindow;
|
||||
|
||||
beforeEach(async () => {
|
||||
someWindowFake = createTestWindow(mainDi, "some-window");
|
||||
someWindowFake = builder.applicationWindow.create("some-window");
|
||||
|
||||
await someWindowFake.start();
|
||||
});
|
||||
@ -95,8 +88,8 @@ describe("channel", () => {
|
||||
});
|
||||
|
||||
it("given multiple started windows, when sending message, triggers listeners in all windows", async () => {
|
||||
const someWindowFake = createTestWindow(mainDi, "some-window");
|
||||
const someOtherWindowFake = createTestWindow(mainDi, "some-other-window");
|
||||
const someWindowFake = builder.applicationWindow.create("some-window");
|
||||
const someOtherWindowFake = builder.applicationWindow.create("some-other-window");
|
||||
|
||||
await someWindowFake.start();
|
||||
await someOtherWindowFake.start();
|
||||
@ -113,16 +106,11 @@ describe("channel", () => {
|
||||
describe("messaging from renderer to main, given listener for channel in a main and application has started", () => {
|
||||
let testMessageChannel: TestMessageChannel;
|
||||
let messageListenerInMainMock: jest.Mock;
|
||||
let rendererDi: DiContainer;
|
||||
let mainDi: DiContainer;
|
||||
let messageToChannel: MessageToChannel;
|
||||
|
||||
beforeEach(async () => {
|
||||
const applicationBuilder = getApplicationBuilder();
|
||||
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
|
||||
messageListenerInMainMock = jest.fn();
|
||||
|
||||
const testChannelListenerInMainInjectable = getInjectable({
|
||||
@ -137,19 +125,21 @@ describe("channel", () => {
|
||||
injectionToken: messageChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
mainDi.register(testChannelListenerInMainInjectable);
|
||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.register(testChannelListenerInMainInjectable);
|
||||
mainDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
|
||||
// Notice how test channel has presence in both DIs, being from common
|
||||
mainDi.register(testMessageChannelInjectable);
|
||||
rendererDi.register(testMessageChannelInjectable);
|
||||
|
||||
testMessageChannel = rendererDi.inject(testMessageChannelInjectable);
|
||||
|
||||
messageToChannel = rendererDi.inject(
|
||||
messageToChannelInjectionToken,
|
||||
);
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testMessageChannelInjectable);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
|
||||
const windowDi = applicationBuilder.applicationWindow.only.di;
|
||||
|
||||
testMessageChannel = windowDi.inject(testMessageChannelInjectable);
|
||||
messageToChannel = windowDi.inject(messageToChannelInjectionToken);
|
||||
});
|
||||
|
||||
it("when sending message, triggers listener in main", () => {
|
||||
@ -162,16 +152,11 @@ describe("channel", () => {
|
||||
describe("requesting from main in renderer, given listener for channel in a main and application has started", () => {
|
||||
let testRequestChannel: TestRequestChannel;
|
||||
let requestListenerInMainMock: AsyncFnMock<(arg: string) => string>;
|
||||
let rendererDi: DiContainer;
|
||||
let mainDi: DiContainer;
|
||||
let requestFromChannel: RequestFromChannel;
|
||||
|
||||
beforeEach(async () => {
|
||||
const applicationBuilder = getApplicationBuilder();
|
||||
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
|
||||
requestListenerInMainMock = asyncFn();
|
||||
|
||||
const testChannelListenerInMainInjectable = getInjectable({
|
||||
@ -186,19 +171,24 @@ describe("channel", () => {
|
||||
injectionToken: requestChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
mainDi.register(testChannelListenerInMainInjectable);
|
||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.register(testChannelListenerInMainInjectable);
|
||||
mainDi.register(testRequestChannelInjectable);
|
||||
});
|
||||
|
||||
// Notice how test channel has presence in both DIs, being from common
|
||||
mainDi.register(testRequestChannelInjectable);
|
||||
rendererDi.register(testRequestChannelInjectable);
|
||||
|
||||
testRequestChannel = rendererDi.inject(testRequestChannelInjectable);
|
||||
|
||||
requestFromChannel = rendererDi.inject(
|
||||
requestFromChannelInjectionToken,
|
||||
);
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testRequestChannelInjectable);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
|
||||
const windowDi = applicationBuilder.applicationWindow.only.di;
|
||||
|
||||
testRequestChannel = windowDi.inject(testRequestChannelInjectable);
|
||||
|
||||
requestFromChannel = windowDi.inject(
|
||||
requestFromChannelInjectionToken,
|
||||
);
|
||||
});
|
||||
|
||||
describe("when requesting from channel", () => {
|
||||
@ -245,29 +235,3 @@ const testRequestChannelInjectable = getInjectable({
|
||||
}),
|
||||
});
|
||||
|
||||
const createTestWindow = (di: DiContainer, id: string) => {
|
||||
const testWindowInjectable = getInjectable({
|
||||
id,
|
||||
|
||||
instantiate: (di) => {
|
||||
const createLensWindow = di.inject(createLensWindowInjectable);
|
||||
|
||||
return createLensWindow({
|
||||
id,
|
||||
title: "Some test window",
|
||||
defaultHeight: 42,
|
||||
defaultWidth: 42,
|
||||
getContentSource: () => ({ url: "some-content-url" }),
|
||||
resizable: true,
|
||||
windowFrameUtilitiesAreShown: false,
|
||||
centered: false,
|
||||
});
|
||||
},
|
||||
|
||||
injectionToken: lensWindowInjectionToken,
|
||||
});
|
||||
|
||||
di.register(testWindowInjectable);
|
||||
|
||||
return di.inject(testWindowInjectable);
|
||||
};
|
||||
|
||||
@ -2,13 +2,14 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { observe, runInAction } from "mobx";
|
||||
import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import createSyncBoxInjectable from "./create-sync-box.injectable";
|
||||
import { flushPromises } from "../../test-utils/flush-promises";
|
||||
import type { SyncBox } from "./sync-box-injection-token";
|
||||
import { syncBoxInjectionToken } from "./sync-box-injection-token";
|
||||
|
||||
describe("sync-box", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
@ -16,19 +17,23 @@ describe("sync-box", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.dis.mainDi.register(someInjectable);
|
||||
applicationBuilder.dis.rendererDi.register(someInjectable);
|
||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
||||
mainDi.register(someInjectable);
|
||||
});
|
||||
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(someInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Separate starting for main application and starting of window in application builder
|
||||
xdescribe("given application is started, when value is set in main", () => {
|
||||
describe("given application is started, when value is set in main", () => {
|
||||
let valueInMain: string;
|
||||
let syncBoxInMain: SyncBox<string>;
|
||||
|
||||
beforeEach(async () => {
|
||||
syncBoxInMain = applicationBuilder.dis.mainDi.inject(someInjectable);
|
||||
await applicationBuilder.startHidden();
|
||||
|
||||
// await applicationBuilder.start();
|
||||
syncBoxInMain = applicationBuilder.mainDi.inject(someInjectable);
|
||||
|
||||
observe(syncBoxInMain.value, ({ newValue }) => {
|
||||
valueInMain = newValue as string;
|
||||
@ -46,48 +51,28 @@ describe("sync-box", () => {
|
||||
describe("when window starts", () => {
|
||||
let valueInRenderer: string;
|
||||
let syncBoxInRenderer: SyncBox<string>;
|
||||
let rendererDi: DiContainer;
|
||||
|
||||
beforeEach(() => {
|
||||
// applicationBuilder.renderWindow()
|
||||
beforeEach(async () => {
|
||||
const applicationWindow =
|
||||
applicationBuilder.applicationWindow.create("some-window-id");
|
||||
|
||||
syncBoxInRenderer = applicationBuilder.dis.rendererDi.inject(someInjectable);
|
||||
await applicationWindow.start();
|
||||
|
||||
rendererDi = applicationWindow.di;
|
||||
|
||||
syncBoxInRenderer = rendererDi.inject(someInjectable);
|
||||
|
||||
observe(syncBoxInRenderer.value, ({ newValue }) => {
|
||||
valueInRenderer = newValue as string;
|
||||
}, true);
|
||||
});
|
||||
|
||||
it("does not have the initial value yet", () => {
|
||||
expect(valueInRenderer).toBe(undefined);
|
||||
it("has the value from main", () => {
|
||||
expect(valueInRenderer).toBe("some-value-from-main");
|
||||
});
|
||||
|
||||
describe("when getting initial value resolves", () => {
|
||||
beforeEach(async () => {
|
||||
await flushPromises();
|
||||
});
|
||||
|
||||
it("has value in renderer", () => {
|
||||
expect(valueInRenderer).toBe("some-value-from-main");
|
||||
});
|
||||
|
||||
describe("when value is set from renderer", () => {
|
||||
beforeEach(() => {
|
||||
runInAction(() => {
|
||||
syncBoxInRenderer.set("some-value-from-renderer");
|
||||
});
|
||||
});
|
||||
|
||||
it("has value in main", () => {
|
||||
expect(valueInMain).toBe("some-value-from-renderer");
|
||||
});
|
||||
|
||||
it("has value in renderer", () => {
|
||||
expect(valueInRenderer).toBe("some-value-from-renderer");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when value is set from renderer before getting initial value from main resolves", () => {
|
||||
describe("when value is set from renderer", () => {
|
||||
beforeEach(() => {
|
||||
runInAction(() => {
|
||||
syncBoxInRenderer.set("some-value-from-renderer");
|
||||
@ -112,11 +97,13 @@ describe("sync-box", () => {
|
||||
let syncBoxInRenderer: SyncBox<string>;
|
||||
|
||||
beforeEach(async () => {
|
||||
syncBoxInMain = applicationBuilder.dis.mainDi.inject(someInjectable);
|
||||
syncBoxInRenderer = applicationBuilder.dis.rendererDi.inject(someInjectable);
|
||||
|
||||
await applicationBuilder.render();
|
||||
|
||||
const applicationWindow = applicationBuilder.applicationWindow.only;
|
||||
|
||||
syncBoxInMain = applicationBuilder.mainDi.inject(someInjectable);
|
||||
syncBoxInRenderer = applicationWindow.di.inject(someInjectable);
|
||||
|
||||
observe(syncBoxInRenderer.value, ({ newValue }) => {
|
||||
valueInRenderer = newValue as string;
|
||||
}, true);
|
||||
@ -176,4 +163,6 @@ const someInjectable = getInjectable({
|
||||
|
||||
return createSyncBox("some-sync-box", "some-initial-value");
|
||||
},
|
||||
|
||||
injectionToken: syncBoxInjectionToken,
|
||||
});
|
||||
|
||||
@ -21,7 +21,7 @@ import periodicalCheckForUpdatesInjectable from "../../main/application-update/p
|
||||
import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
|
||||
describe("analytics for installing update", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
|
||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||
let analyticsListenerMock: jest.Mock;
|
||||
@ -30,11 +30,11 @@ describe("analytics for installing update", () => {
|
||||
beforeEach(async () => {
|
||||
useFakeTime("2015-10-21T07:28:00Z");
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
analyticsListenerMock = jest.fn();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart(mainDi => {
|
||||
mainDi.override(appVersionInjectable, () => "42.0.0");
|
||||
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
@ -56,7 +56,7 @@ describe("analytics for installing update", () => {
|
||||
eventBus.addListener(analyticsListenerMock);
|
||||
});
|
||||
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
mainDi = builder.mainDi;
|
||||
});
|
||||
|
||||
describe("given application is started and checking updates periodically", () => {
|
||||
@ -64,7 +64,7 @@ describe("analytics for installing update", () => {
|
||||
mainDi.unoverride(periodicalCheckForUpdatesInjectable);
|
||||
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
});
|
||||
|
||||
@ -101,7 +101,7 @@ describe("analytics for installing update", () => {
|
||||
beforeEach(async () => {
|
||||
analyticsListenerMock.mockClear();
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
});
|
||||
|
||||
it("sends event to analytics about the current version", () => {
|
||||
@ -119,7 +119,7 @@ describe("analytics for installing update", () => {
|
||||
it("when checking for updates using tray, sends event to analytics for being checked from tray", async () => {
|
||||
analyticsListenerMock.mockClear();
|
||||
|
||||
applicationBuilder.tray.click("check-for-updates");
|
||||
builder.tray.click("check-for-updates");
|
||||
|
||||
expect(analyticsListenerMock.mock.calls).toEqual([
|
||||
[
|
||||
@ -140,7 +140,7 @@ describe("analytics for installing update", () => {
|
||||
it("when checking for updates using application menu, sends event to analytics for being checked from application menu", async () => {
|
||||
analyticsListenerMock.mockClear();
|
||||
|
||||
applicationBuilder.applicationMenu.click("root.check-for-updates");
|
||||
builder.applicationMenu.click("root.check-for-updates");
|
||||
|
||||
expect(analyticsListenerMock.mock.calls).toEqual([
|
||||
[
|
||||
@ -24,7 +24,7 @@ describe("downgrading version update", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
|
||||
mainDi.override(
|
||||
@ -36,7 +36,7 @@ describe("downgrading version update", () => {
|
||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||
});
|
||||
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
mainDi = applicationBuilder.mainDi;
|
||||
});
|
||||
|
||||
[
|
||||
@ -35,10 +35,7 @@ describe("force user to update when too long since update was downloaded", () =>
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
|
||||
rendererDi.unoverride(forceUpdateModalRootFrameComponentInjectable);
|
||||
rendererDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable);
|
||||
|
||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
|
||||
mainDi.override(checkForPlatformUpdatesInjectable, () => checkForPlatformUpdatesMock);
|
||||
@ -50,13 +47,17 @@ describe("force user to update when too long since update was downloaded", () =>
|
||||
quitAndInstallUpdateMock = jest.fn();
|
||||
|
||||
mainDi.override(quitAndInstallUpdateInjectable, () => quitAndInstallUpdateMock);
|
||||
|
||||
rendererDi.override(timeAfterUpdateMustBeInstalledInjectable, () => TIME_AFTER_UPDATE_MUST_BE_INSTALLED);
|
||||
|
||||
rendererDi.override(secondsAfterInstallStartsInjectable, () => TIME_AFTER_INSTALL_STARTS / 1000);
|
||||
});
|
||||
|
||||
mainDi = applicationBuilder.dis.mainDi;
|
||||
applicationBuilder.beforeWindowStart(windowDi => {
|
||||
windowDi.unoverride(forceUpdateModalRootFrameComponentInjectable);
|
||||
windowDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable);
|
||||
|
||||
windowDi.override(timeAfterUpdateMustBeInstalledInjectable, () => TIME_AFTER_UPDATE_MUST_BE_INSTALLED);
|
||||
windowDi.override(secondsAfterInstallStartsInjectable, () => TIME_AFTER_INSTALL_STARTS / 1000);
|
||||
});
|
||||
|
||||
mainDi = applicationBuilder.mainDi;
|
||||
});
|
||||
|
||||
describe("when application is started", () => {
|
||||
@ -33,7 +33,7 @@ describe("encourage user to update when sufficient time passed since update was
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
downloadPlatformUpdateMock = asyncFn();
|
||||
|
||||
@ -76,7 +76,7 @@ describe("encourage user to update when sufficient time passed since update was
|
||||
let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>;
|
||||
|
||||
beforeEach(async () => {
|
||||
processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(
|
||||
processCheckingForUpdates = applicationBuilder.mainDi.inject(
|
||||
processCheckingForUpdatesInjectable,
|
||||
);
|
||||
|
||||
@ -105,8 +105,15 @@ describe("encourage user to update when sufficient time passed since update was
|
||||
expect(button).toHaveAttribute("data-warning-level", "light");
|
||||
});
|
||||
|
||||
// TODO: Implement after starting main and renderer is separated in ApplicationBuilder
|
||||
xit("given closing the application window, when starting the application window again, still shows the button", () => {
|
||||
it("given closing the application window, when starting the application window again, still shows the button", async () => {
|
||||
applicationBuilder.applicationWindow.closeAll();
|
||||
|
||||
const window = applicationBuilder.applicationWindow.create("some-window-id");
|
||||
|
||||
await window.start();
|
||||
|
||||
const button = window.rendered.queryByTestId("update-button");
|
||||
|
||||
expect(button).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@ -13,19 +13,18 @@ import type { AsyncFnMock } from "@async-fn/jest";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||
import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||
import closeAllWindowsInjectable from "../../main/start-main-application/lens-window/hide-all-windows/close-all-windows.injectable";
|
||||
import applicationWindowInjectable from "../../main/start-main-application/lens-window/application-window/application-window.injectable";
|
||||
import type { LensWindow } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||
import type { LensWindow } from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||
import getCurrentApplicationWindowInjectable from "../../main/start-main-application/lens-window/application-window/get-current-application-window.injectable";
|
||||
|
||||
describe("installing update using tray", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
|
||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
downloadPlatformUpdateMock = asyncFn();
|
||||
|
||||
@ -48,7 +47,7 @@ describe("installing update using tray", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -56,23 +55,20 @@ describe("installing update using tray", () => {
|
||||
});
|
||||
|
||||
it("user cannot install update yet", () => {
|
||||
expect(applicationBuilder.tray.get("install-update")).toBeNull();
|
||||
expect(builder.tray.get("install-update")).toBeNull();
|
||||
});
|
||||
|
||||
describe("given all application windows are closed, when checking for updates", () => {
|
||||
let applicationWindow: LensWindow;
|
||||
let closeAllWindows: () => void;
|
||||
let getCurrentApplicationWindow: () => LensWindow | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
const mainDi = applicationBuilder.dis.mainDi;
|
||||
getCurrentApplicationWindow = builder.mainDi.inject(
|
||||
getCurrentApplicationWindowInjectable,
|
||||
);
|
||||
|
||||
closeAllWindows = mainDi.inject(closeAllWindowsInjectable);
|
||||
builder.applicationWindow.closeAll();
|
||||
|
||||
applicationWindow = mainDi.inject(applicationWindowInjectable);
|
||||
|
||||
closeAllWindows();
|
||||
|
||||
applicationBuilder.tray.click("check-for-updates");
|
||||
builder.tray.click("check-for-updates");
|
||||
});
|
||||
|
||||
describe("when check for update resolves with new update", () => {
|
||||
@ -84,37 +80,44 @@ describe("installing update using tray", () => {
|
||||
});
|
||||
|
||||
it("does not show application window yet", () => {
|
||||
expect(applicationWindow.isVisible).toBe(false);
|
||||
const actual = getCurrentApplicationWindow();
|
||||
|
||||
expect(actual).toBeUndefined();
|
||||
});
|
||||
|
||||
describe("when download of update resolves with success", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true });
|
||||
});
|
||||
|
||||
it("shows the application window", () => {
|
||||
expect(applicationWindow.isVisible).toBe(true);
|
||||
const actual = getCurrentApplicationWindow();
|
||||
|
||||
expect(actual).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("given closing application window again and checking for updates again using tray, when check resolves with same version that was earlier downloaded, shows the application window", async () => {
|
||||
closeAllWindows();
|
||||
builder.applicationWindow.closeAll();
|
||||
|
||||
applicationBuilder.tray.click("check-for-updates");
|
||||
builder.tray.click("check-for-updates");
|
||||
|
||||
await checkForPlatformUpdatesMock.resolve({
|
||||
updateWasDiscovered: true,
|
||||
version: "some-version",
|
||||
});
|
||||
|
||||
expect(applicationWindow.isVisible).toBe(true);
|
||||
const actual = getCurrentApplicationWindow();
|
||||
|
||||
expect(actual).not.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("when download of update resolves with failure, does not show the application window", async () => {
|
||||
await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: false });
|
||||
|
||||
expect(applicationWindow.isVisible).toBe(false);
|
||||
const actual = getCurrentApplicationWindow();
|
||||
|
||||
expect(actual).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@ -123,29 +126,31 @@ describe("installing update using tray", () => {
|
||||
updateWasDiscovered: false,
|
||||
});
|
||||
|
||||
expect(applicationWindow.isVisible).toBe(false);
|
||||
const actual = getCurrentApplicationWindow();
|
||||
|
||||
expect(actual).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when user checks for updates using tray", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.tray.click("check-for-updates");
|
||||
builder.tray.click("check-for-updates");
|
||||
});
|
||||
|
||||
it("user cannot check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
builder.tray.get("check-for-updates")?.enabled,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("name of tray item for checking updates indicates that checking is happening", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.label,
|
||||
builder.tray.get("check-for-updates")?.label,
|
||||
).toBe("Checking for updates...");
|
||||
});
|
||||
|
||||
it("user cannot install update yet", () => {
|
||||
expect(applicationBuilder.tray.get("install-update")).toBeNull();
|
||||
expect(builder.tray.get("install-update")).toBeNull();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -160,18 +165,18 @@ describe("installing update using tray", () => {
|
||||
});
|
||||
|
||||
it("user cannot install update", () => {
|
||||
expect(applicationBuilder.tray.get("install-update")).toBeNull();
|
||||
expect(builder.tray.get("install-update")).toBeNull();
|
||||
});
|
||||
|
||||
it("user can check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
builder.tray.get("check-for-updates")?.enabled,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("name of tray item for checking updates no longer indicates that checking is happening", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.label,
|
||||
builder.tray.get("check-for-updates")?.label,
|
||||
).toBe("Check for updates");
|
||||
});
|
||||
|
||||
@ -190,13 +195,13 @@ describe("installing update using tray", () => {
|
||||
|
||||
it("user cannot check for updates again yet", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
builder.tray.get("check-for-updates")?.enabled,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("name of tray item for checking updates indicates that downloading is happening", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.label,
|
||||
builder.tray.get("check-for-updates")?.label,
|
||||
).toBe("Downloading update some-version (0%)...");
|
||||
});
|
||||
|
||||
@ -204,12 +209,12 @@ describe("installing update using tray", () => {
|
||||
downloadPlatformUpdateMock.mock.calls[0][0]({ percentage: 42.424242 });
|
||||
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.label,
|
||||
builder.tray.get("check-for-updates")?.label,
|
||||
).toBe("Downloading update some-version (42%)...");
|
||||
});
|
||||
|
||||
it("user still cannot install update", () => {
|
||||
expect(applicationBuilder.tray.get("install-update")).toBeNull();
|
||||
expect(builder.tray.get("install-update")).toBeNull();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -223,19 +228,19 @@ describe("installing update using tray", () => {
|
||||
|
||||
it("user cannot install update", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("install-update"),
|
||||
builder.tray.get("install-update"),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("user can check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
builder.tray.get("check-for-updates")?.enabled,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("name of tray item for checking updates no longer indicates that downloading is happening", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.label,
|
||||
builder.tray.get("check-for-updates")?.label,
|
||||
).toBe("Check for updates");
|
||||
});
|
||||
|
||||
@ -251,19 +256,19 @@ describe("installing update using tray", () => {
|
||||
|
||||
it("user can install update", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("install-update")?.label,
|
||||
builder.tray.get("install-update")?.label,
|
||||
).toBe("Install update some-version");
|
||||
});
|
||||
|
||||
it("user can check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
builder.tray.get("check-for-updates")?.enabled,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("name of tray item for checking updates no longer indicates that downloading is happening", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.label,
|
||||
builder.tray.get("check-for-updates")?.label,
|
||||
).toBe("Check for updates");
|
||||
});
|
||||
|
||||
@ -20,7 +20,7 @@ import { useFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
|
||||
|
||||
describe("installing update", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let quitAndInstallUpdateMock: jest.Mock;
|
||||
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
|
||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||
@ -29,9 +29,9 @@ describe("installing update", () => {
|
||||
beforeEach(() => {
|
||||
useFakeTime("2015-10-21T07:28:00Z");
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
quitAndInstallUpdateMock = jest.fn();
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
downloadPlatformUpdateMock = asyncFn();
|
||||
@ -66,9 +66,9 @@ describe("installing update", () => {
|
||||
let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
|
||||
processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(
|
||||
processCheckingForUpdates = builder.mainDi.inject(
|
||||
processCheckingForUpdatesInjectable,
|
||||
);
|
||||
});
|
||||
@ -78,7 +78,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -96,7 +96,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows tray icon for checking for updates", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconCheckingForUpdatesTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -113,7 +113,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows tray icon for normal", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -140,7 +140,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("still shows tray icon for downloading", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconCheckingForUpdatesTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -159,7 +159,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("still shows normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -179,7 +179,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows tray icon for update being available", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconUpdateAvailableTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -196,7 +196,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows tray icon for checking for updates", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconCheckingForUpdatesTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -214,7 +214,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows tray icon for update being available", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconUpdateAvailableTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -233,7 +233,7 @@ describe("installing update", () => {
|
||||
});
|
||||
|
||||
it("shows tray icon for downloading update", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
expect(builder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconCheckingForUpdatesTemplate.png",
|
||||
);
|
||||
});
|
||||
@ -14,15 +14,15 @@ import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-t
|
||||
const ENOUGH_TIME = 1000 * 60 * 60 * 2;
|
||||
|
||||
describe("periodical checking of updates", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let processCheckingForUpdatesMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
useFakeTime("2015-10-21T07:28:00Z");
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.unoverride(periodicalCheckForUpdatesInjectable);
|
||||
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
|
||||
|
||||
@ -39,12 +39,12 @@ describe("periodical checking of updates", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -74,12 +74,12 @@ describe("periodical checking of updates", () => {
|
||||
|
||||
describe("given updater is enabled but no configuration exist, when started", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
||||
mainDi.override(publishIsConfiguredInjectable, () => false);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
});
|
||||
|
||||
it("does not check for updates", () => {
|
||||
@ -95,12 +95,12 @@ describe("periodical checking of updates", () => {
|
||||
|
||||
describe("given updater is not enabled but and configuration exist, when started", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(electronUpdaterIsActiveInjectable, () => false);
|
||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
});
|
||||
|
||||
it("does not check for updates", () => {
|
||||
@ -22,26 +22,25 @@ import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-upda
|
||||
import showInfoNotificationInjectable from "../../renderer/components/notifications/show-info-notification.injectable";
|
||||
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
|
||||
import appVersionInjectable from "../../common/vars/app-version.injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
|
||||
describe("selection of update stability", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let quitAndInstallUpdateMock: jest.Mock;
|
||||
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
|
||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||
let setUpdateOnQuitMock: jest.Mock;
|
||||
let showInfoNotificationMock: jest.Mock;
|
||||
let mainDi: DiContainer;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
quitAndInstallUpdateMock = jest.fn();
|
||||
checkForPlatformUpdatesMock = asyncFn();
|
||||
downloadPlatformUpdateMock = asyncFn();
|
||||
setUpdateOnQuitMock = jest.fn();
|
||||
showInfoNotificationMock = jest.fn(() => () => {});
|
||||
|
||||
rendererDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
||||
|
||||
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
|
||||
|
||||
@ -63,6 +62,14 @@ describe("selection of update stability", () => {
|
||||
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||
});
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
showInfoNotificationMock = jest.fn(() => () => {});
|
||||
|
||||
windowDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
||||
});
|
||||
|
||||
mainDi = builder.mainDi;
|
||||
});
|
||||
|
||||
describe("when started", () => {
|
||||
@ -70,9 +77,9 @@ describe("selection of update stability", () => {
|
||||
let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
|
||||
processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -86,7 +93,7 @@ describe("selection of update stability", () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
selectedUpdateChannel = applicationBuilder.dis.mainDi.inject(
|
||||
selectedUpdateChannel = mainDi.inject(
|
||||
selectedUpdateChannelInjectable,
|
||||
);
|
||||
|
||||
@ -177,7 +184,7 @@ describe("selection of update stability", () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
selectedUpdateChannel = applicationBuilder.dis.mainDi.inject(
|
||||
selectedUpdateChannel = mainDi.inject(
|
||||
selectedUpdateChannelInjectable,
|
||||
);
|
||||
|
||||
@ -224,7 +231,7 @@ describe("selection of update stability", () => {
|
||||
});
|
||||
|
||||
it("given valid update channel selection is stored, when checking for updates, checks for updates from the update channel", async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
// TODO: Switch to more natural way of setting initial value
|
||||
// TODO: UserStore is currently responsible for getting and setting initial value
|
||||
const selectedUpdateChannel = mainDi.inject(selectedUpdateChannelInjectable);
|
||||
@ -232,9 +239,9 @@ describe("selection of update stability", () => {
|
||||
selectedUpdateChannel.setValue(updateChannels.beta.id);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
|
||||
processCheckingForUpdates("irrelevant");
|
||||
|
||||
@ -242,7 +249,7 @@ describe("selection of update stability", () => {
|
||||
});
|
||||
|
||||
it("given invalid update channel selection is stored, when checking for updates, checks for updates from the update channel", async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
// TODO: Switch to more natural way of setting initial value
|
||||
// TODO: UserStore is currently responsible for getting and setting initial value
|
||||
const selectedUpdateChannel = mainDi.inject(selectedUpdateChannelInjectable);
|
||||
@ -250,9 +257,9 @@ describe("selection of update stability", () => {
|
||||
selectedUpdateChannel.setValue("something-invalid" as UpdateChannelId);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
|
||||
processCheckingForUpdates("irrelevant");
|
||||
|
||||
@ -260,13 +267,13 @@ describe("selection of update stability", () => {
|
||||
});
|
||||
|
||||
it('given no update channel selection is stored and currently using stable release, when user checks for updates, checks for updates from "latest" update channel by default', async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(appVersionInjectable, () => "1.0.0");
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
|
||||
processCheckingForUpdates("irrelevant");
|
||||
|
||||
@ -277,13 +284,13 @@ describe("selection of update stability", () => {
|
||||
});
|
||||
|
||||
it('given no update channel selection is stored and currently using alpha release, when checking for updates, checks for updates from "alpha" channel', async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(appVersionInjectable, () => "1.0.0-alpha");
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
|
||||
processCheckingForUpdates("irrelevant");
|
||||
|
||||
@ -291,13 +298,13 @@ describe("selection of update stability", () => {
|
||||
});
|
||||
|
||||
it('given no update channel selection is stored and currently using beta release, when checking for updates, checks for updates from "beta" channel', async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(appVersionInjectable, () => "1.0.0-beta");
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
|
||||
processCheckingForUpdates("irrelevant");
|
||||
|
||||
@ -305,7 +312,7 @@ describe("selection of update stability", () => {
|
||||
});
|
||||
|
||||
it("given update channel selection is stored and currently using prerelease, when checking for updates, checks for updates from stored channel", async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(appVersionInjectable, () => "1.0.0-alpha");
|
||||
|
||||
// TODO: Switch to more natural way of setting initial value
|
||||
@ -315,9 +322,9 @@ describe("selection of update stability", () => {
|
||||
selectedUpdateChannel.setValue(updateChannels.beta.id);
|
||||
});
|
||||
|
||||
await applicationBuilder.render();
|
||||
await builder.render();
|
||||
|
||||
const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
|
||||
processCheckingForUpdates("irrelevant");
|
||||
|
||||
@ -8,7 +8,6 @@ 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 type { TestExtensionRenderer } from "../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getExtensionFakeFor } from "../../../renderer/components/test-utils/get-extension-fake";
|
||||
import type { KubernetesCluster } from "../../../common/catalog-entities";
|
||||
import React from "react";
|
||||
import extensionShouldBeEnabledForClusterFrameInjectable from "../../../renderer/extension-loader/extension-should-be-enabled-for-cluster-frame.injectable";
|
||||
@ -24,13 +23,13 @@ describe("disable-cluster-pages-when-cluster-is-not-relevant", () => {
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.dis.rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -43,13 +42,14 @@ describe("disable-cluster-pages-when-cluster-is-not-relevant", () => {
|
||||
},
|
||||
}],
|
||||
},
|
||||
});
|
||||
|
||||
rendererTestExtension = testExtension.renderer;
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
builder.extensions.enable(testExtension);
|
||||
|
||||
rendererTestExtension =
|
||||
builder.extensions.get("test-extension-id").applicationWindows.only;
|
||||
});
|
||||
|
||||
describe("given not yet known if extension should be enabled for the cluster, when navigating", () => {
|
||||
@ -7,7 +7,6 @@ import asyncFn from "@async-fn/jest";
|
||||
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 { getExtensionFakeFor } from "../../../renderer/components/test-utils/get-extension-fake";
|
||||
import type { KubernetesCluster } from "../../../common/catalog-entities";
|
||||
import React from "react";
|
||||
import extensionShouldBeEnabledForClusterFrameInjectable from "../../../renderer/extension-loader/extension-should-be-enabled-for-cluster-frame.injectable";
|
||||
@ -22,13 +21,13 @@ describe("disable sidebar items when cluster is not relevant", () => {
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.dis.rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -52,7 +51,7 @@ describe("disable sidebar items when cluster is not relevant", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
@ -9,24 +9,21 @@ import React from "react";
|
||||
import type { TestExtensionRenderer } from "../../../renderer/components/test-utils/get-extension-fake";
|
||||
import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../renderer/components/test-utils/get-extension-fake";
|
||||
|
||||
describe("reactively disable cluster pages", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
let someObservable: IObservableValue<boolean>;
|
||||
let rendererTestExtension: TestExtensionRenderer;
|
||||
let testExtensionInstance: TestExtensionRenderer;
|
||||
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtensionOptions = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -39,17 +36,18 @@ describe("reactively disable cluster pages", () => {
|
||||
enabled: computed(() => someObservable.get()),
|
||||
}],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
builder.extensions.enable(testExtension);
|
||||
builder.extensions.enable(testExtensionOptions);
|
||||
|
||||
rendererTestExtension = testExtension.renderer;
|
||||
testExtensionInstance =
|
||||
builder.extensions.get("test-extension-id").applicationWindows.only;
|
||||
});
|
||||
|
||||
it("when navigating to the page, does not show the page", () => {
|
||||
rendererTestExtension.navigate();
|
||||
testExtensionInstance.navigate();
|
||||
|
||||
const actual = rendered.queryByTestId("some-test-page");
|
||||
|
||||
@ -61,7 +59,7 @@ describe("reactively disable cluster pages", () => {
|
||||
someObservable.set(true);
|
||||
});
|
||||
|
||||
rendererTestExtension.navigate();
|
||||
testExtensionInstance.navigate();
|
||||
|
||||
const actual = rendered.queryByTestId("some-test-page");
|
||||
|
||||
@ -8,7 +8,6 @@ import type { RenderResult } from "@testing-library/react";
|
||||
import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
@ -30,9 +29,10 @@ describe("disable kube object detail items when cluster is not relevant", () =>
|
||||
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
apiManagerInjectable,
|
||||
() =>
|
||||
({
|
||||
@ -42,21 +42,15 @@ describe("disable kube object detail items when cluster is not relevant", () =>
|
||||
}),
|
||||
} as unknown as ApiManager),
|
||||
);
|
||||
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
rendererDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -77,12 +71,14 @@ describe("disable kube object detail items when cluster is not relevant", () =>
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
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 { getExtensionFakeFor } from "../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import type { IObservableValue } from "mobx";
|
||||
@ -26,8 +25,10 @@ describe("reactively hide kube object detail item", () => {
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
apiManagerInjectable,
|
||||
() =>
|
||||
({
|
||||
@ -37,19 +38,13 @@ describe("reactively hide kube object detail item", () => {
|
||||
}),
|
||||
} as unknown as ApiManager),
|
||||
);
|
||||
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -71,12 +66,14 @@ describe("reactively hide kube object detail item", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
|
||||
@ -8,7 +8,6 @@ import type { RenderResult } from "@testing-library/react";
|
||||
import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
@ -29,19 +28,16 @@ describe("disable kube object menu items when cluster is not relevant", () => {
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
rendererDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -60,12 +56,14 @@ describe("disable kube object menu items when cluster is not relevant", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
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 { getExtensionFakeFor } from "../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import type { IObservableValue } from "mobx";
|
||||
@ -24,17 +23,15 @@ describe("reactively hide kube object menu item", () => {
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -53,12 +50,14 @@ describe("reactively hide kube object menu item", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
|
||||
@ -8,7 +8,6 @@ import type { RenderResult } from "@testing-library/react";
|
||||
import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { KubernetesCluster } from "../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import { computed } from "mobx";
|
||||
@ -30,19 +29,16 @@ describe("disable kube object statuses when cluster is not relevant", () => {
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
rendererDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -61,12 +57,14 @@ describe("disable kube object statuses when cluster is not relevant", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
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 { getExtensionFakeFor } from "../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
||||
import type { IObservableValue } from "mobx";
|
||||
@ -26,19 +25,16 @@ describe("reactively hide kube object status", () => {
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
rendererDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||
});
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -57,12 +53,14 @@ describe("reactively hide kube object status", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
|
||||
@ -32,8 +32,6 @@ describe("show status for a kube object", () => {
|
||||
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
infoStatusIsShown = false;
|
||||
|
||||
const infoStatusInjectable = getInjectable({
|
||||
@ -95,34 +93,36 @@ describe("show status for a kube object", () => {
|
||||
}),
|
||||
});
|
||||
|
||||
rendererDi.register(
|
||||
testRouteInjectable,
|
||||
testRouteComponentInjectable,
|
||||
infoStatusInjectable,
|
||||
warningStatusInjectable,
|
||||
criticalStatusInjectable,
|
||||
someAtomInjectable,
|
||||
);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(
|
||||
testRouteInjectable,
|
||||
testRouteComponentInjectable,
|
||||
infoStatusInjectable,
|
||||
warningStatusInjectable,
|
||||
criticalStatusInjectable,
|
||||
someAtomInjectable,
|
||||
);
|
||||
});
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
});
|
||||
|
||||
describe("given application starts and in test page", () => {
|
||||
let rendererDi: DiContainer;
|
||||
let windowDi: DiContainer;
|
||||
let rendered: RenderResult;
|
||||
let rerenderParent: () => void;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await builder.render();
|
||||
|
||||
rendererDi = builder.dis.rendererDi;
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const someAtom = rendererDi.inject(someAtomInjectable);
|
||||
const someAtom = windowDi.inject(someAtomInjectable);
|
||||
|
||||
rerenderParent = rerenderParentFor(someAtom);
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = rendererDi.inject(testRouteInjectable);
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const testRoute = windowDi.inject(testRouteInjectable);
|
||||
|
||||
navigateToRoute(testRoute);
|
||||
});
|
||||
@ -141,7 +141,7 @@ describe("show status for a kube object", () => {
|
||||
|
||||
describe("when status for irrelevant kube object kind emerges", () => {
|
||||
beforeEach(() => {
|
||||
rendererDi.register(statusForIrrelevantKubeObjectKindInjectable);
|
||||
windowDi.register(statusForIrrelevantKubeObjectKindInjectable);
|
||||
|
||||
rerenderParent();
|
||||
});
|
||||
@ -161,7 +161,7 @@ describe("show status for a kube object", () => {
|
||||
|
||||
describe("when status for irrelevant kube object api version emerges", () => {
|
||||
beforeEach(() => {
|
||||
rendererDi.register(statusForIrrelevantKubeObjectApiVersionInjectable);
|
||||
windowDi.register(statusForIrrelevantKubeObjectApiVersionInjectable);
|
||||
|
||||
rerenderParent();
|
||||
});
|
||||
@ -44,34 +44,34 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
|
||||
showSuccessNotificationMock = jest.fn();
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
directoryForLensLocalStorageInjectable,
|
||||
() => "/some-directory-for-lens-local-storage",
|
||||
);
|
||||
|
||||
rendererDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
|
||||
storagesAreReady = controlWhenStoragesAreReady(rendererDi);
|
||||
storagesAreReady = controlWhenStoragesAreReady(windowDi);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
showSuccessNotificationInjectable,
|
||||
() => showSuccessNotificationMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
showErrorNotificationInjectable,
|
||||
() => showErrorNotificationMock,
|
||||
);
|
||||
|
||||
rendererDi.override(getRandomIdForEditResourceTabInjectable, () =>
|
||||
windowDi.override(getRandomIdForEditResourceTabInjectable, () =>
|
||||
jest
|
||||
.fn(() => "some-irrelevant-random-id")
|
||||
.mockReturnValueOnce("some-first-tab-id")
|
||||
.mockReturnValueOnce("some-second-tab-id"),
|
||||
);
|
||||
|
||||
rendererDi.override(callForResourceInjectable, () => async (selfLink: string) => {
|
||||
windowDi.override(callForResourceInjectable, () => async (selfLink: string) => {
|
||||
if (
|
||||
[
|
||||
"/apis/some-api-version/namespaces/some-uid",
|
||||
@ -84,7 +84,7 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
|
||||
return undefined;
|
||||
});
|
||||
|
||||
rendererDi.override(callForPatchResourceInjectable, () => async (namespace, ...args) => {
|
||||
windowDi.override(callForPatchResourceInjectable, () => async (namespace, ...args) => {
|
||||
if (
|
||||
[
|
||||
"/apis/some-api-version/namespaces/some-uid",
|
||||
@ -103,22 +103,22 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
|
||||
|
||||
describe("when navigating to namespaces", () => {
|
||||
let rendered: RenderResult;
|
||||
let rendererDi: DiContainer;
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await builder.render();
|
||||
|
||||
await storagesAreReady();
|
||||
|
||||
rendererDi = builder.dis.rendererDi;
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToNamespaces = rendererDi.inject(
|
||||
const navigateToNamespaces = windowDi.inject(
|
||||
navigateToNamespacesInjectable,
|
||||
);
|
||||
|
||||
navigateToNamespaces();
|
||||
|
||||
const dockStore = rendererDi.inject(dockStoreInjectable);
|
||||
const dockStore = windowDi.inject(dockStoreInjectable);
|
||||
|
||||
// TODO: Make TerminalWindow unit testable to allow realistic behaviour
|
||||
dockStore.closeTab("terminal");
|
||||
@ -168,7 +168,7 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
|
||||
// TODO: Make implementation match the description (tests above)
|
||||
const namespaceStub = new Namespace(someNamespaceDataStub);
|
||||
|
||||
const createEditResourceTab = rendererDi.inject(createEditResourceTabInjectable);
|
||||
const createEditResourceTab = windowDi.inject(createEditResourceTabInjectable);
|
||||
|
||||
createEditResourceTab(namespaceStub);
|
||||
});
|
||||
@ -510,7 +510,7 @@ metadata:
|
||||
});
|
||||
|
||||
it("stores the changed configuration", async () => {
|
||||
const readJsonFile = rendererDi.inject(
|
||||
const readJsonFile = windowDi.inject(
|
||||
readJsonFileInjectable,
|
||||
);
|
||||
|
||||
@ -719,7 +719,7 @@ metadata:
|
||||
// TODO: Make implementation match the description
|
||||
const namespaceStub = new Namespace(someOtherNamespaceDataStub);
|
||||
|
||||
const createEditResourceTab = rendererDi.inject(createEditResourceTabInjectable);
|
||||
const createEditResourceTab = windowDi.inject(createEditResourceTabInjectable);
|
||||
|
||||
createEditResourceTab(namespaceStub);
|
||||
});
|
||||
@ -29,17 +29,17 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
|
||||
|
||||
callForNamespaceMock = asyncFn();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
directoryForLensLocalStorageInjectable,
|
||||
() => "/some-directory-for-lens-local-storage",
|
||||
);
|
||||
|
||||
rendererDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
|
||||
storagesAreReady = controlWhenStoragesAreReady(rendererDi);
|
||||
storagesAreReady = controlWhenStoragesAreReady(windowDi);
|
||||
|
||||
rendererDi.override(callForResourceInjectable, () => callForNamespaceMock);
|
||||
windowDi.override(callForResourceInjectable, () => callForNamespaceMock);
|
||||
});
|
||||
|
||||
builder.allowKubeResource("namespaces");
|
||||
@ -49,33 +49,35 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
const writeJsonFile = builder.dis.rendererDi.inject(writeJsonFileInjectable);
|
||||
builder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFile(
|
||||
"/some-directory-for-lens-local-storage/some-cluster-id.json",
|
||||
{
|
||||
dock: {
|
||||
height: 300,
|
||||
tabs: [
|
||||
{
|
||||
id: "some-first-tab-id",
|
||||
kind: TabKind.EDIT_RESOURCE,
|
||||
title: "Namespace: some-namespace",
|
||||
pinned: false,
|
||||
await writeJsonFile(
|
||||
"/some-directory-for-lens-local-storage/some-cluster-id.json",
|
||||
{
|
||||
dock: {
|
||||
height: 300,
|
||||
tabs: [
|
||||
{
|
||||
id: "some-first-tab-id",
|
||||
kind: TabKind.EDIT_RESOURCE,
|
||||
title: "Namespace: some-namespace",
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
|
||||
isOpen: true,
|
||||
},
|
||||
|
||||
edit_resource_store: {
|
||||
"some-first-tab-id": {
|
||||
resource: "/apis/some-api-version/namespaces/some-uid",
|
||||
draft: "some-saved-configuration",
|
||||
},
|
||||
],
|
||||
|
||||
isOpen: true,
|
||||
},
|
||||
|
||||
edit_resource_store: {
|
||||
"some-first-tab-id": {
|
||||
resource: "/apis/some-api-version/namespaces/some-uid",
|
||||
draft: "some-saved-configuration",
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
);
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
@ -14,19 +14,21 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
|
||||
|
||||
describe("cluster - order of sidebar items", () => {
|
||||
let rendered: RenderResult;
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder().setEnvironmentToClusterFrame();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.register(testSidebarItemsInjectable);
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -27,24 +27,21 @@ import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-t
|
||||
import storageSaveDelayInjectable from "../../renderer/utils/create-storage/storage-save-delay.injectable";
|
||||
|
||||
describe("cluster - sidebar and tab navigation for core", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let rendererDi: DiContainer;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(() => {
|
||||
useFakeTime("2015-10-21T07:28:00Z");
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.setEnvironmentToClusterFrame();
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(hostedClusterIdInjectable, () => "some-hosted-cluster-id");
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(hostedClusterIdInjectable, () => "some-hosted-cluster-id");
|
||||
windowDi.override(storageSaveDelayInjectable, () => 250);
|
||||
|
||||
rendererDi.override(storageSaveDelayInjectable, () => 250);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
directoryForLensLocalStorageInjectable,
|
||||
() => "/some-directory-for-lens-local-storage",
|
||||
);
|
||||
@ -53,24 +50,23 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
|
||||
describe("given core registrations", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.register(testRouteInjectable);
|
||||
rendererDi.register(testRouteComponentInjectable);
|
||||
rendererDi.register(testSidebarItemsInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testRouteInjectable);
|
||||
windowDi.register(testRouteComponentInjectable);
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(({ rendererDi }) => {
|
||||
const route = rendererDi.inject(testRouteInjectable);
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
navigateToRoute(route);
|
||||
});
|
||||
const route = windowDi.inject(testRouteInjectable);
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
navigateToRoute(route);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -96,8 +92,8 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
|
||||
describe("given state for expanded sidebar items already exists, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const writeJsonFileFake = rendererDi.inject(writeJsonFileInjectable);
|
||||
builder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -108,15 +104,13 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const sidebarStorage = rendererDi.inject(sidebarStorageInjectable);
|
||||
const sidebarStorage = windowDi.inject(sidebarStorageInjectable);
|
||||
|
||||
await sidebarStorage.whenReady;
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -138,8 +132,8 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
|
||||
describe("given state for expanded unknown sidebar items already exists, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const writeJsonFileFake = rendererDi.inject(writeJsonFileInjectable);
|
||||
builder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -152,7 +146,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders without errors", () => {
|
||||
@ -168,8 +162,8 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
|
||||
describe("given empty state for expanded sidebar items already exists, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const writeJsonFileFake = rendererDi.inject(writeJsonFileInjectable);
|
||||
builder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -179,7 +173,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders without errors", () => {
|
||||
@ -194,8 +188,12 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
});
|
||||
|
||||
describe("given no initially persisted state for sidebar items, when rendered", () => {
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -271,7 +269,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
it("when not enough time passes, does not store state for expanded sidebar items to file system yet", async () => {
|
||||
advanceFakeTime(250 - 1);
|
||||
|
||||
const pathExistsFake = rendererDi.inject(pathExistsInjectable);
|
||||
const pathExistsFake = windowDi.inject(pathExistsInjectable);
|
||||
|
||||
const actual = await pathExistsFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -283,7 +281,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
||||
it("when enough time passes, stores state for expanded sidebar items to file system", async () => {
|
||||
advanceFakeTime(250);
|
||||
|
||||
const readJsonFileFake = rendererDi.inject(readJsonFileInjectable);
|
||||
const readJsonFileFake = windowDi.inject(readJsonFileInjectable);
|
||||
|
||||
const actual = await readJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -13,35 +13,31 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
|
||||
import writeJsonFileInjectable from "../../common/fs/write-json-file.injectable";
|
||||
import pathExistsInjectable from "../../common/fs/path-exists.injectable";
|
||||
import readJsonFileInjectable from "../../common/fs/read-json-file.injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
|
||||
import assert from "assert";
|
||||
import hostedClusterIdInjectable from "../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
||||
import { advanceFakeTime, useFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import { getExtensionFakeFor } from "../../renderer/components/test-utils/get-extension-fake";
|
||||
import type { IObservableValue } from "mobx";
|
||||
import { runInAction, computed, observable } from "mobx";
|
||||
import storageSaveDelayInjectable from "../../renderer/utils/create-storage/storage-save-delay.injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
|
||||
describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let rendererDi: DiContainer;
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(() => {
|
||||
useFakeTime("2015-10-21T07:28:00Z");
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
|
||||
applicationBuilder.setEnvironmentToClusterFrame();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(hostedClusterIdInjectable, () => "some-hosted-cluster-id");
|
||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(hostedClusterIdInjectable, () => "some-hosted-cluster-id");
|
||||
windowDi.override(storageSaveDelayInjectable, () => 250);
|
||||
|
||||
rendererDi.override(storageSaveDelayInjectable, () => 250);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
directoryForLensLocalStorageInjectable,
|
||||
() => "/some-directory-for-lens-local-storage",
|
||||
);
|
||||
@ -54,9 +50,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
beforeEach(() => {
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(applicationBuilder);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "some-extension-id",
|
||||
name: "some-extension-name",
|
||||
|
||||
@ -130,29 +124,31 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
applicationBuilder.extensions.enable(testExtension);
|
||||
});
|
||||
|
||||
describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(({ rendererDi }) => {
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const route = rendererDi
|
||||
.inject(routesInjectable)
|
||||
.get()
|
||||
.find(
|
||||
matches({
|
||||
path: "/extension/some-extension-name/some-child-page-id",
|
||||
}),
|
||||
);
|
||||
|
||||
assert(route);
|
||||
navigateToRoute(route);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
|
||||
const windowDi = applicationBuilder.applicationWindow.only.di;
|
||||
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
|
||||
const route = windowDi
|
||||
.inject(routesInjectable)
|
||||
.get()
|
||||
.find(
|
||||
matches({
|
||||
path: "/extension/some-extension-name/some-child-page-id",
|
||||
}),
|
||||
);
|
||||
|
||||
assert(route);
|
||||
navigateToRoute(route);
|
||||
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -178,8 +174,8 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
|
||||
describe("given state for expanded sidebar items already exists, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const writeJsonFileFake = rendererDi.inject(writeJsonFileInjectable);
|
||||
applicationBuilder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -214,8 +210,8 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
|
||||
describe("given state for expanded unknown sidebar items already exists, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const writeJsonFileFake = rendererDi.inject(writeJsonFileInjectable);
|
||||
applicationBuilder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -244,8 +240,8 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
|
||||
describe("given empty state for expanded sidebar items already exists, when rendered", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(async ({ rendererDi }) => {
|
||||
const writeJsonFileFake = rendererDi.inject(writeJsonFileInjectable);
|
||||
applicationBuilder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
await writeJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -270,8 +266,12 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
});
|
||||
|
||||
describe("given no initially persisted state for sidebar items, when rendered", () => {
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
|
||||
windowDi = applicationBuilder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -387,7 +387,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
it("when not enough time passes, does not store state for expanded sidebar items to file system yet", async () => {
|
||||
advanceFakeTime(250 - 1);
|
||||
|
||||
const pathExistsFake = rendererDi.inject(pathExistsInjectable);
|
||||
const pathExistsFake = windowDi.inject(pathExistsInjectable);
|
||||
|
||||
const actual = await pathExistsFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -399,7 +399,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
||||
it("when enough time passes, stores state for expanded sidebar items to file system", async () => {
|
||||
advanceFakeTime(250);
|
||||
|
||||
const readJsonFileFake = rendererDi.inject(readJsonFileInjectable);
|
||||
const readJsonFileFake = windowDi.inject(readJsonFileInjectable);
|
||||
|
||||
const actual = await readJsonFileFake(
|
||||
"/some-directory-for-lens-local-storage/some-hosted-cluster-id.json",
|
||||
@ -16,24 +16,24 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
|
||||
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
|
||||
|
||||
describe("cluster - visibility of sidebar items", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.setEnvironmentToClusterFrame();
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.register(testRouteInjectable);
|
||||
rendererDi.register(testRouteComponentInjectable);
|
||||
rendererDi.register(testSidebarItemsInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testRouteInjectable);
|
||||
windowDi.register(testRouteComponentInjectable);
|
||||
windowDi.register(testSidebarItemsInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
describe("given kube resource for route is not allowed", () => {
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -48,7 +48,7 @@ describe("cluster - visibility of sidebar items", () => {
|
||||
|
||||
describe("when kube resource becomes allowed", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.allowKubeResource("namespaces");
|
||||
builder.allowKubeResource("namespaces");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -8,7 +8,6 @@ import type { RenderResult } from "@testing-library/react";
|
||||
import type { ApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder";
|
||||
import type { KubernetesCluster } from "../../../../../common/catalog-entities";
|
||||
import { getApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import extensionShouldBeEnabledForClusterFrameInjectable from "../../../../../renderer/extension-loader/extension-should-be-enabled-for-cluster-frame.injectable";
|
||||
import apiManagerInjectable from "../../../../../common/k8s-api/api-manager/manager.injectable";
|
||||
import navigateToWorkloadsOverviewInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/overview/navigate-to-workloads-overview.injectable";
|
||||
@ -24,21 +23,19 @@ describe("disable workloads overview details when cluster is not relevant", () =
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.beforeApplicationStart(({ mainDi }) => {
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(apiManagerInjectable, () => ({}));
|
||||
});
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
rendererDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(extensionShouldBeEnabledForClusterFrameInjectable);
|
||||
});
|
||||
|
||||
isEnabledForClusterMock = asyncFn();
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -55,11 +52,13 @@ describe("disable workloads overview details when cluster is not relevant", () =
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToWorkloadsOverview = rendererDi.inject(
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToWorkloadsOverview = windowDi.inject(
|
||||
navigateToWorkloadsOverviewInjectable,
|
||||
);
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
*/
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { getApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../../../renderer/components/test-utils/get-extension-fake";
|
||||
import React from "react";
|
||||
import getRandomIdInjectable from "../../../../../common/utils/get-random-id.injectable";
|
||||
import { workloadOverviewDetailInjectionToken } from "../../../../../renderer/components/+workloads-overview/workload-overview-details/workload-overview-detail-injection-token";
|
||||
@ -17,16 +16,22 @@ describe("order of workload overview details", () => {
|
||||
beforeEach(async () => {
|
||||
const builder = getApplicationBuilder();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.unoverride(getRandomIdInjectable);
|
||||
rendererDi.permitSideEffects(getRandomIdInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.unoverride(getRandomIdInjectable);
|
||||
windowDi.permitSideEffects(getRandomIdInjectable);
|
||||
|
||||
windowDi.register(
|
||||
someCoreItemWithLowOrderNumberInjectable,
|
||||
someCoreItemWithHighOrderNumberInjectable,
|
||||
someCoreItemWithDefaultOrderNumberInjectable,
|
||||
);
|
||||
});
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const testExtension = getExtensionFakeFor(builder)({
|
||||
const testExtension = {
|
||||
id: "some-extension-id",
|
||||
name: "some-extension",
|
||||
|
||||
@ -66,16 +71,9 @@ describe("order of workload overview details", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
builder.extensions.enable(testExtension);
|
||||
|
||||
|
||||
builder.dis.rendererDi.register(
|
||||
someCoreItemWithLowOrderNumberInjectable,
|
||||
someCoreItemWithHighOrderNumberInjectable,
|
||||
someCoreItemWithDefaultOrderNumberInjectable,
|
||||
);
|
||||
});
|
||||
|
||||
it("shows items in correct order", () => {
|
||||
@ -9,7 +9,6 @@ import React from "react";
|
||||
import navigateToWorkloadsOverviewInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/overview/navigate-to-workloads-overview.injectable";
|
||||
import type { ApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../../../../renderer/components/test-utils/get-extension-fake";
|
||||
|
||||
describe("reactively hide workloads overview details item", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
@ -19,15 +18,11 @@ describe("reactively hide workloads overview details item", () => {
|
||||
beforeEach(async () => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "test-extension-id",
|
||||
name: "test-extension",
|
||||
|
||||
@ -44,11 +39,13 @@ describe("reactively hide workloads overview details item", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
const navigateToWorkloadsOverview = rendererDi.inject(
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToWorkloadsOverview = windowDi.inject(
|
||||
navigateToWorkloadsOverviewInjectable,
|
||||
);
|
||||
|
||||
@ -9,17 +9,20 @@ import platformInjectable from "../../common/vars/platform.injectable";
|
||||
import { type ApplicationBuilder, getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
|
||||
describe("Command Pallet: keyboard shortcut tests", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
});
|
||||
|
||||
describe("when on macOS", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.dis.rendererDi.override(platformInjectable, () => "darwin");
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(platformInjectable, () => "darwin");
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -83,8 +86,11 @@ describe("Command Pallet: keyboard shortcut tests", () => {
|
||||
|
||||
describe("when on linux", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.dis.rendererDi.override(platformInjectable, () => "linux");
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(platformInjectable, () => "linux");
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -2,30 +2,27 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { FakeExtensionData, TestExtension } from "../renderer/components/test-utils/get-renderer-extension-fake";
|
||||
import { getRendererExtensionFakeFor } from "../renderer/components/test-utils/get-renderer-extension-fake";
|
||||
import React from "react";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import currentPathInjectable from "../renderer/routes/current-path.injectable";
|
||||
import type { ApplicationBuilder } from "../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../renderer/components/test-utils/get-application-builder";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import type { FakeExtensionOptions } from "../renderer/components/test-utils/get-extension-fake";
|
||||
|
||||
describe("extension special characters in page registrations", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
let testExtension: TestExtension;
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
testExtension = getRendererExtensionFake(
|
||||
extensionWithPagesHavingSpecialCharacters,
|
||||
);
|
||||
rendered = await builder.render();
|
||||
|
||||
applicationBuilder.extensions.renderer.enable(testExtension);
|
||||
builder.extensions.enable(extensionWithPagesHavingSpecialCharacters);
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -34,6 +31,9 @@ describe("extension special characters in page registrations", () => {
|
||||
|
||||
describe("when navigating to route with ID having special characters", () => {
|
||||
beforeEach(() => {
|
||||
const testExtension =
|
||||
builder.extensions.get("some-extension-id").applicationWindows.only;
|
||||
|
||||
testExtension.navigate("/some-page-id/");
|
||||
});
|
||||
|
||||
@ -42,22 +42,25 @@ describe("extension special characters in page registrations", () => {
|
||||
});
|
||||
|
||||
it("knows URL", () => {
|
||||
const currentPath = applicationBuilder.dis.rendererDi.inject(currentPathInjectable);
|
||||
const currentPath = windowDi.inject(currentPathInjectable);
|
||||
|
||||
expect(currentPath.get()).toBe("/extension/some-extension-name--/some-page-id");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const extensionWithPagesHavingSpecialCharacters: FakeExtensionData = {
|
||||
const extensionWithPagesHavingSpecialCharacters: FakeExtensionOptions = {
|
||||
id: "some-extension-id",
|
||||
name: "@some-extension-name/",
|
||||
globalPages: [
|
||||
{
|
||||
id: "/some-page-id/",
|
||||
components: {
|
||||
Page: () => <div>Some page</div>,
|
||||
|
||||
rendererOptions: {
|
||||
globalPages: [
|
||||
{
|
||||
id: "/some-page-id/",
|
||||
components: {
|
||||
Page: () => <div>Some page</div>,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
@ -12,18 +12,20 @@ import focusWindowInjectable from "../../renderer/navigation/focus-window.inject
|
||||
jest.mock("../../renderer/components/input/input");
|
||||
|
||||
describe("extensions - navigation using application menu", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
let focusWindowMock: jest.Mock;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder().beforeApplicationStart(({ rendererDi }) => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
focusWindowMock = jest.fn();
|
||||
|
||||
rendererDi.override(focusWindowInjectable, () => focusWindowMock);
|
||||
windowDi.override(focusWindowInjectable, () => focusWindowMock);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -38,7 +40,7 @@ describe("extensions - navigation using application menu", () => {
|
||||
|
||||
describe("when navigating to extensions using application menu", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.applicationMenu.click("root.extensions");
|
||||
builder.applicationMenu.click("root.extensions");
|
||||
});
|
||||
|
||||
it("focuses the window", () => {
|
||||
@ -19,7 +19,7 @@ import showErrorNotificationInjectable from "../../renderer/components/notificat
|
||||
import type { AsyncResult } from "../../common/utils/async-result";
|
||||
|
||||
describe("add custom helm repository in preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let showSuccessNotificationMock: jest.Mock;
|
||||
let showErrorNotificationMock: jest.Mock;
|
||||
let rendered: RenderResult;
|
||||
@ -31,41 +31,35 @@ describe("add custom helm repository in preferences", () => {
|
||||
beforeEach(async () => {
|
||||
jest.useFakeTimers();
|
||||
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
execFileMock = asyncFn();
|
||||
getActiveHelmRepositoriesMock = asyncFn();
|
||||
showSuccessNotificationMock = jest.fn();
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
|
||||
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
|
||||
showSuccessNotificationMock = jest.fn();
|
||||
|
||||
rendererDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
rendererDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
|
||||
// TODO: Figure out how to make async validators unit testable
|
||||
rendererDi.override(isPathInjectable, () => ({ debounce: 0, validate: async () => {} }));
|
||||
|
||||
mainDi.override(
|
||||
getActiveHelmRepositoriesInjectable,
|
||||
() => getActiveHelmRepositoriesMock,
|
||||
);
|
||||
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
||||
mainDi.override(execFileInjectable, () => execFileMock);
|
||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
|
||||
// TODO: Figure out how to make async validators unit testable
|
||||
windowDi.override(isPathInjectable, () => ({ debounce: 0, validate: async () => {} }));
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
describe("when navigating to preferences containing helm repositories", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
applicationBuilder.preferences.navigation.click("kubernetes");
|
||||
builder.preferences.navigate();
|
||||
builder.preferences.navigation.click("kubernetes");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -17,7 +17,7 @@ import showErrorNotificationInjectable from "../../renderer/components/notificat
|
||||
import type { AsyncResult } from "../../common/utils/async-result";
|
||||
|
||||
describe("add helm repository from list in preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let showSuccessNotificationMock: jest.Mock;
|
||||
let showErrorNotificationMock: jest.Mock;
|
||||
let rendered: RenderResult;
|
||||
@ -28,41 +28,33 @@ describe("add helm repository from list in preferences", () => {
|
||||
let callForPublicHelmRepositoriesMock: AsyncFnMock<() => Promise<HelmRepo[]>>;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
execFileMock = asyncFn();
|
||||
getActiveHelmRepositoriesMock = asyncFn();
|
||||
callForPublicHelmRepositoriesMock = asyncFn();
|
||||
showSuccessNotificationMock = jest.fn();
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
|
||||
showSuccessNotificationMock = jest.fn();
|
||||
|
||||
rendererDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
rendererDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
|
||||
rendererDi.override(
|
||||
callForPublicHelmRepositoriesInjectable,
|
||||
() => callForPublicHelmRepositoriesMock,
|
||||
);
|
||||
|
||||
mainDi.override(
|
||||
getActiveHelmRepositoriesInjectable,
|
||||
() => getActiveHelmRepositoriesMock,
|
||||
);
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
||||
mainDi.override(execFileInjectable, () => execFileMock);
|
||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
windowDi.override(callForPublicHelmRepositoriesInjectable, () => callForPublicHelmRepositoriesMock);
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
describe("when navigating to preferences containing helm repositories", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
applicationBuilder.preferences.navigation.click("kubernetes");
|
||||
beforeEach(() => {
|
||||
builder.preferences.navigate();
|
||||
builder.preferences.navigation.click("kubernetes");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -100,7 +92,7 @@ describe("add helm repository from list in preferences", () => {
|
||||
|
||||
describe("when select for adding public repositories is clicked", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.select.openMenu(
|
||||
builder.select.openMenu(
|
||||
"selection-of-active-public-helm-repository",
|
||||
);
|
||||
});
|
||||
@ -113,7 +105,7 @@ describe("add helm repository from list in preferences", () => {
|
||||
beforeEach(async () => {
|
||||
getActiveHelmRepositoriesMock.mockClear();
|
||||
|
||||
applicationBuilder.select.selectOption(
|
||||
builder.select.selectOption(
|
||||
"selection-of-active-public-helm-repository",
|
||||
"Some to be added repository",
|
||||
);
|
||||
@ -207,7 +199,7 @@ describe("add helm repository from list in preferences", () => {
|
||||
|
||||
describe("when select for selecting active repositories is clicked", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.select.openMenu(
|
||||
builder.select.openMenu(
|
||||
"selection-of-active-public-helm-repository",
|
||||
);
|
||||
});
|
||||
@ -221,7 +213,7 @@ describe("add helm repository from list in preferences", () => {
|
||||
execFileMock.mockClear();
|
||||
getActiveHelmRepositoriesMock.mockClear();
|
||||
|
||||
applicationBuilder.select.selectOption(
|
||||
builder.select.selectOption(
|
||||
"selection-of-active-public-helm-repository",
|
||||
"Some already active repository",
|
||||
);
|
||||
@ -1,6 +1,448 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
class="Notifications flex column align-flex-end"
|
||||
/>
|
||||
<div
|
||||
class="mainLayout"
|
||||
style="--sidebar-width: 200px;"
|
||||
>
|
||||
<div
|
||||
class="sidebar"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col"
|
||||
data-testid="cluster-sidebar"
|
||||
>
|
||||
<div
|
||||
class="SidebarCluster"
|
||||
>
|
||||
<div
|
||||
class="Avatar rounded loadingAvatar"
|
||||
style="width: 40px; height: 40px;"
|
||||
>
|
||||
??
|
||||
</div>
|
||||
<div
|
||||
class="loadingClusterName"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="sidebarNav sidebar-active-status"
|
||||
>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="true"
|
||||
data-testid="sidebar-item-workloads"
|
||||
>
|
||||
<a
|
||||
aria-current="page"
|
||||
class="nav-item flex gaps align-center expandable active"
|
||||
data-testid="sidebar-item-link-for-workloads"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon svg focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
/>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Workloads
|
||||
</span>
|
||||
<i
|
||||
class="Icon expand-icon box right material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-config"
|
||||
>
|
||||
<a
|
||||
class="nav-item flex gaps align-center"
|
||||
data-testid="sidebar-item-link-for-config"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="list"
|
||||
>
|
||||
list
|
||||
</span>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Config
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-network"
|
||||
>
|
||||
<a
|
||||
class="nav-item flex gaps align-center expandable"
|
||||
data-testid="sidebar-item-link-for-network"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="device_hub"
|
||||
>
|
||||
device_hub
|
||||
</span>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Network
|
||||
</span>
|
||||
<i
|
||||
class="Icon expand-icon box right material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-storage"
|
||||
>
|
||||
<a
|
||||
class="nav-item flex gaps align-center"
|
||||
data-testid="sidebar-item-link-for-storage"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="storage"
|
||||
>
|
||||
storage
|
||||
</span>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Storage
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-helm"
|
||||
>
|
||||
<a
|
||||
class="nav-item flex gaps align-center expandable"
|
||||
data-testid="sidebar-item-link-for-helm"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon svg focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
/>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Helm
|
||||
</span>
|
||||
<i
|
||||
class="Icon expand-icon box right material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-user-management"
|
||||
>
|
||||
<a
|
||||
class="nav-item flex gaps align-center"
|
||||
data-testid="sidebar-item-link-for-user-management"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="security"
|
||||
>
|
||||
security
|
||||
</span>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Access Control
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="SidebarItem"
|
||||
data-is-active-test="false"
|
||||
data-testid="sidebar-item-custom-resources"
|
||||
>
|
||||
<a
|
||||
class="nav-item flex gaps align-center expandable"
|
||||
data-testid="sidebar-item-link-for-custom-resources"
|
||||
href="/"
|
||||
>
|
||||
<i
|
||||
class="Icon material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="extension"
|
||||
>
|
||||
extension
|
||||
</span>
|
||||
</i>
|
||||
<span
|
||||
class="link-text box grow"
|
||||
>
|
||||
Custom Resources
|
||||
</span>
|
||||
<i
|
||||
class="Icon expand-icon box right material focusable"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="keyboard_arrow_down"
|
||||
>
|
||||
keyboard_arrow_down
|
||||
</span>
|
||||
</i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ResizingAnchor horizontal trailing"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="contents"
|
||||
>
|
||||
<div
|
||||
class="TabLayout"
|
||||
data-testid="tab-layout"
|
||||
>
|
||||
<div
|
||||
class="Tabs center scrollable"
|
||||
>
|
||||
<div
|
||||
class="Tab flex gaps align-center active"
|
||||
data-is-active-test="true"
|
||||
data-testid="tab-link-for-overview"
|
||||
role="tab"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="label"
|
||||
>
|
||||
Overview
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<main>
|
||||
<div
|
||||
class="WorkloadsOverview flex column gaps"
|
||||
>
|
||||
<div
|
||||
class="header flex gaps align-center"
|
||||
>
|
||||
<h5
|
||||
class="box grow"
|
||||
>
|
||||
Overview
|
||||
</h5>
|
||||
<div
|
||||
class="NamespaceSelectFilterParent"
|
||||
data-testid="namespace-select-filter"
|
||||
>
|
||||
<div
|
||||
class="Select theme-dark NamespaceSelect NamespaceSelectFilter css-b62m3t-container"
|
||||
>
|
||||
<span
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
id="react-select-overview-namespace-select-filter-input-live-region"
|
||||
/>
|
||||
<span
|
||||
aria-atomic="false"
|
||||
aria-live="polite"
|
||||
aria-relevant="additions text"
|
||||
class="css-1f43avz-a11yText-A11yText"
|
||||
/>
|
||||
<div
|
||||
class="Select__control css-1s2u09g-control"
|
||||
>
|
||||
<div
|
||||
class="Select__value-container Select__value-container--is-multi css-319lph-ValueContainer"
|
||||
>
|
||||
<div
|
||||
class="Select__placeholder css-14el2xx-placeholder"
|
||||
id="react-select-overview-namespace-select-filter-input-placeholder"
|
||||
>
|
||||
All namespaces
|
||||
</div>
|
||||
<div
|
||||
class="Select__input-container css-6j8wv5-Input"
|
||||
data-value=""
|
||||
>
|
||||
<input
|
||||
aria-autocomplete="list"
|
||||
aria-describedby="react-select-overview-namespace-select-filter-input-placeholder"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
autocapitalize="none"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
class="Select__input"
|
||||
id="overview-namespace-select-filter-input"
|
||||
role="combobox"
|
||||
spellcheck="false"
|
||||
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
|
||||
tabindex="0"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
|
||||
>
|
||||
<span
|
||||
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="css-tj5bde-Svg"
|
||||
focusable="false"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
width="20"
|
||||
>
|
||||
<path
|
||||
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="OverviewStatuses"
|
||||
>
|
||||
<div
|
||||
class="workloads"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="footer"
|
||||
>
|
||||
<div
|
||||
class="Dock"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="ResizingAnchor vertical leading disabled"
|
||||
/>
|
||||
<div
|
||||
class="tabs-container flex align-center"
|
||||
>
|
||||
<div
|
||||
class="dockTabs"
|
||||
role="tablist"
|
||||
>
|
||||
<div
|
||||
class="Tabs tabs"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="toolbar flex gaps align-center box grow pl-0"
|
||||
>
|
||||
<div
|
||||
class="dock-menu box grow"
|
||||
>
|
||||
<i
|
||||
class="Icon new-dock-tab material interactive focusable"
|
||||
id="menu-actions-for-dock"
|
||||
tabindex="0"
|
||||
>
|
||||
<span
|
||||
class="icon"
|
||||
data-icon-name="add"
|
||||
>
|
||||
add
|
||||
</span>
|
||||
</i>
|
||||
<div>
|
||||
New tab
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -927,7 +1369,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -1696,7 +2138,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -2709,7 +3151,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed when version is selected renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed when version is selected renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -3696,7 +4138,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed when version is selected when default configuration resolves renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given changing version to be installed when version is selected when default configuration resolves renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -4678,7 +5120,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given custom name is inputted renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given custom name is inputted renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -5660,7 +6102,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given invalid change in configuration renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given invalid change in configuration renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -6664,7 +7106,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given namespace selection is opened renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given namespace selection is opened renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -7677,7 +8119,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given namespace selection is opened when namespace is selected renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given namespace selection is opened when namespace is selected renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -8659,7 +9101,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -9649,7 +10091,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -10498,7 +10940,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves when selected to see the installed release renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves when selected to see the installed release renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -11271,7 +11713,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves when selected to show execution output renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given no changes in configuration, when installing the chart when installation resolves when selected to show execution output renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -12180,7 +12622,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -13408,7 +13850,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -14226,7 +14668,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart when configuration and versions resolve renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart when configuration and versions resolve renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -15259,7 +15701,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart when configuration and versions resolve when selecting the dock tab for installing first chart renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given opening details for second chart, when details resolve when selecting to install second chart when configuration and versions resolve when selecting the dock tab for installing first chart renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -16290,7 +16732,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given valid change in configuration renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve given valid change in configuration renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -17272,7 +17714,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
@ -18254,7 +18696,7 @@ exports[`installing helm chart from new tab given tab for installing chart was n
|
||||
</body>
|
||||
`;
|
||||
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started, when navigating to helm charts when selecting to install the chart when default configuration and versions resolve when cancelled renders 1`] = `
|
||||
exports[`installing helm chart from new tab given tab for installing chart was not previously opened and application is started when navigating to helm charts when selecting to install the chart when default configuration and versions resolve when cancelled renders 1`] = `
|
||||
<body>
|
||||
<div>
|
||||
<div
|
||||
File diff suppressed because it is too large
Load Diff
@ -15,18 +15,15 @@ import namespaceStoreInjectable from "../../../renderer/components/+namespaces/s
|
||||
import type { NamespaceStore } from "../../../renderer/components/+namespaces/store";
|
||||
import type { CallForHelmChartVersions } from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
|
||||
import callForHelmChartVersionsInjectable from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
|
||||
import { overrideFsWithFakes } from "../../../test-utils/override-fs-with-fakes";
|
||||
import writeJsonFileInjectable from "../../../common/fs/write-json-file.injectable";
|
||||
import directoryForLensLocalStorageInjectable from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
|
||||
import hostedClusterIdInjectable from "../../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
||||
import { TabKind } from "../../../renderer/components/dock/dock/store";
|
||||
import { controlWhenStoragesAreReady } from "../../../renderer/utils/create-storage/storages-are-ready";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import callForCreateHelmReleaseInjectable from "../../../renderer/components/+helm-releases/create-release/call-for-create-helm-release.injectable";
|
||||
|
||||
describe("installing helm chart from previously opened tab", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
let rendererDi: DiContainer;
|
||||
let callForHelmChartVersionsMock: AsyncFnMock<CallForHelmChartVersions>;
|
||||
let callForHelmChartValuesMock: AsyncFnMock<CallForHelmChartValues>;
|
||||
let storagesAreReady: () => Promise<void>;
|
||||
@ -34,45 +31,43 @@ describe("installing helm chart from previously opened tab", () => {
|
||||
beforeEach(() => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
rendererDi = builder.dis.rendererDi;
|
||||
|
||||
overrideFsWithFakes(rendererDi);
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
|
||||
callForHelmChartVersionsMock = asyncFn();
|
||||
callForHelmChartValuesMock = asyncFn();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
directoryForLensLocalStorageInjectable,
|
||||
() => "/some-directory-for-lens-local-storage",
|
||||
);
|
||||
|
||||
rendererDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
|
||||
storagesAreReady = controlWhenStoragesAreReady(rendererDi);
|
||||
storagesAreReady = controlWhenStoragesAreReady(windowDi);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartVersionsInjectable,
|
||||
() => callForHelmChartVersionsMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartValuesInjectable,
|
||||
() => callForHelmChartValuesMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartValuesInjectable,
|
||||
() => callForHelmChartValuesMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForCreateHelmReleaseInjectable,
|
||||
() => jest.fn(),
|
||||
);
|
||||
|
||||
// TODO: Replace store mocking with mock for the actual side-effect (where the namespaces are coming from)
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
namespaceStoreInjectable,
|
||||
() =>
|
||||
({
|
||||
@ -85,51 +80,51 @@ describe("installing helm chart from previously opened tab", () => {
|
||||
} as unknown as NamespaceStore),
|
||||
);
|
||||
|
||||
rendererDi.override(getRandomInstallChartTabIdInjectable, () =>
|
||||
windowDi.override(getRandomInstallChartTabIdInjectable, () =>
|
||||
jest
|
||||
.fn(() => "some-irrelevant-tab-id")
|
||||
.mockReturnValueOnce("some-first-tab-id"),
|
||||
);
|
||||
});
|
||||
|
||||
builder.setEnvironmentToClusterFrame();
|
||||
});
|
||||
|
||||
describe("given tab for installing chart was previously opened, when application is started", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
const writeJsonFile = rendererDi.inject(writeJsonFileInjectable);
|
||||
builder.beforeWindowStart(async (windowDi) => {
|
||||
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
||||
|
||||
writeJsonFile(
|
||||
"/some-directory-for-lens-local-storage/some-cluster-id.json",
|
||||
{
|
||||
dock: {
|
||||
height: 300,
|
||||
tabs: [
|
||||
{
|
||||
id: "some-first-tab-id",
|
||||
kind: TabKind.INSTALL_CHART,
|
||||
title: "Helm Install: some-repository/some-name",
|
||||
pinned: false,
|
||||
await writeJsonFile(
|
||||
"/some-directory-for-lens-local-storage/some-cluster-id.json",
|
||||
{
|
||||
dock: {
|
||||
height: 300,
|
||||
tabs: [
|
||||
{
|
||||
id: "some-first-tab-id",
|
||||
kind: TabKind.INSTALL_CHART,
|
||||
title: "Helm Install: some-repository/some-name",
|
||||
pinned: false,
|
||||
},
|
||||
],
|
||||
|
||||
isOpen: true,
|
||||
},
|
||||
|
||||
install_charts: {
|
||||
"some-first-tab-id": {
|
||||
name: "some-name",
|
||||
repo: "some-repository",
|
||||
version: "some-other-version",
|
||||
values: "some-stored-configuration",
|
||||
releaseName: "some-stored-custom-name",
|
||||
namespace: "some-other-namespace",
|
||||
},
|
||||
],
|
||||
|
||||
isOpen: true,
|
||||
},
|
||||
|
||||
install_charts: {
|
||||
"some-first-tab-id": {
|
||||
name: "some-name",
|
||||
repo: "some-repository",
|
||||
version: "some-other-version",
|
||||
values: "some-stored-configuration",
|
||||
releaseName: "some-stored-custom-name",
|
||||
namespace: "some-other-namespace",
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
);
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
@ -19,15 +19,12 @@ import callForHelmChartReadmeInjectable from "../../../renderer/components/+helm
|
||||
import type { CallForHelmChartVersions } from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
|
||||
import callForHelmChartVersionsInjectable from "../../../renderer/components/+helm-charts/details/versions/call-for-helm-chart-versions.injectable";
|
||||
import { flushPromises } from "../../../common/test-utils/flush-promises";
|
||||
import { overrideFsWithFakes } from "../../../test-utils/override-fs-with-fakes";
|
||||
import directoryForLensLocalStorageInjectable from "../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
|
||||
import hostedClusterIdInjectable from "../../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
||||
import dockStoreInjectable from "../../../renderer/components/dock/dock/store.injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
|
||||
describe("opening dock tab for installing helm chart", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
let rendererDi: DiContainer;
|
||||
let callForHelmChartsMock: AsyncFnMock<CallForHelmCharts>;
|
||||
let callForHelmChartVersionsMock: AsyncFnMock<CallForHelmChartVersions>;
|
||||
let callForHelmChartReadmeMock: AsyncFnMock<CallForHelmChartReadme>;
|
||||
@ -36,49 +33,45 @@ describe("opening dock tab for installing helm chart", () => {
|
||||
beforeEach(() => {
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
rendererDi = builder.dis.rendererDi;
|
||||
|
||||
overrideFsWithFakes(rendererDi);
|
||||
|
||||
callForHelmChartsMock = asyncFn();
|
||||
callForHelmChartVersionsMock = asyncFn();
|
||||
callForHelmChartReadmeMock = asyncFn();
|
||||
callForHelmChartValuesMock = jest.fn();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
directoryForLensLocalStorageInjectable,
|
||||
() => "/some-directory-for-lens-local-storage",
|
||||
);
|
||||
|
||||
rendererDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartsInjectable,
|
||||
() => callForHelmChartsMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartVersionsInjectable,
|
||||
() => callForHelmChartVersionsMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartReadmeInjectable,
|
||||
() => callForHelmChartReadmeMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmChartValuesInjectable,
|
||||
() => callForHelmChartValuesMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForCreateHelmReleaseInjectable,
|
||||
() => jest.fn(),
|
||||
);
|
||||
|
||||
rendererDi.override(getRandomInstallChartTabIdInjectable, () =>
|
||||
windowDi.override(getRandomInstallChartTabIdInjectable, () =>
|
||||
jest
|
||||
.fn(() => "some-irrelevant-tab-id")
|
||||
.mockReturnValueOnce("some-tab-id"),
|
||||
@ -96,7 +89,9 @@ describe("opening dock tab for installing helm chart", () => {
|
||||
|
||||
builder.helmCharts.navigate();
|
||||
|
||||
const dockStore = rendererDi.inject(dockStoreInjectable);
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const dockStore = windowDi.inject(dockStoreInjectable);
|
||||
|
||||
// TODO: Make TerminalWindow unit testable to allow realistic behaviour
|
||||
dockStore.closeTab("terminal");
|
||||
@ -18,7 +18,7 @@ import callForPublicHelmRepositoriesInjectable from "../../renderer/components/+
|
||||
import showErrorNotificationInjectable from "../../renderer/components/notifications/show-error-notification.injectable";
|
||||
|
||||
describe("listing active helm repositories in preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
let readYamlFileMock: AsyncFnMock<ReadYamlFile>;
|
||||
let execFileMock: AsyncFnMock<ReturnType<typeof execFileInjectable["instantiate"]>>;
|
||||
@ -26,31 +26,33 @@ describe("listing active helm repositories in preferences", () => {
|
||||
let showErrorNotificationMock: jest.Mock;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
readYamlFileMock = asyncFn();
|
||||
execFileMock = asyncFn();
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
loggerStub = { error: jest.fn() } as unknown as Logger;
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
|
||||
showErrorNotificationMock = jest.fn();
|
||||
|
||||
rendererDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(readYamlFileInjectable, () => readYamlFileMock);
|
||||
mainDi.override(execFileInjectable, () => execFileMock);
|
||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||
mainDi.override(loggerInjectable, () => loggerStub);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
describe("when navigating to preferences containing helm repositories", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
applicationBuilder.preferences.navigation.click("kubernetes");
|
||||
builder.preferences.navigate();
|
||||
builder.preferences.navigation.click("kubernetes");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -16,7 +16,7 @@ import callForPublicHelmRepositoriesInjectable from "../../renderer/components/+
|
||||
import type { AsyncResult } from "../../common/utils/async-result";
|
||||
|
||||
describe("remove helm repository from list of active repositories in preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
let rendered: RenderResult;
|
||||
let getActiveHelmRepositoriesMock: AsyncFnMock<() => Promise<AsyncResult<HelmRepo[]>>>;
|
||||
let execFileMock: AsyncFnMock<
|
||||
@ -24,30 +24,28 @@ describe("remove helm repository from list of active repositories in preferences
|
||||
>;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
execFileMock = asyncFn();
|
||||
getActiveHelmRepositoriesMock = asyncFn();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ mainDi, rendererDi }) => {
|
||||
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
|
||||
mainDi.override(
|
||||
getActiveHelmRepositoriesInjectable,
|
||||
() => getActiveHelmRepositoriesMock,
|
||||
);
|
||||
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
||||
mainDi.override(execFileInjectable, () => execFileMock);
|
||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
describe("when navigating to preferences containing helm repositories", () => {
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
applicationBuilder.preferences.navigation.click("kubernetes");
|
||||
builder.preferences.navigate();
|
||||
builder.preferences.navigation.click("kubernetes");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -48,43 +48,43 @@ describe("showing details for helm release", () => {
|
||||
showSuccessNotificationMock = jest.fn();
|
||||
showCheckedErrorNotificationMock = jest.fn();
|
||||
|
||||
builder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(
|
||||
getRandomUpgradeChartTabIdInjectable,
|
||||
() => () => "some-tab-id",
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
showSuccessNotificationInjectable,
|
||||
() => showSuccessNotificationMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
showCheckedErrorInjectable,
|
||||
() => showCheckedErrorNotificationMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmReleasesInjectable,
|
||||
() => callForHelmReleasesMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmReleaseInjectable,
|
||||
() => callForHelmReleaseMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmReleaseConfigurationInjectable,
|
||||
() => callForHelmReleaseConfigurationMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
callForHelmReleaseUpdateInjectable,
|
||||
() => callForHelmReleaseUpdateMock,
|
||||
);
|
||||
|
||||
rendererDi.override(
|
||||
windowDi.override(
|
||||
namespaceStoreInjectable,
|
||||
() =>
|
||||
({
|
||||
@ -105,9 +105,9 @@ describe("showing details for helm release", () => {
|
||||
|
||||
describe("when navigating to helm releases", () => {
|
||||
beforeEach(() => {
|
||||
const rendererDi = builder.dis.rendererDi;
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const navigateToHelmReleases = rendererDi.inject(
|
||||
const navigateToHelmReleases = windowDi.inject(
|
||||
navigateToHelmReleasesInjectable,
|
||||
);
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { FakeExtensionData, TestExtension } from "../renderer/components/test-utils/get-renderer-extension-fake";
|
||||
import { getRendererExtensionFakeFor } from "../renderer/components/test-utils/get-renderer-extension-fake";
|
||||
import React from "react";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { fireEvent } from "@testing-library/react";
|
||||
@ -12,29 +10,29 @@ import queryParametersInjectable from "../renderer/routes/query-parameters.injec
|
||||
import currentPathInjectable from "../renderer/routes/current-path.injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import { getApplicationBuilder } from "../renderer/components/test-utils/get-application-builder";
|
||||
import type { FakeExtensionOptions } from "../renderer/components/test-utils/get-extension-fake";
|
||||
import type { LensRendererExtension } from "../extensions/lens-renderer-extension";
|
||||
|
||||
describe("navigate to extension page", () => {
|
||||
let rendered: RenderResult;
|
||||
let testExtension: TestExtension;
|
||||
let testExtension: LensRendererExtension;
|
||||
let queryParameters: IComputedValue<object>;
|
||||
let currentPath: IComputedValue<string>;
|
||||
|
||||
beforeEach(async () => {
|
||||
const applicationBuilder = getApplicationBuilder();
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const builder = getApplicationBuilder();
|
||||
|
||||
testExtension = getRendererExtensionFake(
|
||||
extensionWithPagesHavingParameters,
|
||||
);
|
||||
builder.extensions.enable(extensionWithPagesHavingParameters);
|
||||
|
||||
applicationBuilder.extensions.renderer.enable(testExtension);
|
||||
rendered = await builder.render();
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
const rendererDi = applicationBuilder.dis.rendererDi;
|
||||
testExtension =
|
||||
builder.extensions.get("some-extension-id").applicationWindows.only;
|
||||
|
||||
queryParameters = rendererDi.inject(queryParametersInjectable);
|
||||
currentPath = rendererDi.inject(currentPathInjectable);
|
||||
queryParameters = windowDi.inject(queryParametersInjectable);
|
||||
currentPath = windowDi.inject(currentPathInjectable);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -125,57 +123,60 @@ describe("navigate to extension page", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const extensionWithPagesHavingParameters: FakeExtensionData = {
|
||||
const extensionWithPagesHavingParameters: FakeExtensionOptions = {
|
||||
id: "some-extension-id",
|
||||
name: "some-extension-name",
|
||||
globalPages: [
|
||||
{
|
||||
components: {
|
||||
Page: ({ params }) => (
|
||||
<div>
|
||||
<ul>
|
||||
<li>{params.someStringParameter.get()}</li>
|
||||
<li>{params.someNumberParameter.get()}</li>
|
||||
<li>{params.someArrayParameter.get().join(",")}</li>
|
||||
</ul>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
data-testid="button-to-change-page-parameters"
|
||||
onClick={() => {
|
||||
params.someStringParameter.set("some-changed-string-value");
|
||||
params.someNumberParameter.set(84);
|
||||
params.someArrayParameter.set([
|
||||
"some-changed-array-value",
|
||||
"some-other-changed-array-value",
|
||||
]);
|
||||
}}
|
||||
>
|
||||
Some button
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
rendererOptions: {
|
||||
globalPages: [
|
||||
{
|
||||
components: {
|
||||
Page: ({ params }) => (
|
||||
<div>
|
||||
<ul>
|
||||
<li>{params.someStringParameter.get()}</li>
|
||||
<li>{params.someNumberParameter.get()}</li>
|
||||
<li>{params.someArrayParameter.get().join(",")}</li>
|
||||
</ul>
|
||||
|
||||
params: {
|
||||
someStringParameter: "some-string-value",
|
||||
someNumberParameter: {
|
||||
defaultValue: 42,
|
||||
stringify: (value) => value.toString(),
|
||||
parse: (value) => (value ? Number(value) : undefined),
|
||||
<button
|
||||
type="button"
|
||||
data-testid="button-to-change-page-parameters"
|
||||
onClick={() => {
|
||||
params.someStringParameter.set("some-changed-string-value");
|
||||
params.someNumberParameter.set(84);
|
||||
params.someArrayParameter.set([
|
||||
"some-changed-array-value",
|
||||
"some-other-changed-array-value",
|
||||
]);
|
||||
}}
|
||||
>
|
||||
Some button
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
someArrayParameter: {
|
||||
defaultValue: ["some-array-value", "some-other-array-value"],
|
||||
stringify: (value) => value.join(","),
|
||||
parse: (value: string[]) => (!isEmpty(value) ? value : undefined),
|
||||
|
||||
params: {
|
||||
someStringParameter: "some-string-value",
|
||||
someNumberParameter: {
|
||||
defaultValue: 42,
|
||||
stringify: (value) => value.toString(),
|
||||
parse: (value) => (value ? Number(value) : undefined),
|
||||
},
|
||||
someArrayParameter: {
|
||||
defaultValue: ["some-array-value", "some-other-array-value"],
|
||||
stringify: (value) => value.join(","),
|
||||
parse: (value: string[]) => (!isEmpty(value) ? value : undefined),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "some-child-page-id",
|
||||
components: {
|
||||
Page: () => <div>Child page</div>,
|
||||
{
|
||||
id: "some-child-page-id",
|
||||
components: {
|
||||
Page: () => <div>Child page</div>,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
@ -20,32 +20,34 @@ import { navigateToRouteInjectionToken } from "../common/front-end-routing/navig
|
||||
import routePathParametersInjectable from "../renderer/routes/route-path-parameters.injectable";
|
||||
|
||||
describe("navigating between routes", () => {
|
||||
let rendererDi: DiContainer;
|
||||
let rendered: RenderResult;
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
builder = getApplicationBuilder();
|
||||
});
|
||||
|
||||
describe("given route without path parameters", () => {
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.register(testRouteWithoutPathParametersInjectable);
|
||||
rendererDi.register(testRouteWithoutPathParametersComponentInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testRouteWithoutPathParametersInjectable);
|
||||
windowDi.register(testRouteWithoutPathParametersComponentInjectable);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
describe("when navigating to route", () => {
|
||||
let route: Route;
|
||||
|
||||
beforeEach(() => {
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
|
||||
route = rendererDi.inject(testRouteWithoutPathParametersInjectable);
|
||||
route = windowDi.inject(testRouteWithoutPathParametersInjectable);
|
||||
|
||||
navigateToRoute(route);
|
||||
});
|
||||
@ -55,35 +57,35 @@ describe("navigating between routes", () => {
|
||||
});
|
||||
|
||||
it("knows current route", () => {
|
||||
const currentRoute = rendererDi.inject(currentRouteInjectable);
|
||||
const currentRoute = windowDi.inject(currentRouteInjectable);
|
||||
|
||||
expect(currentRoute.get()).toBe(route);
|
||||
});
|
||||
|
||||
it("knows current path", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable);
|
||||
const currentPath = windowDi.inject(currentPathInjectable);
|
||||
|
||||
expect(currentPath.get()).toBe("/some-path");
|
||||
});
|
||||
|
||||
it("does not have query parameters", () => {
|
||||
const queryParameters = rendererDi.inject(queryParametersInjectable);
|
||||
const queryParameters = windowDi.inject(queryParametersInjectable);
|
||||
|
||||
expect(queryParameters.get()).toEqual({});
|
||||
});
|
||||
|
||||
it("does not have path parameters", () => {
|
||||
const pathParameters = rendererDi.inject(routePathParametersInjectable, route);
|
||||
const pathParameters = windowDi.inject(routePathParametersInjectable, route);
|
||||
|
||||
expect(pathParameters.get()).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
it("when navigating to route with query parameters, knows query parameters", () => {
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const queryParameters = rendererDi.inject(queryParametersInjectable);
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
const queryParameters = windowDi.inject(queryParametersInjectable);
|
||||
|
||||
const route = rendererDi.inject(testRouteWithoutPathParametersInjectable);
|
||||
const route = windowDi.inject(testRouteWithoutPathParametersInjectable);
|
||||
|
||||
navigateToRoute(route, {
|
||||
query: {
|
||||
@ -100,23 +102,26 @@ describe("navigating between routes", () => {
|
||||
});
|
||||
|
||||
describe("given route with optional path parameters", () => {
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.register(routeWithOptionalPathParametersInjectable);
|
||||
rendererDi.register(routeWithOptionalPathParametersComponentInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(routeWithOptionalPathParametersInjectable);
|
||||
windowDi.register(routeWithOptionalPathParametersComponentInjectable);
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
describe("when navigating to route with path parameters", () => {
|
||||
let route: Route<any>;
|
||||
|
||||
beforeEach(() => {
|
||||
route = rendererDi.inject(routeWithOptionalPathParametersInjectable);
|
||||
route = windowDi.inject(routeWithOptionalPathParametersInjectable);
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
|
||||
navigateToRoute(route, {
|
||||
parameters: {
|
||||
@ -131,13 +136,13 @@ describe("navigating between routes", () => {
|
||||
});
|
||||
|
||||
it("knows current route", () => {
|
||||
const currentRoute = rendererDi.inject(currentRouteInjectable);
|
||||
const currentRoute = windowDi.inject(currentRouteInjectable);
|
||||
|
||||
expect(currentRoute.get()).toBe(route);
|
||||
});
|
||||
|
||||
it("knows current path", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable);
|
||||
const currentPath = windowDi.inject(currentPathInjectable);
|
||||
|
||||
expect(currentPath.get()).toBe(
|
||||
"/some-path/some-value/some-other-value",
|
||||
@ -145,7 +150,7 @@ describe("navigating between routes", () => {
|
||||
});
|
||||
|
||||
it("knows path parameters", () => {
|
||||
const pathParameters = rendererDi.inject(routePathParametersInjectable, route);
|
||||
const pathParameters = windowDi.inject(routePathParametersInjectable, route);
|
||||
|
||||
expect(pathParameters.get()).toEqual({
|
||||
someParameter: "some-value",
|
||||
@ -158,27 +163,27 @@ describe("navigating between routes", () => {
|
||||
let route: Route<any>;
|
||||
|
||||
beforeEach(() => {
|
||||
route = rendererDi.inject(routeWithOptionalPathParametersInjectable);
|
||||
route = windowDi.inject(routeWithOptionalPathParametersInjectable);
|
||||
|
||||
const navigateToRoute = rendererDi.inject(navigateToRouteInjectionToken);
|
||||
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
||||
|
||||
navigateToRoute(route);
|
||||
});
|
||||
|
||||
it("knows current route", () => {
|
||||
const currentRoute = rendererDi.inject(currentRouteInjectable);
|
||||
const currentRoute = windowDi.inject(currentRouteInjectable);
|
||||
|
||||
expect(currentRoute.get()).toBe(route);
|
||||
});
|
||||
|
||||
it("knows current path", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable);
|
||||
const currentPath = windowDi.inject(currentPathInjectable);
|
||||
|
||||
expect(currentPath.get()).toBe("/some-path");
|
||||
});
|
||||
|
||||
it("knows path parameters", () => {
|
||||
const pathParameters = rendererDi.inject(routePathParametersInjectable, route);
|
||||
const pathParameters = windowDi.inject(routePathParametersInjectable, route);
|
||||
|
||||
expect(pathParameters.get()).toEqual({
|
||||
someParameter: undefined,
|
||||
@ -24,19 +24,19 @@ import navigateToFrontPageInjectable from "../../common/front-end-routing/naviga
|
||||
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
|
||||
|
||||
describe("preferences - closing-preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.register(testPreferencesRouteInjectable);
|
||||
rendererDi.register(testPreferencesRouteComponentInjectable);
|
||||
rendererDi.register(testFrontPageRouteInjectable);
|
||||
rendererDi.register(testFrontPageRouteComponentInjectable);
|
||||
rendererDi.register(testNavigationItemInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.register(testPreferencesRouteInjectable);
|
||||
windowDi.register(testPreferencesRouteComponentInjectable);
|
||||
windowDi.register(testFrontPageRouteInjectable);
|
||||
windowDi.register(testFrontPageRouteComponentInjectable);
|
||||
windowDi.register(testNavigationItemInjectable);
|
||||
|
||||
rendererDi.override(navigateToFrontPageInjectable, (di) => {
|
||||
windowDi.override(navigateToFrontPageInjectable, (di) => {
|
||||
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
|
||||
const testFrontPage = di.inject(testFrontPageRouteInjectable);
|
||||
|
||||
@ -49,11 +49,11 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("given already in a page and then navigated to preferences", () => {
|
||||
let rendered: RenderResult;
|
||||
let rendererDi: DiContainer;
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(observableHistoryInjectable, () => {
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(observableHistoryInjectable, () => {
|
||||
const historyFake = createMemoryHistory({
|
||||
initialEntries: ["/some-test-path"],
|
||||
initialIndex: 0,
|
||||
@ -65,10 +65,10 @@ describe("preferences - closing-preferences", () => {
|
||||
});
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
rendered = await builder.render();
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
|
||||
applicationBuilder.preferences.navigate();
|
||||
builder.preferences.navigate();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -77,7 +77,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("when preferences are closed", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.close();
|
||||
builder.preferences.close();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -85,7 +85,7 @@ describe("preferences - closing-preferences", () => {
|
||||
});
|
||||
|
||||
it("navigates back to the original page", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable).get();
|
||||
const currentPath = windowDi.inject(currentPathInjectable).get();
|
||||
|
||||
expect(currentPath).toBe("/some-test-path");
|
||||
});
|
||||
@ -93,7 +93,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("when navigating to a tab in preferences", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click(
|
||||
builder.preferences.navigation.click(
|
||||
"some-test-preference-navigation-item-id",
|
||||
);
|
||||
});
|
||||
@ -104,7 +104,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("when preferences are closed", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.close();
|
||||
builder.preferences.close();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -112,7 +112,7 @@ describe("preferences - closing-preferences", () => {
|
||||
});
|
||||
|
||||
it("navigates back to the original page", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable).get();
|
||||
const currentPath = windowDi.inject(currentPathInjectable).get();
|
||||
|
||||
expect(currentPath).toBe("/some-test-path");
|
||||
});
|
||||
@ -122,11 +122,11 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("given accessing preferences directly", () => {
|
||||
let rendered: RenderResult;
|
||||
let rendererDi: DiContainer;
|
||||
let windowDi: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi }) => {
|
||||
rendererDi.override(observableHistoryInjectable, () => {
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(observableHistoryInjectable, () => {
|
||||
const historyFake = createMemoryHistory({
|
||||
initialEntries: ["/preferences/app"],
|
||||
initialIndex: 0,
|
||||
@ -138,9 +138,9 @@ describe("preferences - closing-preferences", () => {
|
||||
});
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
|
||||
rendererDi = applicationBuilder.dis.rendererDi;
|
||||
windowDi = builder.applicationWindow.only.di;
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -149,7 +149,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("when preferences are closed", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.close();
|
||||
builder.preferences.close();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -157,7 +157,7 @@ describe("preferences - closing-preferences", () => {
|
||||
});
|
||||
|
||||
it("navigates back to the front page", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable).get();
|
||||
const currentPath = windowDi.inject(currentPathInjectable).get();
|
||||
|
||||
expect(currentPath).toBe("/some-front-page");
|
||||
});
|
||||
@ -165,7 +165,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("when navigating to a tab in preferences", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click(
|
||||
builder.preferences.navigation.click(
|
||||
"some-test-preference-navigation-item-id",
|
||||
);
|
||||
});
|
||||
@ -176,7 +176,7 @@ describe("preferences - closing-preferences", () => {
|
||||
|
||||
describe("when preferences are closed", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.close();
|
||||
builder.preferences.close();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -184,7 +184,7 @@ describe("preferences - closing-preferences", () => {
|
||||
});
|
||||
|
||||
it("navigates back to the front page", () => {
|
||||
const currentPath = rendererDi.inject(currentPathInjectable).get();
|
||||
const currentPath = windowDi.inject(currentPathInjectable).get();
|
||||
|
||||
expect(currentPath).toBe("/some-front-page");
|
||||
});
|
||||
@ -7,7 +7,6 @@ import type { IObservableValue } from "mobx";
|
||||
import { runInAction, computed, observable } from "mobx";
|
||||
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { getExtensionFakeFor } from "../../renderer/components/test-utils/get-extension-fake";
|
||||
|
||||
describe("preferences: extension adding preference tabs", () => {
|
||||
let builder: ApplicationBuilder;
|
||||
@ -25,11 +24,9 @@ describe("preferences: extension adding preference tabs", () => {
|
||||
|
||||
builder.preferences.navigate();
|
||||
|
||||
const getExtensionFake = getExtensionFakeFor(builder);
|
||||
|
||||
someObservable = observable.box(false);
|
||||
|
||||
const testExtension = getExtensionFake({
|
||||
const testExtension = {
|
||||
id: "some-extension-id",
|
||||
name: "some-extension",
|
||||
|
||||
@ -53,7 +50,7 @@ describe("preferences: extension adding preference tabs", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
builder.extensions.enable(testExtension);
|
||||
|
||||
@ -8,23 +8,23 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
|
||||
import navigateToProxyPreferencesInjectable from "../../common/front-end-routing/routes/preferences/proxy/navigate-to-proxy-preferences.injectable";
|
||||
|
||||
describe("preferences - navigation to application preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
});
|
||||
|
||||
describe("given in some child page of preferences, when rendered", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(({ rendererDi }) => {
|
||||
const navigateToProxyPreferences = rendererDi.inject(navigateToProxyPreferencesInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
const navigateToProxyPreferences = windowDi.inject(navigateToProxyPreferencesInjectable);
|
||||
|
||||
navigateToProxyPreferences();
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -39,7 +39,7 @@ describe("preferences - navigation to application preferences", () => {
|
||||
|
||||
describe("when navigating to application preferences using navigation", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click("application");
|
||||
builder.preferences.navigation.click("application");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -17,7 +17,7 @@ describe("preferences - navigation to editor preferences", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(() => {
|
||||
applicationBuilder.beforeWindowStart(() => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
});
|
||||
|
||||
@ -7,29 +7,25 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/ge
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
import type { FakeExtensionData, TestExtension } from "../../renderer/components/test-utils/get-renderer-extension-fake";
|
||||
import { getRendererExtensionFakeFor } from "../../renderer/components/test-utils/get-renderer-extension-fake";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
|
||||
import extensionPreferencesRouteInjectable from "../../common/front-end-routing/routes/preferences/extension/extension-preferences-route.injectable";
|
||||
|
||||
import type { FakeExtensionOptions } from "../../renderer/components/test-utils/get-extension-fake";
|
||||
|
||||
describe("preferences - navigation to extension specific preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
});
|
||||
|
||||
describe("given in preferences, when rendered", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(() => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
builder.beforeWindowStart(() => {
|
||||
builder.preferences.navigate();
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -49,13 +45,15 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
|
||||
describe("given multiple extensions with specific preferences, when navigating to extension specific preferences page", () => {
|
||||
beforeEach(async () => {
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const someTestExtension = getRendererExtensionFake(extensionStubWithExtensionSpecificPreferenceItems);
|
||||
const someOtherTestExtension = getRendererExtensionFake(someOtherExtensionStubWithExtensionSpecificPreferenceItems);
|
||||
beforeEach(() => {
|
||||
builder.extensions.enable(
|
||||
extensionStubWithExtensionSpecificPreferenceItems,
|
||||
someOtherExtensionStubWithExtensionSpecificPreferenceItems,
|
||||
);
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(someTestExtension, someOtherTestExtension);
|
||||
applicationBuilder.preferences.navigation.click("extension-some-test-extension-id");
|
||||
builder.preferences.navigation.click(
|
||||
"extension-some-test-extension-id",
|
||||
);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -76,13 +74,12 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
|
||||
describe("given multiple extensions with and without specific preferences", () => {
|
||||
beforeEach(async () => {
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const someTestExtension = getRendererExtensionFake(extensionStubWithExtensionSpecificPreferenceItems);
|
||||
const extensionWithoutPreferences = getRendererExtensionFake(extensionStubWithoutPreferences);
|
||||
const extensionWithSpecificTab = getRendererExtensionFake(extensionStubWithShowInPreferencesTab);
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(someTestExtension, extensionWithoutPreferences, extensionWithSpecificTab);
|
||||
beforeEach(() => {
|
||||
builder.extensions.enable(
|
||||
extensionStubWithExtensionSpecificPreferenceItems,
|
||||
extensionStubWithoutPreferences,
|
||||
extensionStubWithShowInPreferencesTab,
|
||||
);
|
||||
});
|
||||
|
||||
it("doesn't show link for extension without preferences", () => {
|
||||
@ -99,16 +96,8 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
|
||||
describe("when extension with specific preferences is enabled", () => {
|
||||
let testExtension: TestExtension;
|
||||
|
||||
beforeEach(() => {
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
|
||||
testExtension = getRendererExtensionFake(
|
||||
extensionStubWithExtensionSpecificPreferenceItems,
|
||||
);
|
||||
|
||||
applicationBuilder.extensions.renderer.enable(testExtension);
|
||||
builder.extensions.enable(extensionStubWithExtensionSpecificPreferenceItems);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -129,7 +118,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when navigating to extension preferences using navigation", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click("extension-some-test-extension-id");
|
||||
builder.preferences.navigation.click("extension-some-test-extension-id");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -168,7 +157,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when extension is disabled", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.extensions.renderer.disable(testExtension);
|
||||
builder.extensions.disable(extensionStubWithExtensionSpecificPreferenceItems);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -180,7 +169,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
|
||||
it("when extension is enabled again, does not show the error message anymore", () => {
|
||||
applicationBuilder.extensions.renderer.enable(testExtension);
|
||||
builder.extensions.enable(extensionStubWithExtensionSpecificPreferenceItems);
|
||||
|
||||
expect(rendered.queryByTestId("error-for-extension-not-being-present")).not.toBeInTheDocument();
|
||||
});
|
||||
@ -189,11 +178,8 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
|
||||
describe("given extension with registered tab", () => {
|
||||
beforeEach(async () => {
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const extension = getRendererExtensionFake(extensionStubWithWithRegisteredTab);
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(extension);
|
||||
beforeEach(() => {
|
||||
builder.extensions.enable(extensionStubWithWithRegisteredTab);
|
||||
});
|
||||
|
||||
it("shows extension tab in general area", () => {
|
||||
@ -210,7 +196,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when navigating to specific extension tab", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click("extension-registered-tab-page-id-nav-item-metrics-extension-tab");
|
||||
builder.preferences.navigation.click("extension-registered-tab-page-id-nav-item-metrics-extension-tab");
|
||||
});
|
||||
it("renders", () => {
|
||||
expect(rendered.container).toMatchSnapshot();
|
||||
@ -232,7 +218,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
it("shows page title same as tab title", () => {
|
||||
const pageTitle = rendered.queryByTestId("extension-preferences-page-title");
|
||||
const tabs = extensionStubWithWithRegisteredTab.appPreferenceTabs;
|
||||
const tabs = extensionStubWithWithRegisteredTab.rendererOptions?.appPreferenceTabs;
|
||||
const tabTitle = tabs && tabs[0].title;
|
||||
|
||||
expect(pageTitle?.innerHTML).toBe(tabTitle);
|
||||
@ -246,11 +232,8 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
"tab-link-for-extension-hello-world-tab-page-id-nav-item-logs-extension-tab",
|
||||
];
|
||||
|
||||
beforeEach(async () => {
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const extension = getRendererExtensionFake(extensionStubWithWithRegisteredTabs);
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(extension);
|
||||
beforeEach(() => {
|
||||
builder.extensions.enable(extensionStubWithWithRegisteredTabs);
|
||||
});
|
||||
|
||||
it.each(tabs)("shows '%s' tab in general area", (tab) => {
|
||||
@ -261,12 +244,8 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
|
||||
describe("given extensions with tabs having same id", () => {
|
||||
beforeEach(async () => {
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const extension = getRendererExtensionFake(extensionStubWithWithRegisteredTab);
|
||||
const otherExtension = getRendererExtensionFake(extensionStubWithWithSameRegisteredTab);
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(extension, otherExtension);
|
||||
beforeEach(() => {
|
||||
builder.extensions.enable(extensionStubWithWithRegisteredTab, extensionStubWithWithSameRegisteredTab);
|
||||
});
|
||||
|
||||
it("shows tab from the first extension", () => {
|
||||
@ -283,7 +262,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when navigating to first extension tab", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click("extension-registered-tab-page-id-nav-item-metrics-extension-tab");
|
||||
builder.preferences.navigation.click("extension-registered-tab-page-id-nav-item-metrics-extension-tab");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -305,7 +284,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when navigating to second extension tab", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click("extension-duplicated-tab-page-id-nav-item-metrics-extension-tab");
|
||||
builder.preferences.navigation.click("extension-duplicated-tab-page-id-nav-item-metrics-extension-tab");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -329,27 +308,21 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when navigating to extension specific tab", () => {
|
||||
let rendered: RenderResult;
|
||||
let di: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
const extensionRoute = windowDi.inject(extensionPreferencesRouteInjectable);
|
||||
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const extension = getRendererExtensionFake(extensionStubWithWithSameRegisteredTab);
|
||||
const otherExtension = getRendererExtensionFake(extensionUsingSomeoneElseTab);
|
||||
|
||||
applicationBuilder.beforeRender(() => {
|
||||
const extensionRoute = di.inject(extensionPreferencesRouteInjectable);
|
||||
const params = { parameters: {
|
||||
extensionId: "duplicated-tab-page-id",
|
||||
tabId: "metrics-extension-tab",
|
||||
}};
|
||||
|
||||
applicationBuilder.preferences.navigateTo(extensionRoute, params);
|
||||
builder.preferences.navigateTo(extensionRoute, params);
|
||||
});
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(extension, otherExtension);
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.extensions.enable(extensionStubWithWithSameRegisteredTab, extensionUsingSomeoneElseTab);
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -367,27 +340,20 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
|
||||
describe("when navigating to someone else extension specific tab", () => {
|
||||
let rendered: RenderResult;
|
||||
let di: DiContainer;
|
||||
|
||||
beforeEach(async () => {
|
||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
|
||||
const extension = getRendererExtensionFake(extensionStubWithWithSameRegisteredTab);
|
||||
const extensionUsingOtherTab = getRendererExtensionFake(extensionUsingSomeoneElseTab);
|
||||
|
||||
applicationBuilder.beforeRender(() => {
|
||||
const extensionRoute = di.inject(extensionPreferencesRouteInjectable);
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
const extensionRoute = windowDi.inject(extensionPreferencesRouteInjectable);
|
||||
const params = { parameters: {
|
||||
extensionId: "extension-using-someone-else-tab-id",
|
||||
tabId: "metrics-extension-tab",
|
||||
}};
|
||||
|
||||
applicationBuilder.preferences.navigateTo(extensionRoute, params);
|
||||
builder.preferences.navigateTo(extensionRoute, params);
|
||||
});
|
||||
|
||||
await applicationBuilder.extensions.renderer.enable(extension, extensionUsingOtherTab);
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.extensions.enable(extensionStubWithWithSameRegisteredTab, extensionUsingSomeoneElseTab);
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -396,193 +362,208 @@ describe("preferences - navigation to extension specific preferences", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const extensionStubWithExtensionSpecificPreferenceItems: FakeExtensionData = {
|
||||
const extensionStubWithExtensionSpecificPreferenceItems: FakeExtensionOptions = {
|
||||
id: "some-test-extension-id",
|
||||
name: "some-test-extension-id",
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Some preference item",
|
||||
id: "some-preference-item-id",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="some-preference-item-hint" />,
|
||||
Input: () => <div data-testid="some-preference-item-input" />,
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Some preference item",
|
||||
id: "some-preference-item-id",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="some-preference-item-hint" />,
|
||||
Input: () => <div data-testid="some-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
title: "irrelevant",
|
||||
id: "some-unrelated-preference-item-id",
|
||||
showInPreferencesTab: "some-tab",
|
||||
{
|
||||
title: "irrelevant",
|
||||
id: "some-unrelated-preference-item-id",
|
||||
showInPreferencesTab: "some-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div />,
|
||||
Input: () => <div />,
|
||||
components: {
|
||||
Hint: () => <div />,
|
||||
Input: () => <div />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const someOtherExtensionStubWithExtensionSpecificPreferenceItems: FakeExtensionData = {
|
||||
const someOtherExtensionStubWithExtensionSpecificPreferenceItems: FakeExtensionOptions = {
|
||||
id: "some-other-test-extension-id",
|
||||
name: "some-other-test-extension-id",
|
||||
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Test preference item",
|
||||
id: "some-other-preference-item-id",
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Test preference item",
|
||||
id: "some-other-preference-item-id",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="some-other-preference-item-hint" />,
|
||||
Input: () => <div data-testid="some-other-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="some-other-preference-item-hint" />,
|
||||
Input: () => <div data-testid="some-other-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const extensionStubWithoutPreferences: FakeExtensionData = {
|
||||
const extensionStubWithoutPreferences: FakeExtensionOptions = {
|
||||
id: "without-preferences-id",
|
||||
name: "without-preferences-id",
|
||||
};
|
||||
|
||||
const extensionStubWithShowInPreferencesTab: FakeExtensionData = {
|
||||
const extensionStubWithShowInPreferencesTab: FakeExtensionOptions = {
|
||||
id: "specified-preferences-page-id",
|
||||
name: "specified-preferences-page-name",
|
||||
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Test preference item",
|
||||
id: "very-other-preference-item-id",
|
||||
showInPreferencesTab: "some-tab",
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Test preference item",
|
||||
id: "very-other-preference-item-id",
|
||||
showInPreferencesTab: "some-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="very-other-preference-item-hint" />,
|
||||
Input: () => <div data-testid="very-other-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="very-other-preference-item-hint" />,
|
||||
Input: () => <div data-testid="very-other-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const extensionStubWithWithRegisteredTab: FakeExtensionData = {
|
||||
const extensionStubWithWithRegisteredTab: FakeExtensionOptions = {
|
||||
id: "registered-tab-page-id",
|
||||
name: "registered-tab-page-id",
|
||||
|
||||
appPreferences: [
|
||||
{
|
||||
title: "License item",
|
||||
id: "metrics-preference-item-id",
|
||||
showInPreferencesTab: "metrics-extension-tab",
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "License item",
|
||||
id: "metrics-preference-item-id",
|
||||
showInPreferencesTab: "metrics-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="metrics-preference-item-hint" />,
|
||||
Input: () => <div data-testid="metrics-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="metrics-preference-item-hint" />,
|
||||
Input: () => <div data-testid="metrics-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Menu item",
|
||||
id: "menu-preference-item-id",
|
||||
showInPreferencesTab: "menu-extension-tab",
|
||||
{
|
||||
title: "Menu item",
|
||||
id: "menu-preference-item-id",
|
||||
showInPreferencesTab: "menu-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="menu-preference-item-hint" />,
|
||||
Input: () => <div data-testid="menu-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="menu-preference-item-hint" />,
|
||||
Input: () => <div data-testid="menu-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Survey item",
|
||||
id: "survey-preference-item-id",
|
||||
showInPreferencesTab: "survey-extension-tab",
|
||||
{
|
||||
title: "Survey item",
|
||||
id: "survey-preference-item-id",
|
||||
showInPreferencesTab: "survey-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="survey-preference-item-hint" />,
|
||||
Input: () => <div data-testid="survey-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="survey-preference-item-hint" />,
|
||||
Input: () => <div data-testid="survey-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
appPreferenceTabs: [{
|
||||
title: "Metrics tab",
|
||||
id: "metrics-extension-tab",
|
||||
orderNumber: 100,
|
||||
}],
|
||||
appPreferenceTabs: [{
|
||||
title: "Metrics tab",
|
||||
id: "metrics-extension-tab",
|
||||
orderNumber: 100,
|
||||
}],
|
||||
},
|
||||
};
|
||||
|
||||
const extensionStubWithWithRegisteredTabs: FakeExtensionData = {
|
||||
const extensionStubWithWithRegisteredTabs: FakeExtensionOptions = {
|
||||
id: "hello-world-tab-page-id",
|
||||
name: "hello-world-tab-page-id",
|
||||
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Hello world",
|
||||
id: "hello-preference-item-id",
|
||||
showInPreferencesTab: "hello-extension-tab",
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Hello world",
|
||||
id: "hello-preference-item-id",
|
||||
showInPreferencesTab: "hello-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="hello-preference-item-hint" />,
|
||||
Input: () => <div data-testid="hello-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="hello-preference-item-hint" />,
|
||||
Input: () => <div data-testid="hello-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Logs",
|
||||
id: "logs-preference-item-id",
|
||||
showInPreferencesTab: "logs-extension-tab",
|
||||
{
|
||||
title: "Logs",
|
||||
id: "logs-preference-item-id",
|
||||
showInPreferencesTab: "logs-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="logs-preference-item-hint" />,
|
||||
Input: () => <div data-testid="logs-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="logs-preference-item-hint" />,
|
||||
Input: () => <div data-testid="logs-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
appPreferenceTabs: [{
|
||||
title: "Metrics tab",
|
||||
id: "hello-extension-tab",
|
||||
orderNumber: 100,
|
||||
}, {
|
||||
title: "Logs tab",
|
||||
id: "logs-extension-tab",
|
||||
orderNumber: 200,
|
||||
}],
|
||||
appPreferenceTabs: [{
|
||||
title: "Metrics tab",
|
||||
id: "hello-extension-tab",
|
||||
orderNumber: 100,
|
||||
}, {
|
||||
title: "Logs tab",
|
||||
id: "logs-extension-tab",
|
||||
orderNumber: 200,
|
||||
}],
|
||||
},
|
||||
};
|
||||
|
||||
const extensionStubWithWithSameRegisteredTab: FakeExtensionData = {
|
||||
const extensionStubWithWithSameRegisteredTab: FakeExtensionOptions = {
|
||||
id: "duplicated-tab-page-id",
|
||||
name: "duplicated-tab-page-id",
|
||||
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Another metrics",
|
||||
id: "another-metrics-preference-item-id",
|
||||
showInPreferencesTab: "metrics-extension-tab",
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "Another metrics",
|
||||
id: "another-metrics-preference-item-id",
|
||||
showInPreferencesTab: "metrics-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="another-metrics-preference-item-hint" />,
|
||||
Input: () => <div data-testid="another-metrics-preference-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="another-metrics-preference-item-hint" />,
|
||||
Input: () => <div data-testid="another-metrics-preference-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
appPreferenceTabs: [{
|
||||
title: "Metrics tab",
|
||||
id: "metrics-extension-tab",
|
||||
orderNumber: 100,
|
||||
}],
|
||||
appPreferenceTabs: [{
|
||||
title: "Metrics tab",
|
||||
id: "metrics-extension-tab",
|
||||
orderNumber: 100,
|
||||
}],
|
||||
},
|
||||
};
|
||||
|
||||
const extensionUsingSomeoneElseTab: FakeExtensionData = {
|
||||
const extensionUsingSomeoneElseTab: FakeExtensionOptions = {
|
||||
id: "extension-using-someone-else-tab-id",
|
||||
name: "extension-using-someone-else-tab-id",
|
||||
|
||||
appPreferences: [
|
||||
{
|
||||
title: "My preferences",
|
||||
id: "my-preferences-item-id",
|
||||
showInPreferencesTab: "metrics-extension-tab",
|
||||
rendererOptions: {
|
||||
appPreferences: [
|
||||
{
|
||||
title: "My preferences",
|
||||
id: "my-preferences-item-id",
|
||||
showInPreferencesTab: "metrics-extension-tab",
|
||||
|
||||
components: {
|
||||
Hint: () => <div data-testid="my-preferences-item-hint" />,
|
||||
Input: () => <div data-testid="my-preferences-item-input" />,
|
||||
components: {
|
||||
Hint: () => <div data-testid="my-preferences-item-hint" />,
|
||||
Input: () => <div data-testid="my-preferences-item-input" />,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
@ -9,30 +9,32 @@ import callForPublicHelmRepositoriesInjectable from "../../renderer/components/+
|
||||
import getActiveHelmRepositoriesInjectable from "../../main/helm/repositories/get-active-helm-repositories/get-active-helm-repositories.injectable";
|
||||
|
||||
describe("preferences - navigation to kubernetes preferences", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let builder: ApplicationBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
builder = getApplicationBuilder();
|
||||
});
|
||||
|
||||
describe("given in preferences, when rendered", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeApplicationStart(({ rendererDi, mainDi }) => {
|
||||
rendererDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
|
||||
builder.beforeApplicationStart((mainDi) => {
|
||||
mainDi.override(
|
||||
getActiveHelmRepositoriesInjectable,
|
||||
() => async () => ({ callWasSuccessful: true, response: [] }),
|
||||
);
|
||||
});
|
||||
|
||||
applicationBuilder.beforeRender(() => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
builder.beforeWindowStart((windowDi) => {
|
||||
windowDi.override(callForPublicHelmRepositoriesInjectable, () => async () => []);
|
||||
});
|
||||
|
||||
rendered = await applicationBuilder.render();
|
||||
builder.beforeWindowStart(() => {
|
||||
builder.preferences.navigate();
|
||||
});
|
||||
|
||||
rendered = await builder.render();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -47,7 +49,7 @@ describe("preferences - navigation to kubernetes preferences", () => {
|
||||
|
||||
describe("when navigating to kubernetes preferences using navigation", () => {
|
||||
beforeEach(() => {
|
||||
applicationBuilder.preferences.navigation.click("kubernetes");
|
||||
builder.preferences.navigation.click("kubernetes");
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
@ -17,7 +17,7 @@ describe("preferences - navigation to proxy preferences", () => {
|
||||
let rendered: RenderResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
applicationBuilder.beforeRender(() => {
|
||||
applicationBuilder.beforeWindowStart(() => {
|
||||
applicationBuilder.preferences.navigate();
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user