95 lines
4.1 KiB
TypeScript
95 lines
4.1 KiB
TypeScript
/**
|
|
* features/chat/components/shipping-review/ReviewLineFulfillmentDetail.spec.ts
|
|
* 用途:锁定 UI-2 行内履约摘要字段与审计入口。
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createI18n } from 'vue-i18n';
|
|
import ReviewLineFulfillmentDetail from './ReviewLineFulfillmentDetail.vue';
|
|
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'zh-CN',
|
|
messages: {
|
|
'zh-CN': {
|
|
chat: {
|
|
shippingOrderReview: {
|
|
lineFulfillmentDetail: {
|
|
title: '行履约摘要',
|
|
wave: '履约波次',
|
|
task: '正式任务',
|
|
snapshotId: '库存快照 ID',
|
|
inventorySource: '实际库存源',
|
|
inventoryFile: '库存文件编号',
|
|
inventoryFileSha256: '库存文件 SHA-256',
|
|
inventoryRow: '库存行号',
|
|
requiredQty: '需求数量',
|
|
availableQty: '可用数量',
|
|
matchAttempt: '匹配 Attempt',
|
|
matchedAt: '匹配校验时间',
|
|
decisionSource: '决定来源',
|
|
decisionSourceValue: {
|
|
system: '系统自动',
|
|
user: '人工',
|
|
unknown: '未知',
|
|
},
|
|
failureReason: '自动履约失败原因',
|
|
noFailure: '无',
|
|
openAudit: '打开审计',
|
|
close: '收起',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
describe('ReviewLineFulfillmentDetail', () => {
|
|
it('renders wave/task/snapshot/source/failure and emits audit', async () => {
|
|
const line: ShippingOrderReviewLineFulfillmentLine = {
|
|
line_key: 'L1',
|
|
inventory_snapshot_id: 42,
|
|
inventory_checked_at: '2026-08-07T01:00:00Z',
|
|
inventory_source_code: 'DBS_DUB',
|
|
inventory_file_no: 'INV-001',
|
|
inventory_file_sha256: 'a'.repeat(64),
|
|
inventory_row_index: 17,
|
|
required_qty: '3',
|
|
available_qty: '8',
|
|
match_attempt_id: 301,
|
|
decision_source: 'system',
|
|
auto_fulfill_error_message: 'wave_explode',
|
|
decision: {
|
|
wave_no: 3,
|
|
task_id: 9,
|
|
decision_source: 'system',
|
|
},
|
|
};
|
|
const wrapper = mount(ReviewLineFulfillmentDetail, {
|
|
props: { line, taskNo: 'SN-100' },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-summary"]').exists()).toBe(true);
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-wave"]').text()).toContain('3');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-task"]').text()).toContain('SN-100');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-snapshot"]').text()).toContain('42');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventorySource"]').text()).toContain('DBS_DUB');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventoryFile"]').text()).toContain('INV-001');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventoryFileSha256"]').text()).toContain('a'.repeat(64));
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventoryRow"]').text()).toContain('17');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-requiredQty"]').text()).toContain('3');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-availableQty"]').text()).toContain('8');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-matchAttempt"]').text()).toContain('301');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-decisionSource"]').text()).toContain('系统自动');
|
|
expect(wrapper.find('[data-testid="review-line-fulfillment-field-failure"]').text()).toContain('wave_explode');
|
|
|
|
await wrapper.get('[data-testid="review-line-fulfillment-open-audit"]').trigger('click');
|
|
expect(wrapper.emitted('open-audit')).toBeTruthy();
|
|
await wrapper.get('[data-testid="review-line-fulfillment-summary-close"]').trigger('click');
|
|
expect(wrapper.emitted('close')).toBeTruthy();
|
|
});
|
|
});
|