/** * features/chat/components/shipping-review/ReviewCustomerResolutionPanel.spec.ts * 用途:锁定唯一标准客户候选的工作台提示,避免将可自动确认状态误报为未识别。 * 依赖:vitest、@vue/test-utils、vue-i18n、ReviewCustomerResolutionPanel。 * 逻辑:unique_candidate 显示自动确认说明和明确按钮;其他未确认状态维持人工选择入口。 */ import { describe, expect, it } from 'vitest'; import { mount } from '@vue/test-utils'; import { createI18n } from 'vue-i18n'; import ReviewCustomerResolutionPanel from './ReviewCustomerResolutionPanel.vue'; const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages: { 'zh-CN': { chat: { shippingCustomer: { loadFailed: '加载失败', confirmFailed: '确认失败' }, shippingOrderReview: { customerResolution: { title: '客户确认', subtitle: '请选择标准客户', uniqueCandidateHint: '已找到唯一标准客户候选;保存校验时系统会自动确认,也可手动确认。', confirmUniqueCandidate: '确认唯一候选', selectCustomer: '选择标准客户', retrying: '识别中…', retryCustomer: '重新识别客户', retryDone: '已重新识别客户', retryFailed: '重新识别客户失败', confirmed: '客户已确认', confirmReason: '人工确认', standardCustomer: '标准客户', customerCode: '客户编码', matchedInputs: '匹配输入', candidates: '候选客户', pdfReparseHint: '请重新识别 PDF', inputLabels: { customerCode: '客户编码', customerName: '客户名称', address: '地址', email: '邮箱', domain: '域名', other: '其他' }, status: { unique_candidate: '唯一候选', unmatched: '未匹配', confirmed: '已确认' }, }, resume: { autoCreated: '已自动建单', waitingManualConfirm: '等待人工确认' }, }, }, }, }, }); function mountPanel(status: string) { return mount(ReviewCustomerResolutionPanel, { props: { caseNo: 'CASE-CUSTOMER-1', editable: true, resolution: { resolved: false, status, raw_name: 'ACME' }, }, global: { plugins: [i18n], stubs: { ShippingCustomerConfirmDialog: true }, }, }); } describe('ReviewCustomerResolutionPanel', () => { it('唯一候选展示自动确认说明和明确确认入口', () => { const wrapper = mountPanel('unique_candidate'); expect(wrapper.text()).toContain('保存校验时系统会自动确认'); expect(wrapper.get('[data-testid="review-select-customer"]').text()).toContain('确认唯一候选'); }); it('非唯一未确认状态维持人工选择客户入口', () => { const wrapper = mountPanel('unmatched'); expect(wrapper.text()).not.toContain('保存校验时系统会自动确认'); expect(wrapper.get('[data-testid="review-select-customer"]').text()).toContain('选择标准客户'); }); });