mirror of
https://github.com/lensapp/lens.git
synced 2025-01-08 17:40:47 +03:00
chore: Fixup unit tests calling 'allowKubeResource' at the wrong time
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
40af0d31c5
commit
6167ad2c25
@ -13,7 +13,6 @@ import type { PodMetricsApi } from "../../../common/k8s-api/endpoints/pod-metric
|
||||
import podMetricsApiInjectable from "../../../common/k8s-api/endpoints/pod-metrics.api.injectable";
|
||||
import type { RequestMetrics } from "../../../common/k8s-api/endpoints/metrics.api/request-metrics.injectable";
|
||||
import requestMetricsInjectable from "../../../common/k8s-api/endpoints/metrics.api/request-metrics.injectable";
|
||||
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||
|
||||
describe("workloads / pods", () => {
|
||||
let rendered: RenderResult;
|
||||
@ -24,19 +23,15 @@ describe("workloads / pods", () => {
|
||||
applicationBuilder = getApplicationBuilder().setEnvironmentToClusterFrame();
|
||||
applicationBuilder.namespaces.add("default");
|
||||
applicationBuilder.beforeWindowStart(({ windowDi }) => {
|
||||
windowDi.override(podMetricsApiInjectable, () => ({
|
||||
list: async () => Promise.resolve(podMetrics),
|
||||
} as PodMetricsApi));
|
||||
});
|
||||
applicationBuilder.afterWindowStart(() => {
|
||||
applicationBuilder.allowKubeResource({
|
||||
apiName: "pods",
|
||||
group: "",
|
||||
});
|
||||
|
||||
windowDi.override(podMetricsApiInjectable, () => ({
|
||||
list: async () => Promise.resolve(podMetrics),
|
||||
} as PodMetricsApi));
|
||||
|
||||
const apiManager = windowDi.inject(apiManagerInjectable);
|
||||
const podStore = windowDi.inject(podStoreInjectable);
|
||||
|
||||
apiManager.registerStore(podStore);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -33,11 +33,14 @@ describe("namespaces route when viewed with some subNamespaces", () => {
|
||||
requestDeleteSubNamespaceAnchorMock = asyncFn();
|
||||
|
||||
builder.beforeWindowStart(({ windowDi }) => {
|
||||
builder.allowKubeResource({ group: "", apiName: "namespaces" });
|
||||
windowDi.override(requestDeleteNormalNamespaceInjectable, () => requestDeleteNormalNamespaceMock);
|
||||
windowDi.override(requestDeleteSubNamespaceAnchorInjectable, () => requestDeleteSubNamespaceAnchorMock);
|
||||
});
|
||||
|
||||
builder.afterWindowStart(() => {
|
||||
builder.allowKubeResource({ group: "", apiName: "namespaces" });
|
||||
});
|
||||
|
||||
result = await builder.render();
|
||||
});
|
||||
|
||||
|
@ -687,8 +687,10 @@ export const getApplicationBuilder = () => {
|
||||
const windowDi = builder.applicationWindow.only.di;
|
||||
const cluster = windowDi.inject(hostedClusterInjectable);
|
||||
|
||||
assert(cluster, "For some reason the hosted cluster is not yet available, are you running in an 'afterWindowStart' callback?");
|
||||
|
||||
runInAction(() => {
|
||||
cluster?.resourcesToShow.add(formatKubeApiResource(resource));
|
||||
cluster.resourcesToShow.add(formatKubeApiResource(resource));
|
||||
});
|
||||
|
||||
return builder;
|
||||
|
Loading…
Reference in New Issue
Block a user