统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
254 lines
9.4 KiB
TypeScript
254 lines
9.4 KiB
TypeScript
/**
|
|
* features/shipping-process-gates/components/ProcessGateRecoveryCard.spec.ts
|
|
* 用途:验证待处理事项卡片不展示未知内部编号和技术诊断文本;审计缓存随 Execution 切换清空。
|
|
* 依赖:Vitest、Vue Test Utils、vue-i18n、process-gates.api mock。
|
|
* 逻辑:构造未知环节/动作/技术自由文本;断言业务文案与审计 i18n;切换 execution_no 后清空审计。
|
|
*/
|
|
import { mount } from '@vue/test-utils';
|
|
import { createI18n } from 'vue-i18n';
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import workspaceZhCn from '@/locales/zh-CN/workspace.json';
|
|
import ProcessGateRecoveryCard from './ProcessGateRecoveryCard.vue';
|
|
import type { ShippingProcessGateUserSummary } from '../types/process-gate.types';
|
|
|
|
const postActionMock = vi.fn();
|
|
|
|
vi.mock('../api/process-gates.api', () => ({
|
|
postWorkspaceProcessGateAction: (...args: unknown[]) => postActionMock(...args),
|
|
}));
|
|
|
|
vi.mock('vue-router', () => ({
|
|
useRouter: () => ({ push: vi.fn() }),
|
|
}));
|
|
|
|
vi.mock('@/shared/composables/useMessage', () => ({
|
|
useMessage: () => ({
|
|
success: vi.fn(),
|
|
warning: vi.fn(),
|
|
error: vi.fn(),
|
|
}),
|
|
}));
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'zh-CN',
|
|
messages: { 'zh-CN': { workspace: workspaceZhCn } },
|
|
});
|
|
|
|
function baseSummary(overrides: Partial<ShippingProcessGateUserSummary> = {}): ShippingProcessGateUserSummary {
|
|
return {
|
|
execution_no: 'EXEC-1',
|
|
status: 'blocked',
|
|
current_blocking_gate: {
|
|
gate_code: 'auto_build_gate_quality_gate_passed',
|
|
label: 'quality_gate_internal',
|
|
status: 'blocked',
|
|
sequence_no: 1,
|
|
evaluation_version: 1,
|
|
blocking_reason_code: 'internal_reason_code',
|
|
next_action_code: 'internal_retry_action',
|
|
},
|
|
blocking_message: 'HTTP 500 error: node_id=abc',
|
|
diagnostic_hint: 'traceback: C:\\service\\worker.py',
|
|
responsible_party: 'owner',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe('ProcessGateRecoveryCard', () => {
|
|
beforeEach(() => {
|
|
postActionMock.mockReset();
|
|
});
|
|
|
|
it('does not expose internal gate, action or diagnostic text', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: { summary: baseSummary(), canHandle: true },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
const text = wrapper.text();
|
|
expect(text).toContain('当前处理环节');
|
|
expect(text).toContain('当前步骤');
|
|
expect(text).toContain('继续处理');
|
|
expect(text).toContain('当前步骤需要人工处理');
|
|
expect(text).toContain('操作建议');
|
|
expect(text).toContain('继续处理');
|
|
expect(text).not.toContain('下一步:');
|
|
expect(text).not.toContain('责任方');
|
|
expect(text).not.toContain('查看审计');
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-primary"]').classes())
|
|
.toEqual(expect.arrayContaining(['min-h-8', 'text-xs', 'border', 'bg-amber-600']));
|
|
for (const technicalText of [
|
|
'auto_build_gate_quality_gate_passed', 'quality_gate_internal', 'internal_reason_code',
|
|
'internal_retry_action', 'HTTP 500', 'node_id', 'traceback', 'worker.py',
|
|
]) {
|
|
expect(text).not.toContain(technicalText);
|
|
}
|
|
});
|
|
|
|
it('hides the card for system worker / technical_auto_only waits', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
technical_auto_only: true,
|
|
owner_type: 'system',
|
|
responsible_party: 'worker',
|
|
next_action_code: 'retry_inventory_preparation',
|
|
}),
|
|
canHandle: false,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-card"]').exists()).toBe(false);
|
|
expect(wrapper.text()).not.toContain('待处理事项');
|
|
});
|
|
|
|
it('hides the card when responsible_party is worker without owner_type', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
responsible_party: 'worker',
|
|
owner_type: undefined,
|
|
technical_auto_only: false,
|
|
}),
|
|
canHandle: false,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-card"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('does not render audit or internal execution details for end users', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: { summary: baseSummary(), canHandle: true },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="process-gate-view-audit"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-targets"]').exists()).toBe(false);
|
|
expect(wrapper.text()).not.toContain('执行尝试');
|
|
expect(wrapper.text()).not.toContain('后台编号');
|
|
});
|
|
|
|
it('renders a safe failure detail without exposing internal error text', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
failure_detail: 'Excel 写入失败:模板列缺失',
|
|
}),
|
|
canHandle: true,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="process-gate-failure-detail"]').text())
|
|
.toContain('Excel 写入失败:模板列缺失');
|
|
});
|
|
|
|
it('keeps one primary action even when server sends prerequisite recovery targets', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
current_blocking_gate: {
|
|
...baseSummary().current_blocking_gate!,
|
|
gate_code: 'inventory_matching',
|
|
next_action_code: 'open_inventory_match_review',
|
|
},
|
|
next_action_code: 'open_inventory_match_review',
|
|
recovery_targets: [{
|
|
action_code: 'retry_inventory_from_preparation',
|
|
target_gate: 'inventory_preparation',
|
|
resume_after_gate: 'inventory_matching',
|
|
invalidates: ['inventory_snapshot'],
|
|
}],
|
|
}),
|
|
canHandle: true,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-targets"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-primary"]').exists()).toBe(true);
|
|
});
|
|
|
|
it('keeps the pending-item explanation but hides all actions in read-only mode', () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: { summary: baseSummary(), canHandle: false, showActions: false },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-card"]').exists()).toBe(true);
|
|
expect(wrapper.find('[data-testid="process-gate-next-action"]').exists()).toBe(true);
|
|
expect(wrapper.find('[data-testid="process-gate-recovery-primary"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="process-gate-readonly-hint"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('shows inventory upload as a secondary entry beside retrying inventory retrieval', async () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
current_blocking_gate: {
|
|
...baseSummary().current_blocking_gate!,
|
|
gate_code: 'inventory_preparation',
|
|
next_action_code: 'retry_inventory_preparation',
|
|
},
|
|
next_action_code: 'retry_inventory_preparation',
|
|
allowed_actions: ['retry_inventory_preparation', 'upload_inventory_file'],
|
|
task_no: 'SN-TEST-001',
|
|
}),
|
|
canHandle: true,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
|
|
const upload = wrapper.get('[data-testid="process-gate-inventory-upload"]');
|
|
expect(upload.text()).toContain('上传库存文件');
|
|
await upload.trigger('click');
|
|
expect(wrapper.emitted('navigate')).toHaveLength(1);
|
|
});
|
|
|
|
it('opens local upload registration when requested by the order review workbench', async () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
current_blocking_gate: {
|
|
...baseSummary().current_blocking_gate!,
|
|
gate_code: 'inventory_preparation',
|
|
next_action_code: 'retry_inventory_preparation',
|
|
},
|
|
next_action_code: 'retry_inventory_preparation',
|
|
allowed_actions: ['retry_inventory_preparation', 'upload_inventory_file'],
|
|
task_no: 'SN-TEST-001',
|
|
}),
|
|
canHandle: true,
|
|
inventoryUploadMode: 'local',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
|
|
await wrapper.get('[data-testid="process-gate-inventory-upload"]').trigger('click');
|
|
expect(wrapper.emitted('manualUpload')).toHaveLength(1);
|
|
expect(wrapper.emitted('navigate')).toBeUndefined();
|
|
});
|
|
|
|
it('opens evidence registration for the manual-upload confirmation primary action', async () => {
|
|
const wrapper = mount(ProcessGateRecoveryCard, {
|
|
props: {
|
|
summary: baseSummary({
|
|
current_blocking_gate: {
|
|
...baseSummary().current_blocking_gate!,
|
|
gate_code: 'manual_upload_handoff',
|
|
next_action_code: 'mark_manual_uploaded',
|
|
},
|
|
next_action_code: 'mark_manual_uploaded',
|
|
allowed_actions: ['mark_manual_uploaded'],
|
|
task_no: 'SN-TEST-001',
|
|
} as ShippingProcessGateUserSummary),
|
|
canHandle: true,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
|
|
await wrapper.get('[data-testid="process-gate-recovery-primary"]').trigger('click');
|
|
|
|
expect(wrapper.emitted('manualUpload')).toHaveLength(1);
|
|
expect(postActionMock).not.toHaveBeenCalled();
|
|
});
|
|
});
|