Files
hapi/web/src/lib/sessionProjectLabel.test.ts
T
SSU-WEI HUANGandGitHub 3f4bd9afea feat(web): show project in session header (#1635)
* feat(web): show project in session header

* fix(web): hide unknown worktree project paths
2026-10-28 12:14:04 +08:00

32 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getSessionProjectLabel, getSessionProjectPath } from './sessionProjectLabel'
describe('session project labels', () => {
it('uses the repository path for worktree sessions', () => {
expect(getSessionProjectPath({
path: '/work/hapi-worktrees/fix-resume',
worktree: { basePath: '/work/hapi' },
})).toBe('/work/hapi')
expect(getSessionProjectLabel('/work/hapi')).toBe('work/hapi')
})
it('formats nested POSIX and Windows paths like the sidebar', () => {
expect(getSessionProjectLabel('/home/user/coding/hapi')).toBe('coding/hapi')
expect(getSessionProjectLabel('C:\\work\\hapi')).toBe('work/hapi')
expect(getSessionProjectLabel('hapi')).toBe('hapi')
})
it('falls back to the session path and hides blank paths', () => {
expect(getSessionProjectPath({ path: '/repo' })).toBe('/repo')
expect(getSessionProjectPath({ path: ' ' })).toBeNull()
expect(getSessionProjectPath(null)).toBeNull()
})
it('does not treat a worktree with no base path as a simple session', () => {
expect(getSessionProjectPath({
path: '/work/hapi-worktrees/fix-resume',
worktree: { basePath: ' ' },
})).toBeNull()
})
})