Files
syops/frontend/src/features/chat/components/messages/TransferPendingMatchPanel.spec.ts
T
hugo 663f401873 feat(in-transit-transfer): 更新证据下载与待匹配清单逻辑
- 修改证据下载接口,分别签发预览地址与带保存名的下载地址,避免浏览器使用对象键哈希作为保存名。
- 待匹配清单接口调整,按外部单号合计数量,不再返回外部项次,提升数据展示的清晰度。
- 移除待匹配桶的「清空并重新解析」功能,简化操作流程,确保用户体验一致性。
- 新增跨页全选支持的 API,允许用户在待处理池中选择全部待处理明细 ID,优化批量操作体验。
2026-10-22 22:08:20 +08:00

88 lines
3.5 KiB
TypeScript

/**
* features/chat/components/messages/TransferPendingMatchPanel.spec.ts
* 用途:验证待匹配清单展示外部单号与合计数量,且不再提供清空重解析入口。
* 依赖:@vue/test-utils、i18n。
* 逻辑:两段表格都渲染外部单号,不渲染外部项次;空白显示占位;翻页只上抛页码。
*/
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferPendingMatchPanel from './TransferPendingMatchPanel.vue';
import type { TransferPendingMatchRecord } from '../../types/transfer.types';
const records: TransferPendingMatchRecord[] = [
{
ledger_record_id: 101,
doc_no: 'HOM-901',
external_doc_no: 'ASN-100',
material_code: 'MAT-9',
material_name: '未匹配物料',
movement_date: '2026-08-04',
source_code: 'DBS-AWSBI',
record_kind: 'inbound',
quantity: '55',
},
{
ledger_record_id: 102,
doc_no: 'HOM-901',
external_doc_no: '',
material_code: 'MAT-8',
material_name: '未匹配物料二',
movement_date: '2026-08-05',
source_code: 'DBS-AWSBI',
record_kind: 'inbound',
quantity: '12',
},
];
/**
* 挂载面板并等到表格行上屏。
* @param customRecords - 下段「其余已落档」当前页
* @param matchableRecords - 上段「当前可匹配」当前页
*/
async function mountFlushedPanel(
customRecords: TransferPendingMatchRecord[] = records,
matchableRecords: TransferPendingMatchRecord[] = [],
) {
const wrapper = mount(TransferPendingMatchPanel, {
props: { records: customRecords, matchableRecords },
global: { plugins: [i18n] },
});
await flushPromises();
return wrapper;
}
describe('TransferPendingMatchPanel 外部单号列', () => {
it('两段清单都显示外部单号和总数量,不显示项次,且没有清空重解析', async () => {
const wrapper = await mountFlushedPanel(records, [records[0]]);
const docs = wrapper.findAll('[data-testid="transfer-pending-match-external-doc"]').map((node) => node.text());
// [断言意图] 上段与下段都渲染外部单号;空白显示占位。项次列已取消。
expect(docs).toEqual(['ASN-100', 'ASN-100', '—']);
expect(wrapper.find('[data-testid="transfer-pending-match-external-line"]').exists()).toBe(false);
expect(wrapper.text()).toContain(i18n.global.t('chat.transfer.transferPendingMatchColExternalDoc'));
expect(wrapper.text()).toContain(i18n.global.t('chat.transfer.transferPendingMatchColQuantity'));
expect(wrapper.text()).toContain('55');
// [断言意图] 整桶重解析入口已下线,行上不再出现该按钮。
expect(wrapper.find('[data-testid="transfer-pending-match-reparse"]').exists()).toBe(false);
});
it('待匹配清单服务端分页:翻页上抛 page-change 由宿主拉取对应页', async () => {
const pageRecords = Array.from({ length: 20 }, (_, i) => ({
ledger_record_id: 200 + i,
doc_no: `HOM-${900 + i}`,
external_doc_no: `EXT-${i}`,
material_code: `MAT-${i}`,
material_name: '未匹配物料',
movement_date: '2026-08-05',
source_code: 'DBS-AWSBI',
quantity: '1',
}));
const wrapper = await mountFlushedPanel(pageRecords);
await wrapper.setProps({ total: 25 });
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(20);
await wrapper.find('.btn-next').trigger('click');
// [断言意图] 组件不自行改数据:翻页仅上抛 page-change({page:2})。
expect(wrapper.emitted('page-change')?.[0][0]).toEqual({ page: 2 });
});
});