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:
Sebastian Malton authored and GitHub committed 2023-03-13 15:35:33 +02:00
1 parent b99b06980e
commit a63f737adb
62 files changed
+185 -189

No files matched your search

@@ -18,20 +18,18 @@ describe("application-menu-in-legacy-extension-api", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart(
(mainDi) => {
runInAction(() => {
mainDi.register(
someTopMenuItemInjectable,
someNonExtensionBasedMenuItemInjectable,
);
});
builder.beforeApplicationStart(({ mainDi }) => {
runInAction(() => {
mainDi.register(
someTopMenuItemInjectable,
someNonExtensionBasedMenuItemInjectable,
);
});
logErrorMock = jest.fn();
logErrorMock = jest.fn();
mainDi.override(logErrorInjectable, () => logErrorMock);
},
);
mainDi.override(logErrorInjectable, () => logErrorMock);
});
await builder.startHidden();
});
@@ -20,7 +20,7 @@ describe.each(allPlatforms)("application-menu, given platform is '%s'", (platfor
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(platformInjectable, () => platform);
mainDi.override(
@@ -25,7 +25,7 @@ describe("handling-of-orphan-application-menu-items, given orphan menu item", ()
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
const someOrphanMenuItemInjectable = getInjectable({
id: "some-orphan-menu-item",
instantiate: () => ({
@@ -35,7 +35,7 @@ describe("analytics for installing update", () => {
analyticsListenerMock = jest.fn();
builder.beforeApplicationStart(mainDi => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(getBuildVersionInjectable, () => () => "42.0.0");
checkForPlatformUpdatesMock = asyncFn();
@@ -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();
@@ -24,7 +24,7 @@ describe("installing update using tray", () => {
beforeEach(() => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn();
@@ -35,7 +35,7 @@ describe("force user to update when too long since update was downloaded", () =>
applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeApplicationStart(mainDi => {
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
checkForPlatformUpdatesMock = asyncFn();
mainDi.override(checkForPlatformUpdatesInjectable, () => checkForPlatformUpdatesMock);
@@ -49,7 +49,7 @@ describe("force user to update when too long since update was downloaded", () =>
mainDi.override(quitAndInstallUpdateInjectable, () => quitAndInstallUpdateMock);
});
applicationBuilder.beforeWindowStart(windowDi => {
applicationBuilder.beforeWindowStart(({ windowDi }) => {
windowDi.unoverride(forceUpdateModalRootFrameComponentInjectable);
windowDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable);
@@ -22,7 +22,7 @@ describe("periodical checking of updates", () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.unoverride(periodicalCheckForUpdatesInjectable);
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
@@ -39,7 +39,7 @@ describe("periodical checking of updates", () => {
let rendered: RenderResult;
beforeEach(async () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(electronUpdaterIsActiveInjectable, () => 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", () => {
beforeEach(async () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
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", () => {
beforeEach(async () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(electronUpdaterIsActiveInjectable, () => false);
mainDi.override(publishIsConfiguredInjectable, () => true);
});
@@ -37,7 +37,7 @@ describe("selection of update stability", () => {
beforeEach(() => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
quitAndInstallUpdateMock = jest.fn();
checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn();
@@ -64,7 +64,7 @@ describe("selection of update stability", () => {
mainDi.override(publishIsConfiguredInjectable, () => true);
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
showInfoNotificationMock = jest.fn(() => () => {});
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 () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
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 () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
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 () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(getBuildVersionInjectable, () => () => "1.0.0-beta");
});
@@ -24,7 +24,7 @@ describe("downgrading version update", () => {
beforeEach(() => {
applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeApplicationStart(mainDi => {
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
checkForPlatformUpdatesMock = asyncFn();
mainDi.override(
@@ -32,7 +32,7 @@ describe("installing update", () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
electronQuitAndInstallUpdateMock = jest.fn();
checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn();
@@ -84,7 +84,7 @@ describe("entity running technical tests", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.afterWindowStart((windowDi) => {
builder.afterWindowStart(({ windowDi }) => {
onRun = jest.fn();
const catalogCategoryRegistery = windowDi.inject(catalogCategoryRegistryInjectable);
@@ -26,7 +26,7 @@ describe("opening catalog entity details panel", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
// TODO: remove once ClusterStore can be used without overriding it
windowDi.override(getClusterByIdInjectable, () => (clusterId) => {
if (clusterId === cluster?.id) {
@@ -39,7 +39,7 @@ describe("opening catalog entity details panel", () => {
testUsingFakeTime();
builder.afterWindowStart((windowDi) => {
builder.afterWindowStart(({ windowDi }) => {
clusterEntity = new KubernetesCluster({
metadata: {
labels: {},
@@ -76,17 +76,17 @@ describe("Deleting a cluster", () => {
config = new KubeConfig();
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(kubectlBinaryNameInjectable, () => "kubectl");
mainDi.override(kubectlDownloadingNormalizedArchInjectable, () => "amd64");
mainDi.override(normalizedPlatformInjectable, () => "darwin");
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
openDeleteClusterDialog = windowDi.inject(openDeleteClusterDialogInjectable);
});
builder.afterWindowStart(windowDi => {
builder.afterWindowStart(({ windowDi }) => {
const navigateToCatalog = windowDi.inject(navigateToCatalogInjectable);
navigateToCatalog();
@@ -26,7 +26,7 @@ describe("disable kube object detail items when cluster is not relevant", () =>
builder = getApplicationBuilder();
builder.setEnvironmentToClusterFrame();
builder.afterWindowStart((windowDi) => {
builder.afterWindowStart(({ windowDi }) => {
const apiManager = windowDi.inject(apiManagerInjectable);
const api = {
apiBase: "/apis/some-api-version/some-kind",
@@ -25,7 +25,7 @@ describe("reactively hide kube object detail item", () => {
builder.setEnvironmentToClusterFrame();
builder.afterWindowStart((windowDi) => {
builder.afterWindowStart(({ windowDi }) => {
const apiManager = windowDi.inject(apiManagerInjectable);
const api = {
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.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
});
@@ -25,7 +25,7 @@ describe("reactively hide kube object menu item", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
});
@@ -30,7 +30,7 @@ describe("disable kube object statuses when cluster is not relevant", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
});
@@ -26,7 +26,7 @@ describe("reactively hide kube object status", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
});
@@ -93,7 +93,7 @@ describe("show status for a kube object", () => {
}),
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(
testRouteInjectable,
@@ -36,7 +36,7 @@ describe("cluster/namespaces - edit namespace from new tab", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(
directoryForLensLocalStorageInjectable,
() => "/some-directory-for-lens-local-storage",
@@ -26,7 +26,7 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
callForNamespaceMock = asyncFn();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(
directoryForLensLocalStorageInjectable,
() => "/some-directory-for-lens-local-storage",
@@ -47,7 +47,7 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
let rendered: RenderResult;
beforeEach(async () => {
builder.beforeWindowStart(async (windowDi) => {
builder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
await writeJsonFile(
@@ -21,7 +21,7 @@ describe("cluster - order of sidebar items", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testSidebarItemsInjectable);
});
@@ -35,14 +35,14 @@ describe("cluster - sidebar and tab navigation for core", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(storageSaveDelayInjectable, () => 250);
});
});
describe("given core registrations", () => {
beforeEach(() => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteInjectable);
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", () => {
beforeEach(async () => {
builder.beforeWindowStart(async (windowDi) => {
builder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
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", () => {
beforeEach(async () => {
builder.beforeWindowStart(async (windowDi) => {
builder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
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", () => {
beforeEach(async () => {
builder.beforeWindowStart(async (windowDi) => {
builder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
await writeJsonFileFake(
@@ -34,7 +34,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
applicationBuilder.setEnvironmentToClusterFrame();
applicationBuilder.beforeWindowStart((windowDi) => {
applicationBuilder.beforeWindowStart(({ windowDi }) => {
windowDi.override(storageSaveDelayInjectable, () => 250);
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", () => {
beforeEach(async () => {
applicationBuilder.beforeWindowStart(async (windowDi) => {
applicationBuilder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
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", () => {
beforeEach(async () => {
applicationBuilder.beforeWindowStart(async (windowDi) => {
applicationBuilder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
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", () => {
beforeEach(async () => {
applicationBuilder.beforeWindowStart(async (windowDi) => {
applicationBuilder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable);
await writeJsonFileFake(
@@ -24,7 +24,7 @@ describe("cluster - visibility of sidebar items", () => {
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteInjectable);
windowDi.register(testRouteComponentInjectable);
@@ -16,7 +16,7 @@ describe("order of workload overview details", () => {
beforeEach(async () => {
const builder = getApplicationBuilder();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.unoverride(getRandomIdInjectable);
windowDi.permitSideEffects(getRandomIdInjectable);
@@ -18,7 +18,7 @@ describe("Command Pallet: keyboard shortcut tests", () => {
describe("when on macOS", () => {
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(platformInjectable, () => "darwin");
});
@@ -86,7 +86,7 @@ describe("Command Pallet: keyboard shortcut tests", () => {
describe("when on linux", () => {
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(platformInjectable, () => "linux");
});
@@ -24,7 +24,7 @@ describe("Showing correct entity settings", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
// TODO: remove once ClusterStore can be used without overriding it
windowDi.override(getClusterByIdInjectable, () => (clusterId) => {
if (clusterId === cluster.id) {
@@ -35,7 +35,7 @@ describe("Showing correct entity settings", () => {
});
});
builder.afterWindowStart((windowDi) => {
builder.afterWindowStart(({ windowDi }) => {
clusterEntity = new KubernetesCluster({
metadata: {
labels: {},
@@ -19,7 +19,7 @@ describe("extensions - navigation using application menu", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
focusWindowMock = jest.fn();
windowDi.override(focusWindowInjectable, () => focusWindowMock);
@@ -40,13 +40,13 @@ describe("add custom helm repository in preferences", () => {
showSuccessNotificationMock = jest.fn();
showErrorNotificationMock = jest.fn();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
@@ -35,13 +35,13 @@ describe("add helm repository from list in preferences", () => {
showSuccessNotificationMock = jest.fn();
showErrorNotificationMock = jest.fn();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
windowDi.override(requestPublicHelmRepositoriesInjectable, () => callForPublicHelmRepositoriesMock);
@@ -55,7 +55,7 @@ describe("installing helm chart from new tab", () => {
requestCreateHelmReleaseMock = asyncFn();
requestHelmReleasesMock = asyncFn();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
windowDi.override(requestDetailedHelmReleaseInjectable, () => requestDetailedHelmReleaseMock);
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
@@ -34,7 +34,7 @@ describe("installing helm chart from previously opened tab", () => {
builder.namespaces.add("default");
builder.namespaces.add("some-other-namespace");
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
windowDi.override(requestHelmChartVersionsInjectable, () => requestHelmChartVersionsMock);
windowDi.override(requestHelmChartValuesInjectable, () => requestHelmChartValuesMock);
@@ -52,7 +52,7 @@ describe("installing helm chart from previously opened tab", () => {
let rendered: RenderResult;
beforeEach(async () => {
builder.beforeWindowStart(async (windowDi) => {
builder.beforeWindowStart(async ({ windowDi }) => {
const writeJsonFile = windowDi.inject(writeJsonFileInjectable);
await writeJsonFile(
@@ -38,7 +38,7 @@ describe("opening dock tab for installing helm chart", () => {
requestHelmChartReadmeMock = asyncFn();
requestHelmChartValuesMock = jest.fn();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(directoryForLensLocalStorageInjectable, () => "/some-directory-for-lens-local-storage");
windowDi.override(hostedClusterIdInjectable, () => "some-cluster-id");
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
@@ -41,14 +41,14 @@ describe("listing active helm repositories in preferences", () => {
warn: noop,
};
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(readYamlFileInjectable, () => readYamlFileMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
mainDi.override(loggerInjectable, () => loggerStub);
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(showErrorNotificationInjectable, () => showErrorNotificationMock);
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
});
@@ -28,13 +28,13 @@ describe("remove helm repository from list of active repositories in preferences
execFileMock = asyncFn();
getActiveHelmRepositoriesMock = asyncFn();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(getActiveHelmRepositoriesInjectable, () => getActiveHelmRepositoriesMock);
mainDi.override(execFileInjectable, () => execFileMock);
mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path");
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
});
@@ -35,7 +35,7 @@ describe("New Upgrade Helm Chart Dock Tab", () => {
builder = getApplicationBuilder();
builder.setEnvironmentToClusterFrame();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
requestHelmReleaseConfigurationMock = asyncFn();
windowDi.override(requestHelmReleaseConfigurationInjectable, () => requestHelmReleaseConfigurationMock);
@@ -63,7 +63,7 @@ describe("showing details for helm release", () => {
showSuccessNotificationMock = jest.fn();
showCheckedErrorNotificationMock = jest.fn();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(getRandomUpgradeChartTabIdInjectable, () => () => "some-tab-id");
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
windowDi.override(showCheckedErrorInjectable, () => showCheckedErrorNotificationMock);
@@ -31,7 +31,7 @@ describe("navigating between routes", () => {
let windowDi: DiContainer;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(testRouteWithoutPathParametersInjectable);
windowDi.register(testRouteWithoutPathParametersComponentInjectable);
@@ -107,7 +107,7 @@ describe("navigating between routes", () => {
let windowDi: DiContainer;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(routeWithOptionalPathParametersInjectable);
windowDi.register(routeWithOptionalPathParametersComponentInjectable);
@@ -57,7 +57,7 @@ describe("download logs options in logs dock tab", () => {
getLogsMock = jest.fn();
getSplittedLogsMock = jest.fn();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(callForLogsInjectable, () => callForLogsMock);
// Overriding internals of logsViewModelInjectable
@@ -99,7 +99,7 @@ describe("download logs options in logs dock tab", () => {
beforeEach(async () => {
rendered = await builder.render();
windowDi = builder.applicationWindow.only.di;
const dockStore = windowDi.inject(dockStoreInjectable);
dockStore.closeTab("terminal");
@@ -108,10 +108,10 @@ describe("download logs options in logs dock tab", () => {
describe("when logs not available", () => {
beforeEach(async () => {
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
getLogsMock.mockReturnValue([]);
getSplittedLogsMock.mockReturnValue([]);
createLogsTab({
selectedPod: pod,
selectedContainer: container,
@@ -132,10 +132,10 @@ describe("download logs options in logs dock tab", () => {
describe("when logs available", () => {
beforeEach(async () => {
const createLogsTab = windowDi.inject(createPodLogsTabInjectable);
getLogsMock.mockReturnValue(["some-logs"]);
getSplittedLogsMock.mockReturnValue([...logs]);
createLogsTab({
selectedPod: pod,
selectedContainer: container,
@@ -157,7 +157,7 @@ describe("download logs options in logs dock tab", () => {
describe("when clicking on dropdown", () => {
beforeEach(() => {
const button = rendered.getByTestId("download-logs-dropdown");
act(() => button.click());
});
@@ -182,7 +182,7 @@ describe("download logs options in logs dock tab", () => {
beforeEach(async () => {
await act(async () => {
const button = rendered.getByTestId("download-all-logs");
button.click();
});
});
@@ -193,11 +193,11 @@ describe("download logs options in logs dock tab", () => {
{ "previous": true, "timestamps": false },
);
});
it("shows save dialog with proper attributes", async () => {
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain");
});
it("doesn't block download dropdown for interaction after click", async () => {
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", () => {
it("block download dropdown for interaction when selected 'download all logs'", async () => {
const downloadMenuItem = rendered.getByTestId("download-all-logs");
act(() => downloadMenuItem.click());
await waitFor(() => {
expect(rendered.getByTestId("download-logs-dropdown")).toHaveAttribute("disabled");
});
});
it("doesn't block dropdown for interaction when selected 'download visible logs'", () => {
const downloadMenuItem = rendered.getByTestId("download-visible-logs");
act(() => downloadMenuItem.click());
expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled");
});
});
@@ -233,7 +233,7 @@ describe("download logs options in logs dock tab", () => {
beforeEach(async () => {
await act(async () => {
const button = rendered.getByTestId("download-all-logs");
button.click();
});
});
@@ -241,7 +241,7 @@ describe("download logs options in logs dock tab", () => {
it("doesn't show save dialog", () => {
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
});
it("shows error notification", () => {
expect(showErrorNotificationMock).toHaveBeenCalled();
});
@@ -252,23 +252,23 @@ describe("download logs options in logs dock tab", () => {
beforeEach(() => {
callForLogsMock.mockRejectedValue("error");
});
describe("when selected 'download all logs'", () => {
beforeEach(async () => {
await act(async () => {
const button = rendered.getByTestId("download-all-logs");
button.click();
});
});
it("logs have been called", () => {
expect(callForLogsMock).toHaveBeenCalledWith(
{ name: "dockerExporter", namespace: "default" },
{ "previous": true, "timestamps": false },
);
});
it("doesn't show save dialog", async () => {
expect(openSaveFileDialogMock).not.toHaveBeenCalled();
});
@@ -26,7 +26,7 @@ describe("preferences - closing-preferences", () => {
beforeEach(() => {
builder = getApplicationBuilder();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
runInAction(() => {
windowDi.register(
testPreferenceTabInjectable,
@@ -54,7 +54,7 @@ describe("preferences - closing-preferences", () => {
let windowDi: DiContainer;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(observableHistoryInjectable, () => {
const historyFake = createMemoryHistory({
initialEntries: ["/some-page"],
@@ -135,7 +135,7 @@ describe("preferences - closing-preferences", () => {
let windowDi: DiContainer;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(observableHistoryInjectable, () => {
const historyFake = createMemoryHistory({
initialEntries: ["/preferences/app"],
@@ -70,7 +70,7 @@ describe("preferences - navigation to application preferences", () => {
let discover: Discover;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
const navigateToProxyPreferences = windowDi.inject(navigateToProxyPreferencesInjectable);
navigateToProxyPreferences();
@@ -27,7 +27,7 @@ describe("preferences - navigation to extension specific preferences", () => {
beforeEach(async () => {
logErrorMock = jest.fn();
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(logErrorInjectable, () => logErrorMock);
builder.preferences.navigate();
@@ -22,14 +22,14 @@ describe("preferences - navigation to kubernetes preferences", () => {
let discover: Discover;
beforeEach(async () => {
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(
getActiveHelmRepositoriesInjectable,
() => async () => ({ callWasSuccessful: true, response: [] }),
);
});
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(requestPublicHelmRepositoriesInjectable, () => async () => []);
});
@@ -142,7 +142,7 @@ describe("preferences - navigation to telemetry preferences", () => {
let discover: Discover;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(sentryDataSourceNameInjectable, () => "some-sentry-dns-url");
});
@@ -177,7 +177,7 @@ describe("preferences - navigation to telemetry preferences", () => {
let discover: Discover;
beforeEach(async () => {
builder.beforeWindowStart((windowDi) => {
builder.beforeWindowStart(({ windowDi }) => {
windowDi.override(sentryDataSourceNameInjectable, () => null);
});
@@ -32,7 +32,7 @@ describe("opening application window using tray", () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(focusApplicationInjectable, () => focusApplicationMock);
mainDi.override(
@@ -22,17 +22,15 @@ describe("quitting the app using application menu", () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart(
(mainDi) => {
mainDi.unoverride(stopServicesAndExitAppInjectable);
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.unoverride(stopServicesAndExitAppInjectable);
clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager;
mainDi.override(clusterManagerInjectable, () => clusterManagerStub);
clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager;
mainDi.override(clusterManagerInjectable, () => clusterManagerStub);
exitAppMock = jest.fn();
mainDi.override(exitAppInjectable, () => exitAppMock);
},
);
exitAppMock = jest.fn();
mainDi.override(exitAppInjectable, () => exitAppMock);
});
await builder.render();
});
@@ -21,7 +21,7 @@ describe("resolve-system-proxy", () => {
resolveSystemProxyFromElectronMock = asyncFn();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(
resolveSystemProxyFromElectronInjectable,
() => resolveSystemProxyFromElectronMock,
@@ -16,7 +16,7 @@ describe("status-bar-items-originating-from-extensions", () => {
beforeEach(() => {
applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeWindowStart((windowDi) => {
applicationBuilder.beforeWindowStart(({ windowDi }) => {
windowDi.unoverride(getRandomIdInjectable);
windowDi.permitSideEffects(getRandomIdInjectable);
});
@@ -15,7 +15,7 @@ describe("clicking tray menu item originating from extension", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
logErrorMock = jest.fn();
mainDi.override(logErrorInjectable, () => logErrorMock);
@@ -12,7 +12,7 @@ describe("multiple separators originating from extension", () => {
beforeEach(async () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
builder.beforeApplicationStart(({ mainDi }) => {
mainDi.unoverride(getRandomIdInjectable);
mainDi.permitSideEffects(getRandomIdInjectable);
});
@@ -24,11 +24,11 @@ describe("setting-welcome-page", () => {
describe("given configuration of welcome page route is the default", () => {
beforeEach(async () => {
applicationBuilder.beforeApplicationStart((mainDi) => {
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
mainDi.override(welcomeRouteConfigInjectable, () => "/welcome");
});
applicationBuilder.beforeWindowStart((windowDi) => {
applicationBuilder.beforeWindowStart(({ windowDi }) => {
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", () => {
beforeEach(async () => {
applicationBuilder.beforeApplicationStart((mainDi) => {
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
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");
});