mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-10 02:01:40 +00:00
feat(web): make session header metadata configurable (#1267)
* feat(web): make session header metadata configurable * fix(web): align mobile header metadata priority
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user