mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
test: remove low-value dialog presentation assertions (#43556)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
-27
@@ -51,30 +51,3 @@ it('moves initial focus to the Agent trigger when detection finishes', async ()
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: 'Agent field' })).toHaveFocus())
|
||||
await userEvent.click(screen.getByRole('button', { name: 'Cancel' }))
|
||||
})
|
||||
|
||||
it('focuses the Agent field and shows the cost helper only for the full transcript', async () => {
|
||||
render(
|
||||
<AgentSessionContinuationDialog
|
||||
open
|
||||
onOpenChange={() => {}}
|
||||
request={{
|
||||
worktreeId: 'wt-1',
|
||||
workspacePath: '/tmp/fix-login',
|
||||
launchSource: 'sidebar',
|
||||
source: {
|
||||
sourceAgent: 'claude',
|
||||
capturedText: 'Current task',
|
||||
transcriptPath: '/tmp/session.jsonl'
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: 'Agent field' })).toHaveFocus())
|
||||
expect(screen.queryByText('Slower, and uses more of your plan or API credits.')).toBeNull()
|
||||
await userEvent.click(screen.getByRole('combobox', { name: 'Context' }))
|
||||
await userEvent.click(screen.getByRole('option', { name: 'Full transcript' }))
|
||||
expect(screen.getByText('Slower, and uses more of your plan or API credits.')).toBeVisible()
|
||||
await userEvent.click(screen.getByRole('combobox', { name: 'Context' }))
|
||||
await userEvent.click(screen.getByRole('option', { name: 'Latest status (recommended)' }))
|
||||
expect(screen.queryByText('Slower, and uses more of your plan or API credits.')).toBeNull()
|
||||
})
|
||||
|
||||
@@ -49,33 +49,6 @@ describe('AddWslHostDialogBody', () => {
|
||||
progress = null
|
||||
})
|
||||
|
||||
it('names the install lock an Add waits on instead of the generic setup hint', async () => {
|
||||
render(<Harness />)
|
||||
const add = await screen.findByRole('button', { name: 'Add host' })
|
||||
await waitFor(() => expect(add.hasAttribute('disabled')).toBe(false))
|
||||
fireEvent.click(add)
|
||||
await waitFor(() => expect(progress).not.toBeNull())
|
||||
expect(screen.getByText(/Installing and starting the Orca server/)).toBeTruthy()
|
||||
|
||||
const waiting =
|
||||
'Waiting for another Orca install in this distro to finish. If it doesn’t, Orca stops waiting in about 2 minutes.'
|
||||
act(() =>
|
||||
progress?.({
|
||||
distro: 'Ubuntu',
|
||||
detail: waiting,
|
||||
detailCode: 'installLockWaitGivesUp',
|
||||
detailParams: { count: 2 }
|
||||
})
|
||||
)
|
||||
expect(screen.getByText(waiting)).toBeTruthy()
|
||||
expect(screen.queryByText(/Installing and starting the Orca server/)).toBeNull()
|
||||
|
||||
// Once the lock is taken, the setup hint returns.
|
||||
act(() => progress?.({ distro: 'Ubuntu', detail: null }))
|
||||
expect(screen.queryByText(waiting)).toBeNull()
|
||||
expect(screen.getByText(/Installing and starting the Orca server/)).toBeTruthy()
|
||||
})
|
||||
|
||||
// Another window's Add broadcasts to every window; it must not touch this dialog's wait.
|
||||
it('ignores another distro’s Add progress and matches its own case-insensitively', async () => {
|
||||
const hosts = window.api.runtimeEnvironments?.wslHosts
|
||||
|
||||
-138
@@ -1,138 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { afterEach, expect, it } from 'vitest'
|
||||
import { makeWorktree } from '@/store/slices/worktrees/worktree.test-fixture'
|
||||
import { getWorktreeHostIdentity } from '../../../../../../shared/worktree/host-qualified-identity'
|
||||
import { DeleteWorktreeTargetPreview } from './DeleteWorktreeTargetPreview'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
it('does not present a partial numeric total when one workspace has uncounted dirty changes', () => {
|
||||
const worktrees = [
|
||||
makeWorktree({ id: 'wt-1', repoId: 'repo-1' }),
|
||||
makeWorktree({ id: 'wt-2', repoId: 'repo-1' })
|
||||
]
|
||||
const { container } = render(
|
||||
<DeleteWorktreeTargetPreview
|
||||
isBatchDelete
|
||||
worktree={null}
|
||||
worktrees={worktrees}
|
||||
collisionWorktrees={worktrees}
|
||||
hostLabelById={new Map()}
|
||||
deleteStateByWorktreeId={{}}
|
||||
dirtyChangeCountsByWorktreeId={
|
||||
new Map([
|
||||
['wt-1', 3],
|
||||
['wt-2', 0]
|
||||
])
|
||||
}
|
||||
dirtyChangePreviewsByWorktreeId={new Map()}
|
||||
/>
|
||||
)
|
||||
expect(container.querySelector('[data-slot="dialog-warning"]')).toHaveTextContent(
|
||||
'Uncommitted changes will be lost'
|
||||
)
|
||||
})
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: 'unsaved-only with incomplete scans',
|
||||
changes: undefined,
|
||||
unsaved: 2,
|
||||
ignored: false,
|
||||
incomplete: true,
|
||||
warning: '2 unsaved files will be lost'
|
||||
},
|
||||
{
|
||||
name: 'uncommitted changes and ignored files',
|
||||
changes: 13,
|
||||
unsaved: 0,
|
||||
ignored: true,
|
||||
incomplete: false,
|
||||
warning: '26 uncommitted changes and ignored files will be lost'
|
||||
},
|
||||
{
|
||||
name: 'all three known losses',
|
||||
changes: 13,
|
||||
unsaved: 2,
|
||||
ignored: true,
|
||||
incomplete: false,
|
||||
warning: '26 uncommitted changes, 2 unsaved files and ignored files will be lost'
|
||||
},
|
||||
{
|
||||
name: 'clean workspaces with incomplete scans',
|
||||
changes: undefined,
|
||||
unsaved: 0,
|
||||
ignored: false,
|
||||
incomplete: true,
|
||||
warning: null
|
||||
},
|
||||
{
|
||||
name: 'ignored files only',
|
||||
changes: undefined,
|
||||
unsaved: 0,
|
||||
ignored: true,
|
||||
incomplete: false,
|
||||
warning: 'Ignored files will be lost'
|
||||
}
|
||||
])(
|
||||
'preserves the independent consequences for $name',
|
||||
({ changes, unsaved, ignored, incomplete, warning }) => {
|
||||
const worktrees = [
|
||||
makeWorktree({ id: 'wt-1', repoId: 'repo-1', displayName: 'fix-login' }),
|
||||
makeWorktree({ id: 'wt-2', repoId: 'repo-1', displayName: 'docs-refresh' })
|
||||
]
|
||||
const { container } = render(
|
||||
<DeleteWorktreeTargetPreview
|
||||
isBatchDelete
|
||||
worktree={null}
|
||||
worktrees={worktrees}
|
||||
collisionWorktrees={worktrees}
|
||||
unsavedFileCount={unsaved}
|
||||
hostLabelById={new Map()}
|
||||
deleteStateByWorktreeId={{}}
|
||||
dirtyChangeCountsByWorktreeId={
|
||||
new Map(
|
||||
changes === undefined
|
||||
? []
|
||||
: [
|
||||
['wt-1', changes],
|
||||
['wt-2', changes]
|
||||
]
|
||||
)
|
||||
}
|
||||
dirtyChangePreviewsByWorktreeId={new Map()}
|
||||
changeCheckStatesByWorktreeId={
|
||||
new Map([
|
||||
['wt-1', incomplete ? 'unavailable' : 'complete'],
|
||||
['wt-2', 'complete']
|
||||
])
|
||||
}
|
||||
atRiskLocalFilesByIdentity={
|
||||
new Map(
|
||||
worktrees.map((item) => [
|
||||
getWorktreeHostIdentity(item),
|
||||
{
|
||||
status: 'complete',
|
||||
files: {
|
||||
count: ignored ? 2 : 0,
|
||||
samplePaths: ignored ? ['.env'] : [],
|
||||
complete: !incomplete
|
||||
}
|
||||
}
|
||||
])
|
||||
)
|
||||
}
|
||||
/>
|
||||
)
|
||||
const warnings = container.querySelectorAll('[data-slot="dialog-warning"]')
|
||||
expect(warnings).toHaveLength(warning ? 1 : 0)
|
||||
if (warning) {
|
||||
expect(warnings[0]).toHaveTextContent(warning)
|
||||
}
|
||||
expect(screen.queryByText('Some changes couldn’t be fully checked.')).toBe(
|
||||
incomplete ? screen.getByText('Some changes couldn’t be fully checked.') : null
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -43,31 +43,11 @@ function UnifiedDialog({
|
||||
describe('unified dialog layout', () => {
|
||||
afterEach(cleanup)
|
||||
|
||||
it('drops the close X when the footer has Cancel, and keeps it on default dialogs', () => {
|
||||
const { unmount } = render(<UnifiedDialog />)
|
||||
expect(screen.queryByRole('button', { name: 'Close' })).not.toBeInTheDocument()
|
||||
unmount()
|
||||
|
||||
render(
|
||||
<Dialog open>
|
||||
<DialogContent aria-describedby={undefined}>
|
||||
<DialogTitle>Settings</DialogTitle>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('starts focus on Cancel when asked, ahead of earlier controls', async () => {
|
||||
render(<UnifiedDialog initialFocus="cancel" />)
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: 'Cancel' })).toHaveFocus())
|
||||
})
|
||||
|
||||
it('keeps focus inside a busy dialog whose Cancel button is disabled', async () => {
|
||||
render(<UnifiedDialog busy initialFocus="cancel" />)
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: 'Show changes' })).toHaveFocus())
|
||||
})
|
||||
|
||||
it('blocks Esc and Cancel while busy, and closes on Esc otherwise', async () => {
|
||||
const onOpenChange = vi.fn()
|
||||
const { rerender } = render(<UnifiedDialog busy onOpenChange={onOpenChange} />)
|
||||
|
||||
Reference in New Issue
Block a user