mirror of
https://github.com/stablyai/orca.git
synced 2026-10-26 16:02:42 +00:00
Add an Open in Terminal action for file-explorer directories and preserve terminal startup cwd through restore/session paths.
73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { parseWorkspaceSession } from './workspace-session-schema'
|
|
|
|
describe('parseWorkspaceSession terminal fields', () => {
|
|
it('preserves terminal startup cwd while accepting older omitted fields', () => {
|
|
const result = parseWorkspaceSession({
|
|
activeRepoId: null,
|
|
activeWorktreeId: 'wt',
|
|
activeTabId: 'tab1',
|
|
tabsByWorktree: {
|
|
wt: [
|
|
{
|
|
id: 'tab1',
|
|
ptyId: null,
|
|
worktreeId: 'wt',
|
|
title: 'Terminal 1',
|
|
defaultTitle: 'Terminal 1',
|
|
startupCwd: '/repo/packages/app',
|
|
customTitle: null,
|
|
color: null,
|
|
sortOrder: 0,
|
|
createdAt: 0
|
|
},
|
|
{
|
|
id: 'tab2',
|
|
ptyId: null,
|
|
worktreeId: 'wt',
|
|
title: 'Terminal 2',
|
|
customTitle: null,
|
|
color: null,
|
|
sortOrder: 1,
|
|
createdAt: 1
|
|
}
|
|
]
|
|
},
|
|
terminalLayoutsByTabId: {}
|
|
})
|
|
|
|
expect(result.ok).toBe(true)
|
|
if (result.ok) {
|
|
expect(result.value.tabsByWorktree.wt[0].startupCwd).toBe('/repo/packages/app')
|
|
expect(result.value.tabsByWorktree.wt[1].startupCwd).toBeUndefined()
|
|
}
|
|
})
|
|
|
|
it('rejects empty terminal startup cwd values', () => {
|
|
const result = parseWorkspaceSession({
|
|
activeRepoId: null,
|
|
activeWorktreeId: 'wt',
|
|
activeTabId: 'tab1',
|
|
tabsByWorktree: {
|
|
wt: [
|
|
{
|
|
id: 'tab1',
|
|
ptyId: null,
|
|
worktreeId: 'wt',
|
|
title: 'Terminal 1',
|
|
defaultTitle: 'Terminal 1',
|
|
startupCwd: '',
|
|
customTitle: null,
|
|
color: null,
|
|
sortOrder: 0,
|
|
createdAt: 0
|
|
}
|
|
]
|
|
},
|
|
terminalLayoutsByTabId: {}
|
|
})
|
|
|
|
expect(result.ok).toBe(false)
|
|
})
|
|
})
|