86 lines
3.0 KiB
TypeScript
86 lines
3.0 KiB
TypeScript
/**
|
|
* features/workspace/shipping-task-center/TaskProgressTimeline.spec.ts
|
|
* 用途:锁定任务中心时间线仅消费统一 ShippingAuditEvent 条目。
|
|
* 依赖:Vitest、@vue/test-utils、TaskProgressTimeline。
|
|
* 逻辑:渲染 auditItems;未知内部码与敏感字段不直出;空态与 loading 态可区分。
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createI18n } from 'vue-i18n';
|
|
import TaskProgressTimeline from './TaskProgressTimeline.vue';
|
|
|
|
const messages = {
|
|
'zh-CN': {
|
|
workspace: {
|
|
shippingNotice: {
|
|
events: '事件时间线',
|
|
operator: '操作者 {id}',
|
|
auditTimeline: {
|
|
events: { task_created: '任务已创建' },
|
|
},
|
|
eventTypes: { system: '系统' },
|
|
timeline: {
|
|
empty: '暂无事件记录',
|
|
loading: '加载中…',
|
|
sourceAudit: '审计记录',
|
|
updated: '处理状态已更新',
|
|
actors: { user: '业务人员', system: '系统' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
describe('TaskProgressTimeline', () => {
|
|
it('renders unified audit items with actor display and source badge', () => {
|
|
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
|
|
const wrapper = mount(TaskProgressTimeline, {
|
|
props: {
|
|
items: [
|
|
{
|
|
id: 1,
|
|
event_type: 'task_created',
|
|
actor_display: '业务人员',
|
|
created_at: '2026-07-31T01:00:00Z',
|
|
reason: '任务创建成功',
|
|
},
|
|
{
|
|
id: 2,
|
|
event_type: 'upload_rpa_triggered',
|
|
actor_type: 'system',
|
|
created_at: '2026-07-31T01:01:00Z',
|
|
},
|
|
],
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
// 关键断言:统一审计来源标签与本地化事件文案可见。
|
|
expect(wrapper.text()).toContain('审计记录');
|
|
expect(wrapper.text()).toContain('任务已创建');
|
|
expect(wrapper.text()).toContain('处理状态已更新');
|
|
expect(wrapper.text()).toContain('操作者 业务人员');
|
|
expect(wrapper.text()).toContain('操作者 系统');
|
|
expect(wrapper.text()).toContain('任务创建成功');
|
|
expect(wrapper.text()).not.toContain('upload_rpa_triggered');
|
|
});
|
|
|
|
it('shows empty state when no audit items', () => {
|
|
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
|
|
const wrapper = mount(TaskProgressTimeline, {
|
|
props: { items: [] },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('暂无事件记录');
|
|
});
|
|
|
|
it('shows loading placeholder before items arrive', () => {
|
|
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
|
|
const wrapper = mount(TaskProgressTimeline, {
|
|
props: { items: [], loading: true },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('加载中…');
|
|
expect(wrapper.text()).not.toContain('暂无事件记录');
|
|
});
|
|
});
|