Skip to content

Commit e68d5c0

Browse files
[scanner] 🐛 fix: repair ClusterCardList test selectors for refresh button (#19284)
The ActionTooltipWrapper span carries role="button" (added in PR #19270), which caused getByRole('button', { name: /common\.refresh/i }) to match both the wrapper span and the inner <button> — throwing "Found multiple elements". Fix mirrors the pattern already used in ClusterCardFull.test.tsx: use getAllByRole(...).find(el => el.tagName === 'BUTTON')! to target the actual <button> element. Signed-off-by: hive-scanner <hive-scanner@kubestellar.io> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b93eb8a commit e68d5c0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

web/src/components/clusters/components/__tests__/ClusterCardList.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('ClusterCardList', () => {
9999
it('calls onRefreshCluster when refresh button is clicked', () => {
100100
const onRefreshCluster = vi.fn()
101101
render(<ClusterCardList {...defaultProps} onRefreshCluster={onRefreshCluster} />)
102-
const refreshButton = screen.getByRole('button', { name: /common\.refresh/i })
102+
const refreshButton = screen.getAllByRole('button', { name: /common\.refresh/i }).find(el => el.tagName === 'BUTTON')!
103103
fireEvent.click(refreshButton)
104104
expect(onRefreshCluster).toHaveBeenCalledTimes(1)
105105
})
@@ -108,7 +108,7 @@ describe('ClusterCardList', () => {
108108
const cluster = createMockCluster({ healthy: false, reachable: false })
109109
const onRefreshCluster = vi.fn()
110110
render(<ClusterCardList {...defaultProps} cluster={cluster} onRefreshCluster={onRefreshCluster} />)
111-
const refreshButton = screen.getByRole('button', { name: /cluster\.controlsDisabledOffline/i })
111+
const refreshButton = screen.getAllByRole('button', { name: /cluster\.controlsDisabledOffline/i }).find(el => el.tagName === 'BUTTON')!
112112
expect(refreshButton).toBeDisabled()
113113
})
114114

0 commit comments

Comments
 (0)