mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-07-16 21:50:15 +00:00
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { mount, flushPromises } from '@vue/test-utils'
|
|
import { createPinia, setActivePinia } from 'pinia'
|
|
import GroupChatView from '@/views/hermes/GroupChatView.vue'
|
|
import { useGroupChatStore } from '@/stores/hermes/group-chat'
|
|
import { useSettingsStore } from '@/stores/hermes/settings'
|
|
|
|
vi.mock('@/components/hermes/group-chat/GroupChatPanel.vue', () => ({
|
|
default: { template: '<div data-testid="group-chat-panel" />' },
|
|
}))
|
|
|
|
const mockRoute = {
|
|
params: {},
|
|
}
|
|
const mockReplace = vi.fn()
|
|
|
|
vi.mock('vue-router', async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import('vue-router')>()
|
|
return {
|
|
...actual,
|
|
useRoute: () => mockRoute,
|
|
useRouter: () => ({ replace: mockReplace }),
|
|
}
|
|
})
|
|
|
|
describe('GroupChatView settings preload', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
setActivePinia(createPinia())
|
|
})
|
|
|
|
it('loads display settings when entering group chat directly', async () => {
|
|
const groupStore = useGroupChatStore()
|
|
const settingsStore = useSettingsStore()
|
|
vi.spyOn(groupStore, 'connect').mockImplementation(() => undefined)
|
|
vi.spyOn(groupStore, 'loadRooms').mockResolvedValue(undefined as any)
|
|
vi.spyOn(settingsStore, 'fetchSettings').mockResolvedValue(undefined as any)
|
|
|
|
mount(GroupChatView)
|
|
await flushPromises()
|
|
|
|
expect(groupStore.connect).toHaveBeenCalledOnce()
|
|
expect(groupStore.loadRooms).toHaveBeenCalledOnce()
|
|
expect(settingsStore.fetchSettings).toHaveBeenCalledOnce()
|
|
})
|
|
})
|