fix(cloud): theme-offer tests; state word's separator only when a branch follows (RA-6)

This commit is contained in:
Neil
2026-11-10 16:49:06 -08:00
parent 2ea97f9c54
commit 02bc806fec
2 changed files with 74 additions and 1 deletions
@@ -1,5 +1,6 @@
import React from 'react'
import { useAppStore } from '@/store'
import { findWorktreeById } from '@/store/github/refresh/worktree-refresh'
import { useTranslate } from '@/i18n/use-translate'
import { cn } from '@/lib/utils'
import { HostGlyph, vmStateToDot } from '@/components/host-row-icon'
@@ -87,6 +88,8 @@ export function WorktreeCardHostStateWord({
? vmStateToDot(selectEphemeralVmWorkspaceState(state, worktreeId))
: null
)
// The separator only when line 2 goes on (a branch); "Asleep ·" alone reads as cut off.
const hasBranch = useAppStore((state) => Boolean(findWorktreeById(state, worktreeId)?.branch))
const t = useTranslate()
const state = cloud.isCloud ? cloud.state : vmDot
// Unknown is not a state to name (the panel shows a placeholder until the first read).
@@ -101,7 +104,8 @@ export function WorktreeCardHostStateWord({
PROBLEM.has(state) ? 'text-destructive' : 'text-muted-foreground'
)}
>
{cloudStateLabel(state, t)} ·
{cloudStateLabel(state, t)}
{hasBranch ? ' ·' : null}
</span>
)
}
@@ -0,0 +1,69 @@
// @vitest-environment happy-dom
import { act, cleanup, renderHook } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const toast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() }))
vi.mock('sonner', () => ({ toast }))
vi.mock('@/lib/desktop-window-chrome', () => ({ isPairedWebClientWindow: () => false }))
import { useAppStore } from '@/store/index'
import { seedCloudWorkspaceSnapshot } from '@/lib/orca-cloud/orca-cloud-workspace-store'
import { useClaudeThemeSyncOffer } from './claude-theme-sync-offer'
const initial = useAppStore.getState()
function seed(active: { id: string; host: string | null }): void {
useAppStore.setState({
settings: {
...initial.settings,
claudeCodeThemeSyncOffer: 'pending'
} as typeof initial.settings,
updateSettings: vi.fn(async () => undefined) as unknown as typeof initial.updateSettings,
activeWorktreeId: active.id,
activeWorkspaceExecutionHostId: active.host as typeof initial.activeWorkspaceExecutionHostId,
activePendingCreationId: null,
tabsByWorktree: {
[active.id]: [{ id: 'tab-1', launchAgent: 'claude' }]
} as unknown as typeof initial.tabsByWorktree
})
}
beforeEach(() => toast.mockClear())
afterEach(() => {
cleanup()
seedCloudWorkspaceSnapshot({})
useAppStore.setState(initial, true)
})
describe('Claude Code theme-sync offer (RA-6)', () => {
it('holds the offer while Claude runs in an Orca Cloud workspace, then makes it on a local one', () => {
seedCloudWorkspaceSnapshot({ ids: new Set(['cloud-ws']), idsLoaded: true })
seed({ id: 'cloud-ws', host: 'runtime:env-a' })
renderHook(() => useClaudeThemeSyncOffer())
expect(toast).not.toHaveBeenCalled()
act(() => {
useAppStore.setState({
activeWorktreeId: 'local-ws',
activeWorkspaceExecutionHostId: 'local'
})
})
expect(toast).toHaveBeenCalledTimes(1)
expect(toast.mock.calls[0]?.[0]).toBe('Match Claude Code to your Orca theme?')
})
it('holds it for a brand-new cloud workspace that is not in the cloud id list yet', () => {
seedCloudWorkspaceSnapshot({ ids: new Set(), idsLoaded: true })
seed({ id: 'new-cloud-ws', host: 'runtime:env-b' })
renderHook(() => useClaudeThemeSyncOffer())
expect(toast).not.toHaveBeenCalled()
})
it('offers right away when Claude runs on this computer', () => {
seedCloudWorkspaceSnapshot({ ids: new Set(), idsLoaded: true })
seed({ id: 'local-ws', host: 'local' })
renderHook(() => useClaudeThemeSyncOffer())
expect(toast).toHaveBeenCalledTimes(1)
})
})