- 退役 erp_adapter/gateway_adapter:外部查询/写经 capability_client 走集成连接器,端点凭据与并发超时由客户端实例管理 - 域能力代码注册 capabilities:入参出参 Schema、幂等语义与读写标志随域代码版本化,组合根 create_app 幂等注册 - 新增调拨业务类型 transfer_type(在途仓至HUB/HUB维修出/HUB间)冻结枚举,迁移落 CheckConstraint 数据库兜底 - 外部仓库映射新增 in_transit_warehouse_code 拨出库位来源,管理端库存映射页同步维护 - 单据命名外部化:erp_* 字段与索引改称 external_*,单据号格式交由连接器映射,测试数据同步换牌 - 收料归档文件可用性判定收敛 receipt_file_gate 单一事实来源(当天抓取/保留期/清理态) - 同步 chat 调拨卡片、useChatTransfer、e2e、全套服务/API/Job 测试与域文档
169 lines
8.3 KiB
TypeScript
169 lines
8.3 KiB
TypeScript
/**
|
||
* features/chat/components/messages/transferCards.spec.ts
|
||
* 用途:验证在途调拨三张核心卡片(文件进度/预检/结果)+ 关闭弹窗的交互与禁用语义。
|
||
* 依赖:@vue/test-utils、i18n、transfer.types。
|
||
* 逻辑:断言按钮禁用、勾选禁用、ERP 单号展开/收起、异常展示、下载按钮与
|
||
* 结果页不出现“查看执行审计”入口(决策 19)。
|
||
*/
|
||
import { mount } from '@vue/test-utils';
|
||
import { describe, expect, it } from 'vitest';
|
||
import i18n from '@/i18n';
|
||
import TransferFileProgressCard from './TransferFileProgressCard.vue';
|
||
import TransferPrecheckCard from './TransferPrecheckCard.vue';
|
||
import TransferResultCard from './TransferResultCard.vue';
|
||
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
|
||
|
||
const mountOptions = { global: { plugins: [i18n] } };
|
||
|
||
const summary = {
|
||
precheck_id: 'TPC-1',
|
||
status: 'ready_to_execute',
|
||
business_date: '2026-08-06',
|
||
eligible_receipt_date_to: '2026-08-05',
|
||
expires_at: '',
|
||
counts: { file_invoice_count: 3, not_matured_count: 1, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
|
||
estimated_transfer_quantity: '2400',
|
||
estimated_external_write_count: 2,
|
||
precheck_hash: 'sha256:x',
|
||
};
|
||
|
||
const items = [
|
||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器', specification: 'A', invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
|
||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: '控制器', specification: 'B', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'not_matured' },
|
||
];
|
||
|
||
describe('TransferFileProgressCard', () => {
|
||
it('按来源显示阶段,不伪造总百分比', () => {
|
||
const wrapper = mount(TransferFileProgressCard, {
|
||
props: { sources: [
|
||
{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1', file_version: 'v3' },
|
||
{ source_code: 'CRANE-SZ', stage: 'waiting_rpa_callback' },
|
||
] },
|
||
...mountOptions,
|
||
});
|
||
expect(wrapper.find('[data-testid="transfer-source-DBS-AWSBI"]').text()).toContain('REC-1');
|
||
expect(wrapper.find('[data-testid="transfer-source-CRANE-SZ"]').text()).toContain('RPA');
|
||
});
|
||
});
|
||
|
||
describe('TransferPrecheckCard', () => {
|
||
it('阻断/未成熟项 checkbox 禁用;可执行项可选', () => {
|
||
const wrapper = mount(TransferPrecheckCard, {
|
||
props: { summary, items, selected: new Set(['INV-001']) },
|
||
...mountOptions,
|
||
});
|
||
const executableCheck = wrapper.find('[data-testid="transfer-check-INV-001"]');
|
||
const maturedCheck = wrapper.find('[data-testid="transfer-check-INV-041"]');
|
||
expect((executableCheck.element as HTMLInputElement).disabled).toBe(false);
|
||
expect((maturedCheck.element as HTMLInputElement).disabled).toBe(true);
|
||
});
|
||
|
||
it('未选择任何项时生成按钮禁用', () => {
|
||
const wrapper = mount(TransferPrecheckCard, {
|
||
props: { summary, items, selected: new Set() },
|
||
...mountOptions,
|
||
});
|
||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||
});
|
||
|
||
it('busy 时生成按钮禁用', () => {
|
||
const wrapper = mount(TransferPrecheckCard, {
|
||
props: { summary, items, selected: new Set(['INV-001']), busy: true },
|
||
...mountOptions,
|
||
});
|
||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||
});
|
||
|
||
it('点击生成按钮仅提交可执行勾选项', async () => {
|
||
const wrapper = mount(TransferPrecheckCard, {
|
||
props: { summary, items, selected: new Set(['INV-001']) },
|
||
...mountOptions,
|
||
});
|
||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||
expect(wrapper.emitted('execute')?.[0][0]).toEqual(['INV-001']);
|
||
});
|
||
|
||
it('同 Invoice 跨收料日期拆票(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||
// [断言意图] 回归防线(2026-09-21):拆票设计下 invoice_no 不再唯一,
|
||
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
|
||
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
|
||
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
|
||
const dupItems = [
|
||
{ source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', receipt_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||
{ source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||
{ source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||
];
|
||
const wrapper = mount(TransferPrecheckCard, {
|
||
props: { summary, items: dupItems, selected: new Set() },
|
||
...mountOptions,
|
||
});
|
||
expect(wrapper.findAll('tbody tr').length).toBe(3);
|
||
await wrapper.find('[data-testid="transfer-precheck-filter"]').setValue('HOX');
|
||
const rows = wrapper.findAll('tbody tr');
|
||
expect(rows.length).toBe(1);
|
||
expect(rows[0].text()).toContain('HOX-1');
|
||
});
|
||
});
|
||
|
||
describe('TransferResultCard', () => {
|
||
const run = {
|
||
run_no: 'RUN-1',
|
||
status: 'partial_failed',
|
||
result: {
|
||
external_documents: [{
|
||
document_no: 'TRF-10001',
|
||
from_warehouse: 'DBS-TRANSIT',
|
||
to_warehouse: 'HUB-CN01',
|
||
material_count: 1,
|
||
total_quantity: '1200',
|
||
posting_status: 'posted',
|
||
lines: [{ material_no: 'MAT-1', material_name: '连接器', specification: 'A', invoice_no: 'INV-001', quantity: '1200' }],
|
||
}],
|
||
exceptions: [{ source_code: 'DBS-AWSBI', invoice_no: 'INV-999', material_no: 'MAT-9', reason: 'business_failed', facts: '收料 300 / ERP 280' }],
|
||
},
|
||
};
|
||
|
||
it('按 ERP 单号聚合展示,物料明细可展开/收起', async () => {
|
||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||
const doc = wrapper.find('[data-testid="transfer-erp-document"]');
|
||
expect(doc.text()).toContain('TRF-10001');
|
||
expect(doc.attributes('open')).toBeUndefined();
|
||
await doc.find('summary').trigger('click');
|
||
expect(doc.attributes('open')).toBeDefined();
|
||
expect(wrapper.find('[data-testid="transfer-erp-document-lines"]').text()).toContain('INV-001');
|
||
});
|
||
|
||
it('未生成单据异常单独展示', () => {
|
||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||
expect(wrapper.find('[data-testid="transfer-exceptions-area"]').text()).toContain('INV-999');
|
||
});
|
||
|
||
it('提供两个下载按钮(收料来源文件 + ERP 库存表)', async () => {
|
||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||
await wrapper.find('[data-testid="transfer-download-receipt"]').trigger('click');
|
||
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
|
||
expect(wrapper.emitted('downloadReceipt')).toBeTruthy();
|
||
expect(wrapper.emitted('downloadErp')).toBeTruthy();
|
||
});
|
||
|
||
it('结果页不出现“查看执行审计”入口(决策 19)', () => {
|
||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||
expect(wrapper.text()).not.toContain('审计');
|
||
});
|
||
});
|
||
|
||
describe('TransferManualCloseDialog', () => {
|
||
it('原因为空时确认按钮禁用;填写后可提交', async () => {
|
||
const wrapper = mount(TransferManualCloseDialog, {
|
||
props: { open: true, invoiceNo: 'INV-001' },
|
||
...mountOptions,
|
||
});
|
||
const confirm = wrapper.find('[data-testid="transfer-close-confirm"]');
|
||
expect((confirm.element as HTMLButtonElement).disabled).toBe(true);
|
||
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('线下已处理');
|
||
expect((confirm.element as HTMLButtonElement).disabled).toBe(false);
|
||
await confirm.trigger('click');
|
||
expect(wrapper.emitted('confirm')?.[0][0]).toBe('线下已处理');
|
||
});
|
||
});
|