|
|
@@ -18,6 +18,8 @@ describe('薪资管理API集成测试', () => {
|
|
|
let testProvince: AreaEntity;
|
|
|
let testCity: AreaEntity;
|
|
|
let testDistrict: AreaEntity;
|
|
|
+ let testProvince2: AreaEntity;
|
|
|
+ let testCity2: AreaEntity;
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
// 创建测试客户端
|
|
|
@@ -72,6 +74,24 @@ describe('薪资管理API集成测试', () => {
|
|
|
parentId: testCity.id
|
|
|
});
|
|
|
await areaRepository.save(testDistrict);
|
|
|
+
|
|
|
+ // 创建第二个省份
|
|
|
+ testProvince2 = areaRepository.create({
|
|
|
+ code: '120000',
|
|
|
+ name: '天津市',
|
|
|
+ level: 1,
|
|
|
+ parentId: null
|
|
|
+ });
|
|
|
+ await areaRepository.save(testProvince2);
|
|
|
+
|
|
|
+ // 创建第二个城市
|
|
|
+ testCity2 = areaRepository.create({
|
|
|
+ code: '120100',
|
|
|
+ name: '天津市',
|
|
|
+ level: 2,
|
|
|
+ parentId: testProvince2.id
|
|
|
+ });
|
|
|
+ await areaRepository.save(testCity2);
|
|
|
});
|
|
|
|
|
|
describe('POST /salary/create', () => {
|
|
|
@@ -80,12 +100,10 @@ describe('薪资管理API集成测试', () => {
|
|
|
provinceId: testProvince.id,
|
|
|
cityId: testCity.id,
|
|
|
districtId: testDistrict.id,
|
|
|
- basicSalary: 5000.00,
|
|
|
- allowance: 1000.00,
|
|
|
- insurance: 500.00,
|
|
|
- housingFund: 800.00
|
|
|
+ basicSalary: 5000.00
|
|
|
};
|
|
|
|
|
|
+ console.debug('发送的创建数据:', JSON.stringify(createData, null, 2));
|
|
|
const response = await client.create.$post({
|
|
|
json: createData
|
|
|
}, {
|
|
|
@@ -94,6 +112,10 @@ 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) {
|
|
|
@@ -103,7 +125,7 @@ describe('薪资管理API集成测试', () => {
|
|
|
expect(data.cityId).toBe(testCity.id);
|
|
|
expect(data.districtId).toBe(testDistrict.id);
|
|
|
expect(data.basicSalary).toBe(5000.00);
|
|
|
- expect(data.totalSalary).toBe(7300.00); // 5000 + 1000 + 500 + 800
|
|
|
+ expect(data.totalSalary).toBe(5000.00); // 只有基本工资
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -175,8 +197,8 @@ describe('薪资管理API集成测试', () => {
|
|
|
await salaryRepository.save(salary1);
|
|
|
|
|
|
const salary2 = salaryRepository.create({
|
|
|
- provinceId: testProvince.id,
|
|
|
- cityId: testCity.id,
|
|
|
+ provinceId: testProvince2.id, // 使用不同的省份
|
|
|
+ cityId: testCity2.id, // 使用不同的城市
|
|
|
basicSalary: 6000.00,
|
|
|
allowance: 1200.00,
|
|
|
insurance: 600.00,
|