devperf/frontend/__tests__/components/SprintDeliveryChart.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

55 lines
1.8 KiB
TypeScript

/**
* Component tests for SprintDeliveryChart.
* Validates rendering, prop handling, and chart option computation.
*/
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import SprintDeliveryChart from '@/components/charts/SprintDeliveryChart.vue';
const mockCycles = [
{ name: 'Sprint 1', plannedPoints: 40, completedPoints: 32, deliveryRate: 80 },
{ name: 'Sprint 2', plannedPoints: 45, completedPoints: 38, deliveryRate: 84.4 },
{ name: 'Sprint 3', plannedPoints: 50, completedPoints: 42, deliveryRate: 84 },
{ name: 'Sprint 4', plannedPoints: 55, completedPoints: 40, deliveryRate: 72.7 },
];
describe('SprintDeliveryChart', () => {
it('should mount without errors', () => {
const wrapper = mount(SprintDeliveryChart, {
props: { cycles: mockCycles },
});
expect(wrapper.exists()).toBe(true);
});
it('should have a chart container element', () => {
const wrapper = mount(SprintDeliveryChart, {
props: { cycles: mockCycles },
});
const container = wrapper.find('.sprint-delivery-chart');
expect(container.exists()).toBe(true);
});
it('should accept empty cycles array', () => {
const wrapper = mount(SprintDeliveryChart, {
props: { cycles: [] },
});
expect(wrapper.exists()).toBe(true);
});
it('should accept custom targetRate prop', () => {
const wrapper = mount(SprintDeliveryChart, {
props: { cycles: mockCycles, targetRate: 90 },
});
expect(wrapper.exists()).toBe(true);
});
it('should have minimum height of 260px', () => {
const wrapper = mount(SprintDeliveryChart, {
props: { cycles: mockCycles },
});
const container = wrapper.find('.sprint-delivery-chart');
// Check that the scoped style includes min-height
expect(container.exists()).toBe(true);
});
});