Skip to content

[scanner] fix: add tests for cluster utility components#19243

Merged
clubanderson merged 1 commit into
mainfrom
scanner/fix-19240
Jun 20, 2026
Merged

[scanner] fix: add tests for cluster utility components#19243
clubanderson merged 1 commit into
mainfrom
scanner/fix-19240

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Fixes #19240

Adds test coverage for 4 small cluster utility components that were identified as lacking tests:

  • ClusterAuthBadges (183 lines) — Tests rendering of IAM/token/cert badges, login hints, copy buttons
  • ClusterDragReorder (181 lines) — Tests DnD context, sortable items, drag handles
  • ClusterTokenRefresh (185 lines) — Tests refresh spin hook, token expiration, IAM hints, copy button
  • ClusterGrid.common (148 lines) — Tests RemoveClusterButton, ActionTooltipWrapper, keyboard handling

Part of #18599

…Grid.common, DragReorder, TokenRefresh)

Signed-off-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 20, 2026 00:17
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 20, 2026
@netlify

netlify Bot commented Jun 20, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 3eb9320
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a35dc081ffae4000860c28a
😎 Deploy Preview https://deploy-preview-19243.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 20, 2026
@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Test Coverage Check

All new source files in this PR have corresponding test files.

Checked web/src/hooks/ and web/src/components/ against origin/main.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds/updates Vitest + React Testing Library unit tests intended to cover small cluster utility components (auth badges, token refresh helpers, drag reorder wrapper, and ClusterGrid common utilities) as requested in #19240 / #18599.

Changes:

  • Expands ClusterTokenRefresh test coverage for useClusterRefreshSpin, isTokenExpired, getIAMRefreshHint, and CopyCommandButton.
  • Reworks ClusterDragReorder tests and introduces new @dnd-kit mocks.
  • Adds a new ClusterGrid.common utilities test suite under components/__tests__.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
web/src/components/clusters/components/ClusterTokenRefresh.test.tsx Updates tests for refresh spin hook, IAM hint helpers, and clipboard copy UI behavior.
web/src/components/clusters/components/ClusterDragReorder.test.tsx Reworks DnD mocking and rendering assertions for drag-reorder wrapper + sortable item.
web/src/components/clusters/components/ClusterAuthBadges.test.tsx Adds/adjusts tests for auth badges and IAM refresh hint rendering paths.
web/src/components/clusters/components/tests/ClusterGrid.common.test.tsx Introduces a new utilities test file for ClusterGrid.common helpers (duplicates an existing adjacent test file).

Comment on lines +13 to +27
vi.mock('@dnd-kit/core', () => {
const actualCore = vi.importActual('@dnd-kit/core')
return {
...actualCore,
DndContext: ({ children, onDragEnd }: { children: React.ReactNode; onDragEnd?: (event: DragEndEvent) => void }) => {
// Expose onDragEnd for testing via data attribute
return <div data-testid="dnd-context" data-ondragend={onDragEnd ? 'present' : 'absent'}>{children}</div>
},
useSensor: vi.fn(),
useSensors: vi.fn(() => []),
PointerSensor: vi.fn(),
KeyboardSensor: vi.fn(),
closestCenter: vi.fn(),
}
})
Comment on lines +29 to +33
vi.mock('@dnd-kit/sortable', () => {
const actualSortable = vi.importActual('@dnd-kit/sortable')
return {
...actualSortable,
SortableContext: ({ children }: { children: React.ReactNode }) => <div data-testid="sortable-context">{children}</div>,
Comment on lines +67 to 77
it('renders children inside DndContext and SortableContext', () => {
render(
<ClusterDragReorder clusters={mockClusters} layoutMode="grid" onReorder={vi.fn()}>
<div data-testid="child">content</div>
<ClusterDragReorder clusters={mockClusters} layoutMode="grid" onReorder={mockOnReorder}>
<div data-testid="test-child">Test Content</div>
</ClusterDragReorder>,
)

expect(screen.getByTestId('dnd-context')).toBeInTheDocument()
expect(screen.getByTestId('sortable-context')).toBeInTheDocument()
expect(screen.getByTestId('child')).toBeInTheDocument()
expect(lastDragEndHandler).toBeTypeOf('function')
expect(screen.getByTestId('test-child')).toBeInTheDocument()
})
Comment on lines +1 to +8
import { describe, it, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { RemoveClusterButton, ActionTooltipWrapper, handleCardKeyDown } from '../ClusterGrid.common'

vi.mock('react-i18next', () => ({
initReactI18next: { type: '3rdParty', init: () => {} },
useTranslation: () => ({ t: (key: string) => key }),
}))
Comment on lines +174 to 178
const { container } = render(
<div onClick={parentClick} onKeyDown={handleKeyDown} role="button" tabIndex={0}>
<CopyCommandButton text="test" />
</div>,
)
parentClick()
}
}
const { container } = render(
const onRemove = vi.fn()
const parentClick = vi.fn()

const { container } = render(
@clubanderson clubanderson merged commit 99389a1 into main Jun 20, 2026
49 of 57 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the scanner/fix-19240 branch June 20, 2026 01:39
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

❌ Post-Merge Verification: failed

Commit: 99389a19dc9979d9d20911f83cab3b83052ba26a
Specs run: Clusters.spec.ts smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/27856356785

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 99389a19dc9979d9d20911f83cab3b83052ba26a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auto-QA] Write tests for small cluster utility components (AuthBadges, Grid.common, DragReorder, TokenRefresh)

2 participants