interfaceMode.test.ts 1.1 KB

12345678910111213141516171819202122232425
  1. import { beforeEach, describe, expect, it } from 'vitest'
  2. import { rememberInterfacePath, savedInterfacePath } from '@/utils/interfaceMode'
  3. beforeEach(() => localStorage.clear())
  4. describe('last interface mode', () => {
  5. it('opens application-owned chats by default and remembers an explicit history choice', () => {
  6. expect(savedInterfacePath()).toBe('/conversations')
  7. rememberInterfacePath('/conversations/existing-group')
  8. expect(savedInterfacePath()).toBe('/conversations')
  9. rememberInterfacePath('/files')
  10. expect(savedInterfacePath()).toBe('/conversations')
  11. rememberInterfacePath('/history/existing-session')
  12. expect(savedInterfacePath()).toBe('/conversations')
  13. rememberInterfacePath('/chat/existing-session')
  14. expect(savedInterfacePath()).toBe('/chat')
  15. })
  16. it('does not mistake unrelated paths or invalid storage for a mode', () => {
  17. localStorage.setItem('hermes-yaoyao:interface-mode', 'invalid')
  18. expect(savedInterfacePath()).toBe('/conversations')
  19. rememberInterfacePath('/conversations-other')
  20. expect(savedInterfacePath()).toBe('/conversations')
  21. })
  22. })