mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix edit-namespace-from-new-tab tests
- Get proper syncing of allowed resource to happen Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
4815510019
commit
34713974ed
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,6 @@ import { ClusterFrame } from "../../renderer/frames/cluster-frame/cluster-frame"
|
|||||||
import hostedClusterIdInjectable from "../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
import hostedClusterIdInjectable from "../../renderer/cluster-frame-context/hosted-cluster-id.injectable";
|
||||||
import namespaceStoreInjectable from "../../renderer/components/+namespaces/store.injectable";
|
import namespaceStoreInjectable from "../../renderer/components/+namespaces/store.injectable";
|
||||||
import createApplicationWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-application-window.injectable";
|
import createApplicationWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-application-window.injectable";
|
||||||
import type { CreateElectronWindow } from "../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
|
|
||||||
import createElectronWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
|
import createElectronWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-electron-window.injectable";
|
||||||
import { applicationWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/application-window-injection-token";
|
import { applicationWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/application-window-injection-token";
|
||||||
import closeAllWindowsInjectable from "../../main/start-main-application/lens-window/hide-all-windows/close-all-windows.injectable";
|
import closeAllWindowsInjectable from "../../main/start-main-application/lens-window/hide-all-windows/close-all-windows.injectable";
|
||||||
@ -210,6 +209,57 @@ export const setupInitializingApplicationBuilder = (init: (builder: ApplicationB
|
|||||||
}
|
}
|
||||||
|
|
||||||
let environment = environments.application;
|
let environment = environments.application;
|
||||||
|
let trayMenuIconPath: string;
|
||||||
|
const traySetMenuItemsMock = jest.fn<any, [MinimalTrayMenuItem[]]>();
|
||||||
|
let applicationHasStarted = false;
|
||||||
|
const namespaces = observable.set<string>();
|
||||||
|
const namespaceItems = observable.array<Namespace>();
|
||||||
|
const selectedNamespaces = observable.set<string>();
|
||||||
|
const clusters = observable.map<ClusterId, Cluster>();
|
||||||
|
const clusterId = "some-cluster-id";
|
||||||
|
const clusterKubeconfigPath = "/kube-config-path-for-some-cluster-id";
|
||||||
|
const clusterEntity = new KubernetesCluster({
|
||||||
|
metadata: {
|
||||||
|
labels: {},
|
||||||
|
name: "some-context-name",
|
||||||
|
uid: clusterId,
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
kubeconfigContext: "some-context-name",
|
||||||
|
kubeconfigPath: clusterKubeconfigPath,
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
phase: LensKubernetesClusterStatus.DISCONNECTED,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set up kubeconfig path for cluster
|
||||||
|
{
|
||||||
|
const { writeJsonSync } = mainDi.inject(fsInjectable);
|
||||||
|
|
||||||
|
writeJsonSync(clusterKubeconfigPath, {
|
||||||
|
apiVersion: "v1",
|
||||||
|
clusters: [{
|
||||||
|
cluster: {
|
||||||
|
server: "https://localhost:8979",
|
||||||
|
},
|
||||||
|
name: "some-cluster-name",
|
||||||
|
}],
|
||||||
|
contexts: [{
|
||||||
|
context: {
|
||||||
|
cluster: "some-cluster-name",
|
||||||
|
user: "some-user-name",
|
||||||
|
},
|
||||||
|
name: "some-context-name",
|
||||||
|
}],
|
||||||
|
"current-context": "some-context-name",
|
||||||
|
kind: "Config",
|
||||||
|
preferences: {},
|
||||||
|
users: [{
|
||||||
|
name: "some-user-name",
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
mainDi.override(mainExtensionsInjectable, (di) => {
|
mainDi.override(mainExtensionsInjectable, (di) => {
|
||||||
const mainExtensionsState = di.inject(mainExtensionsStateInjectable);
|
const mainExtensionsState = di.inject(mainExtensionsStateInjectable);
|
||||||
@ -219,10 +269,6 @@ export const setupInitializingApplicationBuilder = (init: (builder: ApplicationB
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let trayMenuIconPath: string;
|
|
||||||
|
|
||||||
const traySetMenuItemsMock = jest.fn<any, [MinimalTrayMenuItem[]]>();
|
|
||||||
|
|
||||||
mainDi.override(electronTrayInjectable, () => ({
|
mainDi.override(electronTrayInjectable, () => ({
|
||||||
start: () => {},
|
start: () => {},
|
||||||
stop: () => {},
|
stop: () => {},
|
||||||
@ -235,7 +281,7 @@ export const setupInitializingApplicationBuilder = (init: (builder: ApplicationB
|
|||||||
const allowedResourcesState = observable.set<string>();
|
const allowedResourcesState = observable.set<string>();
|
||||||
const windowHelpers = new Map<string, { di: DiContainer; getRendered: () => RenderResult }>();
|
const windowHelpers = new Map<string, { di: DiContainer; getRendered: () => RenderResult }>();
|
||||||
|
|
||||||
const createElectronWindowFake: CreateElectronWindow = (configuration) => {
|
mainDi.override(createElectronWindowInjectable, () => (configuration) => {
|
||||||
const windowId = configuration.id;
|
const windowId = configuration.id;
|
||||||
const windowDi = getRendererDi({ doGeneralOverrides: true });
|
const windowDi = getRendererDi({ doGeneralOverrides: true });
|
||||||
let rendered: RenderResult;
|
let rendered: RenderResult;
|
||||||
@ -306,31 +352,8 @@ export const setupInitializingApplicationBuilder = (init: (builder: ApplicationB
|
|||||||
throw new Error("Tried to reload application window which is not implemented yet.");
|
throw new Error("Tried to reload application window which is not implemented yet.");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
mainDi.override(createElectronWindowInjectable, () => createElectronWindowFake);
|
|
||||||
|
|
||||||
let applicationHasStarted = false;
|
|
||||||
|
|
||||||
const namespaces = observable.set<string>();
|
|
||||||
const namespaceItems = observable.array<Namespace>();
|
|
||||||
const selectedNamespaces = observable.set<string>();
|
|
||||||
const clusters = observable.map<ClusterId, Cluster>();
|
|
||||||
const clusterId = "some-cluster-id";
|
|
||||||
const clusterEntity = new KubernetesCluster({
|
|
||||||
metadata: {
|
|
||||||
labels: {},
|
|
||||||
name: "some-context-name",
|
|
||||||
uid: clusterId,
|
|
||||||
},
|
|
||||||
spec: {
|
|
||||||
kubeconfigContext: "some-context-name",
|
|
||||||
kubeconfigPath: "/some-kube-config-path",
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
phase: LensKubernetesClusterStatus.DISCONNECTED,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const startMainApplication = mainDi.inject(startMainApplicationInjectable);
|
const startMainApplication = mainDi.inject(startMainApplicationInjectable);
|
||||||
|
|
||||||
const startApplication = async ({ shouldStartHidden }: { shouldStartHidden: boolean }) => {
|
const startApplication = async ({ shouldStartHidden }: { shouldStartHidden: boolean }) => {
|
||||||
@ -387,7 +410,7 @@ export const setupInitializingApplicationBuilder = (init: (builder: ApplicationB
|
|||||||
const cluster = createCluster({
|
const cluster = createCluster({
|
||||||
contextName: "some-context-name",
|
contextName: "some-context-name",
|
||||||
id: clusterId,
|
id: clusterId,
|
||||||
kubeConfigPath: "/some-kube-config-path",
|
kubeConfigPath: clusterKubeconfigPath,
|
||||||
}, {
|
}, {
|
||||||
clusterServerUrl: "https://some-url.com:8797",
|
clusterServerUrl: "https://some-url.com:8797",
|
||||||
});
|
});
|
||||||
@ -610,11 +633,16 @@ export const setupInitializingApplicationBuilder = (init: (builder: ApplicationB
|
|||||||
selectSingle: () => {},
|
selectSingle: () => {},
|
||||||
getByPath: () => undefined,
|
getByPath: () => undefined,
|
||||||
pickOnlySelected: () => [],
|
pickOnlySelected: () => [],
|
||||||
|
isSelected: () => false,
|
||||||
isSelectedAll: () => false,
|
isSelectedAll: () => false,
|
||||||
getTotalCount: () => namespaceItems.length,
|
getTotalCount: () => namespaceItems.length,
|
||||||
} as Partial<NamespaceStore> as NamespaceStore));
|
} as Partial<NamespaceStore> as NamespaceStore));
|
||||||
|
|
||||||
await clusters.get(clusterId)?.activate();
|
const cluster = clusters.get(clusterId);
|
||||||
|
|
||||||
|
assert(cluster, "When in cluster frame, cluster must exist");
|
||||||
|
|
||||||
|
await cluster.activate();
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.afterWindowStart(windowDi => {
|
builder.afterWindowStart(windowDi => {
|
||||||
|
|||||||
@ -103,7 +103,6 @@ class NonInjectedItemListLayoutContent<
|
|||||||
store, hasDetailsView, onDetails,
|
store, hasDetailsView, onDetails,
|
||||||
copyClassNameFromHeadCells, customizeTableRowProps = () => ({}), detailsItem,
|
copyClassNameFromHeadCells, customizeTableRowProps = () => ({}), detailsItem,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isSelected } = store;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
@ -117,7 +116,7 @@ class NonInjectedItemListLayoutContent<
|
|||||||
{isSelectable && (
|
{isSelectable && (
|
||||||
<TableCell
|
<TableCell
|
||||||
checkbox
|
checkbox
|
||||||
isChecked={isSelected(item)}
|
isChecked={store.isSelected(item)}
|
||||||
onClick={prevDefault(() => store.toggleSelection(item))}
|
onClick={prevDefault(() => store.toggleSelection(item))}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user