mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-25 21:40:13 +00:00
b5f0215beb
- Render only the selected status column when status chips are active - Add status color treatments and default assignee normalization - Reuse profile avatars for Kanban card assignee tags - Cover status filtering, default assignee labels, and avatar rendering
81 lines
2.9 KiB
TypeScript
81 lines
2.9 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { defineComponent } from 'vue'
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
vi.mock('vue-i18n', () => ({
|
|
useI18n: () => ({
|
|
t: (key: string, params?: Record<string, number>) => {
|
|
if (key === 'kanban.card.timeAgo.justNow') return '刚刚'
|
|
if (key === 'kanban.card.timeAgo.minutes') return `${params?.count}分钟前`
|
|
if (key === 'kanban.card.timeAgo.hours') return `${params?.count}小时前`
|
|
if (key === 'kanban.card.timeAgo.days') return `${params?.count}天前`
|
|
if (key === 'kanban.card.priority.high') return '高'
|
|
if (key === 'kanban.card.priority.medium') return '中'
|
|
if (key === 'kanban.card.priority.low') return '低'
|
|
if (key === 'kanban.card.assigneeTooltip') return '负责人'
|
|
return key
|
|
},
|
|
}),
|
|
}))
|
|
|
|
vi.mock('naive-ui', () => ({
|
|
NTooltip: defineComponent({
|
|
name: 'NTooltip',
|
|
template: '<div class="n-tooltip-stub"><slot name="trigger" /><div class="tooltip-content"><slot /></div></div>',
|
|
}),
|
|
}))
|
|
|
|
vi.mock('@/components/hermes/profiles/ProfileAvatar.vue', () => ({
|
|
default: defineComponent({
|
|
name: 'ProfileAvatar',
|
|
props: { name: { type: String, required: true }, avatar: { type: Object, required: false }, size: { type: Number, required: false } },
|
|
template: '<span class="assignee-profile-avatar-stub" :data-name="name" :data-avatar-type="avatar?.type || null" :data-avatar-seed="avatar?.seed || null"></span>',
|
|
}),
|
|
}))
|
|
|
|
import KanbanTaskCard from '@/components/hermes/kanban/KanbanTaskCard.vue'
|
|
|
|
describe('KanbanTaskCard i18n', () => {
|
|
afterEach(() => {
|
|
vi.useRealTimers()
|
|
})
|
|
|
|
it('renders localized priority, tooltip, and relative time', () => {
|
|
vi.useFakeTimers()
|
|
vi.setSystemTime(new Date('2026-05-08T03:00:00Z'))
|
|
|
|
const wrapper = mount(KanbanTaskCard, {
|
|
props: {
|
|
assigneeAvatar: { type: 'generated', seed: 'alice-seed' },
|
|
task: {
|
|
id: 'task-1',
|
|
title: 'Ship kanban i18n',
|
|
body: 'Body preview content',
|
|
assignee: 'alice',
|
|
status: 'todo',
|
|
priority: 3,
|
|
created_by: null,
|
|
created_at: Math.floor(new Date('2026-05-08T02:58:00Z').getTime() / 1000),
|
|
started_at: null,
|
|
completed_at: null,
|
|
workspace_kind: 'local',
|
|
workspace_path: null,
|
|
tenant: null,
|
|
result: null,
|
|
skills: null,
|
|
},
|
|
},
|
|
})
|
|
|
|
expect(wrapper.text()).toContain('高')
|
|
expect(wrapper.text()).toContain('2分钟前')
|
|
expect(wrapper.text()).toContain('负责人')
|
|
expect(wrapper.classes()).toContain('status-todo')
|
|
const avatar = wrapper.find('.assignee-profile-avatar-stub')
|
|
expect(avatar.attributes('data-name')).toBe('alice')
|
|
expect(avatar.attributes('data-avatar-type')).toBe('generated')
|
|
expect(avatar.attributes('data-avatar-seed')).toBe('alice-seed')
|
|
})
|
|
})
|