feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口
完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
1 parent
8e0bbf7a81
commit
c94d173f92
181 files changed
+12947
-1724
No files matched your search
+54
-40
@@ -4,18 +4,17 @@
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、process-gates.api mock。
|
||||
* 逻辑:构造未知环节/动作/技术自由文本;断言业务文案与审计 i18n;切换 execution_no 后清空审计。
|
||||
*/
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
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 listAuditMock = vi.fn();
|
||||
const postActionMock = vi.fn();
|
||||
|
||||
vi.mock('../api/process-gates.api', () => ({
|
||||
listWorkspaceProcessGateAuditEvents: (...args: unknown[]) => listAuditMock(...args),
|
||||
postWorkspaceProcessGateAction: vi.fn(),
|
||||
postWorkspaceProcessGateAction: (...args: unknown[]) => postActionMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
@@ -58,16 +57,7 @@ function baseSummary(overrides: Partial<ShippingProcessGateUserSummary> = {}): S
|
||||
|
||||
describe('ProcessGateRecoveryCard', () => {
|
||||
beforeEach(() => {
|
||||
listAuditMock.mockReset();
|
||||
listAuditMock.mockResolvedValue({
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
event_type: 'process_gate_attempt_started',
|
||||
created_at: '2026-08-01T00:00:00Z',
|
||||
},
|
||||
],
|
||||
});
|
||||
postActionMock.mockReset();
|
||||
});
|
||||
|
||||
it('does not expose internal gate, action or diagnostic text', () => {
|
||||
@@ -80,9 +70,13 @@ describe('ProcessGateRecoveryCard', () => {
|
||||
expect(text).toContain('当前步骤');
|
||||
expect(text).toContain('继续处理');
|
||||
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',
|
||||
@@ -123,33 +117,53 @@ describe('ProcessGateRecoveryCard', () => {
|
||||
expect(wrapper.find('[data-testid="process-gate-recovery-card"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('maps audit event codes to business labels and clears cache on execution change', async () => {
|
||||
it('does not render audit or internal execution details for end users', () => {
|
||||
const wrapper = mount(ProcessGateRecoveryCard, {
|
||||
props: { summary: baseSummary({ execution_no: 'EXEC-1' }), canHandle: true },
|
||||
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('后台编号');
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="process-gate-view-audit"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(listAuditMock).toHaveBeenCalledWith('EXEC-1', 1, 20);
|
||||
expect(wrapper.text()).toContain('开始执行处理');
|
||||
expect(wrapper.text()).not.toContain('process_gate_attempt_started');
|
||||
|
||||
listAuditMock.mockResolvedValue({
|
||||
items: [
|
||||
{
|
||||
id: 2,
|
||||
event_type: 'process_gate_blocked',
|
||||
created_at: '2026-08-01T01:00:00Z',
|
||||
},
|
||||
],
|
||||
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] },
|
||||
});
|
||||
await wrapper.setProps({ summary: baseSummary({ execution_no: 'EXEC-2' }) });
|
||||
await flushPromises();
|
||||
expect(wrapper.text()).not.toContain('开始执行处理');
|
||||
await wrapper.get('[data-testid="process-gate-view-audit"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(listAuditMock).toHaveBeenCalledWith('EXEC-2', 1, 20);
|
||||
expect(wrapper.text()).toContain('处理环节已阻断');
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user