mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Render a child subnamespace
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
2d2f2888cd
commit
ecba048c95
@ -128,6 +128,134 @@ exports[`<NamespaceTreeView /> once the subscribe resolves renders namespace wit
|
|||||||
</body>
|
</body>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`<NamespaceTreeView /> once the subscribe resolves renders namespace with children namespaces and a subnamespace 1`] = `
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
data-testid="namespace-tree-view"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="DrawerTitle title"
|
||||||
|
>
|
||||||
|
Tree View
|
||||||
|
</div>
|
||||||
|
<ul
|
||||||
|
aria-multiselectable="false"
|
||||||
|
class="MuiTreeView-root"
|
||||||
|
role="tree"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
aria-expanded="true"
|
||||||
|
class="MuiTreeItem-root Mui-expanded"
|
||||||
|
data-testid="namespace-org-a-1"
|
||||||
|
role="treeitem"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiTreeItem-content"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiTreeItem-iconContainer Component-iconContainer-5"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit"
|
||||||
|
focusable="false"
|
||||||
|
style="width: 14px; height: 14px;"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M22.047 22.074v0 0-20.147 0h-20.12v0 20.147 0h20.12zM22.047 24h-20.12q-.803 0-1.365-.562t-.562-1.365v-20.147q0-.776.562-1.351t1.365-.575h20.147q.776 0 1.351.575t.575 1.351v20.147q0 .803-.575 1.365t-1.378.562v0zM17.873 11.023h-11.826q-.375 0-.669.281t-.294.682v0q0 .401.294 .682t.669.281h11.826q.375 0 .669-.281t.294-.682v0q0-.401-.294-.682t-.669-.281z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="MuiTypography-root MuiTreeItem-label MuiTypography-body1"
|
||||||
|
>
|
||||||
|
org-a
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul
|
||||||
|
class="MuiCollapse-root MuiTreeItem-group Component-group-6 MuiCollapse-entered"
|
||||||
|
role="group"
|
||||||
|
style="min-height: 0px;"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiCollapse-wrapper"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiCollapse-wrapperInner"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
class="MuiTreeItem-root"
|
||||||
|
role="treeitem"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiTreeItem-content"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiTreeItem-iconContainer Component-iconContainer-5"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="MuiSvgIcon-root close MuiSvgIcon-fontSizeInherit"
|
||||||
|
focusable="false"
|
||||||
|
style="width: 14px; height: 14px;"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M17.485 17.512q-.281.281-.682.281t-.696-.268l-4.12-4.147-4.12 4.147q-.294.268-.696.268t-.682-.281-.281-.682.294-.669l4.12-4.147-4.12-4.147q-.294-.268-.294-.669t.281-.682.682-.281.696 .268l4.12 4.147 4.12-4.147q.294-.268.696-.268t.682.281 .281.669-.294.682l-4.12 4.147 4.12 4.147q.294.268 .294.669t-.281.682zM22.047 22.074v0 0-20.147 0h-20.12v0 20.147 0h20.12zM22.047 24h-20.12q-.803 0-1.365-.562t-.562-1.365v-20.147q0-.776.562-1.351t1.365-.575h20.147q.776 0 1.351.575t.575 1.351v20.147q0 .803-.575 1.365t-1.378.562v0z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="MuiTypography-root MuiTreeItem-label MuiTypography-body1"
|
||||||
|
>
|
||||||
|
service-1
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class="MuiTreeItem-root"
|
||||||
|
role="treeitem"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiTreeItem-content"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="MuiTreeItem-iconContainer Component-iconContainer-5"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="MuiSvgIcon-root close MuiSvgIcon-fontSizeInherit"
|
||||||
|
focusable="false"
|
||||||
|
style="width: 14px; height: 14px;"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M17.485 17.512q-.281.281-.682.281t-.696-.268l-4.12-4.147-4.12 4.147q-.294.268-.696.268t-.682-.281-.281-.682.294-.669l4.12-4.147-4.12-4.147q-.294-.268-.294-.669t.281-.682.682-.281.696 .268l4.12 4.147 4.12-4.147q.294-.268.696-.268t.682.281 .281.669-.294.682l-4.12 4.147 4.12 4.147q.294.268 .294.669t-.281.682zM22.047 22.074v0 0-20.147 0h-20.12v0 20.147 0h20.12zM22.047 24h-20.12q-.803 0-1.365-.562t-.562-1.365v-20.147q0-.776.562-1.351t1.365-.575h20.147q.776 0 1.351.575t.575 1.351v20.147q0 .803-.575 1.365t-1.378.562v0z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="MuiTypography-root MuiTreeItem-label MuiTypography-body1"
|
||||||
|
>
|
||||||
|
team-c
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`<NamespaceTreeView /> once the subscribe resolves renders null with regular namespace 1`] = `
|
exports[`<NamespaceTreeView /> once the subscribe resolves renders null with regular namespace 1`] = `
|
||||||
<body>
|
<body>
|
||||||
<div />
|
<div />
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import { NamespaceTreeView } from "./namespace-tree-view";
|
|||||||
import type { NamespaceStore } from "./store";
|
import type { NamespaceStore } from "./store";
|
||||||
import namespaceStoreInjectable from "./store.injectable";
|
import namespaceStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
function createNamespace(name: string, labels?: Record<string, string>): Namespace {
|
function createNamespace(name: string, labels?: Record<string, string>, annotations?: Record<string, string>): Namespace {
|
||||||
return new Namespace({
|
return new Namespace({
|
||||||
apiVersion: "v1",
|
apiVersion: "v1",
|
||||||
kind: "Namespace",
|
kind: "Namespace",
|
||||||
@ -32,6 +32,9 @@ function createNamespace(name: string, labels?: Record<string, string>): Namespa
|
|||||||
uid: `${name}-1`,
|
uid: `${name}-1`,
|
||||||
labels: {
|
labels: {
|
||||||
...labels
|
...labels
|
||||||
|
},
|
||||||
|
annotations: {
|
||||||
|
...annotations
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -45,6 +48,10 @@ const acmeGroup = createNamespace("acme-org", {
|
|||||||
"hnc.x-k8s.io/included-namespace": "true",
|
"hnc.x-k8s.io/included-namespace": "true",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const orgA = createNamespace("org-a", {
|
||||||
|
"hnc.x-k8s.io/included-namespace": "true",
|
||||||
|
});
|
||||||
|
|
||||||
const teamA = createNamespace("team-a", {
|
const teamA = createNamespace("team-a", {
|
||||||
"hnc.x-k8s.io/included-namespace": "true",
|
"hnc.x-k8s.io/included-namespace": "true",
|
||||||
"acme-org.tree.hnc.x-k8s.io/depth": "1",
|
"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",
|
"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("<NamespaceTreeView />", () => {
|
describe("<NamespaceTreeView />", () => {
|
||||||
let di: DiContainer;
|
let di: DiContainer;
|
||||||
let render: DiRender;
|
let render: DiRender;
|
||||||
@ -114,8 +137,11 @@ describe("<NamespaceTreeView />", () => {
|
|||||||
createNamespace("test-4"),
|
createNamespace("test-4"),
|
||||||
createNamespace("test-5"),
|
createNamespace("test-5"),
|
||||||
acmeGroup,
|
acmeGroup,
|
||||||
|
orgA,
|
||||||
teamA,
|
teamA,
|
||||||
teamB,
|
teamB,
|
||||||
|
teamC,
|
||||||
|
service1,
|
||||||
],
|
],
|
||||||
})));
|
})));
|
||||||
});
|
});
|
||||||
@ -135,6 +161,12 @@ describe("<NamespaceTreeView />", () => {
|
|||||||
it("renders namespace with 2 children namespaces", () => {
|
it("renders namespace with 2 children namespaces", () => {
|
||||||
const result = render(<NamespaceTreeView root={acmeGroup} />);
|
const result = render(<NamespaceTreeView root={acmeGroup} />);
|
||||||
|
|
||||||
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders namespace with children namespaces and a subnamespace", () => {
|
||||||
|
const result = render(<NamespaceTreeView root={orgA} />);
|
||||||
|
|
||||||
expect(result.baseElement).toMatchSnapshot();
|
expect(result.baseElement).toMatchSnapshot();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user