mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: drop shallow settings and metadata examples
This commit is contained in:
@@ -33,15 +33,4 @@ describe('NativeChatConnectorAskerTag', () => {
|
||||
forceSystemBrowser: true
|
||||
})
|
||||
})
|
||||
|
||||
it('shows the cached avatar, then initials when it can’t load', () => {
|
||||
const { container } = render(<NativeChatConnectorAskerTag asker={SAM} />)
|
||||
const image = container.querySelector('img')
|
||||
if (!image) {
|
||||
throw new Error('no avatar image')
|
||||
}
|
||||
fireEvent.error(image)
|
||||
expect(container.querySelector('img')).toBeNull()
|
||||
expect(screen.getByText('SL')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { getDefaultSettings } from '../../../../../shared/orca-profiles/constants'
|
||||
|
||||
vi.mock('@/lib/bot-catalog', () => ({ useBots: () => [], useHostBots: () => [] }))
|
||||
vi.mock('@/components/bots/slack/SlackWorkspacesSettings', () => ({
|
||||
slackWorkspaces: () => [],
|
||||
SlackWorkspacesSettings: () => <div>Slack workspaces</div>
|
||||
}))
|
||||
vi.mock('@/components/bots/composio/ComposioKeyControl', () => ({
|
||||
ComposioKeyControl: () => <div>Composio key control</div>
|
||||
}))
|
||||
|
||||
import { BotsSettingsPane } from './BotsSettingsPane'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
function renderPane(botsEnabled?: boolean) {
|
||||
const updateSettings = vi.fn()
|
||||
const settings = { ...getDefaultSettings('/home/me'), botsEnabled }
|
||||
render(<BotsSettingsPane settings={settings} updateSettings={updateSettings} />)
|
||||
return updateSettings
|
||||
}
|
||||
|
||||
describe('BotsSettingsPane', () => {
|
||||
it('has bots on when nothing was saved, and turns them off from its switch', () => {
|
||||
const updateSettings = renderPane(undefined)
|
||||
|
||||
expect(screen.getByText('Slack workspaces')).toBeTruthy()
|
||||
expect(screen.getByText('Composio key control')).toBeTruthy()
|
||||
fireEvent.click(screen.getByRole('switch', { name: 'Enable bots' }))
|
||||
expect(updateSettings).toHaveBeenCalledWith({ botsEnabled: false })
|
||||
})
|
||||
|
||||
it('shows only the switch while bots are off, and turns them back on', () => {
|
||||
const updateSettings = renderPane(false)
|
||||
|
||||
expect(screen.queryByText('Slack workspaces')).toBeNull()
|
||||
fireEvent.click(screen.getByRole('switch', { name: 'Enable bots' }))
|
||||
expect(updateSettings).toHaveBeenCalledWith({ botsEnabled: true })
|
||||
})
|
||||
})
|
||||
@@ -1,172 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { Bot, GitBranch, Mic, Network, Puzzle } from 'lucide-react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { getDefaultSettings } from '../../../../../shared/orca-profiles/constants'
|
||||
import type * as ShortcutLabels from '@/lib/keyboard/useShortcutLabel'
|
||||
import { SettingsSidebar } from './SettingsSidebar'
|
||||
import { TooltipProvider } from '../../ui/tooltip'
|
||||
import type { SettingsSetupGuideProgress } from '../setup-guide/settings-setup-guide-progress'
|
||||
import type { GlobalSettings } from '../../../../../shared/settings/global-settings-types'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
useSettingsSetupGuideProgress: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/keyboard/useShortcutLabel', async () => {
|
||||
const actual = await vi.importActual<typeof ShortcutLabels>('@/lib/keyboard/useShortcutLabel')
|
||||
return {
|
||||
...actual,
|
||||
useShortcutLabel: () => '⌘F',
|
||||
useShortcutKeyComboDetails: () => [{ keys: ['⌘', 'F'], doubleTap: false }]
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('../setup-guide/settings-setup-guide-progress', () => ({
|
||||
useSettingsSetupGuideProgress: mocks.useSettingsSetupGuideProgress
|
||||
}))
|
||||
|
||||
function makeSetupGuideProgress(
|
||||
overrides: Partial<SettingsSetupGuideProgress> = {}
|
||||
): SettingsSetupGuideProgress {
|
||||
return {
|
||||
ready: true,
|
||||
doneCount: 5,
|
||||
total: 8,
|
||||
firstIncompleteStepId: 'agent-capabilities',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
function renderSidebar(
|
||||
activeSectionId = 'orchestration',
|
||||
settings: GlobalSettings = getDefaultSettings('/tmp')
|
||||
): string {
|
||||
return renderToStaticMarkup(
|
||||
<TooltipProvider>
|
||||
<SettingsSidebar
|
||||
activeSectionId={activeSectionId}
|
||||
settings={settings}
|
||||
generalGroups={[
|
||||
{
|
||||
id: 'capabilities',
|
||||
title: 'AI Capabilities',
|
||||
sections: [
|
||||
{
|
||||
id: 'agents',
|
||||
title: 'Agents',
|
||||
icon: Bot
|
||||
},
|
||||
{
|
||||
id: 'orchestration',
|
||||
title: 'Orchestration',
|
||||
icon: Network,
|
||||
installStatus: 'install'
|
||||
},
|
||||
{
|
||||
id: 'voice',
|
||||
title: 'Voice',
|
||||
icon: Mic,
|
||||
installStatus: 'installed'
|
||||
},
|
||||
{
|
||||
id: 'computer-use',
|
||||
title: 'Computer Use',
|
||||
icon: Bot,
|
||||
installStatus: 'up-to-date'
|
||||
},
|
||||
{
|
||||
id: 'voice-loading',
|
||||
title: 'Voice Loading',
|
||||
icon: Mic,
|
||||
installStatus: 'checking'
|
||||
},
|
||||
{
|
||||
id: 'linear',
|
||||
title: 'Linear',
|
||||
icon: GitBranch,
|
||||
installStatus: 'update-available'
|
||||
},
|
||||
{
|
||||
id: 'ephemeral-vms',
|
||||
title: 'Ephemeral VMs',
|
||||
icon: Bot,
|
||||
installStatus: 'needs-attention'
|
||||
},
|
||||
{
|
||||
id: 'plugins',
|
||||
title: 'Plugins',
|
||||
icon: Puzzle
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'setup',
|
||||
title: 'Set Up',
|
||||
sections: [
|
||||
{
|
||||
id: 'accounts',
|
||||
title: 'AI Provider Accounts',
|
||||
icon: Bot,
|
||||
badge: 'Optional'
|
||||
}
|
||||
]
|
||||
}
|
||||
]}
|
||||
repoSections={[]}
|
||||
searchCandidates={[]}
|
||||
onBack={vi.fn()}
|
||||
onSelectSection={vi.fn()}
|
||||
onOpenSearchResult={vi.fn()}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
)
|
||||
}
|
||||
|
||||
describe('SettingsSidebar', () => {
|
||||
beforeEach(() => {
|
||||
mocks.useSettingsSetupGuideProgress.mockReset()
|
||||
mocks.useSettingsSetupGuideProgress.mockReturnValue(makeSetupGuideProgress())
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
it("shows each bot's avatar in its row, above Projects", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<TooltipProvider>
|
||||
<SettingsSidebar
|
||||
activeSectionId="bot-b1"
|
||||
settings={getDefaultSettings('/tmp')}
|
||||
generalGroups={[
|
||||
{
|
||||
id: 'bots',
|
||||
title: 'Bots',
|
||||
sections: [
|
||||
{
|
||||
id: 'bot-b1',
|
||||
title: 'Reviewer',
|
||||
icon: Bot,
|
||||
bot: { id: 'b1', hostId: 'local', name: 'Reviewer', avatar: '🦉' }
|
||||
}
|
||||
]
|
||||
}
|
||||
]}
|
||||
repoSections={[]}
|
||||
searchCandidates={[]}
|
||||
onBack={vi.fn()}
|
||||
onSelectSection={vi.fn()}
|
||||
onOpenSearchResult={vi.fn()}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
)
|
||||
|
||||
expect(markup).toContain('🦉')
|
||||
// The generic icon renders as lucide-bot elsewhere in the nav.
|
||||
expect(renderSidebar()).toContain('lucide-bot')
|
||||
expect(markup).not.toContain('lucide-bot')
|
||||
expect(markup.indexOf('Reviewer')).toBeLessThan(markup.indexOf('Projects'))
|
||||
})
|
||||
})
|
||||
@@ -1,84 +0,0 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import type { ReactNode } from 'react'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { WorktreeCardDetailsHover } from './WorktreeCardMeta'
|
||||
import { WorktreeCardMetaBadges } from '../metadata/WorktreeCardMetaBadges'
|
||||
|
||||
vi.mock('@/components/ui/hover-card', () => ({
|
||||
HoverCard: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
HoverCardContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
HoverCardTrigger: ({ children }: { children: ReactNode }) => <>{children}</>
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui/tooltip', () => ({
|
||||
Tooltip: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
TooltipContent: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
TooltipTrigger: ({ children }: { children: ReactNode }) => <>{children}</>
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui/dropdown-menu', () => ({
|
||||
DropdownMenu: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
DropdownMenuTrigger: ({ children }: { children: ReactNode; asChild?: boolean }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
DropdownMenuContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
DropdownMenuItem: ({ children }: { children: ReactNode; onSelect?: () => void }) => (
|
||||
<div>{children}</div>
|
||||
)
|
||||
}))
|
||||
|
||||
describe('WorktreeCardDetailsHover', () => {
|
||||
it('names the bot that made the workspace', () => {
|
||||
const bot = { id: 'bot-1', hostId: 'local' as const, name: 'Ranger', avatar: null }
|
||||
const badgeMarkup = renderToStaticMarkup(
|
||||
<WorktreeCardMetaBadges
|
||||
issue={null}
|
||||
linearIssue={null}
|
||||
review={null}
|
||||
comment={null}
|
||||
bot={bot}
|
||||
/>
|
||||
)
|
||||
const hoverMarkup = renderToStaticMarkup(
|
||||
<WorktreeCardDetailsHover
|
||||
issue={null}
|
||||
linearIssue={null}
|
||||
review={null}
|
||||
comment={null}
|
||||
bot={bot}
|
||||
>
|
||||
<span>worker</span>
|
||||
</WorktreeCardDetailsHover>
|
||||
)
|
||||
|
||||
expect(badgeMarkup).toContain('Made by Ranger')
|
||||
expect(hoverMarkup).toContain('Made by Ranger')
|
||||
})
|
||||
|
||||
it("shows a bot's workspace by its bot alone, not also as CLI-made", () => {
|
||||
const cliProvenance = { kind: 'created-by-cli' as const, createdAt: 1 }
|
||||
const botMade = renderToStaticMarkup(
|
||||
<WorktreeCardMetaBadges
|
||||
issue={null}
|
||||
linearIssue={null}
|
||||
review={null}
|
||||
comment={null}
|
||||
cliProvenance={cliProvenance}
|
||||
bot={{ id: 'bot-1', hostId: 'local', name: 'Ranger', avatar: null }}
|
||||
/>
|
||||
)
|
||||
const cliMade = renderToStaticMarkup(
|
||||
<WorktreeCardMetaBadges
|
||||
issue={null}
|
||||
linearIssue={null}
|
||||
review={null}
|
||||
comment={null}
|
||||
cliProvenance={cliProvenance}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(botMade).toContain('Made by Ranger')
|
||||
expect(botMade).not.toContain('Created by Orca CLI')
|
||||
expect(cliMade).toContain('Created by Orca CLI')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user