From ecba048c95712a6903362ef953d7523c80fa34cf Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Tue, 31 Jan 2023 13:12:33 +0300 Subject: [PATCH] Render a child subnamespace Signed-off-by: Alex Andreev --- .../namespace-tree-view.test.tsx.snap | 128 ++++++++++++++++++ .../+namespaces/namespace-tree-view.test.tsx | 34 ++++- 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap b/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap index 33fa830569..b24e40bf88 100644 --- a/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap +++ b/packages/core/src/renderer/components/+namespaces/__snapshots__/namespace-tree-view.test.tsx.snap @@ -128,6 +128,134 @@ exports[` once the subscribe resolves renders namespace wit `; +exports[` once the subscribe resolves renders namespace with children namespaces and a subnamespace 1`] = ` + +
+
+
+ Tree View +
+
    +
  • +
    +
    + +
    +
    + org-a +
    +
    +
      +
      +
      +
    • +
      +
      + +
      +
      + service-1 +
      +
      +
    • +
    • +
      +
      + +
      +
      + team-c +
      +
      +
    • +
      +
      +
    +
  • +
+
+
+ +`; + exports[` once the subscribe resolves renders null with regular namespace 1`] = `
diff --git a/packages/core/src/renderer/components/+namespaces/namespace-tree-view.test.tsx b/packages/core/src/renderer/components/+namespaces/namespace-tree-view.test.tsx index 015c1b81c3..55b61d7517 100644 --- a/packages/core/src/renderer/components/+namespaces/namespace-tree-view.test.tsx +++ b/packages/core/src/renderer/components/+namespaces/namespace-tree-view.test.tsx @@ -21,7 +21,7 @@ import { NamespaceTreeView } from "./namespace-tree-view"; import type { NamespaceStore } from "./store"; import namespaceStoreInjectable from "./store.injectable"; -function createNamespace(name: string, labels?: Record): Namespace { +function createNamespace(name: string, labels?: Record, annotations?: Record): Namespace { return new Namespace({ apiVersion: "v1", kind: "Namespace", @@ -32,6 +32,9 @@ function createNamespace(name: string, labels?: Record): Namespa uid: `${name}-1`, labels: { ...labels + }, + annotations: { + ...annotations } }, }); @@ -45,6 +48,10 @@ const acmeGroup = createNamespace("acme-org", { "hnc.x-k8s.io/included-namespace": "true", }); +const orgA = createNamespace("org-a", { + "hnc.x-k8s.io/included-namespace": "true", +}); + const teamA = createNamespace("team-a", { "hnc.x-k8s.io/included-namespace": "true", "acme-org.tree.hnc.x-k8s.io/depth": "1", @@ -59,6 +66,22 @@ const teamB = createNamespace("team-b", { "team-b.tree.hnc.x-k8s.io/depth": "0", }); +const teamC = createNamespace("team-c", { + "hnc.x-k8s.io/included-namespace": "true", + "org-a.tree.hnc.x-k8s.io/depth": "1", + "kubernetes.io/metadata.name": "team-c", + "team-c.tree.hnc.x-k8s.io/depth": "0", +}); + +const service1 = createNamespace("service-1", { + "hnc.x-k8s.io/included-namespace": "true", + "org-a.tree.hnc.x-k8s.io/depth": "1", + "kubernetes.io/metadata.name": "team-c", + "service-1.tree.hnc.x-k8s.io/depth": "0", +}, { + "hnc.x-k8s.io/subnamespace-of": "org-a", +}); + describe("", () => { let di: DiContainer; let render: DiRender; @@ -114,8 +137,11 @@ describe("", () => { createNamespace("test-4"), createNamespace("test-5"), acmeGroup, + orgA, teamA, teamB, + teamC, + service1, ], }))); }); @@ -135,6 +161,12 @@ describe("", () => { it("renders namespace with 2 children namespaces", () => { const result = render(); + expect(result.baseElement).toMatchSnapshot(); + }); + + it("renders namespace with children namespaces and a subnamespace", () => { + const result = render(); + expect(result.baseElement).toMatchSnapshot(); }) });