|
@@ -48,6 +48,7 @@ vi.mock('../../src/api/disabilityClient', () => {
|
|
|
canDirectContact: 1,
|
|
canDirectContact: 1,
|
|
|
isInBlackList: 0,
|
|
isInBlackList: 0,
|
|
|
jobStatus: 1,
|
|
jobStatus: 1,
|
|
|
|
|
+ specificDisability: '左眼视力0.1,右眼视力0.2,需要助听器',
|
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
|
updateTime: '2024-01-01T00:00:00Z'
|
|
updateTime: '2024-01-01T00:00:00Z'
|
|
|
}
|
|
}
|
|
@@ -75,6 +76,7 @@ vi.mock('../../src/api/disabilityClient', () => {
|
|
|
canDirectContact: 1,
|
|
canDirectContact: 1,
|
|
|
isInBlackList: 0,
|
|
isInBlackList: 0,
|
|
|
jobStatus: 0,
|
|
jobStatus: 0,
|
|
|
|
|
+ specificDisability: '双眼视力均为0.05,需要导盲犬辅助',
|
|
|
createTime: '2024-01-02T00:00:00Z',
|
|
createTime: '2024-01-02T00:00:00Z',
|
|
|
updateTime: '2024-01-02T00:00:00Z'
|
|
updateTime: '2024-01-02T00:00:00Z'
|
|
|
}))),
|
|
}))),
|
|
@@ -99,6 +101,7 @@ vi.mock('../../src/api/disabilityClient', () => {
|
|
|
canDirectContact: 1,
|
|
canDirectContact: 1,
|
|
|
isInBlackList: 0,
|
|
isInBlackList: 0,
|
|
|
jobStatus: 1,
|
|
jobStatus: 1,
|
|
|
|
|
+ specificDisability: '左腿截肢,右腿行动不便,需要轮椅',
|
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
|
updateTime: '2024-01-03T00:00:00Z'
|
|
updateTime: '2024-01-03T00:00:00Z'
|
|
|
}))),
|
|
}))),
|
|
@@ -130,6 +133,7 @@ vi.mock('../../src/api/disabilityClient', () => {
|
|
|
canDirectContact: 1,
|
|
canDirectContact: 1,
|
|
|
isInBlackList: 0,
|
|
isInBlackList: 0,
|
|
|
jobStatus: 1,
|
|
jobStatus: 1,
|
|
|
|
|
+ specificDisability: '左眼视力0.1,右眼视力0.2,需要助听器',
|
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
|
updateTime: '2024-01-01T00:00:00Z'
|
|
updateTime: '2024-01-01T00:00:00Z'
|
|
|
},
|
|
},
|
|
@@ -185,6 +189,7 @@ vi.mock('../../src/api/disabilityClient', () => {
|
|
|
canDirectContact: 1,
|
|
canDirectContact: 1,
|
|
|
isInBlackList: 0,
|
|
isInBlackList: 0,
|
|
|
jobStatus: 1,
|
|
jobStatus: 1,
|
|
|
|
|
+ specificDisability: '左眼视力0.1,右眼视力0.2,需要助听器',
|
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
createTime: '2024-01-01T00:00:00Z',
|
|
|
updateTime: '2024-01-01T00:00:00Z'
|
|
updateTime: '2024-01-01T00:00:00Z'
|
|
|
}
|
|
}
|
|
@@ -280,11 +285,39 @@ vi.mock('@d8d/allin-enums', () => ({
|
|
|
}),
|
|
}),
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
-// Mock area-management-ui 的 API - 使用新的测试工具
|
|
|
|
|
|
|
+// Mock area-management-ui 的 API - 使用简单的mock
|
|
|
// 注意:我们不再mock UI组件,只mock API
|
|
// 注意:我们不再mock UI组件,只mock API
|
|
|
-import { createAreaClientMock } from '@d8d/area-management-ui/test-utils';
|
|
|
|
|
-
|
|
|
|
|
-vi.mock('@d8d/area-management-ui/api', () => createAreaClientMock());
|
|
|
|
|
|
|
+vi.mock('@d8d/area-management-ui/api', () => ({
|
|
|
|
|
+ areaClient: {
|
|
|
|
|
+ getAllAreas: {
|
|
|
|
|
+ $get: vi.fn(() => Promise.resolve({
|
|
|
|
|
+ status: 200,
|
|
|
|
|
+ ok: true,
|
|
|
|
|
+ body: null,
|
|
|
|
|
+ bodyUsed: false,
|
|
|
|
|
+ statusText: 'OK',
|
|
|
|
|
+ headers: new Headers(),
|
|
|
|
|
+ url: '',
|
|
|
|
|
+ redirected: false,
|
|
|
|
|
+ type: 'basic',
|
|
|
|
|
+ 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 },
|
|
|
|
|
+ ],
|
|
|
|
|
+ total: 4
|
|
|
|
|
+ }),
|
|
|
|
|
+ text: async () => '',
|
|
|
|
|
+ blob: async () => new Blob(),
|
|
|
|
|
+ arrayBuffer: async () => new ArrayBuffer(0),
|
|
|
|
|
+ formData: async () => new FormData(),
|
|
|
|
|
+ clone: function() { return this; }
|
|
|
|
|
+ })),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+}));
|
|
|
|
|
|
|
|
// Mock 文件选择器组件
|
|
// Mock 文件选择器组件
|
|
|
vi.mock('@d8d/file-management-ui/components', () => ({
|
|
vi.mock('@d8d/file-management-ui/components', () => ({
|
|
@@ -613,6 +646,97 @@ describe('残疾人个人管理集成测试', () => {
|
|
|
fireEvent.click(addPhotoButton);
|
|
fireEvent.click(addPhotoButton);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ it('应该测试具体残疾部位和情况字段', async () => {
|
|
|
|
|
+ renderComponent();
|
|
|
|
|
+
|
|
|
|
|
+ // 等待数据加载
|
|
|
|
|
+ await waitFor(() => {
|
|
|
|
|
+ expect(screen.getByText('张三')).toBeInTheDocument();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 打开创建模态框 - 使用测试ID
|
|
|
|
|
+ const addButton = screen.getByTestId('add-disabled-person-button');
|
|
|
|
|
+ fireEvent.click(addButton);
|
|
|
|
|
+
|
|
|
|
|
+ // 等待模态框打开 - 使用测试ID
|
|
|
|
|
+ await waitFor(() => {
|
|
|
|
|
+ expect(screen.getByTestId('create-disabled-person-dialog-title')).toBeInTheDocument();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 验证具体残疾部位和情况字段存在
|
|
|
|
|
+ const specificDisabilityTextarea = screen.getByTestId('specific-disability-textarea');
|
|
|
|
|
+ expect(specificDisabilityTextarea).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByText('具体残疾部位和情况(可选)')).toBeInTheDocument();
|
|
|
|
|
+
|
|
|
|
|
+ // 输入具体残疾部位和情况
|
|
|
|
|
+ fireEvent.change(specificDisabilityTextarea, {
|
|
|
|
|
+ target: { value: '左眼视力0.1,右眼视力0.2,需要助听器' }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 填写其他必填字段
|
|
|
|
|
+ const nameInput = screen.getByPlaceholderText('请输入姓名');
|
|
|
|
|
+ const idCardInput = screen.getByPlaceholderText('请输入身份证号');
|
|
|
|
|
+ const disabilityIdInput = screen.getByPlaceholderText('请输入残疾证号');
|
|
|
|
|
+ const phoneInput = screen.getByPlaceholderText('请输入联系电话');
|
|
|
|
|
+ const idAddressInput = screen.getByPlaceholderText('请输入身份证地址');
|
|
|
|
|
+
|
|
|
|
|
+ fireEvent.change(nameInput, { target: { value: '测试人员' } });
|
|
|
|
|
+ fireEvent.change(idCardInput, { target: { value: '110101199001011234' } });
|
|
|
|
|
+ fireEvent.change(disabilityIdInput, { target: { value: 'D123456789' } });
|
|
|
|
|
+ fireEvent.change(phoneInput, { target: { value: '13800138000' } });
|
|
|
|
|
+ fireEvent.change(idAddressInput, { target: { value: '北京市东城区' } });
|
|
|
|
|
+
|
|
|
|
|
+ // 选择性别
|
|
|
|
|
+ const genderSelect = screen.getByTestId('gender-select');
|
|
|
|
|
+ fireEvent.change(genderSelect, { target: { value: '男' } });
|
|
|
|
|
+
|
|
|
|
|
+ // 选择残疾类型
|
|
|
|
|
+ const disabilityTypeSelect = screen.getByTestId('disability-type-select');
|
|
|
|
|
+ fireEvent.change(disabilityTypeSelect, { target: { value: '视力残疾' } });
|
|
|
|
|
+
|
|
|
|
|
+ // 选择残疾等级
|
|
|
|
|
+ const disabilityLevelSelect = screen.getByTestId('disability-level-select');
|
|
|
|
|
+ fireEvent.change(disabilityLevelSelect, { target: { value: '一级' } });
|
|
|
|
|
+
|
|
|
|
|
+ // 选择省份和城市
|
|
|
|
|
+ const provinceSelect = screen.getByTestId('province-select-form');
|
|
|
|
|
+ const citySelect = screen.getByTestId('city-select-form');
|
|
|
|
|
+
|
|
|
|
|
+ await act(async () => {
|
|
|
|
|
+ fireEvent.change(provinceSelect, { target: { value: '1' } });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ await act(async () => {
|
|
|
|
|
+ fireEvent.change(citySelect, { target: { value: '2' } });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 提交表单
|
|
|
|
|
+ const submitButton = screen.getByText('创建');
|
|
|
|
|
+
|
|
|
|
|
+ // 使用act包装状态更新
|
|
|
|
|
+ await act(async () => {
|
|
|
|
|
+ fireEvent.click(submitButton);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 验证API调用包含specificDisability字段
|
|
|
|
|
+ await waitFor(() => {
|
|
|
|
|
+ const mockClient = (disabilityClientManager.get as any)();
|
|
|
|
|
+ expect(mockClient.createDisabledPerson.$post).toHaveBeenCalled();
|
|
|
|
|
+ }, { timeout: 3000 });
|
|
|
|
|
+
|
|
|
|
|
+ // 验证具体的调用参数包含specificDisability
|
|
|
|
|
+ const mockClient = (disabilityClientManager.get as any)();
|
|
|
|
|
+ const call = mockClient.createDisabledPerson.$post.mock.calls[0];
|
|
|
|
|
+ expect(call).toBeDefined();
|
|
|
|
|
+
|
|
|
|
|
+ if (call) {
|
|
|
|
|
+ expect(call[0].json).toMatchObject({
|
|
|
|
|
+ name: '测试人员',
|
|
|
|
|
+ specificDisability: '左眼视力0.1,右眼视力0.2,需要助听器',
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
it('应该测试枚举选择器集成', async () => {
|
|
it('应该测试枚举选择器集成', async () => {
|
|
|
renderComponent();
|
|
renderComponent();
|
|
|
|
|
|