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

Commit a4dc332

Browse files
committed
test(console): use getAllByTitle instead of direct DOM queries
Replace document.querySelectorAll lookups for the pods-unavailable tooltip with screen.getAllByTitle so the assertions go through Testing Library's accessible queries and are less brittle to DOM structure. Address review feedback on the cluster-usage page and aggregates tests. Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent b06c208 commit a4dc332

2 files changed

Lines changed: 6 additions & 8 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
@@ -109,9 +109,8 @@ describe("ClusterUsageAggregates", () => {
109109
)
110110
// The numeric Requested value should not be visible; em dashes appear
111111
// and at least one element has the explanatory tooltip on title.
112-
const tooltipNodes = document.querySelectorAll(
113-
'[title="Requires cluster-wide pod read access"]',
114-
)
115-
expect(tooltipNodes.length).toBeGreaterThan(0)
112+
expect(
113+
screen.getAllByTitle("Requires cluster-wide pod read access").length,
114+
).toBeGreaterThan(0)
116115
})
117116
})

‎apps/console/src/routes/ClusterUsagePage.test.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ describe("ClusterUsagePage", () => {
143143
})
144144
renderWithK8sProvider(<ClusterUsagePage />, { client })
145145
await screen.findAllByText(/allocatable/i)
146-
const tooltipNodes = document.querySelectorAll(
147-
'[title="Requires cluster-wide pod read access"]',
148-
)
149-
expect(tooltipNodes.length).toBeGreaterThan(0)
146+
expect(
147+
screen.getAllByTitle("Requires cluster-wide pod read access").length,
148+
).toBeGreaterThan(0)
150149
})
151150

152151
it("renders the node-summary line in the aggregates header", async () => {

0 commit comments

Comments
 (0)