Merge branch 'dev' into runny827
feat(training): 新增精益培训视频与周任务管理 # Conflicts: # backend/app/models/__init__.py
This commit is contained in:
1 parent
85d27e9ffa
commit
91b7233872
812 files changed
+73763
-18908
No files matched your search
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingProcessingWorkItem.spec.ts
|
||||
* 用途:验收 work-item 轮询 composable 不二次 normalize、能落盘 API 已规范化投影。
|
||||
* 依赖:Vitest、Vue、useShippingProcessingWorkItem。
|
||||
* 逻辑:API 层已 snake→camel;若 composable 再 normalize(只认 snake),会把投影洗成 null。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { defineComponent, nextTick, ref } from 'vue';
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
|
||||
const getWorkspaceShippingProcessingWorkItem = vi.fn();
|
||||
|
||||
vi.mock('../api/shipping.api', () => ({
|
||||
getWorkspaceShippingProcessingWorkItem: (...args: unknown[]) => (
|
||||
getWorkspaceShippingProcessingWorkItem(...args)
|
||||
),
|
||||
}));
|
||||
|
||||
import { useShippingProcessingWorkItem } from './useShippingProcessingWorkItem';
|
||||
|
||||
describe('useShippingProcessingWorkItem', () => {
|
||||
beforeEach(() => {
|
||||
getWorkspaceShippingProcessingWorkItem.mockReset();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('keeps API-normalized camelCase projection (must not re-normalize to null)', async () => {
|
||||
// 关键断言:右卡「正在获取最新状态/待机」曾因二次 normalize 只读 snake 把
|
||||
// workItemNo 读空、整包洗成 null;API 已返回的 camelCase 投影必须原样落盘。
|
||||
getWorkspaceShippingProcessingWorkItem.mockResolvedValue({
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-20260905-DAC55F90',
|
||||
sourceType: 'eml',
|
||||
status: 'waiting_review',
|
||||
stage: 'inventory_matching',
|
||||
progressVersion: 24,
|
||||
lastActivityAt: '2026-09-05T11:25:45Z',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
userStatus: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'inventory_matching',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [],
|
||||
blocking_reason: { code: 'inventory_shortage_review_required' },
|
||||
primary_action: { code: 'retry_inventory_matching' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'a.pdf',
|
||||
documentId: 1,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
hasFormalOt: false,
|
||||
});
|
||||
|
||||
const workItemNo = ref('OT-20260905-DAC55F90');
|
||||
let api: ReturnType<typeof useShippingProcessingWorkItem> | null = null;
|
||||
const Comp = defineComponent({
|
||||
setup() {
|
||||
api = useShippingProcessingWorkItem('order_task', workItemNo, {
|
||||
continuousPolling: false,
|
||||
monotonicProgressVersion: true,
|
||||
});
|
||||
return () => null;
|
||||
},
|
||||
});
|
||||
mount(Comp);
|
||||
await flushPromises();
|
||||
await nextTick();
|
||||
|
||||
expect(getWorkspaceShippingProcessingWorkItem).toHaveBeenCalledWith(
|
||||
'order_task',
|
||||
'OT-20260905-DAC55F90',
|
||||
);
|
||||
expect(api!.projection.value).not.toBeNull();
|
||||
expect(api!.projection.value?.workItemNo).toBe('OT-20260905-DAC55F90');
|
||||
expect(api!.projection.value?.userStatus).toBe('waiting_human');
|
||||
expect(api!.projection.value?.uiState?.lifecycleStage).toBe('fulfillment_prep');
|
||||
expect(api!.projection.value?.uiState?.primary_action?.code).toBe('retry_inventory_matching');
|
||||
expect(api!.error.value).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user