devperf/frontend/__tests__/components/OKRProgressBars.test.ts
zyc 44464dd334 feat: DevPerf Dashboard 研发人效看板 v1.0
- 后端:Bun + Hono + Drizzle ORM + SQLite
- 前端:Vue 3 + Naive UI + ECharts
- 项目管理:创建项目 + 绑定 Git 仓库
- OKR 系统:目标/关键结果 CRUD + 进度追踪
- Git 同步:Gitea API 自动同步 commit/PR + 作者关联
- 数据看板:项目 OKR 进度 + KR 状态分布 + 代码活动
- 权限体系:admin/manager/developer/viewer 四级
- Docker 部署:docker-compose + nginx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 17:57:14 +08:00

60 lines
1.6 KiB
TypeScript

/**
* Component tests for OKRProgressBars.
* Validates rendering with OKR objective data.
*/
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import OKRProgressBars from '@/components/charts/OKRProgressBars.vue';
const mockObjectives = [
{
id: 'o1',
title: 'Improve delivery rate to 85%',
ownerName: 'Alice',
progress: 72,
keyResults: [
{ title: 'Sprint delivery > 80%', current: 80, target: 100, unit: '%' },
{ title: 'Reduce bug density', current: 0.08, target: 0.05, unit: '/kloc' },
],
},
{
id: 'o2',
title: 'Ship v2.0 platform',
ownerName: 'Bob',
progress: 45,
keyResults: [
{ title: 'Core features completed', current: 3, target: 5, unit: 'features' },
],
},
];
describe('OKRProgressBars', () => {
it('should mount with objectives data', () => {
const wrapper = mount(OKRProgressBars, {
props: { objectives: mockObjectives },
});
expect(wrapper.exists()).toBe(true);
});
it('should have chart container', () => {
const wrapper = mount(OKRProgressBars, {
props: { objectives: mockObjectives },
});
expect(wrapper.find('.okr-progress-bars').exists()).toBe(true);
});
it('should handle empty objectives', () => {
const wrapper = mount(OKRProgressBars, {
props: { objectives: [] },
});
expect(wrapper.exists()).toBe(true);
});
it('should handle single objective', () => {
const wrapper = mount(OKRProgressBars, {
props: { objectives: [mockObjectives[0]] },
});
expect(wrapper.exists()).toBe(true);
});
});