feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码
This commit is contained in:
1 parent
935bf26fa6
commit
7cfd5d167e
230 files changed
+9337
-10989
No files matched your search
@@ -136,7 +136,7 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
it('merges sibling Runs from one upload batch into one chat status card', async () => {
|
||||
it('keeps the submitted Run card independent from sibling Runs in the same upload batch', async () => {
|
||||
const first = Object.assign(run({
|
||||
run_no: 'SNER-BATCH-1',
|
||||
conversation_id: 'conv-batch',
|
||||
@@ -191,7 +191,6 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
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');
|
||||
@@ -199,14 +198,14 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
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,
|
||||
totalDocuments: 1,
|
||||
pendingDocuments: 1,
|
||||
processingDocuments: 1,
|
||||
processingDocuments: 0,
|
||||
});
|
||||
expect(cards[0]?.shipping_order_extraction_state?.documents?.map((item) => item.fileName)).toEqual([
|
||||
'notice-a.pdf',
|
||||
'notice-b.pdf',
|
||||
]);
|
||||
expect(api.listRuns).not.toHaveBeenCalled();
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
@@ -290,25 +289,27 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
api.getRun.mockReturnValueOnce(pending.promise);
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-old';
|
||||
await harness.runs.restoreForConversation('conv-old');
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
const oldRestore = harness.runs.restoreForConversation('conv-old');
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
expect(api.getRun).toHaveBeenCalledWith('SNER-OLD', expect.any(AbortSignal));
|
||||
|
||||
harness.conversationId.value = 'conv-new';
|
||||
await expect(harness.runs.restoreForConversation('conv-new')).resolves.toBeUndefined();
|
||||
pending.resolve(run({ run_no: 'SNER-OLD', conversation_id: 'conv-old', status: 'completed' }));
|
||||
await Promise.resolve();
|
||||
await oldRestore;
|
||||
expect(harness.runs.getActiveRunNo()).toBe('');
|
||||
expect(harness.messages.value).toHaveLength(1);
|
||||
expect(harness.messages.value[0]?.shipping_order_extraction_state?.status).toBe('processing');
|
||||
expect(harness.messages.value).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('notifies session work items refresh after restoring a terminal run', async () => {
|
||||
api.listRuns.mockResolvedValue({
|
||||
items: [run({ run_no: 'SNER-DONE', status: 'completed', phase: 'completed' })],
|
||||
});
|
||||
const summary = run({ run_no: 'SNER-DONE', status: 'completed', phase: 'completed' });
|
||||
const detail = run({ run_no: 'SNER-DONE', status: 'completed', phase: 'completed' });
|
||||
api.listRuns.mockResolvedValue({ items: [summary] });
|
||||
api.getRun.mockResolvedValue(detail);
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-1';
|
||||
await harness.runs.restoreForConversation('conv-1');
|
||||
expect(api.getRun).toHaveBeenCalledWith('SNER-DONE', expect.any(AbortSignal));
|
||||
expect(harness.options.onWorkflowRefresh).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -348,7 +349,7 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
const queued = run({ run_no: 'SNER-RETRY', status: 'queued', phase: 'manual_retry_queued', error: null });
|
||||
api.listRuns.mockResolvedValue({ items: [failed] });
|
||||
api.retryRun.mockResolvedValue({ run: queued, reused: false });
|
||||
api.getRun.mockResolvedValue(queued);
|
||||
api.getRun.mockResolvedValueOnce(failed).mockResolvedValue(queued);
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-1';
|
||||
await harness.runs.restoreForConversation('conv-1');
|
||||
@@ -381,7 +382,7 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
});
|
||||
api.listRuns.mockResolvedValue({ items: [source] });
|
||||
api.reparseRun.mockResolvedValue({ run: replacement, reused: false });
|
||||
api.getRun.mockResolvedValue(replacement);
|
||||
api.getRun.mockResolvedValueOnce(source).mockResolvedValueOnce(source).mockResolvedValue(replacement);
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-1';
|
||||
await harness.runs.restoreForConversation('conv-1');
|
||||
@@ -393,6 +394,21 @@ describe('useShippingOrderExtractionRuns lifecycle', () => {
|
||||
expect(harness.messages.value).toHaveLength(2);
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
|
||||
it('uses a lightweight Run list only to locate the latest Run before loading one detail', async () => {
|
||||
const latest = run({ run_no: 'SNER-LATEST', conversation_id: 'conv-1', status: 'processing' });
|
||||
const older = run({ run_no: 'SNER-OLDER', conversation_id: 'conv-1', status: 'completed' });
|
||||
api.listRuns.mockResolvedValue({ items: [latest, older] });
|
||||
api.getRun.mockResolvedValue(latest);
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-1';
|
||||
|
||||
await harness.runs.restoreForConversation('conv-1');
|
||||
|
||||
expect(api.getRun).toHaveBeenCalledTimes(1);
|
||||
expect(api.getRun).toHaveBeenCalledWith('SNER-LATEST', expect.any(AbortSignal));
|
||||
harness.runs.stopPolling();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -644,6 +660,7 @@ describe('mapOrderExtractionRunToMessageState', () => {
|
||||
it('acknowledges a terminal Run only after it is restored into the active conversation', async () => {
|
||||
const terminal = run({ run_no: 'SNER-SEEN', status: 'completed' });
|
||||
api.listRuns.mockResolvedValue({ items: [terminal] });
|
||||
api.getRun.mockResolvedValue(terminal);
|
||||
api.markSeen.mockResolvedValue({ seen: true });
|
||||
const harness = createHarness();
|
||||
harness.conversationId.value = 'conv-1';
|
||||
|
||||
Reference in new issue
Block a user