resourceSidebar.test.ts 1.0 KB

12345678910111213141516171819202122232425
  1. import { mount } from '@vue/test-utils'
  2. import { describe, expect, it } from 'vitest'
  3. import ResourceSidebar from '@/components/app/ResourceSidebar.vue'
  4. describe('ResourceSidebar', () => {
  5. it('keeps fallback avatars stable across topics from the same team', () => {
  6. const wrapper = mount(ResourceSidebar, {
  7. props: {
  8. items: [
  9. { id: 'topic:room-1:topic-1', title: '话题一', topic: true, avatar: '', avatarFallbackKey: 'room-1' },
  10. { id: 'topic:room-1:topic-2', title: '话题二', topic: true, avatar: '', avatarFallbackKey: 'room-1' },
  11. ],
  12. },
  13. })
  14. const signatures = wrapper.findAll('.team-avatar').map(team => team.findAll('.agent-avatar').map(agent => {
  15. const shape = agent.find('.agent-avatar__body').element.firstElementChild?.tagName
  16. const color = agent.find('stop[offset="0.5"]').attributes('stop-color')
  17. return `${shape}:${color}`
  18. }))
  19. expect(signatures).toHaveLength(2)
  20. expect(signatures[0]).toHaveLength(3)
  21. expect(signatures[1]).toEqual(signatures[0])
  22. })
  23. })