mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 00:04:01 +00:00
76 lines
2.0 KiB
TypeScript
76 lines
2.0 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('drops a tab with an empty startup cwd instead of failing the session', () => {
|
|
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(true)
|
|
if (result.ok) {
|
|
expect(result.value.tabsByWorktree.wt).toEqual([])
|
|
}
|
|
})
|
|
})
|