mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
* feat(web): show project in session header * fix(web): hide unknown worktree project paths
32 lines
1.3 KiB
TypeScript
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()
|
|
})
|
|
})
|