Просмотр исходного кода

✅ test(integration): 完善残疾人个人管理集成测试

- 为rpcClient添加index.$get模拟以支持行政区划数据获取
- 更新adminAreas.index.$get的调试日志信息
- 扩展创建残疾人测试断言以包含性别、残疾类型、残疾等级和省市字段
- 更新更新残疾人测试断言以适配personInfo嵌套结构
yourname 1 неделя назад
Родитель
Сommit
3c0b687390

+ 29 - 4
allin-packages/disability-person-management-ui/tests/integration/disability-person.integration.test.tsx

@@ -410,10 +410,28 @@ vi.mock('@d8d/shared-ui-components/utils/hc', () => ({
           })
         }))
       },
+      index: {
+        $get: vi.fn(() => {
+          console.debug('rpcClient index.$get called (for adminAreas)');
+          return Promise.resolve({
+            status: 200,
+            json: async () => ({
+              data: [
+                { id: 1, name: '北京市', parentId: null, level: 1 },
+                { id: 2, name: '上海市', parentId: null, level: 1 },
+                { id: 3, name: '东城区', parentId: 1, level: 2 },
+                { id: 4, name: '黄浦区', parentId: 2, level: 2 },
+                { id: 5, name: '东城区街道', parentId: 3, level: 3 },
+              ],
+              total: 5
+            })
+          });
+        })
+      },
       adminAreas: {
         index: {
           $get: vi.fn(() => {
-            console.debug('rpcClient areas.index.$get called');
+            console.debug('rpcClient adminAreas.index.$get called');
             return Promise.resolve({
               status: 200,
               json: async () => ({
@@ -561,12 +579,17 @@ describe('残疾人个人管理集成测试', () => {
     expect(call).toBeDefined();
 
     if (call) {
-      expect(call[0].json).toMatchObject({
+      expect(call[0].json.personInfo).toMatchObject({
         name: '李四',
         idCard: '110101199002021234',
         disabilityId: 'D123456790',
         phone: '13900139000',
         idAddress: '上海市黄浦区',
+        gender: '女',
+        disabilityType: '视力残疾',
+        disabilityLevel: '二级',
+        province: '1',
+        city: '3',
       });
     }
   });
@@ -601,8 +624,10 @@ describe('残疾人个人管理集成测试', () => {
       const mockClient = (disabilityClientManager.get as any)();
       expect(mockClient.updateAggregatedDisabledPerson[':id']['$put']).toHaveBeenCalledWith({
         json: expect.objectContaining({
-          id: 1,
-          phone: '13800138001',
+          personInfo: expect.objectContaining({
+            id: 1,
+            phone: '13800138001',
+          }),
         }),
       });
     });