mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
* feat(web): make session header metadata configurable * fix(web): align mobile header metadata priority
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import { DEFAULT_SESSION_HEADER_METADATA, parseSessionHeaderMetadata } from './useSessionHeaderMetadata'
|
|
|
|
describe('parseSessionHeaderMetadata', () => {
|
|
beforeEach(() => localStorage.clear())
|
|
|
|
it('preserves the existing header display by default', () => {
|
|
expect(parseSessionHeaderMetadata(null)).toEqual(DEFAULT_SESSION_HEADER_METADATA)
|
|
expect(DEFAULT_SESSION_HEADER_METADATA).toMatchObject({
|
|
showLabels: true,
|
|
agent: true,
|
|
model: true,
|
|
reasoning: true,
|
|
fastMode: true,
|
|
machine: true,
|
|
lastActive: true,
|
|
createdAt: false,
|
|
updatedAt: false,
|
|
worktree: true,
|
|
})
|
|
})
|
|
|
|
it('merges stored booleans with defaults for forward compatibility', () => {
|
|
expect(parseSessionHeaderMetadata(JSON.stringify({ showLabels: false, reasoning: false, createdAt: true, model: 'nope' }))).toEqual({
|
|
...DEFAULT_SESSION_HEADER_METADATA,
|
|
showLabels: false,
|
|
reasoning: false,
|
|
createdAt: true,
|
|
})
|
|
})
|
|
|
|
it('ignores invalid stored values', () => {
|
|
expect(parseSessionHeaderMetadata('{')).toEqual(DEFAULT_SESSION_HEADER_METADATA)
|
|
expect(parseSessionHeaderMetadata('[]')).toEqual(DEFAULT_SESSION_HEADER_METADATA)
|
|
})
|
|
})
|