Files
syops/frontend/src/features/chat/components/ChatInputBar.spec.ts
T
hugo 1b6483a4ea feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
2026-08-20 20:23:10 +08:00

116 lines
4.7 KiB
TypeScript

/**
* features/chat/components/ChatInputBar.spec.ts
* 用途:验证采购合同双文件在聊天输入栏中的统一卡片展示与删除交互。
* 依赖:Vue Test Utils、Vue I18n、ChatInputBar。
* 逻辑:我方原合同和卖方回传合同均以附件卡片展示;删除我方原合同必须通知上层清除对应资产状态。
*/
import { mount } from '@vue/test-utils';
import { ref } from 'vue';
import { createI18n } from 'vue-i18n';
import { describe, expect, it } from 'vitest';
import ChatInputBar from './ChatInputBar.vue';
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: { 'zh-CN': {} },
});
/** 创建采购合同双文件输入栏所需的最小属性。 */
function mountProcurementInputBar() {
return mount(ChatInputBar, {
props: {
modelValue: '',
procurementReviewMode: 'compare',
attachments: [{
id: 'seller-contract',
kind: 'local',
file: new File(['seller'], '卖方回传合同.md', { type: 'text/markdown' }),
type: 'document',
uploadStatus: 'waiting',
uploadProgress: 0,
}],
attachmentPolicy: { anyEnabled: true, canLocal: true, canRemote: false, accept: '.md' },
isThinking: false,
isVoiceRecording: false,
isVoiceTranscribing: false,
isUploadingAttachments: false,
canSendMessage: true,
isShippingNoticeAgent: false,
isProcurementContractAgent: true,
procurementOriginalContractName: '我方原合同.md',
isMaintenanceAgent: false,
canManageMaintenance: false,
canForceCreateShippingDuplicate: false,
shippingSuggestedPrompt: '',
shippingPickerRefHolder: { pickerRef: ref(null) },
shippingNoticePickerRefHolder: { pickerRef: ref(null) },
},
global: { plugins: [i18n] },
});
}
/** 创建仅选择我方原合同、尚未选择卖方回传合同的输入栏。 */
function mountOriginalContractOnlyInputBar() {
return mount(ChatInputBar, {
props: {
modelValue: '',
procurementReviewMode: 'compare',
attachments: [],
attachmentPolicy: { anyEnabled: true, canLocal: true, canRemote: false, accept: '.md' },
isThinking: false,
isVoiceRecording: false,
isVoiceTranscribing: false,
isUploadingAttachments: true,
canSendMessage: false,
isShippingNoticeAgent: false,
isProcurementContractAgent: true,
procurementOriginalContractName: '我方原合同.md',
isMaintenanceAgent: false,
canManageMaintenance: false,
canForceCreateShippingDuplicate: false,
shippingSuggestedPrompt: '',
shippingPickerRefHolder: { pickerRef: ref(null) },
shippingNoticePickerRefHolder: { pickerRef: ref(null) },
},
global: { plugins: [i18n] },
});
}
describe('ChatInputBar procurement contract attachments', () => {
it('shows the original contract immediately even before a seller contract is selected', () => {
const wrapper = mountOriginalContractOnlyInputBar();
// 原合同上传中时卖方附件数组为空,仍必须显示原合同卡片提供明确反馈。
expect(wrapper.get('[data-testid="chat-attachment-list"]')).toBeTruthy();
expect(wrapper.get('[data-testid="procurement-original-contract-card"]')).toBeTruthy();
expect(wrapper.findAll('[data-testid="chat-attachment-card"]')).toHaveLength(0);
});
it('renders the original contract as a standard attachment card and clears it on delete', async () => {
const wrapper = mountProcurementInputBar();
// 断言两份合同使用同一附件卡片结构,防止我方原合同退化回独立小标签。
expect(wrapper.get('[data-testid="procurement-original-contract-card"]')).toBeTruthy();
expect(wrapper.findAll('[data-testid="chat-attachment-card"], [data-testid="procurement-original-contract-card"]')).toHaveLength(2);
await wrapper.get('[data-testid="remove-procurement-original-contract"]').trigger('click');
// 删除操作必须交由父级清空 originalContractAssetNo 与名称,避免残留无形基准文件。
expect(wrapper.emitted('clear-procurement-original-contract')).toHaveLength(1);
});
it('keeps original-contract delete pointer events out of the attachment drag surface', async () => {
const wrapper = mountProcurementInputBar();
let dragSurfaceReceivedPointerDown = false;
wrapper.get('[data-testid="chat-attachment-list"]').element.addEventListener('pointerdown', () => {
dragSurfaceReceivedPointerDown = true;
});
// 删除按钮不能触发横向拖拽容器,否则指针捕获会干扰实际 click 事件。
await wrapper.get('[data-testid="remove-procurement-original-contract"]').trigger('pointerdown');
expect(dragSurfaceReceivedPointerDown).toBe(false);
});
});