Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit f90314b

Browse files
committed
test(console): assert actual ordering in cluster-usage card/column tests
The standard-card test used arrayContaining and the extended-column test used toContain, so neither actually verified the rendered order. Pin the exact card order (CPU, Memory, Storage, Pods) and assert the extended columns follow extendedKeys order via their header indices. Address review feedback on the cluster-usage component tests. Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 4c1e11b commit f90314b

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎apps/console/src/components/cluster-usage/ClusterUsageAggregates.test.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ describe("ClusterUsageAggregates", () => {
4646

4747
it("renders the four standard cards in order CPU, Memory, Storage, Pods", () => {
4848
render(<ClusterUsageAggregates aggregates={empty()} nodeSummary={summary()} />)
49-
const headings = screen.getAllByText(/CPU|Memory|Storage|Pods/i)
49+
const headings = screen.getAllByText(/^(CPU|Memory|Storage|Pods)$/)
5050
const labels = headings.map((h) => h.textContent)
51-
expect(labels).toEqual(
52-
expect.arrayContaining(["CPU", "Memory", "Storage", "Pods"]),
53-
)
51+
// Exact array (not arrayContaining) so the card order is actually pinned.
52+
expect(labels).toEqual(["CPU", "Memory", "Storage", "Pods"])
5453
})
5554

5655
it("does not render the extended-resources section when none are present", () => {

‎apps/console/src/components/cluster-usage/ClusterUsageTable.test.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ describe("ClusterUsageTable", () => {
9595
/>,
9696
)
9797
const headers = screen.getAllByRole("columnheader").map((h) => h.textContent)
98-
expect(headers).toContain("nvidia.com/gpu")
99-
expect(headers).toContain("amd.com/gpu")
98+
const nvidiaAt = headers.indexOf("nvidia.com/gpu")
99+
const amdAt = headers.indexOf("amd.com/gpu")
100+
expect(nvidiaAt).toBeGreaterThanOrEqual(0)
101+
expect(amdAt).toBeGreaterThanOrEqual(0)
102+
// Columns must follow extendedKeys order: nvidia before amd.
103+
expect(nvidiaAt).toBeLessThan(amdAt)
100104
})
101105

102106
it("renders em dash in extended-resource cell when the node does not expose it", () => {

0 commit comments

Comments
 (0)