|
|
@@ -7,7 +7,7 @@ import { File } from '@d8d/file-module';
|
|
|
import orderRoutes from '../../src/routes/order.routes';
|
|
|
import { EmploymentOrder } from '../../src/entities/employment-order.entity';
|
|
|
import { OrderPerson } from '../../src/entities/order-person.entity';
|
|
|
-import { OrderPersonAsset } from '../../src/entities/order-person-asset.entity';
|
|
|
+import { OrderPersonAsset, AssetType, AssetFileType } from '../../src/entities/order-person-asset.entity';
|
|
|
import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
|
|
|
|
|
|
// 设置集成测试钩子
|
|
|
@@ -100,12 +100,12 @@ describe('订单管理API集成测试', () => {
|
|
|
companyId: 1,
|
|
|
channelId: 1,
|
|
|
expectedStartDate: new Date().toISOString(),
|
|
|
- orderStatus: 'INVALID_STATUS', // 无效的状态
|
|
|
+ orderStatus: 'invalid_status', // 无效的状态
|
|
|
workStatus: WorkStatus.NOT_WORKING
|
|
|
};
|
|
|
|
|
|
const response = await client.create.$post({
|
|
|
- json: createData
|
|
|
+ json: createData as any // 使用any绕过类型检查,因为这里故意测试无效的枚举值
|
|
|
}, {
|
|
|
headers: {
|
|
|
'Authorization': `Bearer ${testToken}`
|
|
|
@@ -123,11 +123,11 @@ describe('订单管理API集成测试', () => {
|
|
|
channelId: 1,
|
|
|
expectedStartDate: new Date().toISOString(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
- workStatus: 'INVALID_STATUS' // 无效的状态
|
|
|
+ workStatus: 'invalid_status' // 无效的状态
|
|
|
};
|
|
|
|
|
|
const response = await client.create.$post({
|
|
|
- json: createData
|
|
|
+ json: createData as any // 使用any绕过类型检查,因为这里故意测试无效的枚举值
|
|
|
}, {
|
|
|
headers: {
|
|
|
'Authorization': `Bearer ${testToken}`
|
|
|
@@ -146,27 +146,25 @@ describe('订单管理API集成测试', () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '测试订单1',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
channelId: 1,
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
- workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
+ workStatus: WorkStatus.NOT_WORKING
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
|
|
|
- const testOrder2 = orderRepository.create({
|
|
|
+ const testOrder2 = new EmploymentOrder({
|
|
|
orderName: '测试订单2',
|
|
|
platformId: 2,
|
|
|
companyId: 2,
|
|
|
channelId: 2,
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.CONFIRMED,
|
|
|
- workStatus: WorkStatus.PRE_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
+ workStatus: WorkStatus.PRE_WORKING
|
|
|
});
|
|
|
await orderRepository.save(testOrder2);
|
|
|
});
|
|
|
@@ -261,15 +259,14 @@ describe('订单管理API集成测试', () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '测试订单详情',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
channelId: 1,
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
- workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
+ workStatus: WorkStatus.NOT_WORKING
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
});
|
|
|
@@ -314,15 +311,14 @@ describe('订单管理API集成测试', () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '待激活订单',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
channelId: 1,
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
- workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
+ workStatus: WorkStatus.NOT_WORKING
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
});
|
|
|
@@ -391,7 +387,7 @@ describe('订单管理API集成测试', () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '待关闭订单',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
@@ -400,7 +396,6 @@ describe('订单管理API集成测试', () => {
|
|
|
actualStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.CONFIRMED,
|
|
|
workStatus: WorkStatus.PRE_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
});
|
|
|
@@ -469,7 +464,7 @@ describe('订单管理API集成测试', () => {
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '批量添加人员测试订单',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
@@ -477,7 +472,6 @@ describe('订单管理API集成测试', () => {
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
});
|
|
|
@@ -632,7 +626,7 @@ describe('订单管理API集成测试', () => {
|
|
|
const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '资产测试订单',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
@@ -640,7 +634,6 @@ describe('订单管理API集成测试', () => {
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
|
|
|
@@ -658,8 +651,8 @@ describe('订单管理API集成测试', () => {
|
|
|
const assetData = {
|
|
|
orderId: testOrder.id,
|
|
|
personId: testOrderPerson.personId,
|
|
|
- assetType: '身份证',
|
|
|
- assetFileType: 'image',
|
|
|
+ assetType: AssetType.DISABILITY_CERT,
|
|
|
+ assetFileType: AssetFileType.IMAGE,
|
|
|
fileId: testFile.id,
|
|
|
relatedTime: new Date().toISOString()
|
|
|
};
|
|
|
@@ -672,6 +665,11 @@ describe('订单管理API集成测试', () => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ if (response.status !== 200) {
|
|
|
+ const error = await response.json();
|
|
|
+ console.debug('创建订单人员资产失败:', JSON.stringify(error, null, 2));
|
|
|
+ }
|
|
|
+
|
|
|
expect(response.status).toBe(200);
|
|
|
|
|
|
if (response.status === 200) {
|
|
|
@@ -679,7 +677,7 @@ describe('订单管理API集成测试', () => {
|
|
|
expect(data.id).toBeDefined();
|
|
|
expect(data.orderId).toBe(testOrder.id);
|
|
|
expect(data.personId).toBe(testOrderPerson.personId);
|
|
|
- expect(data.assetType).toBe('身份证');
|
|
|
+ expect(data.assetType).toBe(AssetType.DISABILITY_CERT);
|
|
|
expect(data.fileId).toBe(testFile.id);
|
|
|
}
|
|
|
});
|
|
|
@@ -688,8 +686,8 @@ describe('订单管理API集成测试', () => {
|
|
|
const assetData = {
|
|
|
orderId: testOrder.id,
|
|
|
personId: testOrderPerson.personId,
|
|
|
- assetType: '身份证',
|
|
|
- assetFileType: 'image',
|
|
|
+ assetType: AssetType.DISABILITY_CERT,
|
|
|
+ assetFileType: AssetFileType.IMAGE,
|
|
|
fileId: 999999, // 不存在的文件ID
|
|
|
relatedTime: new Date().toISOString()
|
|
|
};
|
|
|
@@ -709,8 +707,8 @@ describe('订单管理API集成测试', () => {
|
|
|
const assetData = {
|
|
|
orderId: testOrder.id,
|
|
|
personId: 999999, // 不在订单中的人员
|
|
|
- assetType: '身份证',
|
|
|
- assetFileType: 'image',
|
|
|
+ assetType: AssetType.DISABILITY_CERT,
|
|
|
+ assetFileType: AssetFileType.IMAGE,
|
|
|
fileId: testFile.id,
|
|
|
relatedTime: new Date().toISOString()
|
|
|
};
|
|
|
@@ -739,7 +737,7 @@ describe('订单管理API集成测试', () => {
|
|
|
const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
const assetRepository = dataSource.getRepository(OrderPersonAsset);
|
|
|
|
|
|
- testOrder = orderRepository.create({
|
|
|
+ testOrder = new EmploymentOrder({
|
|
|
orderName: '资产查询测试订单',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
@@ -747,7 +745,6 @@ describe('订单管理API集成测试', () => {
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
|
|
|
@@ -760,22 +757,22 @@ describe('订单管理API集成测试', () => {
|
|
|
});
|
|
|
await orderPersonRepository.save(testOrderPerson);
|
|
|
|
|
|
- testAsset = assetRepository.create({
|
|
|
+ testAsset = new OrderPersonAsset({
|
|
|
orderId: testOrder.id,
|
|
|
personId: testOrderPerson.personId,
|
|
|
- assetType: '身份证',
|
|
|
- assetFileType: 'image',
|
|
|
+ assetType: AssetType.DISABILITY_CERT,
|
|
|
+ assetFileType: AssetFileType.IMAGE,
|
|
|
fileId: testFile.id,
|
|
|
relatedTime: new Date()
|
|
|
});
|
|
|
await assetRepository.save(testAsset);
|
|
|
|
|
|
// 创建第二个资产
|
|
|
- const testAsset2 = assetRepository.create({
|
|
|
+ const testAsset2 = new OrderPersonAsset({
|
|
|
orderId: testOrder.id,
|
|
|
personId: testOrderPerson.personId,
|
|
|
- assetType: '学历证书',
|
|
|
- assetFileType: 'pdf',
|
|
|
+ assetType: AssetType.OTHER,
|
|
|
+ assetFileType: AssetFileType.IMAGE,
|
|
|
fileId: testFile.id,
|
|
|
relatedTime: new Date()
|
|
|
});
|
|
|
@@ -845,7 +842,7 @@ describe('订单管理API集成测试', () => {
|
|
|
it('应该支持按资产类型查询', async () => {
|
|
|
const response = await client.assets.query.$get({
|
|
|
query: {
|
|
|
- assetType: '身份证'
|
|
|
+ assetType: AssetType.DISABILITY_CERT
|
|
|
}
|
|
|
}, {
|
|
|
headers: {
|
|
|
@@ -894,7 +891,7 @@ describe('订单管理API集成测试', () => {
|
|
|
const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
const assetRepository = dataSource.getRepository(OrderPersonAsset);
|
|
|
|
|
|
- const testOrder = orderRepository.create({
|
|
|
+ const testOrder = new EmploymentOrder({
|
|
|
orderName: '资产删除测试订单',
|
|
|
platformId: 1,
|
|
|
companyId: 1,
|
|
|
@@ -902,7 +899,6 @@ describe('订单管理API集成测试', () => {
|
|
|
expectedStartDate: new Date(),
|
|
|
orderStatus: OrderStatus.DRAFT,
|
|
|
workStatus: WorkStatus.NOT_WORKING,
|
|
|
- createdBy: testUser.id
|
|
|
});
|
|
|
await orderRepository.save(testOrder);
|
|
|
|
|
|
@@ -915,11 +911,11 @@ describe('订单管理API集成测试', () => {
|
|
|
});
|
|
|
await orderPersonRepository.save(testOrderPerson);
|
|
|
|
|
|
- testAsset = assetRepository.create({
|
|
|
+ testAsset = new OrderPersonAsset({
|
|
|
orderId: testOrder.id,
|
|
|
personId: testOrderPerson.personId,
|
|
|
- assetType: '身份证',
|
|
|
- assetFileType: 'image',
|
|
|
+ assetType: AssetType.DISABILITY_CERT,
|
|
|
+ assetFileType: AssetFileType.IMAGE,
|
|
|
fileId: testFile.id,
|
|
|
relatedTime: new Date()
|
|
|
});
|