mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-25 13:30:14 +00:00
904ca8c648
Add modular group-chat mention routing helpers for the reserved @all token, route it to every non-sender agent, and strip routing tokens before model input. Expose @all in mention autocomplete, highlight it in group messages, reserve literal all agent names, and cover boundary/partial-match regressions with tests.
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
vi.mock('vue-i18n', () => ({
|
|
useI18n: () => ({
|
|
t: (key: string) => key,
|
|
}),
|
|
}))
|
|
|
|
vi.mock('naive-ui', async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import('naive-ui')>()
|
|
return {
|
|
...actual,
|
|
useMessage: () => ({
|
|
error: vi.fn(),
|
|
success: vi.fn(),
|
|
warning: vi.fn(),
|
|
info: vi.fn(),
|
|
}),
|
|
}
|
|
})
|
|
|
|
vi.mock('@/api/hermes/download', () => ({
|
|
downloadFile: vi.fn(),
|
|
getDownloadUrl: vi.fn((path: string) => `/download?path=${encodeURIComponent(path)}`),
|
|
}))
|
|
|
|
vi.mock('@/components/hermes/chat/mermaidRenderer', () => ({
|
|
renderMermaidDiagram: vi.fn(),
|
|
}))
|
|
|
|
import MarkdownRenderer from '@/components/hermes/chat/MarkdownRenderer.vue'
|
|
|
|
describe('MarkdownRenderer special mentions', () => {
|
|
it('highlights @all as a mention when provided by group chat', () => {
|
|
const wrapper = mount(MarkdownRenderer, {
|
|
props: {
|
|
content: '@all, please compare options',
|
|
mentionNames: ['all', 'Alice'],
|
|
},
|
|
})
|
|
|
|
expect(wrapper.find('.mention-highlight').text()).toBe('@all')
|
|
})
|
|
|
|
it('highlights @all at the end of rendered paragraphs and after opening punctuation', () => {
|
|
for (const content of ['@all', 'please compare @all', '(@all)']) {
|
|
const wrapper = mount(MarkdownRenderer, {
|
|
props: {
|
|
content,
|
|
mentionNames: ['all', 'Alice'],
|
|
},
|
|
})
|
|
|
|
expect(wrapper.find('.mention-highlight').text()).toBe('@all')
|
|
}
|
|
})
|
|
|
|
it('does not highlight @alligator as @all', () => {
|
|
const wrapper = mount(MarkdownRenderer, {
|
|
props: {
|
|
content: '@alligator should stay plain',
|
|
mentionNames: ['all'],
|
|
},
|
|
})
|
|
|
|
expect(wrapper.find('.mention-highlight').exists()).toBe(false)
|
|
})
|
|
})
|