sessionPreferences.test.ts 1.4 KB

123456789101112131415161718192021222324252627282930
  1. import { describe, expect, it } from 'vitest'
  2. import {
  3. moveSessionFastMode, readAgentShowThinking, readSessionFastMode, writeAgentShowThinking, writeSessionFastMode,
  4. } from '@/utils/sessionPreferences'
  5. describe('session and Agent display preferences', () => {
  6. it('isolates fast mode by account, Agent, and session', () => {
  7. writeSessionFastMode('u1', 'yaoer', 's1', true)
  8. expect(readSessionFastMode('u1', 'yaoer', 's1')).toBe(true)
  9. expect(readSessionFastMode('u1', 'default', 's1')).toBe(false)
  10. expect(readSessionFastMode('u2', 'yaoer', 's1')).toBe(false)
  11. expect(readSessionFastMode('u1', 'yaoer', 's2')).toBe(false)
  12. })
  13. it('moves a draft fast-mode selection to the stored session identity', () => {
  14. writeSessionFastMode('u1', 'default', 'draft-1', true)
  15. moveSessionFastMode('u1', 'default', 'draft-1', 'stored-1', true)
  16. expect(readSessionFastMode('u1', 'default', 'draft-1')).toBe(false)
  17. expect(readSessionFastMode('u1', 'default', 'stored-1')).toBe(true)
  18. })
  19. it('stores show-thinking once per account and Agent', () => {
  20. expect(readAgentShowThinking('u1', 'yaoer')).toBe(true)
  21. writeAgentShowThinking('u1', 'yaoer', false)
  22. expect(readAgentShowThinking('u1', 'yaoer')).toBe(false)
  23. expect(readAgentShowThinking('u1', 'default')).toBe(true)
  24. writeAgentShowThinking('u1', 'yaoer', true)
  25. expect(readAgentShowThinking('u1', 'yaoer')).toBe(true)
  26. })
  27. })