Ver Fonte

✨ feat(test): 为残疾人管理新增/编辑功能添加聚合接口的集成测试

- 在模拟客户端中新增 `createAggregatedDisabledPerson` 和 `updateAggregatedDisabledPerson` 接口的模拟实现
- 更新测试用例以使用新的聚合接口进行创建和更新操作的验证
- 调整测试中断言,将 `createDisabledPerson` 和 `updateDisabledPerson` 的调用验证替换为对应的聚合接口
- 更新相关故事文档的状态为【进行中】
yourname há 1 semana atrás
pai
commit
9e67c20908

+ 69 - 5
allin-packages/disability-person-management-ui/tests/integration/disability-person.integration.test.tsx

@@ -81,6 +81,37 @@ vi.mock('../../src/api/disabilityClient', () => {
         updateTime: '2024-01-02T00:00:00Z'
       }))),
     },
+    createAggregatedDisabledPerson: {
+      $post: vi.fn(() => Promise.resolve(createMockResponse(200, {
+        personInfo: {
+          id: 2,
+          name: '李四',
+          gender: '女',
+          idCard: '110101199002021234',
+          disabilityId: 'D123456790',
+          disabilityType: '视力残疾',
+          disabilityLevel: '二级',
+          idAddress: '上海市黄浦区',
+          phone: '13900139000',
+          province: '上海市',
+          city: '上海市',
+          district: '黄浦区',
+          detailedAddress: '某街道某号',
+          nation: '汉族',
+          isMarried: 1,
+          canDirectContact: 1,
+          isInBlackList: 0,
+          jobStatus: 0,
+          specificDisability: '双眼视力均为0.05,需要导盲犬辅助',
+          createTime: '2024-01-02T00:00:00Z',
+          updateTime: '2024-01-02T00:00:00Z'
+        },
+        bankCards: [],
+        photos: [],
+        remarks: [],
+        visits: []
+      }))),
+    },
     updateDisabledPerson: {
       $post: vi.fn(() => Promise.resolve(createMockResponse(200, {
         id: 1,
@@ -106,6 +137,39 @@ vi.mock('../../src/api/disabilityClient', () => {
         updateTime: '2024-01-03T00:00:00Z'
       }))),
     },
+    updateAggregatedDisabledPerson: {
+      ':id': {
+        $put: vi.fn(() => Promise.resolve(createMockResponse(200, {
+          personInfo: {
+            id: 1,
+            name: '张三(已更新)',
+            gender: '男',
+            idCard: '110101199001011234',
+            disabilityId: 'D123456789',
+            disabilityType: '肢体残疾',
+            disabilityLevel: '一级',
+            idAddress: '北京市东城区',
+            phone: '13800138001',
+            province: '北京市',
+            city: '北京市',
+            district: '东城区',
+            detailedAddress: '更新后的地址',
+            nation: '汉族',
+            isMarried: 1,
+            canDirectContact: 1,
+            isInBlackList: 0,
+            jobStatus: 1,
+            specificDisability: '左腿截肢,右腿行动不便,需要轮椅',
+            createTime: '2024-01-01T00:00:00Z',
+            updateTime: '2024-01-03T00:00:00Z'
+          },
+          bankCards: [],
+          photos: [],
+          remarks: [],
+          visits: []
+        }))),
+      },
+    },
     deleteDisabledPerson: {
       $post: vi.fn(() => Promise.resolve(createMockResponse(200, {
         success: true
@@ -459,12 +523,12 @@ describe('残疾人个人管理集成测试', () => {
     // 验证API调用 - 增加等待时间
     await waitFor(() => {
       const mockClient = (disabilityClientManager.get as any)();
-      expect(mockClient.createDisabledPerson.$post).toHaveBeenCalled();
+      expect(mockClient.createAggregatedDisabledPerson.$post).toHaveBeenCalled();
     }, { timeout: 3000 });
 
     // 验证具体的调用参数
     const mockClient = (disabilityClientManager.get as any)();
-    const call = mockClient.createDisabledPerson.$post.mock.calls[0];
+    const call = mockClient.createAggregatedDisabledPerson.$post.mock.calls[0];
     expect(call).toBeDefined();
 
     if (call) {
@@ -506,7 +570,7 @@ describe('残疾人个人管理集成测试', () => {
     // 验证API调用
     await waitFor(() => {
       const mockClient = (disabilityClientManager.get as any)();
-      expect(mockClient.updateDisabledPerson.$post).toHaveBeenCalledWith({
+      expect(mockClient.updateAggregatedDisabledPerson[':id']['$put']).toHaveBeenCalledWith({
         json: expect.objectContaining({
           id: 1,
           phone: '13800138001',
@@ -723,12 +787,12 @@ describe('残疾人个人管理集成测试', () => {
     // 验证API调用包含specificDisability字段
     await waitFor(() => {
       const mockClient = (disabilityClientManager.get as any)();
-      expect(mockClient.createDisabledPerson.$post).toHaveBeenCalled();
+      expect(mockClient.createAggregatedDisabledPerson.$post).toHaveBeenCalled();
     }, { timeout: 3000 });
 
     // 验证具体的调用参数包含specificDisability
     const mockClient = (disabilityClientManager.get as any)();
-    const call = mockClient.createDisabledPerson.$post.mock.calls[0];
+    const call = mockClient.createAggregatedDisabledPerson.$post.mock.calls[0];
     expect(call).toBeDefined();
 
     if (call) {

+ 1 - 1
docs/stories/010.007.story.md

@@ -1,7 +1,7 @@
 # Story 010.007: 完善残疾人管理新增/编辑功能集成测试
 
 ## Status
-Draft
+In Progress
 
 ## Story
 **As a** 测试工程师