feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
84a881b554
commit
74270adc22
149 files changed
+20111
-3871
No files matched your search
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* features/chat/shipping/conversationProcessingDisplay.spec.ts
|
||||
* 用途:验收主文件回退与正式任务统计。
|
||||
* 依赖:Vitest、conversationProcessingDisplay。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type {
|
||||
ConversationProcessingObject,
|
||||
ConversationProcessingUserTask,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
getPrimaryDocumentName,
|
||||
resolveFormalTaskCount,
|
||||
resolveFormalTaskFileCount,
|
||||
} from './conversationProcessingDisplay';
|
||||
|
||||
/** 构造最小任务卡。 */
|
||||
function task(partial: Partial<ConversationProcessingUserTask>): ConversationProcessingUserTask {
|
||||
return {
|
||||
user_task_no: 'OT-1',
|
||||
group: 'needs_action',
|
||||
can_append: true,
|
||||
...partial,
|
||||
};
|
||||
}
|
||||
|
||||
/** 带可选 primary 标记的 document 行。 */
|
||||
function doc(
|
||||
filename: string,
|
||||
flags: { is_primary?: boolean; primary?: boolean; evidence_role?: string } = {},
|
||||
): ConversationProcessingObject & Record<string, unknown> {
|
||||
return {
|
||||
kind: 'document',
|
||||
object_key: `DOC-${filename}`,
|
||||
label: filename,
|
||||
filename,
|
||||
...flags,
|
||||
};
|
||||
}
|
||||
|
||||
describe('getPrimaryDocumentName', () => {
|
||||
it('prefers primary-marked document filename', () => {
|
||||
const name = getPrimaryDocumentName(task({
|
||||
document_names: ['first.pdf', 'second.pdf'],
|
||||
objects: [doc('first.pdf'), doc('second.pdf', { is_primary: true })],
|
||||
}));
|
||||
expect(name).toBe('second.pdf');
|
||||
});
|
||||
|
||||
it('falls back to document_names[0] without using root_document_id', () => {
|
||||
const name = getPrimaryDocumentName(task({
|
||||
document_names: ['alpha.pdf', 'beta.pdf'],
|
||||
objects: [{
|
||||
kind: 'document',
|
||||
object_key: 'DOC-9',
|
||||
label: 'DOC-9',
|
||||
root_document_id: 99,
|
||||
filename: null,
|
||||
}],
|
||||
}));
|
||||
expect(name).toBe('alpha.pdf');
|
||||
});
|
||||
|
||||
it('returns null when no filename is available', () => {
|
||||
expect(getPrimaryDocumentName(task({ document_names: [], objects: [] }))).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveFormalTaskCount / resolveFormalTaskFileCount', () => {
|
||||
it('reads summary totals without collapsing files into tasks', () => {
|
||||
const projection = {
|
||||
summary: {
|
||||
total_tasks: 3,
|
||||
total_files: 6,
|
||||
processing: 1,
|
||||
needs_action: 2,
|
||||
history: 0,
|
||||
},
|
||||
needs_action: [],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
};
|
||||
expect(resolveFormalTaskCount(projection)).toBe(3);
|
||||
expect(resolveFormalTaskFileCount(projection)).toBe(6);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user