|
@@ -0,0 +1,494 @@
|
|
|
|
|
+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 { UserEntity, Role } from '@d8d/user-module';
|
|
|
|
|
+import { File } from '@d8d/file-module';
|
|
|
|
|
+import { DisabledPerson, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit } from '@d8d/allin-disability-module';
|
|
|
|
|
+import { Company } from '@d8d/allin-company-module/entities';
|
|
|
|
|
+import { Platform } from '@d8d/allin-platform-module';
|
|
|
|
|
+import { BankName } from '@d8d/bank-names-module';
|
|
|
|
|
+import talentEmploymentRoutes from '../../src/routes/talent-employment.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 { AssetType, AssetFileType } from '../../src/schemas/order.schema';
|
|
|
|
|
+import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
|
|
|
|
|
+
|
|
|
|
|
+// 设置集成测试钩子
|
|
|
|
|
+setupIntegrationDatabaseHooksWithEntities([
|
|
|
|
|
+ UserEntity, Role, File, Platform, Company,
|
|
|
|
|
+ DisabledPerson, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit,
|
|
|
|
|
+ BankName,
|
|
|
|
|
+ EmploymentOrder, OrderPerson, OrderPersonAsset
|
|
|
|
|
+]);
|
|
|
|
|
+
|
|
|
|
|
+describe('人才就业信息API集成测试 - 故事015.005', () => {
|
|
|
|
|
+ let client: ReturnType<typeof testClient<typeof talentEmploymentRoutes>>;
|
|
|
|
|
+ let testToken: string;
|
|
|
|
|
+ let testTalentUser: UserEntity;
|
|
|
|
|
+ let testDisabledPerson: DisabledPerson;
|
|
|
|
|
+ let testCompany: Company;
|
|
|
|
|
+ let testPlatform: Platform;
|
|
|
|
|
+ let testFile: File;
|
|
|
|
|
+
|
|
|
|
|
+ beforeEach(async () => {
|
|
|
|
|
+ // 创建测试客户端
|
|
|
|
|
+ client = testClient(talentEmploymentRoutes);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取数据源
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试平台
|
|
|
|
|
+ const platformRepository = dataSource.getRepository(Platform);
|
|
|
|
|
+ testPlatform = platformRepository.create({
|
|
|
|
|
+ platformName: '测试平台',
|
|
|
|
|
+ status: 1
|
|
|
|
|
+ });
|
|
|
|
|
+ await platformRepository.save(testPlatform);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试企业
|
|
|
|
|
+ const companyRepository = dataSource.getRepository(Company);
|
|
|
|
|
+ testCompany = companyRepository.create({
|
|
|
|
|
+ platformId: testPlatform.id,
|
|
|
|
|
+ companyName: '测试科技有限公司',
|
|
|
|
|
+ contactPerson: '张三',
|
|
|
|
|
+ contactPhone: '13800138000',
|
|
|
|
|
+ status: 1
|
|
|
|
|
+ });
|
|
|
|
|
+ await companyRepository.save(testCompany);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试文件(用于视频资产)
|
|
|
|
|
+ const fileRepository = dataSource.getRepository(File);
|
|
|
|
|
+ testFile = fileRepository.create({
|
|
|
|
|
+ name: '工资视频_2025-01.mp4',
|
|
|
|
|
+ type: 'video/mp4',
|
|
|
|
|
+ size: 1024000,
|
|
|
|
|
+ path: `videos/${Date.now()}_salary_video.mp4`,
|
|
|
|
|
+ fullUrl: `https://example.com/videos/salary_video.mp4`,
|
|
|
|
|
+ uploadTime: new Date(),
|
|
|
|
|
+ createdAt: new Date(),
|
|
|
|
|
+ updatedAt: new Date()
|
|
|
|
|
+ });
|
|
|
|
|
+ await fileRepository.save(testFile);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试银行名称
|
|
|
|
|
+ const bankNameRepository = dataSource.getRepository(BankName);
|
|
|
|
|
+ const testBankName = bankNameRepository.create({
|
|
|
|
|
+ name: '测试银行',
|
|
|
|
|
+ code: 'TEST001',
|
|
|
|
|
+ remark: '测试银行',
|
|
|
|
|
+ status: 1
|
|
|
|
|
+ });
|
|
|
|
|
+ await bankNameRepository.save(testBankName);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试残疾人
|
|
|
|
|
+ const personRepository = dataSource.getRepository(DisabledPerson);
|
|
|
|
|
+ testDisabledPerson = personRepository.create({
|
|
|
|
|
+ name: '李四',
|
|
|
|
|
+ gender: 'male',
|
|
|
|
|
+ disabilityType: 'physical',
|
|
|
|
|
+ idCard: '110101199001011234',
|
|
|
|
|
+ phone: '13900139000',
|
|
|
|
|
+ address: '北京市朝阳区',
|
|
|
|
|
+ status: 1
|
|
|
|
|
+ });
|
|
|
|
|
+ await personRepository.save(testDisabledPerson);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建测试人才用户
|
|
|
|
|
+ const userRepository = dataSource.getRepository(UserEntity);
|
|
|
|
|
+ testTalentUser = userRepository.create({
|
|
|
|
|
+ username: `talent_${Date.now()}`,
|
|
|
|
|
+ password: 'test_password',
|
|
|
|
|
+ nickname: '测试人才',
|
|
|
|
|
+ userType: 'talent',
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ registrationSource: 'mini'
|
|
|
|
|
+ });
|
|
|
|
|
+ await userRepository.save(testTalentUser);
|
|
|
|
|
+
|
|
|
|
|
+ // 生成测试用户的token
|
|
|
|
|
+ testToken = JWTUtil.generateToken({
|
|
|
|
|
+ id: testTalentUser.id,
|
|
|
|
|
+ username: testTalentUser.username,
|
|
|
|
|
+ userType: 'talent',
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ roles: [{ name: 'talent' }]
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ describe('GET /employment/status - 当前就业状态查询', () => {
|
|
|
|
|
+ it('应该成功查询当前就业状态 - 在职状态', async () => {
|
|
|
|
|
+ // 创建测试订单
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+ const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
+ const testOrder = orderRepository.create({
|
|
|
|
|
+ platformId: testPlatform.id,
|
|
|
|
|
+ companyId: testCompany.id,
|
|
|
|
|
+ orderName: '包装工',
|
|
|
|
|
+ expectedStartDate: new Date('2025-01-01'),
|
|
|
|
|
+ actualStartDate: new Date('2025-01-15'),
|
|
|
|
|
+ orderStatus: OrderStatus.IN_PROGRESS,
|
|
|
|
|
+ workStatus: WorkStatus.WORKING
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderRepository.save(testOrder);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建订单人员关联
|
|
|
|
|
+ const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
|
|
+ const orderPerson = orderPersonRepository.create({
|
|
|
|
|
+ orderId: testOrder.id,
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ joinDate: new Date('2025-01-15'),
|
|
|
|
|
+ actualStartDate: new Date('2025-01-15'),
|
|
|
|
|
+ workStatus: WorkStatus.WORKING,
|
|
|
|
|
+ salaryDetail: 3500.00
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderPersonRepository.save(orderPerson);
|
|
|
|
|
+
|
|
|
|
|
+ // 查询当前就业状态
|
|
|
|
|
+ const response = await client['employment.status'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.companyName).toBe('测试科技有限公司');
|
|
|
|
|
+ expect(data.orderId).toBe(testOrder.id);
|
|
|
|
|
+ expect(data.orderName).toBe('包装工');
|
|
|
|
|
+ expect(data.positionName).toBe('包装工');
|
|
|
|
|
+ expect(data.joinDate).toBe('2025-01-15');
|
|
|
|
|
+ expect(data.workStatus).toBe('working');
|
|
|
|
|
+ expect(data.salaryLevel).toBe(3500.00);
|
|
|
|
|
+ expect(data.actualStartDate).toBe('2025-01-15');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该返回404当用户无就业记录时', async () => {
|
|
|
|
|
+ const response = await client['employment.status'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(404);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.code).toBe(404);
|
|
|
|
|
+ expect(data.message).toContain('未找到就业记录');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该返回401当用户未认证时', async () => {
|
|
|
|
|
+ const response = await client['employment.status'].$get();
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(401);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ describe('GET /employment/salary-records - 薪资记录查询', () => {
|
|
|
|
|
+ beforeEach(async () => {
|
|
|
|
|
+ // 创建测试订单和人员关联
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+ const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建3个不同月份的订单
|
|
|
|
|
+ const orders = [
|
|
|
|
|
+ { orderName: '包装工1月', joinDate: new Date('2025-01-15'), salary: 3500.00 },
|
|
|
|
|
+ { orderName: '包装工2月', joinDate: new Date('2025-02-01'), salary: 3600.00 },
|
|
|
|
|
+ { orderName: '包装工3月', joinDate: new Date('2025-03-10'), salary: 3700.00 }
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ for (const orderData of orders) {
|
|
|
|
|
+ const testOrder = orderRepository.create({
|
|
|
|
|
+ platformId: testPlatform.id,
|
|
|
|
|
+ companyId: testCompany.id,
|
|
|
|
|
+ orderName: orderData.orderName,
|
|
|
|
|
+ expectedStartDate: orderData.joinDate,
|
|
|
|
|
+ actualStartDate: orderData.joinDate,
|
|
|
|
|
+ orderStatus: OrderStatus.IN_PROGRESS,
|
|
|
|
|
+ workStatus: WorkStatus.WORKING
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderRepository.save(testOrder);
|
|
|
|
|
+
|
|
|
|
|
+ const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
|
|
+ const orderPerson = orderPersonRepository.create({
|
|
|
|
|
+ orderId: testOrder.id,
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ joinDate: orderData.joinDate,
|
|
|
|
|
+ workStatus: WorkStatus.WORKING,
|
|
|
|
|
+ salaryDetail: orderData.salary
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderPersonRepository.save(orderPerson);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该成功查询薪资记录列表', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-records'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(3);
|
|
|
|
|
+ expect(data.data).toHaveLength(3);
|
|
|
|
|
+ expect(data.data[0].month).toBe('2025-03'); // 按joinDate降序
|
|
|
|
|
+ expect(data.data[0].salaryAmount).toBe(3700.00);
|
|
|
|
|
+ expect(data.data[0].companyName).toBe('测试科技有限公司');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该支持按月份过滤', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-records'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {
|
|
|
|
|
+ month: '2025-01'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(1);
|
|
|
|
|
+ expect(data.data[0].month).toBe('2025-01');
|
|
|
|
|
+ expect(data.data[0].salaryAmount).toBe(3500.00);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该支持分页', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-records'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {
|
|
|
|
|
+ skip: 0,
|
|
|
|
|
+ take: 2
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(3);
|
|
|
|
|
+ expect(data.data).toHaveLength(2);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ describe('GET /employment/history - 就业历史查询', () => {
|
|
|
|
|
+ beforeEach(async () => {
|
|
|
|
|
+ // 创建测试订单和人员关联
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+ const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建包含不同状态的订单
|
|
|
|
|
+ const orders = [
|
|
|
|
|
+ {
|
|
|
|
|
+ orderName: '包装工',
|
|
|
|
|
+ joinDate: new Date('2025-01-15'),
|
|
|
|
|
+ leaveDate: null,
|
|
|
|
|
+ workStatus: WorkStatus.WORKING,
|
|
|
|
|
+ salary: 3500.00
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ orderName: '清洁工',
|
|
|
|
|
+ joinDate: new Date('2024-06-01'),
|
|
|
|
|
+ leaveDate: new Date('2024-12-31'),
|
|
|
|
|
+ workStatus: WorkStatus.RESIGNED,
|
|
|
|
|
+ salary: 3200.00
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ for (const orderData of orders) {
|
|
|
|
|
+ const testOrder = orderRepository.create({
|
|
|
|
|
+ platformId: testPlatform.id,
|
|
|
|
|
+ companyId: testCompany.id,
|
|
|
|
|
+ orderName: orderData.orderName,
|
|
|
|
|
+ expectedStartDate: orderData.joinDate,
|
|
|
|
|
+ actualStartDate: orderData.joinDate,
|
|
|
|
|
+ actualEndDate: orderData.leaveDate,
|
|
|
|
|
+ orderStatus: OrderStatus.IN_PROGRESS,
|
|
|
|
|
+ workStatus: orderData.workStatus
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderRepository.save(testOrder);
|
|
|
|
|
+
|
|
|
|
|
+ const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
|
|
+ const orderPerson = orderPersonRepository.create({
|
|
|
|
|
+ orderId: testOrder.id,
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ joinDate: orderData.joinDate,
|
|
|
|
|
+ leaveDate: orderData.leaveDate,
|
|
|
|
|
+ workStatus: orderData.workStatus,
|
|
|
|
|
+ salaryDetail: orderData.salary
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderPersonRepository.save(orderPerson);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该成功查询就业历史,包含所有状态', async () => {
|
|
|
|
|
+ const response = await client['employment.history'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(2);
|
|
|
|
|
+ expect(data.data).toHaveLength(2);
|
|
|
|
|
+ expect(data.data[0].workStatus).toBe('working'); // 最新的在前
|
|
|
|
|
+ expect(data.data[1].workStatus).toBe('resigned');
|
|
|
|
|
+ expect(data.data[1].leaveDate).toBe('2024-12-31');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该支持分页', async () => {
|
|
|
|
|
+ const response = await client['employment.history'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {
|
|
|
|
|
+ skip: 0,
|
|
|
|
|
+ take: 1
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(2);
|
|
|
|
|
+ expect(data.data).toHaveLength(1);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ describe('GET /employment/salary-videos - 薪资视频查询', () => {
|
|
|
|
|
+ beforeEach(async () => {
|
|
|
|
|
+ // 创建测试订单和视频资产
|
|
|
|
|
+ const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
|
|
+ const orderRepository = dataSource.getRepository(EmploymentOrder);
|
|
|
|
|
+
|
|
|
|
|
+ const testOrder = orderRepository.create({
|
|
|
|
|
+ platformId: testPlatform.id,
|
|
|
|
|
+ companyId: testCompany.id,
|
|
|
|
|
+ orderName: '包装工',
|
|
|
|
|
+ expectedStartDate: new Date('2025-01-01'),
|
|
|
|
|
+ actualStartDate: new Date('2025-01-15'),
|
|
|
|
|
+ orderStatus: OrderStatus.IN_PROGRESS,
|
|
|
|
|
+ workStatus: WorkStatus.WORKING
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderRepository.save(testOrder);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建订单人员关联
|
|
|
|
|
+ const orderPersonRepository = dataSource.getRepository(OrderPerson);
|
|
|
|
|
+ const orderPerson = orderPersonRepository.create({
|
|
|
|
|
+ orderId: testOrder.id,
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ joinDate: new Date('2025-01-15'),
|
|
|
|
|
+ workStatus: WorkStatus.WORKING,
|
|
|
|
|
+ salaryDetail: 3500.00
|
|
|
|
|
+ });
|
|
|
|
|
+ await orderPersonRepository.save(orderPerson);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建视频资产
|
|
|
|
|
+ const assetRepository = dataSource.getRepository(OrderPersonAsset);
|
|
|
|
|
+ const assets = [
|
|
|
|
|
+ {
|
|
|
|
|
+ assetType: AssetType.SALARY_VIDEO,
|
|
|
|
|
+ relatedTime: new Date('2025-01-15T10:00:00Z')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ assetType: AssetType.TAX_VIDEO,
|
|
|
|
|
+ relatedTime: new Date('2025-01-20T14:00:00Z')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ assetType: AssetType.SALARY_VIDEO,
|
|
|
|
|
+ relatedTime: new Date('2025-02-15T10:00:00Z')
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ for (const assetData of assets) {
|
|
|
|
|
+ const asset = assetRepository.create({
|
|
|
|
|
+ orderId: testOrder.id,
|
|
|
|
|
+ personId: testDisabledPerson.id,
|
|
|
|
|
+ assetType: assetData.assetType,
|
|
|
|
|
+ assetFileType: AssetFileType.VIDEO,
|
|
|
|
|
+ fileId: testFile.id,
|
|
|
|
|
+ relatedTime: assetData.relatedTime,
|
|
|
|
|
+ status: 'verified'
|
|
|
|
|
+ });
|
|
|
|
|
+ await assetRepository.save(asset);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该成功查询薪资视频列表', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-videos'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(3);
|
|
|
|
|
+ expect(data.data).toHaveLength(3);
|
|
|
|
|
+ expect(data.data[0].assetType).toBe('salary_video');
|
|
|
|
|
+ expect(data.data[0].fileUrl).toBe('https://example.com/videos/salary_video.mp4');
|
|
|
|
|
+ expect(data.data[0].status).toBe('verified');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该支持按视频类型过滤', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-videos'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {
|
|
|
|
|
+ assetType: 'salary_video'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(2);
|
|
|
|
|
+ expect(data.data.every((v: any) => v.assetType === 'salary_video')).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该支持按月份过滤', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-videos'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {
|
|
|
|
|
+ month: '2025-01'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(2);
|
|
|
|
|
+ expect(data.data.every((v: any) => v.month === '2025-01')).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('应该支持分页', async () => {
|
|
|
|
|
+ const response = await client['employment.salary-videos'].$get({
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Authorization': `Bearer ${testToken}`
|
|
|
|
|
+ },
|
|
|
|
|
+ query: {
|
|
|
|
|
+ skip: 0,
|
|
|
|
|
+ take: 2
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ expect(response.status).toBe(200);
|
|
|
|
|
+
|
|
|
|
|
+ const data = await response.json();
|
|
|
|
|
+ expect(data.total).toBe(3);
|
|
|
|
|
+ expect(data.data).toHaveLength(2);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+});
|