diff --git a/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts b/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts index 5a993ebd7088..25190598f443 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/databases/util.spec.ts @@ -25,7 +25,7 @@ describe("Getting nodes by region string", () => { "3": "region3", }; const result = getNodesByRegionString(nodes, regions, false); - assert.deepStrictEqual(result, `region1(n1), region2(n2), region3(n3)`); + expect(result).toEqual(`region1(n1), region2(n2), region3(n3)`); }); it("when all nodes same region", () => { @@ -36,7 +36,7 @@ describe("Getting nodes by region string", () => { "3": "region1", }; const result = getNodesByRegionString(nodes, regions, false); - assert.deepStrictEqual(result, `region1(n1,n2,n3)`); + expect(result).toEqual(`region1(n1,n2,n3)`); }); it("when some nodes different regions", () => { @@ -47,14 +47,14 @@ describe("Getting nodes by region string", () => { "3": "region2", }; const result = getNodesByRegionString(nodes, regions, false); - assert.deepStrictEqual(result, `region1(n1,n2), region2(n3)`); + expect(result).toEqual(`region1(n1,n2), region2(n3)`); }); it("when region map is empty", () => { const nodes = [1, 2, 3]; const regions = {}; const result = getNodesByRegionString(nodes, regions, false); - assert.deepStrictEqual(result, `undefined(n1,n2,n3)`); + expect(result).toEqual(""); }); it("when nodes are empty", () => { @@ -65,7 +65,7 @@ describe("Getting nodes by region string", () => { "3": "region2", }; const result = getNodesByRegionString(nodes, regions, false); - assert.deepStrictEqual(result, ""); + expect(result).toEqual(""); }); }); }); @@ -74,19 +74,13 @@ describe("Normalize privileges", () => { it("sorts correctly when input is disordered", () => { const privs = ["CREATE", "DELETE", "UPDATE", "ALL", "GRANT"]; const result = normalizePrivileges(privs); - assert.deepStrictEqual(result, [ - "ALL", - "CREATE", - "GRANT", - "UPDATE", - "DELETE", - ]); + expect(result).toEqual(["ALL", "CREATE", "GRANT", "UPDATE", "DELETE"]); }); it("removes duplicates", () => { const privs = ["CREATE", "CREATE", "UPDATE", "ALL", "GRANT"]; const result = normalizePrivileges(privs); - assert.deepStrictEqual(result, ["ALL", "CREATE", "GRANT", "UPDATE"]); + expect(result).toEqual(["ALL", "CREATE", "GRANT", "UPDATE"]); }); }); @@ -94,12 +88,12 @@ describe("Normalize roles", () => { it("sorts correctly when input is disordered", () => { const roles = ["public", "root", "admin"]; const result = normalizeRoles(roles); - assert.deepStrictEqual(result, ["root", "admin", "public"]); + expect(result).toEqual(["root", "admin", "public"]); }); it("removes duplicates", () => { const roles = ["public", "admin", "admin"]; const result = normalizeRoles(roles); - assert.deepStrictEqual(result, ["admin", "public"]); + expect(result).toEqual(["admin", "public"]); }); }); diff --git a/pkg/ui/workspaces/cluster-ui/src/databases/util.tsx b/pkg/ui/workspaces/cluster-ui/src/databases/util.tsx index bf43759bf382..2a831dfef803 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databases/util.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databases/util.tsx @@ -108,6 +108,10 @@ export function createNodesByRegionMap( ): Record { const nodesByRegionMap: Record = {}; nodes.forEach((node: number) => { + // If the node's region doesn't exist skip it. + if (nodeRegions[node.toString()] == null) { + return; + } const region: string = nodeRegions[node.toString()]; if (nodesByRegionMap[region] == null) { nodesByRegionMap[region] = []; diff --git a/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts b/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts index 25d18e340720..0631d305b6d7 100644 --- a/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts +++ b/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts @@ -407,7 +407,7 @@ describe("Database Details Page", function () { live_percentage: 0.5, }, nodes: [1, 2, 3], - nodesByRegionString: "undefined(n1,n2,n3)", + nodesByRegionString: "", }, }); @@ -437,7 +437,7 @@ describe("Database Details Page", function () { approximate_disk_bytes: 10, }, nodes: [1, 2, 3, 4, 5], - nodesByRegionString: "undefined(n1,n2,n3,n4,n5)", + nodesByRegionString: "", }, }); }); diff --git a/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts b/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts index 354a413104d4..b482367f61e2 100644 --- a/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts +++ b/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts @@ -300,7 +300,7 @@ describe("Database Table Page", function () { totalBytes: 45, sizeInBytes: 23, rangeCount: 56, - nodesByRegionString: "undefined(n1,n2,n3,n4,n5)", + nodesByRegionString: "", }); });