1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove console logs and fix stubs to fix tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-02-24 15:44:04 -05:00
parent d2d4ffbe5b
commit 45b22ff159

View File

@ -46,7 +46,6 @@ import { renderFor } from "./renderFor";
import { RootFrame } from "../../frames/root-frame/root-frame"; import { RootFrame } from "../../frames/root-frame/root-frame";
import { ClusterFrame } from "../../frames/cluster-frame/cluster-frame"; import { ClusterFrame } from "../../frames/cluster-frame/cluster-frame";
import hostedClusterIdInjectable from "../../cluster-frame-context/hosted-cluster-id.injectable"; import hostedClusterIdInjectable from "../../cluster-frame-context/hosted-cluster-id.injectable";
import activeKubernetesClusterInjectable from "../../cluster-frame-context/active-kubernetes-cluster.injectable";
import { catalogEntityFromCluster } from "../../../main/cluster/manager"; import { catalogEntityFromCluster } from "../../../main/cluster/manager";
import namespaceStoreInjectable from "../+namespaces/store.injectable"; import namespaceStoreInjectable from "../+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";
@ -69,6 +68,7 @@ import fsInjectable from "../../../common/fs/fs.injectable";
import joinPathsInjectable from "../../../common/path/join-paths.injectable"; import joinPathsInjectable from "../../../common/path/join-paths.injectable";
import homeDirectoryPathInjectable from "../../../common/os/home-directory-path.injectable"; import homeDirectoryPathInjectable from "../../../common/os/home-directory-path.injectable";
import { testUsingFakeTime } from "../../../common/test-utils/use-fake-time"; import { testUsingFakeTime } from "../../../common/test-utils/use-fake-time";
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
type Callback = (di: DiContainer) => void | Promise<void>; type Callback = (di: DiContainer) => void | Promise<void>;
@ -249,36 +249,25 @@ export const getApplicationBuilder = () => {
close: () => {}, close: () => {},
loadFile: async () => {}, loadFile: async () => {},
loadUrl: async () => { loadUrl: async () => {
console.log("+beforeWindowStarts");
for (const callback of beforeWindowStartCallbacks) { for (const callback of beforeWindowStartCallbacks) {
await callback(windowDi); await callback(windowDi);
} }
console.log("-beforeWindowStarts");
const startFrame = windowDi.inject(startFrameInjectable); const startFrame = windowDi.inject(startFrameInjectable);
console.log("start frame");
await startFrame(); await startFrame();
console.log("+afterWindowStarts");
for (const callback of afterWindowStartCallbacks) { for (const callback of afterWindowStartCallbacks) {
await callback(windowDi); await callback(windowDi);
} }
console.log("-afterWindowStarts");
const history = windowDi.inject(historyInjectable);
const render = renderFor(windowDi); const render = renderFor(windowDi);
console.log("renderFor"); rendered = render((
<Router history={windowDi.inject(historyInjectable)}>
rendered = render(
<Router history={history}>
<environment.RootComponent /> <environment.RootComponent />
</Router>, </Router>
); ));
console.log("finished application-builder loadUrl");
}, },
send: (arg) => { send: (arg) => {
@ -303,18 +292,13 @@ export const getApplicationBuilder = () => {
const startApplication = async ({ shouldStartHidden }: { shouldStartHidden: boolean }) => { const startApplication = async ({ shouldStartHidden }: { shouldStartHidden: boolean }) => {
mainDi.inject(lensProxyPortInjectable).set(42); mainDi.inject(lensProxyPortInjectable).set(42);
console.log("beforeApplicationStartCallbacks");
for (const callback of beforeApplicationStartCallbacks) { for (const callback of beforeApplicationStartCallbacks) {
await callback(mainDi); await callback(mainDi);
} }
mainDi.override(shouldStartHiddenInjectable, () => shouldStartHidden); mainDi.override(shouldStartHiddenInjectable, () => shouldStartHidden);
console.log("startMainApplication");
await startMainApplication(); await startMainApplication();
console.log("afterApplicationStartCallbacks");
for (const callback of afterApplicationStartCallbacks) { for (const callback of afterApplicationStartCallbacks) {
await callback(mainDi); await callback(mainDi);
} }
@ -519,11 +503,12 @@ export const getApplicationBuilder = () => {
id: "some-cluster-id", id: "some-cluster-id",
accessibleNamespaces: observable.array(), accessibleNamespaces: observable.array(),
shouldShowResource: (kind) => allowedResourcesState.has(formatKubeApiResource(kind)), shouldShowResource: (kind) => allowedResourcesState.has(formatKubeApiResource(kind)),
ready: true,
} as Partial<Cluster> as Cluster; } as Partial<Cluster> as Cluster;
windowDi.override(activeKubernetesClusterInjectable, () => windowDi.inject(catalogEntityRegistryInjectable).updateItems([
computed(() => catalogEntityFromCluster(clusterStub)), catalogEntityFromCluster(clusterStub),
); ]);
windowDi.override(hostedClusterIdInjectable, () => clusterStub.id); windowDi.override(hostedClusterIdInjectable, () => clusterStub.id);
windowDi.override(hostedClusterInjectable, () => clusterStub); windowDi.override(hostedClusterInjectable, () => clusterStub);