|
|
@@ -2,12 +2,14 @@ import { describe, it, expect, beforeEach } from 'vitest';
|
|
|
import { testClient } from 'hono/testing';
|
|
|
import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
|
|
|
import { JWTUtil } from '@d8d/shared-utils';
|
|
|
+import { JWTPayload } from '@d8d/shared-types';
|
|
|
import { UserEntity, Role } from '@d8d/user-module';
|
|
|
import { File } from '@d8d/file-module';
|
|
|
import { Platform } from '@d8d/allin-platform-module/entities';
|
|
|
import { EmploymentOrder, OrderPerson } from '@d8d/allin-order-module/entities';
|
|
|
import { DisabledPerson, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit } from '@d8d/allin-disability-module/entities';
|
|
|
import { BankName } from '@d8d/bank-names-module';
|
|
|
+import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
|
|
|
import companyStatisticsRoutes from '../../src/routes/company-statistics.route';
|
|
|
import { Company } from '../../src/entities/company.entity';
|
|
|
|
|
|
@@ -38,7 +40,6 @@ describe('企业统计API集成测试', () => {
|
|
|
contactPerson: '平台管理员',
|
|
|
contactPhone: '13800138000',
|
|
|
contactEmail: 'admin@example.com',
|
|
|
- address: '测试地址',
|
|
|
status: 1
|
|
|
});
|
|
|
await platformRepository.save(testPlatform);
|
|
|
@@ -71,9 +72,8 @@ describe('企业统计API集成测试', () => {
|
|
|
testToken = JWTUtil.generateToken({
|
|
|
id: testUser.id,
|
|
|
username: testUser.username,
|
|
|
- roles: [{ name: 'enterprise_user' }],
|
|
|
- companyId: testCompany.id
|
|
|
- });
|
|
|
+ roles: [{ name: 'enterprise_user' }]
|
|
|
+ }, { companyId: testCompany.id } as Partial<JWTPayload & { companyId: number }>);
|
|
|
});
|
|
|
|
|
|
describe('GET /api/v1/yongren/company/overview', () => {
|
|
|
@@ -94,8 +94,7 @@ describe('企业统计API集成测试', () => {
|
|
|
idAddress: '身份证地址',
|
|
|
phone: '13800138000',
|
|
|
province: '北京市',
|
|
|
- city: '北京市',
|
|
|
- address: '测试地址'
|
|
|
+ city: '北京市'
|
|
|
});
|
|
|
await disabledPersonRepo.save(disabledPerson);
|
|
|
|
|
|
@@ -105,8 +104,8 @@ describe('企业统计API集成测试', () => {
|
|
|
orderName: '测试订单',
|
|
|
platformId: testPlatform.id,
|
|
|
companyId: testCompany.id,
|
|
|
- orderStatus: 'in_progress',
|
|
|
- workStatus: 'working'
|
|
|
+ orderStatus: OrderStatus.IN_PROGRESS,
|
|
|
+ workStatus: WorkStatus.WORKING
|
|
|
});
|
|
|
await orderRepo.save(order);
|
|
|
|
|
|
@@ -116,7 +115,7 @@ describe('企业统计API集成测试', () => {
|
|
|
orderId: order.id,
|
|
|
personId: disabledPerson.id,
|
|
|
joinDate: new Date('2024-01-01'),
|
|
|
- workStatus: 'working',
|
|
|
+ workStatus: WorkStatus.WORKING,
|
|
|
salaryDetail: 5000.00
|
|
|
});
|
|
|
await orderPersonRepo.save(orderPerson);
|
|
|
@@ -129,7 +128,7 @@ describe('企业统计API集成测试', () => {
|
|
|
});
|
|
|
|
|
|
expect(response.status).toBe(200);
|
|
|
- const data = await response.json();
|
|
|
+ const data = await response.json() as any;
|
|
|
|
|
|
// 验证响应结构
|
|
|
expect(data).toHaveProperty('在职人员数');
|
|
|
@@ -197,8 +196,7 @@ describe('企业统计API集成测试', () => {
|
|
|
phone: `1380013800${i}`,
|
|
|
province: '北京市',
|
|
|
city: '北京市',
|
|
|
- address: '测试地址'
|
|
|
- });
|
|
|
+ });
|
|
|
await disabledPersonRepo.save(person);
|
|
|
disabledPersons.push(person);
|
|
|
}
|
|
|
@@ -209,8 +207,8 @@ describe('企业统计API集成测试', () => {
|
|
|
orderName: '测试订单',
|
|
|
platformId: testPlatform.id,
|
|
|
companyId: testCompany.id,
|
|
|
- orderStatus: 'in_progress',
|
|
|
- workStatus: 'working'
|
|
|
+ orderStatus: OrderStatus.IN_PROGRESS,
|
|
|
+ workStatus: WorkStatus.WORKING
|
|
|
});
|
|
|
await orderRepo.save(order);
|
|
|
|
|
|
@@ -222,7 +220,7 @@ describe('企业统计API集成测试', () => {
|
|
|
orderId: order.id,
|
|
|
personId: person.id,
|
|
|
joinDate: new Date('2024-01-01'),
|
|
|
- workStatus: i === 0 ? 'working' : 'resigned', // 第一个在职,其他离职
|
|
|
+ workStatus: i === 0 ? WorkStatus.WORKING : WorkStatus.RESIGNED, // 第一个在职,其他离职
|
|
|
salaryDetail: 5000.00 + i * 1000
|
|
|
});
|
|
|
await orderPersonRepo.save(orderPerson);
|
|
|
@@ -244,7 +242,7 @@ describe('企业统计API集成测试', () => {
|
|
|
}
|
|
|
|
|
|
expect(response.status).toBe(200);
|
|
|
- const data = await response.json();
|
|
|
+ const data = await response.json() as any;
|
|
|
|
|
|
// 验证响应结构
|
|
|
expect(data).toHaveProperty('人才列表');
|