-
Notifications
You must be signed in to change notification settings - Fork 282
refactor: extract shared UI components (Phase 08) #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
reachrazamair
merged 4 commits into
RunMaestro:rc
from
jSydorowicz21:dedup/phase-08-shared-ui-components
Apr 16, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b74b631
refactor: extract shared UI components (Phase 08)
jSydorowicz21 8ed6903
fix: TransferProgressModal close handler bug and accessibility labels
jSydorowicz21 0201f5f
fix: add testId prop to Spinner component for stable test selectors
jSydorowicz21 d96adf6
chore: retrigger CI
jSydorowicz21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/__tests__/renderer/components/ui/EmptyStatePlaceholder.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /** | ||
| * Tests for EmptyStatePlaceholder component | ||
| */ | ||
|
|
||
| import { describe, it, expect } from 'vitest'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { EmptyStatePlaceholder } from '../../../../renderer/components/ui/EmptyStatePlaceholder'; | ||
| import type { Theme } from '../../../../renderer/types'; | ||
|
|
||
| const mockTheme: Theme = { | ||
| id: 'test-theme', | ||
| name: 'Test Theme', | ||
| mode: 'dark', | ||
| colors: { | ||
| bgMain: '#1a1a1a', | ||
| bgSidebar: '#242424', | ||
| bgActivity: '#2a2a2a', | ||
| textMain: '#ffffff', | ||
| textDim: '#888888', | ||
| accent: '#3b82f6', | ||
| accentForeground: '#ffffff', | ||
| border: '#333333', | ||
| error: '#ef4444', | ||
| success: '#22c55e', | ||
| warning: '#f59e0b', | ||
| cursor: '#ffffff', | ||
| terminalBg: '#1a1a1a', | ||
| }, | ||
| }; | ||
|
|
||
| describe('EmptyStatePlaceholder', () => { | ||
| it('renders title only', () => { | ||
| render(<EmptyStatePlaceholder theme={mockTheme} title="No items" />); | ||
| expect(screen.getByText('No items')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders icon when provided', () => { | ||
| render( | ||
| <EmptyStatePlaceholder theme={mockTheme} title="No items" icon={<svg data-testid="icon" />} /> | ||
| ); | ||
| expect(screen.getByTestId('icon')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders description when provided', () => { | ||
| render( | ||
| <EmptyStatePlaceholder | ||
| theme={mockTheme} | ||
| title="Empty" | ||
| description="Try adjusting your filters" | ||
| /> | ||
| ); | ||
| expect(screen.getByText('Try adjusting your filters')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders action when provided', () => { | ||
| render( | ||
| <EmptyStatePlaceholder theme={mockTheme} title="Empty" action={<button>Clear</button>} /> | ||
| ); | ||
| expect(screen.getByRole('button', { name: 'Clear' })).toBeInTheDocument(); | ||
| }); | ||
| }); |
71 changes: 71 additions & 0 deletions
71
src/__tests__/renderer/components/ui/GhostIconButton.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * Tests for GhostIconButton component | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { render, screen, fireEvent } from '@testing-library/react'; | ||
| import { GhostIconButton } from '../../../../renderer/components/ui/GhostIconButton'; | ||
|
|
||
| describe('GhostIconButton', () => { | ||
| it('renders children and default classes', () => { | ||
| render( | ||
| <GhostIconButton ariaLabel="Close"> | ||
| <span data-testid="icon">x</span> | ||
| </GhostIconButton> | ||
| ); | ||
| const btn = screen.getByRole('button', { name: 'Close' }); | ||
| expect(btn).toBeInTheDocument(); | ||
| expect(btn).toHaveClass('rounded'); | ||
| expect(btn).toHaveClass('hover:bg-white/10'); | ||
| expect(btn).toHaveClass('p-1'); | ||
| expect(screen.getByTestId('icon')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('calls onClick when clicked', () => { | ||
| const onClick = vi.fn(); | ||
| render( | ||
| <GhostIconButton onClick={onClick} ariaLabel="Do it"> | ||
| <span>x</span> | ||
| </GhostIconButton> | ||
| ); | ||
| fireEvent.click(screen.getByRole('button', { name: 'Do it' })); | ||
| expect(onClick).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('respects disabled prop', () => { | ||
| const onClick = vi.fn(); | ||
| render( | ||
| <GhostIconButton onClick={onClick} disabled ariaLabel="Disabled"> | ||
| <span>x</span> | ||
| </GhostIconButton> | ||
| ); | ||
| const btn = screen.getByRole('button', { name: 'Disabled' }); | ||
| expect(btn).toBeDisabled(); | ||
| fireEvent.click(btn); | ||
| expect(onClick).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('applies custom padding', () => { | ||
| render( | ||
| <GhostIconButton padding="p-2" ariaLabel="Pad"> | ||
| <span>x</span> | ||
| </GhostIconButton> | ||
| ); | ||
| expect(screen.getByRole('button', { name: 'Pad' })).toHaveClass('p-2'); | ||
| }); | ||
|
|
||
| it('stops propagation when stopPropagation is true', () => { | ||
| const parentClick = vi.fn(); | ||
| const onClick = vi.fn(); | ||
| render( | ||
| <div onClick={parentClick}> | ||
| <GhostIconButton onClick={onClick} stopPropagation ariaLabel="Stop"> | ||
| <span>x</span> | ||
| </GhostIconButton> | ||
| </div> | ||
| ); | ||
| fireEvent.click(screen.getByRole('button', { name: 'Stop' })); | ||
| expect(onClick).toHaveBeenCalledTimes(1); | ||
| expect(parentClick).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * Tests for Spinner component | ||
| */ | ||
|
|
||
| import { describe, it, expect } from 'vitest'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { Spinner } from '../../../../renderer/components/ui/Spinner'; | ||
|
|
||
| describe('Spinner', () => { | ||
| it('renders with default size', () => { | ||
| render(<Spinner />); | ||
| const icon = screen.getByTestId('loader2-icon'); | ||
| expect(icon).toBeInTheDocument(); | ||
| expect(icon).toHaveClass('animate-spin'); | ||
| expect(icon).toHaveStyle({ width: '16px', height: '16px' }); | ||
| }); | ||
|
|
||
| it('applies custom size', () => { | ||
| render(<Spinner size={32} />); | ||
| const icon = screen.getByTestId('loader2-icon'); | ||
| expect(icon).toHaveStyle({ width: '32px', height: '32px' }); | ||
| }); | ||
|
|
||
| it('applies custom color', () => { | ||
| render(<Spinner color="rgb(255, 0, 0)" />); | ||
| const icon = screen.getByTestId('loader2-icon'); | ||
| expect(icon).toHaveStyle({ color: 'rgb(255, 0, 0)' }); | ||
| }); | ||
|
|
||
| it('merges custom className', () => { | ||
| render(<Spinner className="text-blue-500" />); | ||
| const icon = screen.getByTestId('loader2-icon'); | ||
| expect(icon).toHaveClass('animate-spin'); | ||
| expect(icon).toHaveClass('text-blue-500'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.