Files
hermes-ui/tests/client/kanban-task-card.test.ts
T
toor 1e9ea89d86
Build / build (push) Canceled after 0s
NPM Lockfile Check / npm ci --ignore-scripts (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s
chore: bootstrap hermes-ui skeleton from 0.6.29 snapshot
Import the client, server, skills, tests, and build scripts as the starting
point for the rebuild, then trim the surfaces this project does not ship:
Electron desktop packaging, the marketing website, and the ESP32 firmware
tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows.

Rename the package and CLI entry points to hermes-ui, drop the prepare hook so
npm ci no longer triggers a build, and drop the removed tsconfig and nodemon
references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs
so the documented package map and hard rules match this repository.

reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
2026-10-16 10:34:35 +08:00

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')
})
})