mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Critical and high: - repos: unlinking a local repo removes only the Manager reference and alias, never the repository files; confirm button reads "Unlink" - auth: rate-limit by the socket address; trust proxy headers only when AUTH_TRUSTED_PROXY_HEADERS is set (documented and forwarded in compose) - composer: per-session in-memory drafts (text, bash mode, attachments); Escape no longer clears the prompt - url params: compose same-tick updates so schedule dialogs stay closed after create/delete; delete dialog names the job Medium: - tool rows show failures (non-zero shell exit, failed exploration members) - voice conversation shows the specific error and a starting state - settings: Escape in dropdowns and the shortcut recorder no longer closes the dialog; mobile deep links open the requested section; one content tree per platform - closing pushed sheets, settings, tool panels and schedule dialogs goes back in history - login returns to the requested page; signed-out pages make no authenticated requests - action terminals keep their output (Manager-side output capture and replay) - unpushed-commit detection, commit message kept on failure - binary files with unknown extensions are detected and not editable - tool panel resizes when docked and floats as a dismissible sheet when the page is too narrow - Docker image runs tini as PID 1 Low: not-found states, add-repo and branch validation errors (4xx), search-aware empty states, mobile repo sort/filter/select cues, sidebar resize affordance and collapse shortcut, mobile unread badge, preview port filtering, terminal close handling, walkthrough empty state and helper session filtering, placeholder contrast, permission labels and focus, TTS task-list sanitizing, git identity email validation, quieter git logging, hermetic worktree tests, and accessible names for icon-only controls.
118 lines
3.4 KiB
TypeScript
118 lines
3.4 KiB
TypeScript
import { describe, it, expect, vi, afterEach } from 'vitest'
|
|
import { render, screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import type { GitFileStatus } from '@/types/git'
|
|
import { GitFlatFileItem } from './GitFlatFileItem'
|
|
|
|
const defaultViewportWidth = window.innerWidth
|
|
|
|
function buildFile(overrides: Partial<GitFileStatus> = {}): GitFileStatus {
|
|
return { path: 'notes.txt', status: 'modified', staged: false, ...overrides }
|
|
}
|
|
|
|
function setViewportWidth(width: number) {
|
|
Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: width })
|
|
}
|
|
|
|
describe('GitFlatFileItem', () => {
|
|
afterEach(() => {
|
|
setViewportWidth(defaultViewportWidth)
|
|
})
|
|
|
|
it('renders an untracked directory once with its trailing slash', () => {
|
|
render(
|
|
<GitFlatFileItem
|
|
file={buildFile({ path: '.ocm/', status: 'untracked' })}
|
|
isSelected={false}
|
|
onSelect={vi.fn()}
|
|
onStage={vi.fn()}
|
|
onDiscard={vi.fn()}
|
|
/>,
|
|
)
|
|
|
|
expect(screen.getByText('.ocm/')).toBeInTheDocument()
|
|
expect(screen.queryByText('.ocm')).toBeNull()
|
|
})
|
|
|
|
it('keeps the parent directory of a nested untracked directory', () => {
|
|
render(
|
|
<GitFlatFileItem
|
|
file={buildFile({ path: 'src/.ocm/', status: 'untracked' })}
|
|
isSelected={false}
|
|
onSelect={vi.fn()}
|
|
onStage={vi.fn()}
|
|
/>,
|
|
)
|
|
|
|
expect(screen.getByText('.ocm/')).toBeInTheDocument()
|
|
expect(screen.getByText('src')).toBeInTheDocument()
|
|
})
|
|
|
|
it('names the stage and discard actions after the file', async () => {
|
|
const user = userEvent.setup()
|
|
const onStage = vi.fn()
|
|
const onDiscard = vi.fn()
|
|
render(
|
|
<GitFlatFileItem
|
|
file={buildFile({ path: 'src/notes.txt' })}
|
|
isSelected={false}
|
|
onSelect={vi.fn()}
|
|
onStage={onStage}
|
|
onDiscard={onDiscard}
|
|
/>,
|
|
)
|
|
|
|
await user.click(screen.getByRole('button', { name: 'Stage notes.txt' }))
|
|
await user.click(screen.getByRole('button', { name: 'Discard changes to notes.txt' }))
|
|
|
|
expect(onStage).toHaveBeenCalledWith('src/notes.txt')
|
|
expect(onDiscard).toHaveBeenCalledWith('src/notes.txt', false)
|
|
})
|
|
|
|
it('names the unstage action for staged files', () => {
|
|
render(
|
|
<GitFlatFileItem
|
|
file={buildFile({ path: 'notes.txt', staged: true })}
|
|
isSelected={false}
|
|
onSelect={vi.fn()}
|
|
onUnstage={vi.fn()}
|
|
/>,
|
|
)
|
|
|
|
expect(screen.getByRole('button', { name: 'Unstage notes.txt' })).toBeInTheDocument()
|
|
})
|
|
|
|
it('reveals the row actions without hovering on touch-sized viewports', () => {
|
|
setViewportWidth(500)
|
|
render(
|
|
<GitFlatFileItem
|
|
file={buildFile()}
|
|
isSelected={false}
|
|
onSelect={vi.fn()}
|
|
onStage={vi.fn()}
|
|
onDiscard={vi.fn()}
|
|
/>,
|
|
)
|
|
|
|
expect(screen.getByRole('button', { name: 'Stage notes.txt' })).toHaveClass('opacity-100')
|
|
})
|
|
|
|
it('reveals hover-only actions when they receive focus', () => {
|
|
setViewportWidth(1280)
|
|
render(
|
|
<GitFlatFileItem
|
|
file={buildFile()}
|
|
isSelected={false}
|
|
onSelect={vi.fn()}
|
|
onStage={vi.fn()}
|
|
onDiscard={vi.fn()}
|
|
/>,
|
|
)
|
|
|
|
const stageButton = screen.getByRole('button', { name: 'Stage notes.txt' })
|
|
expect(stageButton).toHaveClass('opacity-0')
|
|
expect(stageButton).toHaveClass('focus-visible:opacity-100')
|
|
expect(stageButton).toHaveClass('group-focus-within:opacity-100')
|
|
})
|
|
})
|