mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Change typing for after/before window/application start (#7342)
- Now the callback is provided with an object containing either `mainDi` or `windowDi` fields. This should help with confusion over which environment the `di` is for Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
b99b06980e
commit
a63f737adb
@ -38,7 +38,7 @@ describe("app-paths", () => {
|
|||||||
userData: "/some-irrelevant-user-data",
|
userData: "/some-irrelevant-user-data",
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
getElectronAppPathInjectable,
|
getElectronAppPathInjectable,
|
||||||
() =>
|
() =>
|
||||||
@ -120,7 +120,7 @@ describe("app-paths", () => {
|
|||||||
let windowDi: DiContainer;
|
let windowDi: DiContainer;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
directoryForIntegrationTestingInjectable,
|
directoryForIntegrationTestingInjectable,
|
||||||
() => "/some-integration-testing-app-data",
|
() => "/some-integration-testing-app-data",
|
||||||
|
|||||||
@ -50,7 +50,7 @@ describe("channel", () => {
|
|||||||
injectionToken: messageChannelListenerInjectionToken,
|
injectionToken: messageChannelListenerInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testChannelListenerInTestWindowInjectable);
|
windowDi.register(testChannelListenerInTestWindowInjectable);
|
||||||
});
|
});
|
||||||
@ -123,7 +123,7 @@ describe("channel", () => {
|
|||||||
injectionToken: messageChannelListenerInjectionToken,
|
injectionToken: messageChannelListenerInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
mainDi.register(testChannelListenerInMainInjectable);
|
mainDi.register(testChannelListenerInMainInjectable);
|
||||||
});
|
});
|
||||||
@ -157,7 +157,7 @@ describe("channel", () => {
|
|||||||
handler: () => requestListenerInMainMock,
|
handler: () => requestListenerInMainMock,
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
mainDi.register(testChannelListenerInMainInjectable);
|
mainDi.register(testChannelListenerInMainInjectable);
|
||||||
});
|
});
|
||||||
@ -224,7 +224,7 @@ describe("channel", () => {
|
|||||||
injectionToken: requestChannelListenerInjectionToken,
|
injectionToken: requestChannelListenerInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
mainDi.register(someChannelListenerInjectable);
|
mainDi.register(someChannelListenerInjectable);
|
||||||
mainDi.register(someOtherChannelListenerInjectable);
|
mainDi.register(someOtherChannelListenerInjectable);
|
||||||
|
|||||||
@ -17,13 +17,13 @@ describe("sync-box", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
mainDi.register(someInjectable);
|
mainDi.register(someInjectable);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(someInjectable);
|
windowDi.register(someInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -15,13 +15,11 @@ describe("configurable directories for extension files", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart(
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
(mainDi) => {
|
runInAction(() => {
|
||||||
runInAction(() => {
|
mainDi.override(getHashInjectable, () => x => x);
|
||||||
mainDi.override(getHashInjectable, () => x => x);
|
});
|
||||||
});
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
await builder.startHidden();
|
await builder.startHidden();
|
||||||
|
|
||||||
|
|||||||
@ -18,20 +18,18 @@ describe("application-menu-in-legacy-extension-api", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart(
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
(mainDi) => {
|
runInAction(() => {
|
||||||
runInAction(() => {
|
mainDi.register(
|
||||||
mainDi.register(
|
someTopMenuItemInjectable,
|
||||||
someTopMenuItemInjectable,
|
someNonExtensionBasedMenuItemInjectable,
|
||||||
someNonExtensionBasedMenuItemInjectable,
|
);
|
||||||
);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
logErrorMock = jest.fn();
|
logErrorMock = jest.fn();
|
||||||
|
|
||||||
mainDi.override(logErrorInjectable, () => logErrorMock);
|
mainDi.override(logErrorInjectable, () => logErrorMock);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
await builder.startHidden();
|
await builder.startHidden();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@ describe.each(allPlatforms)("application-menu, given platform is '%s'", (platfor
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(platformInjectable, () => platform);
|
mainDi.override(platformInjectable, () => platform);
|
||||||
|
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
|
|||||||
@ -25,7 +25,7 @@ describe("handling-of-orphan-application-menu-items, given orphan menu item", ()
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
const someOrphanMenuItemInjectable = getInjectable({
|
const someOrphanMenuItemInjectable = getInjectable({
|
||||||
id: "some-orphan-menu-item",
|
id: "some-orphan-menu-item",
|
||||||
instantiate: () => ({
|
instantiate: () => ({
|
||||||
|
|||||||
@ -35,7 +35,7 @@ describe("analytics for installing update", () => {
|
|||||||
|
|
||||||
analyticsListenerMock = jest.fn();
|
analyticsListenerMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeApplicationStart(mainDi => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getBuildVersionInjectable, () => () => "42.0.0");
|
mainDi.override(getBuildVersionInjectable, () => () => "42.0.0");
|
||||||
|
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
|
|||||||
@ -33,7 +33,7 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
|
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
downloadPlatformUpdateMock = asyncFn();
|
downloadPlatformUpdateMock = asyncFn();
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ describe("installing update using tray", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
downloadPlatformUpdateMock = asyncFn();
|
downloadPlatformUpdateMock = asyncFn();
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ describe("force user to update when too long since update was downloaded", () =>
|
|||||||
|
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
|
|
||||||
mainDi.override(checkForPlatformUpdatesInjectable, () => checkForPlatformUpdatesMock);
|
mainDi.override(checkForPlatformUpdatesInjectable, () => checkForPlatformUpdatesMock);
|
||||||
@ -49,7 +49,7 @@ describe("force user to update when too long since update was downloaded", () =>
|
|||||||
mainDi.override(quitAndInstallUpdateInjectable, () => quitAndInstallUpdateMock);
|
mainDi.override(quitAndInstallUpdateInjectable, () => quitAndInstallUpdateMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeWindowStart(windowDi => {
|
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.unoverride(forceUpdateModalRootFrameComponentInjectable);
|
windowDi.unoverride(forceUpdateModalRootFrameComponentInjectable);
|
||||||
windowDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable);
|
windowDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable);
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ describe("periodical checking of updates", () => {
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.unoverride(periodicalCheckForUpdatesInjectable);
|
mainDi.unoverride(periodicalCheckForUpdatesInjectable);
|
||||||
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
|
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ describe("periodical checking of updates", () => {
|
|||||||
let rendered: RenderResult;
|
let rendered: RenderResult;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
||||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||||
});
|
});
|
||||||
@ -74,7 +74,7 @@ describe("periodical checking of updates", () => {
|
|||||||
|
|
||||||
describe("given updater is enabled but no configuration exist, when started", () => {
|
describe("given updater is enabled but no configuration exist, when started", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
||||||
mainDi.override(publishIsConfiguredInjectable, () => false);
|
mainDi.override(publishIsConfiguredInjectable, () => false);
|
||||||
});
|
});
|
||||||
@ -95,7 +95,7 @@ describe("periodical checking of updates", () => {
|
|||||||
|
|
||||||
describe("given updater is not enabled but and configuration exist, when started", () => {
|
describe("given updater is not enabled but and configuration exist, when started", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(electronUpdaterIsActiveInjectable, () => false);
|
mainDi.override(electronUpdaterIsActiveInjectable, () => false);
|
||||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,7 +37,7 @@ describe("selection of update stability", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
quitAndInstallUpdateMock = jest.fn();
|
quitAndInstallUpdateMock = jest.fn();
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
downloadPlatformUpdateMock = asyncFn();
|
downloadPlatformUpdateMock = asyncFn();
|
||||||
@ -64,7 +64,7 @@ describe("selection of update stability", () => {
|
|||||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
showInfoNotificationMock = jest.fn(() => () => {});
|
showInfoNotificationMock = jest.fn(() => () => {});
|
||||||
|
|
||||||
windowDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
windowDi.override(showInfoNotificationInjectable, () => showInfoNotificationMock);
|
||||||
@ -260,7 +260,7 @@ 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 () => {
|
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 () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0");
|
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ 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 () => {
|
it('given no update channel selection is stored and currently using alpha release, when checking for updates, checks for updates from "alpha" channel', async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0-alpha");
|
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0-alpha");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ 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 () => {
|
it('given no update channel selection is stored and currently using beta release, when checking for updates, checks for updates from "beta" channel', async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0-beta");
|
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0-beta");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ describe("downgrading version update", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart(mainDi => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
|
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
|
|||||||
@ -32,7 +32,7 @@ describe("installing update", () => {
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
electronQuitAndInstallUpdateMock = jest.fn();
|
electronQuitAndInstallUpdateMock = jest.fn();
|
||||||
checkForPlatformUpdatesMock = asyncFn();
|
checkForPlatformUpdatesMock = asyncFn();
|
||||||
downloadPlatformUpdateMock = asyncFn();
|
downloadPlatformUpdateMock = asyncFn();
|
||||||
|
|||||||
@ -84,7 +84,7 @@ describe("entity running technical tests", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.afterWindowStart((windowDi) => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
onRun = jest.fn();
|
onRun = jest.fn();
|
||||||
|
|
||||||
const catalogCategoryRegistery = windowDi.inject(catalogCategoryRegistryInjectable);
|
const catalogCategoryRegistery = windowDi.inject(catalogCategoryRegistryInjectable);
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe("opening catalog entity details panel", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
// TODO: remove once ClusterStore can be used without overriding it
|
// TODO: remove once ClusterStore can be used without overriding it
|
||||||
windowDi.override(getClusterByIdInjectable, () => (clusterId) => {
|
windowDi.override(getClusterByIdInjectable, () => (clusterId) => {
|
||||||
if (clusterId === cluster?.id) {
|
if (clusterId === cluster?.id) {
|
||||||
@ -39,7 +39,7 @@ describe("opening catalog entity details panel", () => {
|
|||||||
|
|
||||||
testUsingFakeTime();
|
testUsingFakeTime();
|
||||||
|
|
||||||
builder.afterWindowStart((windowDi) => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
clusterEntity = new KubernetesCluster({
|
clusterEntity = new KubernetesCluster({
|
||||||
metadata: {
|
metadata: {
|
||||||
labels: {},
|
labels: {},
|
||||||
|
|||||||
@ -76,17 +76,17 @@ describe("Deleting a cluster", () => {
|
|||||||
config = new KubeConfig();
|
config = new KubeConfig();
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(kubectlBinaryNameInjectable, () => "kubectl");
|
mainDi.override(kubectlBinaryNameInjectable, () => "kubectl");
|
||||||
mainDi.override(kubectlDownloadingNormalizedArchInjectable, () => "amd64");
|
mainDi.override(kubectlDownloadingNormalizedArchInjectable, () => "amd64");
|
||||||
mainDi.override(normalizedPlatformInjectable, () => "darwin");
|
mainDi.override(normalizedPlatformInjectable, () => "darwin");
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
openDeleteClusterDialog = windowDi.inject(openDeleteClusterDialogInjectable);
|
openDeleteClusterDialog = windowDi.inject(openDeleteClusterDialogInjectable);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.afterWindowStart(windowDi => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
const navigateToCatalog = windowDi.inject(navigateToCatalogInjectable);
|
const navigateToCatalog = windowDi.inject(navigateToCatalogInjectable);
|
||||||
|
|
||||||
navigateToCatalog();
|
navigateToCatalog();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe("disable kube object detail items when cluster is not relevant", () =>
|
|||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.afterWindowStart((windowDi) => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
const apiManager = windowDi.inject(apiManagerInjectable);
|
const apiManager = windowDi.inject(apiManagerInjectable);
|
||||||
const api = {
|
const api = {
|
||||||
apiBase: "/apis/some-api-version/some-kind",
|
apiBase: "/apis/some-api-version/some-kind",
|
||||||
|
|||||||
@ -25,7 +25,7 @@ describe("reactively hide kube object detail item", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.afterWindowStart((windowDi) => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
const apiManager = windowDi.inject(apiManagerInjectable);
|
const apiManager = windowDi.inject(apiManagerInjectable);
|
||||||
const api = {
|
const api = {
|
||||||
apiBase: "/apis/some-api-version/some-kind",
|
apiBase: "/apis/some-api-version/some-kind",
|
||||||
|
|||||||
@ -29,7 +29,7 @@ describe("disable kube object menu items when cluster is not relevant", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -25,7 +25,7 @@ describe("reactively hide kube object menu item", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -30,7 +30,7 @@ describe("disable kube object statuses when cluster is not relevant", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe("reactively hide kube object status", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -93,7 +93,7 @@ describe("show status for a kube object", () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(
|
windowDi.register(
|
||||||
testRouteInjectable,
|
testRouteInjectable,
|
||||||
|
|||||||
@ -36,7 +36,7 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(
|
windowDi.override(
|
||||||
directoryForLensLocalStorageInjectable,
|
directoryForLensLocalStorageInjectable,
|
||||||
() => "/some-directory-for-lens-local-storage",
|
() => "/some-directory-for-lens-local-storage",
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
|
|||||||
|
|
||||||
callForNamespaceMock = asyncFn();
|
callForNamespaceMock = asyncFn();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(
|
windowDi.override(
|
||||||
directoryForLensLocalStorageInjectable,
|
directoryForLensLocalStorageInjectable,
|
||||||
() => "/some-directory-for-lens-local-storage",
|
() => "/some-directory-for-lens-local-storage",
|
||||||
@ -47,7 +47,7 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
|
|||||||
let rendered: RenderResult;
|
let rendered: RenderResult;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(async (windowDi) => {
|
builder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFile(
|
await writeJsonFile(
|
||||||
|
|||||||
@ -21,7 +21,7 @@ describe("cluster - order of sidebar items", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testSidebarItemsInjectable);
|
windowDi.register(testSidebarItemsInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -35,14 +35,14 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(storageSaveDelayInjectable, () => 250);
|
windowDi.override(storageSaveDelayInjectable, () => 250);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("given core registrations", () => {
|
describe("given core registrations", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteInjectable);
|
windowDi.register(testRouteInjectable);
|
||||||
windowDi.register(testRouteComponentInjectable);
|
windowDi.register(testRouteComponentInjectable);
|
||||||
@ -86,7 +86,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
|||||||
|
|
||||||
describe("given state for expanded sidebar items already exists, when rendered", () => {
|
describe("given state for expanded sidebar items already exists, when rendered", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(async (windowDi) => {
|
builder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFile(
|
await writeJsonFile(
|
||||||
@ -122,7 +122,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
|||||||
|
|
||||||
describe("given state for expanded unknown sidebar items already exists, when rendered", () => {
|
describe("given state for expanded unknown sidebar items already exists, when rendered", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(async (windowDi) => {
|
builder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFileFake(
|
await writeJsonFileFake(
|
||||||
@ -152,7 +152,7 @@ describe("cluster - sidebar and tab navigation for core", () => {
|
|||||||
|
|
||||||
describe("given empty state for expanded sidebar items already exists, when rendered", () => {
|
describe("given empty state for expanded sidebar items already exists, when rendered", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(async (windowDi) => {
|
builder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFileFake(
|
await writeJsonFileFake(
|
||||||
|
|||||||
@ -34,7 +34,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
|||||||
|
|
||||||
applicationBuilder.setEnvironmentToClusterFrame();
|
applicationBuilder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(storageSaveDelayInjectable, () => 250);
|
windowDi.override(storageSaveDelayInjectable, () => 250);
|
||||||
|
|
||||||
windowDi.override(
|
windowDi.override(
|
||||||
@ -171,7 +171,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
|||||||
|
|
||||||
describe("given state for expanded sidebar items already exists, when rendered", () => {
|
describe("given state for expanded sidebar items already exists, when rendered", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
applicationBuilder.beforeWindowStart(async (windowDi) => {
|
applicationBuilder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFileFake(
|
await writeJsonFileFake(
|
||||||
@ -207,7 +207,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
|||||||
|
|
||||||
describe("given state for expanded unknown sidebar items already exists, when rendered", () => {
|
describe("given state for expanded unknown sidebar items already exists, when rendered", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
applicationBuilder.beforeWindowStart(async (windowDi) => {
|
applicationBuilder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFileFake(
|
await writeJsonFileFake(
|
||||||
@ -237,7 +237,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
|
|||||||
|
|
||||||
describe("given empty state for expanded sidebar items already exists, when rendered", () => {
|
describe("given empty state for expanded sidebar items already exists, when rendered", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
applicationBuilder.beforeWindowStart(async (windowDi) => {
|
applicationBuilder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFileFake(
|
await writeJsonFileFake(
|
||||||
|
|||||||
@ -24,7 +24,7 @@ describe("cluster - visibility of sidebar items", () => {
|
|||||||
|
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteInjectable);
|
windowDi.register(testRouteInjectable);
|
||||||
windowDi.register(testRouteComponentInjectable);
|
windowDi.register(testRouteComponentInjectable);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ describe("order of workload overview details", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const builder = getApplicationBuilder();
|
const builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.unoverride(getRandomIdInjectable);
|
windowDi.unoverride(getRandomIdInjectable);
|
||||||
windowDi.permitSideEffects(getRandomIdInjectable);
|
windowDi.permitSideEffects(getRandomIdInjectable);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ describe("Command Pallet: keyboard shortcut tests", () => {
|
|||||||
|
|
||||||
describe("when on macOS", () => {
|
describe("when on macOS", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(platformInjectable, () => "darwin");
|
windowDi.override(platformInjectable, () => "darwin");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ describe("Command Pallet: keyboard shortcut tests", () => {
|
|||||||
|
|
||||||
describe("when on linux", () => {
|
describe("when on linux", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(platformInjectable, () => "linux");
|
windowDi.override(platformInjectable, () => "linux");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ describe("Showing correct entity settings", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
// TODO: remove once ClusterStore can be used without overriding it
|
// TODO: remove once ClusterStore can be used without overriding it
|
||||||
windowDi.override(getClusterByIdInjectable, () => (clusterId) => {
|
windowDi.override(getClusterByIdInjectable, () => (clusterId) => {
|
||||||
if (clusterId === cluster.id) {
|
if (clusterId === cluster.id) {
|
||||||
@ -35,7 +35,7 @@ describe("Showing correct entity settings", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.afterWindowStart((windowDi) => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
clusterEntity = new KubernetesCluster({
|
clusterEntity = new KubernetesCluster({
|
||||||
metadata: {
|
metadata: {
|
||||||
labels: {},
|
labels: {},
|
||||||
|
|||||||
@ -19,7 +19,7 @@ describe("extensions - navigation using application menu", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
focusWindowMock = jest.fn();
|
focusWindowMock = jest.fn();
|
||||||
|
|
||||||
windowDi.override(focusWindowInjectable, () => focusWindowMock);
|
windowDi.override(focusWindowInjectable, () => focusWindowMock);
|
||||||
|
|||||||
@ -40,13 +40,13 @@ describe("add custom helm repository in preferences", () => {
|
|||||||
showSuccessNotificationMock = jest.fn();
|
showSuccessNotificationMock = jest.fn();
|
||||||
showErrorNotificationMock = jest.fn();
|
showErrorNotificationMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
||||||
mainDi.override(execFileInjectable, () => execFileMock);
|
mainDi.override(execFileInjectable, () => execFileMock);
|
||||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
||||||
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||||
|
|||||||
@ -35,13 +35,13 @@ describe("add helm repository from list in preferences", () => {
|
|||||||
showSuccessNotificationMock = jest.fn();
|
showSuccessNotificationMock = jest.fn();
|
||||||
showErrorNotificationMock = jest.fn();
|
showErrorNotificationMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
||||||
mainDi.override(execFileInjectable, () => execFileMock);
|
mainDi.override(execFileInjectable, () => execFileMock);
|
||||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||||
windowDi.override(requestPublicHelmRepositoriesInjectable, () => callForPublicHelmRepositoriesMock);
|
windowDi.override(requestPublicHelmRepositoriesInjectable, () => callForPublicHelmRepositoriesMock);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ describe("installing helm chart from new tab", () => {
|
|||||||
requestCreateHelmReleaseMock = asyncFn();
|
requestCreateHelmReleaseMock = asyncFn();
|
||||||
requestHelmReleasesMock = asyncFn();
|
requestHelmReleasesMock = asyncFn();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
|
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
|
||||||
windowDi.override(requestDetailedHelmReleaseInjectable, () => requestDetailedHelmReleaseMock);
|
windowDi.override(requestDetailedHelmReleaseInjectable, () => requestDetailedHelmReleaseMock);
|
||||||
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
|
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
|
||||||
|
|||||||
@ -34,7 +34,7 @@ describe("installing helm chart from previously opened tab", () => {
|
|||||||
builder.namespaces.add("default");
|
builder.namespaces.add("default");
|
||||||
builder.namespaces.add("some-other-namespace");
|
builder.namespaces.add("some-other-namespace");
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
|
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
|
||||||
windowDi.override(requestHelmChartVersionsInjectable, () => requestHelmChartVersionsMock);
|
windowDi.override(requestHelmChartVersionsInjectable, () => requestHelmChartVersionsMock);
|
||||||
windowDi.override(requestHelmChartValuesInjectable, () => requestHelmChartValuesMock);
|
windowDi.override(requestHelmChartValuesInjectable, () => requestHelmChartValuesMock);
|
||||||
@ -52,7 +52,7 @@ describe("installing helm chart from previously opened tab", () => {
|
|||||||
let rendered: RenderResult;
|
let rendered: RenderResult;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart(async (windowDi) => {
|
builder.beforeWindowStart(async ({ windowDi }) => {
|
||||||
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
|
||||||
|
|
||||||
await writeJsonFile(
|
await writeJsonFile(
|
||||||
|
|||||||
@ -38,7 +38,7 @@ describe("opening dock tab for installing helm chart", () => {
|
|||||||
requestHelmChartReadmeMock = asyncFn();
|
requestHelmChartReadmeMock = asyncFn();
|
||||||
requestHelmChartValuesMock = jest.fn();
|
requestHelmChartValuesMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
|
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
|
||||||
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
|
||||||
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
|
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
|
||||||
|
|||||||
@ -41,14 +41,14 @@ describe("listing active helm repositories in preferences", () => {
|
|||||||
warn: noop,
|
warn: noop,
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(readYamlFileInjectable, () => readYamlFileMock);
|
mainDi.override(readYamlFileInjectable, () => readYamlFileMock);
|
||||||
mainDi.override(execFileInjectable, () => execFileMock);
|
mainDi.override(execFileInjectable, () => execFileMock);
|
||||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||||
mainDi.override(loggerInjectable, () => loggerStub);
|
mainDi.override(loggerInjectable, () => loggerStub);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
|
||||||
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -28,13 +28,13 @@ describe("remove helm repository from list of active repositories in preferences
|
|||||||
execFileMock = asyncFn();
|
execFileMock = asyncFn();
|
||||||
getActiveHelmRepositoriesMock = asyncFn();
|
getActiveHelmRepositoriesMock = asyncFn();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
|
||||||
mainDi.override(execFileInjectable, () => execFileMock);
|
mainDi.override(execFileInjectable, () => execFileMock);
|
||||||
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ describe("New Upgrade Helm Chart Dock Tab", () => {
|
|||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
builder.setEnvironmentToClusterFrame();
|
builder.setEnvironmentToClusterFrame();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
requestHelmReleaseConfigurationMock = asyncFn();
|
requestHelmReleaseConfigurationMock = asyncFn();
|
||||||
windowDi.override(requestHelmReleaseConfigurationInjectable, () => requestHelmReleaseConfigurationMock);
|
windowDi.override(requestHelmReleaseConfigurationInjectable, () => requestHelmReleaseConfigurationMock);
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@ describe("showing details for helm release", () => {
|
|||||||
showSuccessNotificationMock = jest.fn();
|
showSuccessNotificationMock = jest.fn();
|
||||||
showCheckedErrorNotificationMock = jest.fn();
|
showCheckedErrorNotificationMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(getRandomUpgradeChartTabIdInjectable, () => () => "some-tab-id");
|
windowDi.override(getRandomUpgradeChartTabIdInjectable, () => () => "some-tab-id");
|
||||||
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
|
||||||
windowDi.override(showCheckedErrorInjectable, () => showCheckedErrorNotificationMock);
|
windowDi.override(showCheckedErrorInjectable, () => showCheckedErrorNotificationMock);
|
||||||
|
|||||||
@ -31,7 +31,7 @@ describe("navigating between routes", () => {
|
|||||||
let windowDi: DiContainer;
|
let windowDi: DiContainer;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(testRouteWithoutPathParametersInjectable);
|
windowDi.register(testRouteWithoutPathParametersInjectable);
|
||||||
windowDi.register(testRouteWithoutPathParametersComponentInjectable);
|
windowDi.register(testRouteWithoutPathParametersComponentInjectable);
|
||||||
@ -107,7 +107,7 @@ describe("navigating between routes", () => {
|
|||||||
let windowDi: DiContainer;
|
let windowDi: DiContainer;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(routeWithOptionalPathParametersInjectable);
|
windowDi.register(routeWithOptionalPathParametersInjectable);
|
||||||
windowDi.register(routeWithOptionalPathParametersComponentInjectable);
|
windowDi.register(routeWithOptionalPathParametersComponentInjectable);
|
||||||
|
|||||||
@ -57,7 +57,7 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
getLogsMock = jest.fn();
|
getLogsMock = jest.fn();
|
||||||
getSplittedLogsMock = jest.fn();
|
getSplittedLogsMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(callForLogsInjectable, () => callForLogsMock);
|
windowDi.override(callForLogsInjectable, () => callForLogsMock);
|
||||||
|
|
||||||
// Overriding internals of logsViewModelInjectable
|
// Overriding internals of logsViewModelInjectable
|
||||||
@ -99,7 +99,7 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
rendered = await builder.render();
|
rendered = await builder.render();
|
||||||
windowDi = builder.applicationWindow.only.di;
|
windowDi = builder.applicationWindow.only.di;
|
||||||
|
|
||||||
const dockStore = windowDi.inject(dockStoreInjectable);
|
const dockStore = windowDi.inject(dockStoreInjectable);
|
||||||
|
|
||||||
dockStore.closeTab("terminal");
|
dockStore.closeTab("terminal");
|
||||||
@ -108,10 +108,10 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
describe("when logs not available", () => {
|
describe("when logs not available", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
||||||
|
|
||||||
getLogsMock.mockReturnValue([]);
|
getLogsMock.mockReturnValue([]);
|
||||||
getSplittedLogsMock.mockReturnValue([]);
|
getSplittedLogsMock.mockReturnValue([]);
|
||||||
|
|
||||||
createLogsTab({
|
createLogsTab({
|
||||||
selectedPod: pod,
|
selectedPod: pod,
|
||||||
selectedContainer: container,
|
selectedContainer: container,
|
||||||
@ -132,10 +132,10 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
describe("when logs available", () => {
|
describe("when logs available", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
|
||||||
|
|
||||||
getLogsMock.mockReturnValue(["some-logs"]);
|
getLogsMock.mockReturnValue(["some-logs"]);
|
||||||
getSplittedLogsMock.mockReturnValue([...logs]);
|
getSplittedLogsMock.mockReturnValue([...logs]);
|
||||||
|
|
||||||
createLogsTab({
|
createLogsTab({
|
||||||
selectedPod: pod,
|
selectedPod: pod,
|
||||||
selectedContainer: container,
|
selectedContainer: container,
|
||||||
@ -157,7 +157,7 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
describe("when clicking on dropdown", () => {
|
describe("when clicking on dropdown", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const button = rendered.getByTestId("download-logs-dropdown");
|
const button = rendered.getByTestId("download-logs-dropdown");
|
||||||
|
|
||||||
act(() => button.click());
|
act(() => button.click());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
const button = rendered.getByTestId("download-all-logs");
|
const button = rendered.getByTestId("download-all-logs");
|
||||||
|
|
||||||
button.click();
|
button.click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -193,11 +193,11 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
{ "previous": true, "timestamps": false },
|
{ "previous": true, "timestamps": false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows save dialog with proper attributes", async () => {
|
it("shows save dialog with proper attributes", async () => {
|
||||||
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain");
|
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't block download dropdown for interaction after click", async () => {
|
it("doesn't block download dropdown for interaction after click", async () => {
|
||||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||||
});
|
});
|
||||||
@ -206,19 +206,19 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
describe("blocking user interaction after menu item click", () => {
|
describe("blocking user interaction after menu item click", () => {
|
||||||
it("block download dropdown for interaction when selected 'download all logs'", async () => {
|
it("block download dropdown for interaction when selected 'download all logs'", async () => {
|
||||||
const downloadMenuItem = rendered.getByTestId("download-all-logs");
|
const downloadMenuItem = rendered.getByTestId("download-all-logs");
|
||||||
|
|
||||||
act(() => downloadMenuItem.click());
|
act(() => downloadMenuItem.click());
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(rendered.getByTestId("download-logs-dropdown")).toHaveAttribute("disabled");
|
expect(rendered.getByTestId("download-logs-dropdown")).toHaveAttribute("disabled");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't block dropdown for interaction when selected 'download visible logs'", () => {
|
it("doesn't block dropdown for interaction when selected 'download visible logs'", () => {
|
||||||
const downloadMenuItem = rendered.getByTestId("download-visible-logs");
|
const downloadMenuItem = rendered.getByTestId("download-visible-logs");
|
||||||
|
|
||||||
act(() => downloadMenuItem.click());
|
act(() => downloadMenuItem.click());
|
||||||
|
|
||||||
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -233,7 +233,7 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
const button = rendered.getByTestId("download-all-logs");
|
const button = rendered.getByTestId("download-all-logs");
|
||||||
|
|
||||||
button.click();
|
button.click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -241,7 +241,7 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
it("doesn't show save dialog", () => {
|
it("doesn't show save dialog", () => {
|
||||||
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows error notification", () => {
|
it("shows error notification", () => {
|
||||||
expect(showErrorNotificationMock).toHaveBeenCalled();
|
expect(showErrorNotificationMock).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -252,23 +252,23 @@ describe("download logs options in logs dock tab", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
callForLogsMock.mockRejectedValue("error");
|
callForLogsMock.mockRejectedValue("error");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when selected 'download all logs'", () => {
|
describe("when selected 'download all logs'", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
const button = rendered.getByTestId("download-all-logs");
|
const button = rendered.getByTestId("download-all-logs");
|
||||||
|
|
||||||
button.click();
|
button.click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("logs have been called", () => {
|
it("logs have been called", () => {
|
||||||
expect(callForLogsMock).toHaveBeenCalledWith(
|
expect(callForLogsMock).toHaveBeenCalledWith(
|
||||||
{ name: "dockerExporter", namespace: "default" },
|
{ name: "dockerExporter", namespace: "default" },
|
||||||
{ "previous": true, "timestamps": false },
|
{ "previous": true, "timestamps": false },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't show save dialog", async () => {
|
it("doesn't show save dialog", async () => {
|
||||||
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe("preferences - closing-preferences", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
windowDi.register(
|
windowDi.register(
|
||||||
testPreferenceTabInjectable,
|
testPreferenceTabInjectable,
|
||||||
@ -54,7 +54,7 @@ describe("preferences - closing-preferences", () => {
|
|||||||
let windowDi: DiContainer;
|
let windowDi: DiContainer;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(observableHistoryInjectable, () => {
|
windowDi.override(observableHistoryInjectable, () => {
|
||||||
const historyFake = createMemoryHistory({
|
const historyFake = createMemoryHistory({
|
||||||
initialEntries: ["/some-page"],
|
initialEntries: ["/some-page"],
|
||||||
@ -135,7 +135,7 @@ describe("preferences - closing-preferences", () => {
|
|||||||
let windowDi: DiContainer;
|
let windowDi: DiContainer;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(observableHistoryInjectable, () => {
|
windowDi.override(observableHistoryInjectable, () => {
|
||||||
const historyFake = createMemoryHistory({
|
const historyFake = createMemoryHistory({
|
||||||
initialEntries: ["/preferences/app"],
|
initialEntries: ["/preferences/app"],
|
||||||
|
|||||||
@ -70,7 +70,7 @@ describe("preferences - navigation to application preferences", () => {
|
|||||||
let discover: Discover;
|
let discover: Discover;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
const navigateToProxyPreferences = windowDi.inject(navigateToProxyPreferencesInjectable);
|
const navigateToProxyPreferences = windowDi.inject(navigateToProxyPreferencesInjectable);
|
||||||
|
|
||||||
navigateToProxyPreferences();
|
navigateToProxyPreferences();
|
||||||
|
|||||||
@ -27,7 +27,7 @@ describe("preferences - navigation to extension specific preferences", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
logErrorMock = jest.fn();
|
logErrorMock = jest.fn();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(logErrorInjectable, () => logErrorMock);
|
windowDi.override(logErrorInjectable, () => logErrorMock);
|
||||||
|
|
||||||
builder.preferences.navigate();
|
builder.preferences.navigate();
|
||||||
|
|||||||
@ -22,14 +22,14 @@ describe("preferences - navigation to kubernetes preferences", () => {
|
|||||||
let discover: Discover;
|
let discover: Discover;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
getActiveHelmRepositoriesInjectable,
|
getActiveHelmRepositoriesInjectable,
|
||||||
() => async () => ({ callWasSuccessful: true, response: [] }),
|
() => async () => ({ callWasSuccessful: true, response: [] }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,7 @@ describe("preferences - navigation to telemetry preferences", () => {
|
|||||||
let discover: Discover;
|
let discover: Discover;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(sentryDataSourceNameInjectable, () => "some-sentry-dns-url");
|
windowDi.override(sentryDataSourceNameInjectable, () => "some-sentry-dns-url");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ describe("preferences - navigation to telemetry preferences", () => {
|
|||||||
let discover: Discover;
|
let discover: Discover;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(sentryDataSourceNameInjectable, () => null);
|
windowDi.override(sentryDataSourceNameInjectable, () => null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ describe("opening application window using tray", () => {
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(focusApplicationInjectable, () => focusApplicationMock);
|
mainDi.override(focusApplicationInjectable, () => focusApplicationMock);
|
||||||
|
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
|
|||||||
@ -22,17 +22,15 @@ describe("quitting the app using application menu", () => {
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart(
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
(mainDi) => {
|
mainDi.unoverride(stopServicesAndExitAppInjectable);
|
||||||
mainDi.unoverride(stopServicesAndExitAppInjectable);
|
|
||||||
|
|
||||||
clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager;
|
clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager;
|
||||||
mainDi.override(clusterManagerInjectable, () => clusterManagerStub);
|
mainDi.override(clusterManagerInjectable, () => clusterManagerStub);
|
||||||
|
|
||||||
exitAppMock = jest.fn();
|
exitAppMock = jest.fn();
|
||||||
mainDi.override(exitAppInjectable, () => exitAppMock);
|
mainDi.override(exitAppInjectable, () => exitAppMock);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
await builder.render();
|
await builder.render();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -21,7 +21,7 @@ describe("resolve-system-proxy", () => {
|
|||||||
|
|
||||||
resolveSystemProxyFromElectronMock = asyncFn();
|
resolveSystemProxyFromElectronMock = asyncFn();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
resolveSystemProxyFromElectronInjectable,
|
resolveSystemProxyFromElectronInjectable,
|
||||||
() => resolveSystemProxyFromElectronMock,
|
() => resolveSystemProxyFromElectronMock,
|
||||||
|
|||||||
@ -16,7 +16,7 @@ describe("status-bar-items-originating-from-extensions", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
|
|
||||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.unoverride(getRandomIdInjectable);
|
windowDi.unoverride(getRandomIdInjectable);
|
||||||
windowDi.permitSideEffects(getRandomIdInjectable);
|
windowDi.permitSideEffects(getRandomIdInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -15,7 +15,7 @@ describe("clicking tray menu item originating from extension", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
logErrorMock = jest.fn();
|
logErrorMock = jest.fn();
|
||||||
|
|
||||||
mainDi.override(logErrorInjectable, () => logErrorMock);
|
mainDi.override(logErrorInjectable, () => logErrorMock);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ describe("multiple separators originating from extension", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeApplicationStart((mainDi) => {
|
builder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.unoverride(getRandomIdInjectable);
|
mainDi.unoverride(getRandomIdInjectable);
|
||||||
mainDi.permitSideEffects(getRandomIdInjectable);
|
mainDi.permitSideEffects(getRandomIdInjectable);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -24,11 +24,11 @@ describe("setting-welcome-page", () => {
|
|||||||
|
|
||||||
describe("given configuration of welcome page route is the default", () => {
|
describe("given configuration of welcome page route is the default", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(welcomeRouteConfigInjectable, () => "/welcome");
|
mainDi.override(welcomeRouteConfigInjectable, () => "/welcome");
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(welcomeRouteConfigInjectable, () => "/welcome");
|
windowDi.override(welcomeRouteConfigInjectable, () => "/welcome");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,11 +54,11 @@ describe("setting-welcome-page", () => {
|
|||||||
|
|
||||||
describe("given configuration of welcome page route is set to a custom page", () => {
|
describe("given configuration of welcome page route is set to a custom page", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
applicationBuilder.beforeApplicationStart((mainDi) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
mainDi.override(welcomeRouteConfigInjectable, () => "/extension/some-extension-name/some-welcome-page");
|
mainDi.override(welcomeRouteConfigInjectable, () => "/extension/some-extension-name/some-welcome-page");
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBuilder.beforeWindowStart((windowDi) => {
|
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(welcomeRouteConfigInjectable, () => "/extension/some-extension-name/some-welcome-page");
|
windowDi.override(welcomeRouteConfigInjectable, () => "/extension/some-extension-name/some-welcome-page");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ describe("<StatusBar />", () => {
|
|||||||
|
|
||||||
builder = getApplicationBuilder();
|
builder = getApplicationBuilder();
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.unoverride(getRandomIdInjectable);
|
windowDi.unoverride(getRandomIdInjectable);
|
||||||
windowDi.permitSideEffects(getRandomIdInjectable);
|
windowDi.permitSideEffects(getRandomIdInjectable);
|
||||||
windowDi.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
|
windowDi.override(directoryForUserDataInjectable, () => "some-directory-for-user-data");
|
||||||
@ -63,7 +63,7 @@ describe("<StatusBar />", () => {
|
|||||||
const testId = "testId";
|
const testId = "testId";
|
||||||
const text = "heee";
|
const text = "heee";
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
windowDi.override(statusBarItemsInjectable, () => computed(() => ({
|
windowDi.override(statusBarItemsInjectable, () => computed(() => ({
|
||||||
right: [ { origin: testId, component: () => <span data-testid={testId} >{text}</span> }],
|
right: [ { origin: testId, component: () => <span data-testid={testId} >{text}</span> }],
|
||||||
left: [],
|
left: [],
|
||||||
|
|||||||
@ -72,7 +72,8 @@ import { applicationFeatureForElectronMain, testUtils as applicationForElectronT
|
|||||||
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
||||||
import { testUsingFakeTime } from "../../../test-utils/use-fake-time";
|
import { testUsingFakeTime } from "../../../test-utils/use-fake-time";
|
||||||
|
|
||||||
type Callback = (di: DiContainer) => void | Promise<void>;
|
type MainDiCallback = (container: { mainDi: DiContainer }) => void | Promise<void>;
|
||||||
|
type WindowDiCallback = (container: { windowDi: DiContainer }) => void | Promise<void>;
|
||||||
|
|
||||||
type LensWindowWithHelpers = LensWindow & { rendered: RenderResult; di: DiContainer };
|
type LensWindowWithHelpers = LensWindow & { rendered: RenderResult; di: DiContainer };
|
||||||
|
|
||||||
@ -115,10 +116,10 @@ export interface ApplicationBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
allowKubeResource: (resource: KubeApiResourceDescriptor) => ApplicationBuilder;
|
allowKubeResource: (resource: KubeApiResourceDescriptor) => ApplicationBuilder;
|
||||||
beforeApplicationStart: (callback: Callback) => ApplicationBuilder;
|
beforeApplicationStart: (callback: MainDiCallback) => ApplicationBuilder;
|
||||||
afterApplicationStart: (callback: Callback) => ApplicationBuilder;
|
afterApplicationStart: (callback: MainDiCallback) => ApplicationBuilder;
|
||||||
beforeWindowStart: (callback: Callback) => ApplicationBuilder;
|
beforeWindowStart: (callback: WindowDiCallback) => ApplicationBuilder;
|
||||||
afterWindowStart: (callback: Callback) => ApplicationBuilder;
|
afterWindowStart: (callback: WindowDiCallback) => ApplicationBuilder;
|
||||||
|
|
||||||
startHidden: () => Promise<void>;
|
startHidden: () => Promise<void>;
|
||||||
render: () => Promise<RenderResult>;
|
render: () => Promise<RenderResult>;
|
||||||
@ -180,10 +181,10 @@ export const getApplicationBuilder = () => {
|
|||||||
|
|
||||||
const { overrideForWindow, sendToWindow } = overrideChannels(mainDi);
|
const { overrideForWindow, sendToWindow } = overrideChannels(mainDi);
|
||||||
|
|
||||||
const beforeApplicationStartCallbacks: Callback[] = [];
|
const beforeApplicationStartCallbacks: MainDiCallback[] = [];
|
||||||
const afterApplicationStartCallbacks: Callback[] = [];
|
const afterApplicationStartCallbacks: MainDiCallback[] = [];
|
||||||
const beforeWindowStartCallbacks: Callback[] = [];
|
const beforeWindowStartCallbacks: WindowDiCallback[] = [];
|
||||||
const afterWindowStartCallbacks: Callback[] = [];
|
const afterWindowStartCallbacks: WindowDiCallback[] = [];
|
||||||
|
|
||||||
const overrideFsWithFakes = getOverrideFsWithFakes();
|
const overrideFsWithFakes = getOverrideFsWithFakes();
|
||||||
|
|
||||||
@ -261,7 +262,7 @@ export const getApplicationBuilder = () => {
|
|||||||
loadFile: async () => {},
|
loadFile: async () => {},
|
||||||
loadUrl: async () => {
|
loadUrl: async () => {
|
||||||
for (const callback of beforeWindowStartCallbacks) {
|
for (const callback of beforeWindowStartCallbacks) {
|
||||||
await callback(windowDi);
|
await callback({ windowDi });
|
||||||
}
|
}
|
||||||
|
|
||||||
const startApplication = windowDi.inject(startApplicationInjectionToken);
|
const startApplication = windowDi.inject(startApplicationInjectionToken);
|
||||||
@ -269,7 +270,7 @@ export const getApplicationBuilder = () => {
|
|||||||
await startApplication();
|
await startApplication();
|
||||||
|
|
||||||
for (const callback of afterWindowStartCallbacks) {
|
for (const callback of afterWindowStartCallbacks) {
|
||||||
await callback(windowDi);
|
await callback({ windowDi });
|
||||||
}
|
}
|
||||||
|
|
||||||
const history = windowDi.inject(historyInjectable);
|
const history = windowDi.inject(historyInjectable);
|
||||||
@ -306,14 +307,14 @@ export const getApplicationBuilder = () => {
|
|||||||
mainDi.inject(lensProxyPortInjectable).set(42);
|
mainDi.inject(lensProxyPortInjectable).set(42);
|
||||||
|
|
||||||
for (const callback of beforeApplicationStartCallbacks) {
|
for (const callback of beforeApplicationStartCallbacks) {
|
||||||
await callback(mainDi);
|
await callback({ mainDi });
|
||||||
}
|
}
|
||||||
|
|
||||||
mainDi.override(shouldStartHiddenInjectable, () => shouldStartHidden);
|
mainDi.override(shouldStartHiddenInjectable, () => shouldStartHidden);
|
||||||
await startApplication();
|
await startApplication();
|
||||||
|
|
||||||
for (const callback of afterApplicationStartCallbacks) {
|
for (const callback of afterApplicationStartCallbacks) {
|
||||||
await callback(mainDi);
|
await callback({ mainDi });
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationHasStarted = true;
|
applicationHasStarted = true;
|
||||||
@ -516,7 +517,7 @@ export const getApplicationBuilder = () => {
|
|||||||
setEnvironmentToClusterFrame: () => {
|
setEnvironmentToClusterFrame: () => {
|
||||||
environment = environments.clusterFrame;
|
environment = environments.clusterFrame;
|
||||||
|
|
||||||
builder.beforeWindowStart((windowDi) => {
|
builder.beforeWindowStart(({ windowDi }) => {
|
||||||
const cluster = new Cluster({
|
const cluster = new Cluster({
|
||||||
id: "some-cluster-id",
|
id: "some-cluster-id",
|
||||||
contextName: "some-context-name",
|
contextName: "some-context-name",
|
||||||
@ -587,7 +588,7 @@ export const getApplicationBuilder = () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
enable: (...extensions) => {
|
enable: (...extensions) => {
|
||||||
builder.afterWindowStart((windowDi) => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
const rendererExtensionInstances = extensions.map((options) =>
|
const rendererExtensionInstances = extensions.map((options) =>
|
||||||
getExtensionFakeForRenderer(
|
getExtensionFakeForRenderer(
|
||||||
windowDi,
|
windowDi,
|
||||||
@ -602,7 +603,7 @@ export const getApplicationBuilder = () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.afterApplicationStart((mainDi) => {
|
builder.afterApplicationStart(({ mainDi }) => {
|
||||||
const mainExtensionInstances = extensions.map((extension) =>
|
const mainExtensionInstances = extensions.map((extension) =>
|
||||||
getExtensionFakeForMain(mainDi, extension.id, extension.name, extension.mainOptions || {}),
|
getExtensionFakeForMain(mainDi, extension.id, extension.name, extension.mainOptions || {}),
|
||||||
);
|
);
|
||||||
@ -616,7 +617,7 @@ export const getApplicationBuilder = () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
disable: (...extensions) => {
|
disable: (...extensions) => {
|
||||||
builder.afterWindowStart(windowDi => {
|
builder.afterWindowStart(({ windowDi }) => {
|
||||||
extensions
|
extensions
|
||||||
.map((ext) => ext.id)
|
.map((ext) => ext.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
@ -624,7 +625,7 @@ export const getApplicationBuilder = () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.afterApplicationStart(mainDi => {
|
builder.afterApplicationStart(({ mainDi }) => {
|
||||||
extensions
|
extensions
|
||||||
.map((ext) => ext.id)
|
.map((ext) => ext.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
@ -649,7 +650,7 @@ export const getApplicationBuilder = () => {
|
|||||||
|
|
||||||
beforeApplicationStart(callback) {
|
beforeApplicationStart(callback) {
|
||||||
if (applicationHasStarted) {
|
if (applicationHasStarted) {
|
||||||
callback(mainDi);
|
callback({ mainDi });
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeApplicationStartCallbacks.push(callback);
|
beforeApplicationStartCallbacks.push(callback);
|
||||||
@ -659,7 +660,7 @@ export const getApplicationBuilder = () => {
|
|||||||
|
|
||||||
afterApplicationStart(callback) {
|
afterApplicationStart(callback) {
|
||||||
if (applicationHasStarted) {
|
if (applicationHasStarted) {
|
||||||
callback(mainDi);
|
callback({ mainDi });
|
||||||
}
|
}
|
||||||
|
|
||||||
afterApplicationStartCallbacks.push(callback);
|
afterApplicationStartCallbacks.push(callback);
|
||||||
@ -671,7 +672,7 @@ export const getApplicationBuilder = () => {
|
|||||||
const alreadyRenderedWindows = builder.applicationWindow.getAll();
|
const alreadyRenderedWindows = builder.applicationWindow.getAll();
|
||||||
|
|
||||||
alreadyRenderedWindows.forEach((window) => {
|
alreadyRenderedWindows.forEach((window) => {
|
||||||
callback(window.di);
|
callback({ windowDi: window.di });
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeWindowStartCallbacks.push(callback);
|
beforeWindowStartCallbacks.push(callback);
|
||||||
@ -683,7 +684,7 @@ export const getApplicationBuilder = () => {
|
|||||||
const alreadyRenderedWindows = builder.applicationWindow.getAll();
|
const alreadyRenderedWindows = builder.applicationWindow.getAll();
|
||||||
|
|
||||||
alreadyRenderedWindows.forEach((window) => {
|
alreadyRenderedWindows.forEach((window) => {
|
||||||
callback(window.di);
|
callback({ windowDi: window.di });
|
||||||
});
|
});
|
||||||
|
|
||||||
afterWindowStartCallbacks.push(callback);
|
afterWindowStartCallbacks.push(callback);
|
||||||
|
|||||||
@ -8,33 +8,34 @@ import { startApplicationInjectionToken } from "@k8slens/application";
|
|||||||
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
|
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
|
||||||
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./time-slots";
|
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./time-slots";
|
||||||
import { runManySyncFor } from "@k8slens/run-many";
|
import { runManySyncFor } from "@k8slens/run-many";
|
||||||
|
import { curry } from "lodash";
|
||||||
|
|
||||||
type ToBeDecorated = (di: DiContainer, ...args: unknown[]) => (...args: unknown[]) => unknown;
|
type ToBeDecorated = (di: DiContainer, ...args: unknown[]) => (...args: unknown[]) => unknown;
|
||||||
|
|
||||||
|
const decorator = (toBeDecorated: unknown, di: DiContainer, ...args: unknown[]) => {
|
||||||
|
const whenAppIsReady = di.inject(whenAppIsReadyInjectable);
|
||||||
|
const runManySync = runManySyncFor(di);
|
||||||
|
const beforeAnything = runManySync(beforeAnythingInjectionToken);
|
||||||
|
const beforeElectronIsReady = runManySync(beforeElectronIsReadyInjectionToken);
|
||||||
|
const startApplication = (toBeDecorated as ToBeDecorated)(di, ...args);
|
||||||
|
|
||||||
|
return (...startApplicationArgs: unknown[]) => {
|
||||||
|
beforeAnything();
|
||||||
|
beforeElectronIsReady();
|
||||||
|
|
||||||
|
return (async () => {
|
||||||
|
await whenAppIsReady();
|
||||||
|
|
||||||
|
return startApplication(...startApplicationArgs);
|
||||||
|
})();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const startElectronApplicationInjectable = getInjectable({
|
const startElectronApplicationInjectable = getInjectable({
|
||||||
id: "start-electron-application",
|
id: "start-electron-application",
|
||||||
|
|
||||||
instantiate: () => ({
|
instantiate: () => ({
|
||||||
decorate: (toBeDecorated: unknown) => (
|
decorate: curry(decorator),
|
||||||
(di: DiContainer, ...args: unknown[]) => {
|
|
||||||
const whenAppIsReady = di.inject(whenAppIsReadyInjectable);
|
|
||||||
const runManySync = runManySyncFor(di);
|
|
||||||
const beforeAnything = runManySync(beforeAnythingInjectionToken);
|
|
||||||
const beforeElectronIsReady = runManySync(beforeElectronIsReadyInjectionToken);
|
|
||||||
const startApplication = (toBeDecorated as ToBeDecorated)(di, ...args);
|
|
||||||
|
|
||||||
return (...startApplicationArgs: unknown[]) => {
|
|
||||||
beforeAnything();
|
|
||||||
beforeElectronIsReady();
|
|
||||||
|
|
||||||
return (async () => {
|
|
||||||
await whenAppIsReady();
|
|
||||||
|
|
||||||
return startApplication(...startApplicationArgs);
|
|
||||||
})()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
),
|
|
||||||
target: startApplicationInjectionToken,
|
target: startApplicationInjectionToken,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
} from "@k8slens/application";
|
} from "@k8slens/application";
|
||||||
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
||||||
import whenAppIsReadyInjectable from "./start-application/when-app-is-ready.injectable";
|
import whenAppIsReadyInjectable from "./start-application/when-app-is-ready.injectable";
|
||||||
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./start-application/time-slots";
|
import * as timeSlots from "./start-application/time-slots";
|
||||||
|
|
||||||
describe("starting-of-electron-main-application", () => {
|
describe("starting-of-electron-main-application", () => {
|
||||||
let di: DiContainer;
|
let di: DiContainer;
|
||||||
@ -30,13 +30,13 @@ describe("starting-of-electron-main-application", () => {
|
|||||||
const beforeAnythingIsLoadingInjectable = getInjectable({
|
const beforeAnythingIsLoadingInjectable = getInjectable({
|
||||||
id: "before-anything",
|
id: "before-anything",
|
||||||
instantiate: () => ({ run: beforeAnythingMock }),
|
instantiate: () => ({ run: beforeAnythingMock }),
|
||||||
injectionToken: beforeAnythingInjectionToken,
|
injectionToken: timeSlots.beforeAnythingInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
const beforeElectronIsReadyIsLoadingInjectable = getInjectable({
|
const beforeElectronIsReadyIsLoadingInjectable = getInjectable({
|
||||||
id: "before-electron-is-ready",
|
id: "before-electron-is-ready",
|
||||||
instantiate: () => ({ run: beforeElectronIsReadyMock }),
|
instantiate: () => ({ run: beforeElectronIsReadyMock }),
|
||||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
injectionToken: timeSlots.beforeElectronIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
const beforeApplicationIsLoadingInjectable = getInjectable({
|
const beforeApplicationIsLoadingInjectable = getInjectable({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user