mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* feat: show variant label on model picker and add folder upload for agents/commands
- Replace three-dot variant menu trigger with selected variant label
- Add POST /api/settings/opencode-directory-files/install endpoint
- Upload agents/commands markdown folders into .config/opencode/{agents,commands}/
- Reload OpenCode server after upload so files are picked up
* fix: revalidate branch/git caches when mobile sheet opens and on vcs.branch.updated SSE
- add shared invalidateRepoGitCaches() helper for consistent invalidation
- revalidate repo list when mobile repo quick-switch sheet opens
- revalidate current repo when mobile More drawer opens
- revalidate repo/git caches when Source Control dialog opens
- handle vcs.branch.updated SSE event with optimistic cache update
- use helper in branch create/switch mutations in useGit and BranchesTab
* style: make variant selector look more like a button with chevron and compact sizing
* refactor: consolidate settings editors, add folder upload support, and clean up unused code
* refactor: consolidate settings editors, add folder upload support, and clean up unused code
* feat: add opencode-directory-files listing service and consolidate settings editors
* fix: distinguish scroll from tap in suggestion popups on touch devices
* refactor: consolidate settings editors and add DirectoryFilesList component
* refactor: target repo status cache updates only to affected batch entries
* refactor: streamline settings, git hooks, and query invalidation logic
107 lines
3.5 KiB
TypeScript
107 lines
3.5 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import { describe, it, expect, vi } from 'vitest'
|
|
import { SettingsList, SettingsListRow } from './settings-list'
|
|
|
|
describe('SettingsList', () => {
|
|
it('renders emptyTitle and emptyHint when isEmpty and no children visible', () => {
|
|
render(
|
|
<SettingsList isEmpty emptyTitle="Nothing here" emptyHint="Try adding something">
|
|
<div>child</div>
|
|
</SettingsList>,
|
|
)
|
|
expect(screen.getByText('Nothing here')).toBeInTheDocument()
|
|
expect(screen.getByText('Try adding something')).toBeInTheDocument()
|
|
expect(screen.queryByText('child')).not.toBeInTheDocument()
|
|
expect(screen.getByText('Nothing here').parentElement).toHaveClass('max-h-40')
|
|
})
|
|
|
|
it('renders loadingLabel when isLoading', () => {
|
|
render(
|
|
<SettingsList isEmpty={false} isLoading loadingLabel="Please wait...">
|
|
<div>child</div>
|
|
</SettingsList>,
|
|
)
|
|
expect(screen.getByText('Please wait...')).toBeInTheDocument()
|
|
})
|
|
|
|
it('renders error.message when error passed', () => {
|
|
render(
|
|
<SettingsList isEmpty={false} error={new Error('Something broke')}>
|
|
<div>child</div>
|
|
</SettingsList>,
|
|
)
|
|
expect(screen.getByText('Something broke')).toBeInTheDocument()
|
|
})
|
|
})
|
|
|
|
describe('SettingsListRow', () => {
|
|
it('renders title, description, and badges content', () => {
|
|
render(
|
|
<SettingsListRow
|
|
title="Row Title"
|
|
description="Row description"
|
|
badges={<span data-testid="badge">Badge</span>}
|
|
/>,
|
|
)
|
|
expect(screen.getByText('Row Title')).toBeInTheDocument()
|
|
expect(screen.getByText('Row description')).toBeInTheDocument()
|
|
expect(screen.getByTestId('badge')).toHaveTextContent('Badge')
|
|
})
|
|
|
|
it('calls primaryAction.onClick when primary action button is clicked', async () => {
|
|
const user = userEvent.setup()
|
|
const onClick = vi.fn()
|
|
render(<SettingsListRow title="Row" primaryAction={{ label: 'Do It', onClick }} />)
|
|
|
|
await user.click(screen.getByText('Do It'))
|
|
expect(onClick).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('fires row onClick when row body is clicked and does not fire when action-column button is clicked', async () => {
|
|
const user = userEvent.setup()
|
|
const rowClick = vi.fn()
|
|
const primaryClick = vi.fn()
|
|
|
|
render(
|
|
<SettingsListRow
|
|
title="Row"
|
|
onClick={rowClick}
|
|
primaryAction={{ label: 'Action', onClick: primaryClick }}
|
|
/>,
|
|
)
|
|
|
|
await user.click(screen.getByText('Row'))
|
|
expect(rowClick).toHaveBeenCalledTimes(1)
|
|
|
|
await user.click(screen.getByText('Action'))
|
|
expect(primaryClick).toHaveBeenCalledTimes(1)
|
|
expect(rowClick).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('opens overflow menu and clicking action calls onClick; destructive item has text-destructive class', async () => {
|
|
const user = userEvent.setup()
|
|
const actionClick = vi.fn()
|
|
|
|
render(
|
|
<SettingsListRow
|
|
title="Row"
|
|
actionsLabel="More options"
|
|
actions={[
|
|
{ label: 'Edit', onClick: vi.fn() },
|
|
{ label: 'Delete', onClick: actionClick, destructive: true },
|
|
]}
|
|
/>,
|
|
)
|
|
|
|
await user.click(screen.getByLabelText('More options'))
|
|
|
|
const deleteItem = screen.getByText('Delete')
|
|
expect(deleteItem).toBeInTheDocument()
|
|
expect(deleteItem.closest('div[class*="text-destructive"]')).toBeInTheDocument()
|
|
|
|
await user.click(deleteItem)
|
|
expect(actionClick).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|