mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
test: remove 30 low-value cases and 11 suites (#34288)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ const wslMocks = vi.hoisted(() => ({
|
||||
vi.mock('../wsl', () => wslMocks)
|
||||
|
||||
import { WslRelayRecovery } from './wsl-hook-relay-recovery'
|
||||
import { markWslRelayFailed } from './wsl-hook-relay-state-machine'
|
||||
const { markWslRelayFailed } = await import('./wsl-hook-relay-state-machine')
|
||||
import {
|
||||
_resetWslBackgroundDistroGateForTests,
|
||||
isWslDistroRunning,
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { AppState } from '@/store/types'
|
||||
import {
|
||||
EMPTY_WORKTREE_PALETTE_CACHE_INPUTS,
|
||||
selectWorktreePaletteCacheInputs
|
||||
} from './worktree-palette-cache-inputs'
|
||||
|
||||
describe('selectWorktreePaletteCacheInputs', () => {
|
||||
it('stays referentially stable across review cache writes while the palette is closed', () => {
|
||||
const emptyState: Pick<AppState, 'prCache' | 'issueCache' | 'hostedReviewCache'> = {
|
||||
prCache: {},
|
||||
issueCache: {},
|
||||
hostedReviewCache: {}
|
||||
}
|
||||
const filledState: Pick<AppState, 'prCache' | 'issueCache' | 'hostedReviewCache'> = {
|
||||
prCache: { pr: { data: null, fetchedAt: 1 } },
|
||||
issueCache: { issue: { data: null, fetchedAt: 1 } },
|
||||
hostedReviewCache: { review: { data: null, fetchedAt: 1 } }
|
||||
}
|
||||
|
||||
const before = selectWorktreePaletteCacheInputs(emptyState, false)
|
||||
const after = selectWorktreePaletteCacheInputs(filledState, false)
|
||||
|
||||
expect(before).toBe(EMPTY_WORKTREE_PALETTE_CACHE_INPUTS)
|
||||
expect(after).toBe(before)
|
||||
})
|
||||
|
||||
it('returns live cache identities while the palette is visible', () => {
|
||||
const state = {
|
||||
prCache: {},
|
||||
issueCache: {},
|
||||
hostedReviewCache: {}
|
||||
} as Pick<AppState, 'prCache' | 'issueCache' | 'hostedReviewCache'>
|
||||
|
||||
const selected = selectWorktreePaletteCacheInputs(state, true)
|
||||
|
||||
expect(selected).toEqual(state)
|
||||
expect(selected.prCache).toBe(state.prCache)
|
||||
expect(selected.issueCache).toBe(state.issueCache)
|
||||
expect(selected.hostedReviewCache).toBe(state.hostedReviewCache)
|
||||
})
|
||||
})
|
||||
@@ -20,14 +20,6 @@ describe('attemptEditorFileSave', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('reports success only after the save request resolves', async () => {
|
||||
requestEditorFileSave.mockResolvedValue(undefined)
|
||||
|
||||
await expect(attemptEditorFileSave({ fileId: 'file-1' })).resolves.toBe(true)
|
||||
|
||||
expect(toastError).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('surfaces a failed save and reports failure to dependent actions (STA-2027)', async () => {
|
||||
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const cause = new Error('disk full')
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
getVisibleFileExplorerWorktreePath,
|
||||
shouldResetFileExplorerForVisibleWorktree
|
||||
} from './file-explorer-reset'
|
||||
|
||||
describe('getVisibleFileExplorerWorktreePath', () => {
|
||||
it('exposes the worktree path only while the Files view is visible', () => {
|
||||
expect(
|
||||
getVisibleFileExplorerWorktreePath({
|
||||
explorerView: 'files',
|
||||
rightSidebarOpen: true,
|
||||
worktreePath: '/repo'
|
||||
})
|
||||
).toBe('/repo')
|
||||
expect(
|
||||
getVisibleFileExplorerWorktreePath({
|
||||
explorerView: 'search',
|
||||
rightSidebarOpen: true,
|
||||
worktreePath: '/repo'
|
||||
})
|
||||
).toBeNull()
|
||||
expect(
|
||||
getVisibleFileExplorerWorktreePath({
|
||||
explorerView: 'files',
|
||||
rightSidebarOpen: false,
|
||||
worktreePath: '/repo'
|
||||
})
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('shouldResetFileExplorerForVisibleWorktree', () => {
|
||||
it('preserves explorer state across hide and reopen of the same worktree', () => {
|
||||
let lastResetWorktreePath: string | null = null
|
||||
const shouldReset = (visibleWorktreePath: string | null): boolean => {
|
||||
if (shouldResetFileExplorerForVisibleWorktree(lastResetWorktreePath, visibleWorktreePath)) {
|
||||
lastResetWorktreePath = visibleWorktreePath
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
expect(shouldReset(null)).toBe(false)
|
||||
expect(shouldReset('/repo')).toBe(true)
|
||||
expect(shouldReset(null)).toBe(false)
|
||||
expect(shouldReset('/repo')).toBe(false)
|
||||
})
|
||||
|
||||
it('resets when the visible worktree path changes', () => {
|
||||
expect(shouldResetFileExplorerForVisibleWorktree('/repo', '/repo-next')).toBe(true)
|
||||
})
|
||||
})
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createTerminalPaneManagerOptions } from './terminal-pane-manager-options'
|
||||
import type { TerminalPaneManagerOptionsContext } from './terminal-pane-mount-context'
|
||||
|
||||
vi.mock('@/runtime/sync-runtime-graph', () => ({ scheduleRuntimeGraphSync: vi.fn() }))
|
||||
|
||||
function createOptions(shouldPersistLayout = true) {
|
||||
const persistLayoutSnapshot = vi.fn()
|
||||
const context = {
|
||||
deps: {
|
||||
persistLayoutSnapshot,
|
||||
syncExpandedLayout: vi.fn(),
|
||||
tabId: 'tab',
|
||||
worktreeId: 'wt',
|
||||
isVisibleRef: { current: true },
|
||||
settingsRef: { current: null }
|
||||
},
|
||||
ptyDeps: {},
|
||||
syncCanExpandState: vi.fn(),
|
||||
syncPaneCount: vi.fn(),
|
||||
syncPaneLayoutRevision: vi.fn(),
|
||||
queueResizeAll: vi.fn(),
|
||||
shouldPersistLayout: () => shouldPersistLayout
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: building options and running onLayoutChanged read only these fields.
|
||||
const optionsContext = context as unknown as TerminalPaneManagerOptionsContext
|
||||
const options = createTerminalPaneManagerOptions(optionsContext)
|
||||
return { options, persistLayoutSnapshot }
|
||||
}
|
||||
|
||||
describe('terminal pane manager layout persist wiring', () => {
|
||||
it('persists a layout change', () => {
|
||||
const { options, persistLayoutSnapshot } = createOptions()
|
||||
options.onLayoutChanged?.()
|
||||
expect(persistLayoutSnapshot).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('keeps the persist gate', () => {
|
||||
const { options, persistLayoutSnapshot } = createOptions(false)
|
||||
options.onLayoutChanged?.()
|
||||
expect(persistLayoutSnapshot).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,44 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { writeTerminalPastePtyInput } from './terminal-pty-paste-writer'
|
||||
|
||||
describe('terminal PTY paste writer', () => {
|
||||
it('prefers acknowledged PTY writes when available', async () => {
|
||||
const sendInput = vi.fn().mockReturnValue(true)
|
||||
const sendInputAccepted = vi.fn().mockResolvedValue(true)
|
||||
|
||||
await expect(
|
||||
writeTerminalPastePtyInput({ sendInput, sendInputAccepted }, 'payload', 'driving')
|
||||
).resolves.toBe(true)
|
||||
|
||||
expect(sendInputAccepted).toHaveBeenCalledWith('payload', 'driving')
|
||||
expect(sendInput).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('lets the caller withdraw an acknowledged write it stopped waiting for', async () => {
|
||||
const sendInputAccepted = vi.fn().mockResolvedValue(true)
|
||||
const controller = new AbortController()
|
||||
|
||||
await writeTerminalPastePtyInput(
|
||||
{ sendInput: vi.fn(), sendInputAccepted },
|
||||
'payload',
|
||||
'driving',
|
||||
controller.signal
|
||||
)
|
||||
|
||||
expect(sendInputAccepted).toHaveBeenCalledWith('payload', 'driving', {
|
||||
signal: controller.signal
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to queued PTY writes when acknowledged writes are unavailable', () => {
|
||||
const sendInput = vi.fn().mockReturnValue(true)
|
||||
|
||||
expect(writeTerminalPastePtyInput({ sendInput }, 'payload', 'driving')).toBe(true)
|
||||
expect(sendInput).toHaveBeenCalledWith('payload', 'driving')
|
||||
})
|
||||
|
||||
it('rejects writes without a transport', () => {
|
||||
expect(writeTerminalPastePtyInput(undefined, 'payload', 'driving')).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,11 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { extractTerminalHttpLinks } from '../../../../shared/terminal-http-url-extraction'
|
||||
import { TERMINAL_HTTP_URL_MAX_LENGTH } from '../../../../shared/terminal-http-link-limits'
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('extractTerminalHttpLinks', () => {
|
||||
it('extracts regular http links and trims terminal trailing punctuation', () => {
|
||||
const line = 'open https://example.com/path?x=1.'
|
||||
@@ -29,19 +25,4 @@ describe('extractTerminalHttpLinks', () => {
|
||||
|
||||
expect(extractTerminalHttpLinks(overlongUrl)).toEqual([])
|
||||
})
|
||||
|
||||
it('scans large pasted terminal lines without regex match iteration', () => {
|
||||
const matchAllSpy = vi.spyOn(String.prototype, 'matchAll')
|
||||
const pastedPrefix = 'pasted terminal noise '.repeat(10_000)
|
||||
const line = `${pastedPrefix}https://example.com/docs?q=orca.`
|
||||
|
||||
expect(extractTerminalHttpLinks(line)).toEqual([
|
||||
{
|
||||
url: 'https://example.com/docs?q=orca',
|
||||
startIndex: pastedPrefix.length,
|
||||
endIndex: line.length - 1
|
||||
}
|
||||
])
|
||||
expect(matchAllSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import type * as ReactModule from 'react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
getForegroundTerminalTabIds,
|
||||
resetForegroundTerminalTabIdsForTests
|
||||
} from '@/lib/foreground-terminal-tabs'
|
||||
import { useVisibleTerminalTabClaim } from './use-visible-terminal-tab-claim'
|
||||
|
||||
const reactEffects = vi.hoisted(() => ({
|
||||
layoutEffects: [] as (() => void | (() => void))[],
|
||||
passiveEffects: [] as (() => void | (() => void))[]
|
||||
}))
|
||||
|
||||
vi.mock('react', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof ReactModule>()
|
||||
return {
|
||||
...actual,
|
||||
useEffect: (effect: () => void | (() => void)) => {
|
||||
reactEffects.passiveEffects.push(effect)
|
||||
},
|
||||
useLayoutEffect: (effect: () => void | (() => void)) => {
|
||||
reactEffects.layoutEffects.push(effect)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
resetForegroundTerminalTabIdsForTests()
|
||||
reactEffects.layoutEffects = []
|
||||
reactEffects.passiveEffects = []
|
||||
})
|
||||
|
||||
describe('useVisibleTerminalTabClaim', () => {
|
||||
it('registers visible panes through a layout effect', () => {
|
||||
useVisibleTerminalTabClaim({ isVisible: true, tabId: 'tab-visible' })
|
||||
|
||||
expect(reactEffects.passiveEffects).toHaveLength(0)
|
||||
expect(reactEffects.layoutEffects).toHaveLength(1)
|
||||
|
||||
const cleanup = reactEffects.layoutEffects[0]()
|
||||
expect(getForegroundTerminalTabIds()).toEqual(['tab-visible'])
|
||||
|
||||
cleanup?.()
|
||||
expect(getForegroundTerminalTabIds()).toEqual([])
|
||||
})
|
||||
|
||||
it('does not claim hidden panes', () => {
|
||||
useVisibleTerminalTabClaim({ isVisible: false, tabId: 'tab-hidden' })
|
||||
|
||||
reactEffects.layoutEffects[0]()
|
||||
|
||||
expect(getForegroundTerminalTabIds()).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -17,13 +17,6 @@ describe('safeFind (TerminalSearch decoration crash guard)', () => {
|
||||
expect(find).toHaveBeenCalledWith('query', undefined)
|
||||
})
|
||||
|
||||
it('returns the addon result and forwards options on the normal path', () => {
|
||||
const find = vi.fn(() => true)
|
||||
const options = { caseSensitive: true }
|
||||
expect(safeFind(find, 'q', options)).toBe(true)
|
||||
expect(find).toHaveBeenCalledWith('q', options)
|
||||
})
|
||||
|
||||
it('re-throws unrelated errors so genuine bugs are not hidden', () => {
|
||||
const find = vi.fn(() => {
|
||||
throw new TypeError('something genuinely broken')
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { info } = vi.hoisted(() => ({ info: vi.fn() }))
|
||||
vi.mock('sonner', () => ({ toast: { info } }))
|
||||
|
||||
import {
|
||||
registerWslAccountNoticeIpcBridge,
|
||||
showWslAccountNotAppliedNotice
|
||||
} from './wsl-account-notice-ipc-bridge'
|
||||
|
||||
describe('WSL account-not-applied notice', () => {
|
||||
afterEach(() => {
|
||||
info.mockReset()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
it('shows a non-blocking info toast keyed by distro', () => {
|
||||
showWslAccountNotAppliedNotice({ distro: 'Ubuntu' })
|
||||
expect(info).toHaveBeenCalledWith(
|
||||
'Account selection not applied in Ubuntu',
|
||||
expect.objectContaining({ id: 'wsl-account-not-applied:ubuntu' })
|
||||
)
|
||||
expect(info.mock.calls[0][1]).not.toHaveProperty('duration')
|
||||
})
|
||||
|
||||
it('subscribes to the desktop event and skips a client without one', () => {
|
||||
const unsubscribe = vi.fn()
|
||||
let listener: ((event: { distro: string }) => void) | undefined
|
||||
vi.stubGlobal('window', {
|
||||
api: {
|
||||
runtimeEnvironments: {
|
||||
onWslAccountNotApplied: (callback: (event: { distro: string }) => void) => {
|
||||
listener = callback
|
||||
return unsubscribe
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
const unsubs: (() => void)[] = []
|
||||
registerWslAccountNoticeIpcBridge(unsubs)
|
||||
listener?.({ distro: 'Debian' })
|
||||
expect(info).toHaveBeenCalledTimes(1)
|
||||
expect(unsubs).toEqual([unsubscribe])
|
||||
|
||||
vi.stubGlobal('window', { api: { runtimeEnvironments: {} } })
|
||||
const none: (() => void)[] = []
|
||||
registerWslAccountNoticeIpcBridge(none)
|
||||
expect(none).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -1,43 +0,0 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { motionSafeScrollBehavior } from './usePrefersReducedMotion'
|
||||
|
||||
function stubReducedMotion(reduce: boolean): ReturnType<typeof vi.fn> {
|
||||
const matchMedia = vi.fn((query: string) => ({
|
||||
matches: reduce && query === '(prefers-reduced-motion: reduce)'
|
||||
}))
|
||||
vi.stubGlobal('window', { matchMedia })
|
||||
return matchMedia
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
describe('motionSafeScrollBehavior', () => {
|
||||
it('jumps instead of smooth-scrolling when reduced motion is on', () => {
|
||||
const matchMedia = stubReducedMotion(true)
|
||||
|
||||
expect(motionSafeScrollBehavior()).toBe('auto')
|
||||
expect(motionSafeScrollBehavior('smooth')).toBe('auto')
|
||||
expect(motionSafeScrollBehavior('instant')).toBe('instant')
|
||||
expect(motionSafeScrollBehavior('auto')).toBe('auto')
|
||||
expect(matchMedia).toHaveBeenCalledWith('(prefers-reduced-motion: reduce)')
|
||||
})
|
||||
|
||||
it('keeps the requested behavior when reduced motion is off', () => {
|
||||
stubReducedMotion(false)
|
||||
|
||||
expect(motionSafeScrollBehavior()).toBe('smooth')
|
||||
expect(motionSafeScrollBehavior('smooth')).toBe('smooth')
|
||||
expect(motionSafeScrollBehavior('instant')).toBe('instant')
|
||||
})
|
||||
|
||||
it('keeps the requested behavior without matchMedia', () => {
|
||||
expect(typeof window).toBe('undefined')
|
||||
expect(motionSafeScrollBehavior()).toBe('smooth')
|
||||
|
||||
vi.stubGlobal('window', {})
|
||||
expect(motionSafeScrollBehavior('smooth')).toBe('smooth')
|
||||
expect(motionSafeScrollBehavior('auto')).toBe('auto')
|
||||
})
|
||||
})
|
||||
@@ -1,45 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createDivider } from './pane-divider'
|
||||
import { equalizeManagedPaneSizes } from './pane-manager-layout-sweeps'
|
||||
import type { ManagedPaneInternal } from './pane-manager-types'
|
||||
|
||||
function makePane(flex: string): HTMLElement {
|
||||
const pane = document.createElement('div')
|
||||
pane.className = 'pane'
|
||||
pane.style.flex = flex
|
||||
return pane
|
||||
}
|
||||
|
||||
describe('pane layout change notification', () => {
|
||||
it('reports a divider double-click reset', () => {
|
||||
const onLayoutChanged = vi.fn()
|
||||
const split = document.createElement('div')
|
||||
const divider = createDivider(true, {}, { refitPanesUnder: vi.fn(), onLayoutChanged })
|
||||
split.append(makePane('3 1 0%'), divider, makePane('1 1 0%'))
|
||||
|
||||
divider.dispatchEvent(new MouseEvent('dblclick'))
|
||||
|
||||
expect(onLayoutChanged).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('reports an equalize command only when it changes sizes', () => {
|
||||
const onLayoutChanged = vi.fn()
|
||||
const root = document.createElement('div')
|
||||
const split = document.createElement('div')
|
||||
split.className = 'pane-split'
|
||||
split.append(makePane('3 1 0%'), createDivider(true, {}, { refitPanesUnder: vi.fn() }))
|
||||
split.append(makePane('1 1 0%'))
|
||||
root.append(split)
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: equalize reads only the pane count.
|
||||
const panes = new Map([
|
||||
[1, {}],
|
||||
[2, {}]
|
||||
]) as unknown as Map<number, ManagedPaneInternal>
|
||||
|
||||
equalizeManagedPaneSizes(panes, root, onLayoutChanged)
|
||||
equalizeManagedPaneSizes(panes, root, onLayoutChanged)
|
||||
|
||||
expect(onLayoutChanged).toHaveBeenCalledOnce()
|
||||
})
|
||||
})
|
||||
@@ -1,54 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { ActivePluginCommand } from '@/store/plugin-panels'
|
||||
import { registerAppCommandDispatcher } from './app-command-dispatch'
|
||||
import { executePluginCommand } from './plugin-command-execution'
|
||||
|
||||
let unregister: (() => void) | null = null
|
||||
|
||||
afterEach(() => {
|
||||
unregister?.()
|
||||
unregister = null
|
||||
})
|
||||
|
||||
function command(handler: ActivePluginCommand['handler']): ActivePluginCommand {
|
||||
return {
|
||||
pluginKey: 'orca-samples.tasks',
|
||||
pluginName: 'Tasks',
|
||||
id: 'open',
|
||||
title: 'Open Tasks',
|
||||
context: 'global',
|
||||
handler,
|
||||
keybindings: []
|
||||
}
|
||||
}
|
||||
|
||||
describe('plugin command execution', () => {
|
||||
it('dispatches aliases without invoking a plugin worker', async () => {
|
||||
const dispatcher = vi.fn(() => true)
|
||||
const invokeCommand = vi.fn()
|
||||
unregister = registerAppCommandDispatcher(dispatcher)
|
||||
Object.assign(window, { api: { plugins: { invokeCommand } } })
|
||||
|
||||
await executePluginCommand(
|
||||
command({ type: 'built-in', action: 'view.tasks' }),
|
||||
'plugin-palette'
|
||||
)
|
||||
|
||||
expect(dispatcher).toHaveBeenCalledWith('view.tasks', 'plugin-palette')
|
||||
expect(invokeCommand).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('routes worker commands through the authenticated preload binding', async () => {
|
||||
const invokeCommand = vi.fn().mockResolvedValue({ ok: true })
|
||||
Object.assign(window, { api: { plugins: { invokeCommand } } })
|
||||
|
||||
await executePluginCommand(command({ type: 'worker' }), 'plugin-keybinding')
|
||||
|
||||
expect(invokeCommand).toHaveBeenCalledWith({
|
||||
pluginKey: 'orca-samples.tasks',
|
||||
commandId: 'open'
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,64 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { toast } from 'sonner'
|
||||
import { showTerminalShortcutCaptureNotification } from './terminal-shortcut-capture-notification'
|
||||
|
||||
const { toastMessage } = vi.hoisted(() => ({
|
||||
toastMessage: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('sonner', () => ({
|
||||
toast: {
|
||||
message: toastMessage
|
||||
}
|
||||
}))
|
||||
|
||||
function createLocalStorage(): Storage {
|
||||
const values = new Map<string, string>()
|
||||
|
||||
return {
|
||||
get length() {
|
||||
return values.size
|
||||
},
|
||||
clear: () => values.clear(),
|
||||
getItem: (key: string) => values.get(key) ?? null,
|
||||
key: (index: number) => Array.from(values.keys())[index] ?? null,
|
||||
removeItem: (key: string) => {
|
||||
values.delete(key)
|
||||
},
|
||||
setItem: (key: string, value: string) => {
|
||||
values.set(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('showTerminalShortcutCaptureNotification', () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('localStorage', createLocalStorage())
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('keeps the shortcut capture warning visible long enough to act on', () => {
|
||||
showTerminalShortcutCaptureNotification({
|
||||
actionId: 'tab.close',
|
||||
platform: 'darwin'
|
||||
})
|
||||
|
||||
expect(toast.message).toHaveBeenCalledWith(
|
||||
'Terminal shortcut handled',
|
||||
expect.objectContaining({
|
||||
className: expect.stringContaining('!py-2'),
|
||||
classNames: expect.objectContaining({
|
||||
title: expect.stringContaining('truncate'),
|
||||
description: expect.stringContaining('truncate')
|
||||
}),
|
||||
duration: 20_000,
|
||||
dismissible: true,
|
||||
action: expect.objectContaining({ label: 'Open Shortcuts' })
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -30,9 +30,4 @@ describe('remoteRestoreSpawnIntentParams', () => {
|
||||
runtimeEnvironmentSupportsCapability.mockRejectedValueOnce(new Error('offline'))
|
||||
await expect(remoteRestoreSpawnIntentParams('env-1', 'automatic-restore')).resolves.toEqual({})
|
||||
})
|
||||
|
||||
it('does not probe when the connect is not a restore', async () => {
|
||||
await expect(remoteRestoreSpawnIntentParams('env-1', undefined)).resolves.toEqual({})
|
||||
expect(runtimeEnvironmentSupportsCapability).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('../../../../runtime/runtime-rpc-client', () => ({ callRuntimeRpc: vi.fn() }))
|
||||
|
||||
import { callRuntimeRpc } from '../../../../runtime/runtime-rpc-client'
|
||||
import { adoptRuntimeProvisionedRoot } from './runtime-provisioned-root-adoption'
|
||||
|
||||
describe('adoptRuntimeProvisionedRoot', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
vi.stubGlobal('window', {
|
||||
api: { ephemeralVm: { attachWorkspace: vi.fn(async () => ({})) } }
|
||||
})
|
||||
})
|
||||
|
||||
it("adopts the root on the VM's server, then records the workspace on the VM runtime", async () => {
|
||||
vi.mocked(callRuntimeRpc).mockResolvedValue({
|
||||
worktree: { id: 'repo-vm::/workspace/repo', repoId: 'repo-vm' }
|
||||
})
|
||||
const result = await adoptRuntimeProvisionedRoot(
|
||||
{ kind: 'environment', environmentId: 'env-vm' },
|
||||
{ repoId: 'repo-vm', name: 'fix-login', baseBranch: 'main' },
|
||||
{ name: 'fix-login' },
|
||||
{
|
||||
runtimeId: 'runtime-1',
|
||||
executionHostId: 'runtime:env-vm',
|
||||
expectedPath: '/workspace/repo',
|
||||
expectedRefHead: 'abc123'
|
||||
}
|
||||
)
|
||||
expect(callRuntimeRpc).toHaveBeenCalledWith(
|
||||
{ kind: 'environment', environmentId: 'env-vm' },
|
||||
'worktree.adoptProvisionedRoot',
|
||||
expect.objectContaining({
|
||||
repo: 'repo-vm',
|
||||
name: 'fix-login',
|
||||
baseBranch: 'main',
|
||||
expectedPath: '/workspace/repo',
|
||||
expectedRefHead: 'abc123'
|
||||
}),
|
||||
expect.anything()
|
||||
)
|
||||
expect(window.api.ephemeralVm.attachWorkspace).toHaveBeenCalledWith({
|
||||
runtimeId: 'runtime-1',
|
||||
workspaceId: 'repo-vm::/workspace/repo'
|
||||
})
|
||||
expect(result.worktree.id).toBe('repo-vm::/workspace/repo')
|
||||
})
|
||||
})
|
||||
@@ -1,25 +1,8 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
isRemoteRuntimePtyId,
|
||||
parseRemoteRuntimePtyId,
|
||||
toRemoteRuntimePtyId
|
||||
} from './remote-runtime-pty-id'
|
||||
import { isRemoteRuntimePtyId, parseRemoteRuntimePtyId } from './remote-runtime-pty-id'
|
||||
import { getPtyExecutionHost } from '../terminal-execution-host'
|
||||
|
||||
describe('isRemoteRuntimePtyId', () => {
|
||||
it('recognizes minted paired-runtime ids, with and without an owner', () => {
|
||||
expect(isRemoteRuntimePtyId(toRemoteRuntimePtyId('h1', 'env 1'))).toBe(true)
|
||||
expect(isRemoteRuntimePtyId(toRemoteRuntimePtyId('h1'))).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects local, SSH and missing ids', () => {
|
||||
expect(isRemoteRuntimePtyId('pty-1')).toBe(false)
|
||||
expect(isRemoteRuntimePtyId('ssh:conn@@pty-1')).toBe(false)
|
||||
expect(isRemoteRuntimePtyId('')).toBe(false)
|
||||
expect(isRemoteRuntimePtyId(null)).toBe(false)
|
||||
expect(isRemoteRuntimePtyId(undefined)).toBe(false)
|
||||
})
|
||||
|
||||
// Pins the merge of the prefix-only and parse-based copies: an unparseable `remote:` id still
|
||||
// runs off this host, matching getPtyExecutionHost's 'foreign' verdict.
|
||||
it('treats an unparseable remote id as remote, never local', () => {
|
||||
|
||||
Reference in New Issue
Block a user