composer.test.ts 1.4 KB

12345678910111213141516171819202122232425262728
  1. import { mount } from '@vue/test-utils'
  2. import { describe, expect, it } from 'vitest'
  3. import ComposerShell from '@/components/composer/ComposerShell.vue'
  4. describe('composer availability', () => {
  5. it('keeps the group-chat send action available while an Agent is running', () => {
  6. const wrapper = mount(ComposerShell, { props: { mode: 'group', streaming: true } })
  7. expect(wrapper.find('[aria-label="发送消息"]').exists()).toBe(true)
  8. expect(wrapper.find('[aria-label="停止生成"]').exists()).toBe(false)
  9. })
  10. it('keeps the ordinary-chat interrupt action while its server run is active', () => {
  11. const wrapper = mount(ComposerShell, { props: { mode: 'chat', streaming: true } })
  12. expect(wrapper.find('[aria-label="停止生成"]').exists()).toBe(true)
  13. expect(wrapper.find('[aria-label="发送消息"]').exists()).toBe(false)
  14. })
  15. it('places an accessible blue fast-mode toggle beside the model control', () => {
  16. const wrapper = mount(ComposerShell, { props: { mode: 'chat', modelLabel: 'gpt-5.6-terra', fastMode: true } })
  17. const model = wrapper.get('.composer-tool--model')
  18. const fast = wrapper.get('.composer-fast-mode')
  19. expect(model.element.nextElementSibling).toBe(fast.element)
  20. expect(fast.attributes('aria-pressed')).toBe('true')
  21. expect(fast.classes()).toContain('active')
  22. fast.trigger('click')
  23. expect(wrapper.emitted('fastModeToggle')?.[0]).toEqual([false])
  24. })
  25. })