feat(shipping): 实现订单批处理聊天聚合展示与优化后端逻辑
This commit is contained in:
1 parent
11cef575b4
commit
523b791c92
38 files changed
+2868
-414
No files matched your search
@@ -136,6 +136,80 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
it('merges sibling Runs from one upload batch into one chat status card', async () => {
|
||||
const first = Object.assign(run({
|
||||
run_no: 'SNER-BATCH-1',
|
||||
conversation_id: 'conv-batch',
|
||||
intake_nos: ['SNI-BATCH-1'],
|
||||
summary: {
|
||||
total_documents: 1,
|
||||
pending_documents: 1,
|
||||
processing_documents: 0,
|
||||
completed_documents: 0,
|
||||
review_required_documents: 0,
|
||||
failed_documents: 0,
|
||||
candidate_count: 0,
|
||||
},
|
||||
documents: [{
|
||||
unit_id: 1,
|
||||
document_id: 101,
|
||||
file_name: 'notice-a.pdf',
|
||||
status: 'queued',
|
||||
line_count: 0,
|
||||
email_supplement: { status: 'none', relation_codes: [] },
|
||||
available_actions: [],
|
||||
}],
|
||||
}), { upload_batch_id: 'upload-batch-1' });
|
||||
const second = Object.assign(run({
|
||||
run_no: 'SNER-BATCH-2',
|
||||
conversation_id: 'conv-batch',
|
||||
intake_nos: ['SNI-BATCH-2'],
|
||||
summary: {
|
||||
total_documents: 1,
|
||||
pending_documents: 0,
|
||||
processing_documents: 1,
|
||||
completed_documents: 0,
|
||||
review_required_documents: 0,
|
||||
failed_documents: 0,
|
||||
candidate_count: 0,
|
||||
},
|
||||
documents: [{
|
||||
unit_id: 2,
|
||||
document_id: 102,
|
||||
file_name: 'notice-b.pdf',
|
||||
status: 'processing',
|
||||
line_count: 0,
|
||||
email_supplement: { status: 'none', relation_codes: [] },
|
||||
available_actions: [],
|
||||
}],
|
||||
}), { upload_batch_id: 'upload-batch-1' });
|
||||
api.createSubmission.mockResolvedValue({
|
||||
decision: 'created',
|
||||
user_task_no: null,
|
||||
run_no: first.run_no,
|
||||
created_new: true,
|
||||
operation_id: 'op-batch',
|
||||
});
|
||||
api.getRun.mockResolvedValue(first);
|
||||
api.listRuns.mockResolvedValue({ items: [first, second] });
|
||||
const harness = createHarness();
|
||||
|
||||
await harness.runs.startRun('', ['SNI-BATCH-1', 'SNI-BATCH-2'], [], 'upload-batch-1');
|
||||
|
||||
const cards = harness.messages.value.filter((message) => message.shipping_order_extraction_state);
|
||||
expect(cards).toHaveLength(1);
|
||||
expect(cards[0]?.shipping_order_extraction_state?.summary).toMatchObject({
|
||||
totalDocuments: 2,
|
||||
pendingDocuments: 1,
|
||||
processingDocuments: 1,
|
||||
});
|
||||
expect(cards[0]?.shipping_order_extraction_state?.documents?.map((item) => item.fileName)).toEqual([
|
||||
'notice-a.pdf',
|
||||
'notice-b.pdf',
|
||||
]);
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
it('keeps an appended submission in the user message and the existing Run state card only', async () => {
|
||||
const queued = run({
|
||||
run_no: 'SNER-APPENDED',
|
||||
|
||||
Reference in new issue
Block a user