person-extension.integration.test.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /* eslint-disable @typescript-eslint/no-unused-vars */
  2. import { describe, it, expect, beforeEach } from 'vitest';
  3. import { testClient } from 'hono/testing';
  4. import { IntegrationTestDatabase, setupIntegrationDatabaseHooksWithEntities } from '@d8d/shared-test-util';
  5. import { JWTUtil } from '@d8d/shared-utils';
  6. import { JWTPayload } from '@d8d/shared-types';
  7. import { UserEntity, Role } from '@d8d/user-module';
  8. import { File } from '@d8d/file-module';
  9. import { Platform } from '@d8d/allin-platform-module/entities';
  10. import { EmploymentOrder, OrderPerson, OrderPersonAsset } from '@d8d/allin-order-module/entities';
  11. import { AssetType, AssetFileType } from '@d8d/allin-order-module/schemas';
  12. import { OrderStatus, WorkStatus } from '@d8d/allin-order-module/schemas';
  13. import { BankName } from '@d8d/bank-names-module';
  14. import { DisabledPerson, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit } from '../../src/entities';
  15. import personExtensionRoutes from '../../src/routes/person-extension.route';
  16. import { Company } from '@d8d/allin-company-module/entities';
  17. // 设置集成测试钩子 - 需要包含所有相关实体
  18. setupIntegrationDatabaseHooksWithEntities([
  19. UserEntity, File, Role, Platform, Company,
  20. EmploymentOrder, OrderPerson, OrderPersonAsset,
  21. DisabledPerson, BankName, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit
  22. ])
  23. describe('人才扩展API集成测试', () => {
  24. let client: ReturnType<typeof testClient<typeof personExtensionRoutes>>;
  25. let testToken: string;
  26. let testUser: UserEntity;
  27. let testCompany: Company;
  28. let testPlatform: Platform;
  29. let testDisabledPerson: DisabledPerson;
  30. let testOrder: EmploymentOrder;
  31. beforeEach(async () => {
  32. // 创建测试客户端
  33. client = testClient(personExtensionRoutes);
  34. // 获取数据源
  35. const dataSource = await IntegrationTestDatabase.getDataSource();
  36. // 创建测试平台
  37. const platformRepository = dataSource.getRepository(Platform);
  38. testPlatform = platformRepository.create({
  39. platformName: `测试平台_${Date.now()}`,
  40. contactPerson: '平台管理员',
  41. contactPhone: '13800138000',
  42. contactEmail: 'admin@example.com',
  43. status: 1
  44. });
  45. await platformRepository.save(testPlatform);
  46. // 创建测试公司
  47. const companyRepository = dataSource.getRepository(Company);
  48. testCompany = companyRepository.create({
  49. companyName: `测试公司_${Date.now()}`,
  50. contactPerson: '公司联系人',
  51. contactPhone: '13900139000',
  52. contactEmail: 'company@example.com',
  53. address: '公司地址',
  54. platformId: testPlatform.id,
  55. status: 1
  56. });
  57. await companyRepository.save(testCompany);
  58. // 创建测试企业用户
  59. const userRepository = dataSource.getRepository(UserEntity);
  60. testUser = userRepository.create({
  61. username: `enterprise_user_${Date.now()}`,
  62. password: 'test_password',
  63. nickname: '企业测试用户',
  64. registrationSource: 'web',
  65. companyId: testCompany.id
  66. });
  67. await userRepository.save(testUser);
  68. // 生成测试用户的token
  69. testToken = JWTUtil.generateToken({
  70. id: testUser.id,
  71. username: testUser.username,
  72. roles: [{ name: 'enterprise_user' }]
  73. }, { companyId: testCompany.id } as Partial<JWTPayload & { companyId: number }>);
  74. // 创建测试残疾人
  75. const disabledPersonRepo = dataSource.getRepository(DisabledPerson);
  76. testDisabledPerson = disabledPersonRepo.create({
  77. name: '测试残疾人',
  78. idCard: `110101${Date.now() % 100000000}`,
  79. gender: '男',
  80. birthDate: new Date('1990-01-01'),
  81. disabilityType: '视力残疾',
  82. disabilityLevel: '一级',
  83. disabilityId: `DIS${Date.now() % 100000000}`,
  84. idAddress: '身份证地址',
  85. phone: '13800138000',
  86. province: '北京市',
  87. city: '北京市',
  88. detailedAddress: '测试地址'
  89. });
  90. await disabledPersonRepo.save(testDisabledPerson);
  91. // 创建测试订单
  92. const orderRepo = dataSource.getRepository(EmploymentOrder);
  93. testOrder = orderRepo.create({
  94. orderName: '测试订单',
  95. platformId: testPlatform.id,
  96. companyId: testCompany.id,
  97. orderStatus: OrderStatus.CONFIRMED,
  98. });
  99. await orderRepo.save(testOrder);
  100. // 创建订单人员关联,使人员属于该企业
  101. const orderPersonRepo = dataSource.getRepository(OrderPerson);
  102. const orderPerson = orderPersonRepo.create({
  103. orderId: testOrder.id,
  104. personId: testDisabledPerson.id,
  105. joinDate: new Date('2024-01-01'),
  106. workStatus: WorkStatus.WORKING,
  107. salaryDetail: 5000.00
  108. });
  109. await orderPersonRepo.save(orderPerson);
  110. });
  111. describe('GET /api/v1/yongren/disability-person/{id}/work-history', () => {
  112. it('应该返回人员工作历史', async () => {
  113. // 准备测试数据:多个订单关联
  114. const dataSource = await IntegrationTestDatabase.getDataSource();
  115. const orderPersonRepo = dataSource.getRepository(OrderPerson);
  116. // 创建另一个订单关联
  117. const orderRepo = dataSource.getRepository(EmploymentOrder);
  118. const anotherOrder = orderRepo.create({
  119. orderName: '另一个测试订单',
  120. platformId: testPlatform.id,
  121. companyId: testCompany.id,
  122. });
  123. await orderRepo.save(anotherOrder);
  124. const anotherOrderPerson = orderPersonRepo.create({
  125. orderId: anotherOrder.id,
  126. personId: testDisabledPerson.id,
  127. joinDate: new Date('2024-06-01'),
  128. actualStartDate: new Date('2024-06-02'),
  129. leaveDate: new Date('2024-12-31'),
  130. workStatus: WorkStatus.RESIGNED,
  131. salaryDetail: 6000.00
  132. });
  133. await orderPersonRepo.save(anotherOrderPerson);
  134. // 调用API
  135. const response = await client[':id']['work-history'].$get({
  136. param: { id: testDisabledPerson.id }
  137. },{
  138. headers: {
  139. Authorization: `Bearer ${testToken}`
  140. }
  141. });
  142. console.debug('响应状态:', response.status);
  143. // 类型保护:如果状态不是200,抛出错误
  144. if (response.status !== 200) {
  145. try {
  146. const errorData = await response.json();
  147. console.debug('错误响应:', errorData);
  148. throw new Error(`API returned ${response.status}: ${errorData.message}`);
  149. } catch (e) {
  150. console.debug('无法解析错误响应:', e);
  151. throw new Error(`API returned ${response.status} and response could not be parsed`);
  152. }
  153. }
  154. const data = await response.json();
  155. // 验证响应结构
  156. expect(data).toHaveProperty('工作历史');
  157. expect(Array.isArray(data.工作历史)).toBe(true);
  158. // 验证数据
  159. expect(data.工作历史.length).toBeGreaterThanOrEqual(1);
  160. const workHistory = data.工作历史[0];
  161. expect(workHistory).toHaveProperty('订单ID');
  162. expect(workHistory).toHaveProperty('订单名称');
  163. expect(workHistory).toHaveProperty('入职日期');
  164. expect(workHistory).toHaveProperty('工作状态');
  165. expect(workHistory).toHaveProperty('个人薪资');
  166. });
  167. it('访问其他企业人员应该返回403', async () => {
  168. // 创建另一个公司的残疾人
  169. const dataSource = await IntegrationTestDatabase.getDataSource();
  170. // 创建另一个公司
  171. const companyRepository = dataSource.getRepository(Company);
  172. const otherCompany = companyRepository.create({
  173. companyName: `其他公司_${Date.now()}`,
  174. contactPerson: '其他联系人',
  175. contactPhone: '13900139001',
  176. contactEmail: 'other@example.com',
  177. address: '其他地址',
  178. platformId: testPlatform.id,
  179. status: 1
  180. });
  181. await companyRepository.save(otherCompany);
  182. // 创建另一个公司的残疾人
  183. const disabledPersonRepo = dataSource.getRepository(DisabledPerson);
  184. const otherDisabledPerson = disabledPersonRepo.create({
  185. name: '其他公司残疾人',
  186. idCard: `110101${Date.now() % 100000000 + 1000}`,
  187. gender: '女',
  188. birthDate: new Date('1995-01-01'),
  189. disabilityType: '听力残疾',
  190. disabilityLevel: '二级',
  191. disabilityId: `DIS${Date.now() % 100000000 + 1000}`,
  192. idAddress: '其他地址',
  193. phone: '13900139000',
  194. province: '上海市',
  195. city: '上海市',
  196. detailedAddress: '其他地址'
  197. });
  198. await disabledPersonRepo.save(otherDisabledPerson);
  199. // 尝试访问其他公司人员数据
  200. const response = await client[':id']['work-history'].$get({
  201. param: { id: otherDisabledPerson.id }
  202. },{
  203. headers: {
  204. Authorization: `Bearer ${testToken}`
  205. }
  206. });
  207. expect(response.status).toBe(403);
  208. });
  209. });
  210. describe('GET /api/v1/yongren/disability-person/{id}/salary-history', () => {
  211. it('应该返回人员薪资历史', async () => {
  212. // 注意:薪资历史可能需要从薪资模块获取,这里暂时返回空数组
  213. const response = await client[':id']['salary-history'].$get({
  214. param: { id: testDisabledPerson.id }
  215. },{
  216. headers: {
  217. Authorization: `Bearer ${testToken}`
  218. }
  219. });
  220. expect(response.status).toBe(200);
  221. const data = await response.json() as { 薪资历史: any[] };
  222. // 验证响应结构
  223. expect(data).toHaveProperty('薪资历史');
  224. expect(Array.isArray(data.薪资历史)).toBe(true);
  225. });
  226. });
  227. describe('GET /api/v1/yongren/disability-person/{id}/credit-info', () => {
  228. it('应该返回人员征信信息', async () => {
  229. // 准备测试数据:银行卡信息
  230. const dataSource = await IntegrationTestDatabase.getDataSource();
  231. // 创建文件
  232. const fileRepository = dataSource.getRepository(File);
  233. const testFile = fileRepository.create({
  234. name: '银行卡照片.jpg',
  235. type: 'image/jpeg',
  236. size: 1024,
  237. path: 'uploads/bank-card.jpg',
  238. description: '银行卡照片',
  239. uploadUserId: testUser.id,
  240. uploadTime: new Date()
  241. });
  242. await fileRepository.save(testFile);
  243. // 创建银行名称记录
  244. const bankNameRepo = dataSource.getRepository(BankName);
  245. const bankName = bankNameRepo.create({
  246. name: '测试银行',
  247. code: 'TESTBANK',
  248. status: 1
  249. });
  250. await bankNameRepo.save(bankName);
  251. // 创建银行卡记录
  252. const bankCardRepo = dataSource.getRepository(DisabledBankCard);
  253. const bankCard = bankCardRepo.create({
  254. personId: testDisabledPerson.id,
  255. subBankName: '测试支行',
  256. bankNameId: bankName.id, // 使用实际创建的银行ID
  257. cardNumber: '6228481234567890123',
  258. cardholderName: '测试持卡人',
  259. cardType: '一类卡',
  260. fileId: testFile.id,
  261. isDefault: 1
  262. });
  263. await bankCardRepo.save(bankCard);
  264. // 调用API
  265. const response = await client[':id']['credit-info'].$get({
  266. param: { id: testDisabledPerson.id }
  267. },{
  268. headers: {
  269. Authorization: `Bearer ${testToken}`
  270. }
  271. });
  272. expect(response.status).toBe(200);
  273. const data = await response.json() as { 征信信息: any[] };
  274. // 验证响应结构
  275. expect(data).toHaveProperty('征信信息');
  276. expect(Array.isArray(data.征信信息)).toBe(true);
  277. if (data.征信信息.length > 0) {
  278. const creditInfo = data.征信信息[0];
  279. expect(creditInfo).toHaveProperty('文件ID');
  280. expect(creditInfo).toHaveProperty('银行卡号');
  281. expect(creditInfo).toHaveProperty('持卡人姓名');
  282. }
  283. });
  284. });
  285. describe('GET /api/v1/yongren/disability-person/{id}/videos', () => {
  286. it('应该返回人员视频关联', async () => {
  287. // 准备测试数据:订单人员资产(视频)
  288. const dataSource = await IntegrationTestDatabase.getDataSource();
  289. // 创建文件
  290. const fileRepository = dataSource.getRepository(File);
  291. const testFile = fileRepository.create({
  292. name: '工作视频.mp4',
  293. type: 'video/mp4',
  294. size: 1024000,
  295. path: 'uploads/work-video.mp4',
  296. description: '工作视频',
  297. uploadUserId: testUser.id,
  298. uploadTime: new Date()
  299. });
  300. await fileRepository.save(testFile);
  301. // 创建订单人员资产记录
  302. const assetRepo = dataSource.getRepository(OrderPersonAsset);
  303. const asset = assetRepo.create({
  304. orderId: testOrder.id,
  305. personId: testDisabledPerson.id,
  306. assetType: AssetType.WORK_VIDEO,
  307. assetFileType: AssetFileType.VIDEO,
  308. fileId: testFile.id,
  309. relatedTime: new Date()
  310. });
  311. await assetRepo.save(asset);
  312. // 调用API
  313. const response = await client[':id'].videos.$get({
  314. param: { id: testDisabledPerson.id }
  315. },{
  316. headers: {
  317. Authorization: `Bearer ${testToken}`
  318. }
  319. });
  320. expect(response.status).toBe(200);
  321. const data = await response.json() as { 视频列表: any[] };
  322. // 验证响应结构
  323. expect(data).toHaveProperty('视频列表');
  324. expect(Array.isArray(data.视频列表)).toBe(true);
  325. if (data.视频列表.length > 0) {
  326. const video = data.视频列表[0];
  327. expect(video).toHaveProperty('视频类型');
  328. expect(video).toHaveProperty('文件ID');
  329. expect(video).toHaveProperty('关联订单ID');
  330. }
  331. });
  332. });
  333. describe('GET /api/v1/yongren/disability-person (企业专用人才列表)', () => {
  334. it('应该返回企业人才列表', async () => {
  335. console.debug('测试token:', testToken);
  336. console.debug('测试用户companyId:', testUser.companyId);
  337. console.debug('测试公司ID:', testCompany.id);
  338. const response = await client.index.$get({
  339. query: {
  340. page: '1',
  341. limit: '10'
  342. }
  343. }, {
  344. headers: {
  345. Authorization: `Bearer ${testToken}`
  346. }
  347. });
  348. console.debug('响应状态:', response.status);
  349. if (response.status !== 200) {
  350. try {
  351. const errorData = await response.json();
  352. console.debug('错误响应:', errorData);
  353. } catch (e) {
  354. console.debug('无法解析错误响应:', e);
  355. }
  356. }
  357. expect(response.status).toBe(200);
  358. const data = await response.json() as { data: any[], pagination: any };
  359. // 验证响应结构
  360. expect(data).toHaveProperty('data');
  361. expect(data).toHaveProperty('pagination');
  362. expect(Array.isArray(data.data)).toBe(true);
  363. expect(data.pagination).toHaveProperty('page');
  364. expect(data.pagination).toHaveProperty('limit');
  365. expect(data.pagination).toHaveProperty('total');
  366. expect(data.pagination).toHaveProperty('totalPages');
  367. // 应该至少包含我们创建的人员
  368. if (data.data.length > 0) {
  369. const person = data.data[0];
  370. expect(person).toHaveProperty('personId');
  371. expect(person).toHaveProperty('name');
  372. expect(person).toHaveProperty('gender');
  373. expect(person).toHaveProperty('idCard');
  374. expect(person).toHaveProperty('disabilityType');
  375. expect(person).toHaveProperty('disabilityLevel');
  376. expect(person).toHaveProperty('phone');
  377. expect(person).toHaveProperty('jobStatus');
  378. }
  379. });
  380. it('应该支持搜索功能', async () => {
  381. const response = await client.index.$get({
  382. query: {
  383. search: '测试残疾人',
  384. page: '1',
  385. limit: '10'
  386. }
  387. }, {
  388. headers: {
  389. Authorization: `Bearer ${testToken}`
  390. }
  391. });
  392. expect(response.status).toBe(200);
  393. const data = await response.json() as { data: any[], pagination: any };
  394. expect(data.data.length).toBeGreaterThan(0);
  395. });
  396. it('应该支持残疾类型筛选', async () => {
  397. const response = await client.index.$get({
  398. query: {
  399. disabilityType: '视力残疾',
  400. page: '1',
  401. limit: '10'
  402. }
  403. }, {
  404. headers: {
  405. Authorization: `Bearer ${testToken}`
  406. }
  407. });
  408. expect(response.status).toBe(200);
  409. const _data = await response.json() as { data: any[], pagination: any };
  410. // 可能匹配我们创建的人员
  411. });
  412. it('应该支持分页', async () => {
  413. const response = await client.index.$get({
  414. query: {
  415. page: '1',
  416. limit: '5'
  417. }
  418. }, {
  419. headers: {
  420. Authorization: `Bearer ${testToken}`
  421. }
  422. });
  423. expect(response.status).toBe(200);
  424. const data = await response.json() as { data: any[], pagination: any };
  425. expect(data.pagination.limit).toBe(5);
  426. });
  427. it('应该支持工作状态筛选(枚举值)', async () => {
  428. const response = await client.index.$get({
  429. query: {
  430. jobStatus: WorkStatus.WORKING,
  431. page: '1',
  432. limit: '10'
  433. }
  434. }, {
  435. headers: {
  436. Authorization: `Bearer ${testToken}`
  437. }
  438. });
  439. expect(response.status).toBe(200);
  440. const data = await response.json() as { data: any[], pagination: any };
  441. // 应该至少包含一个在职人员(我们创建的人员是在职状态)
  442. });
  443. it('应该支持工作状态筛选(中文标签)', async () => {
  444. const response = await client.index.$get({
  445. query: {
  446. jobStatus: '在职', // 中文标签
  447. page: '1',
  448. limit: '10'
  449. }
  450. }, {
  451. headers: {
  452. Authorization: `Bearer ${testToken}`
  453. }
  454. });
  455. expect(response.status).toBe(200);
  456. const data = await response.json() as { data: any[], pagination: any };
  457. // 验证返回的数据
  458. });
  459. it('其他企业用户不应该看到数据', async () => {
  460. // 创建另一个企业的用户
  461. const dataSource = await IntegrationTestDatabase.getDataSource();
  462. const companyRepository = dataSource.getRepository(Company);
  463. const otherCompany = companyRepository.create({
  464. companyName: `其他公司_${Date.now()}_2`,
  465. contactPerson: '其他联系人2',
  466. contactPhone: '13900139002',
  467. contactEmail: 'other2@example.com',
  468. address: '其他地址2',
  469. platformId: testPlatform.id,
  470. status: 1
  471. });
  472. await companyRepository.save(otherCompany);
  473. const userRepository = dataSource.getRepository(UserEntity);
  474. const otherUser = userRepository.create({
  475. username: `other_enterprise_user_${Date.now()}`,
  476. password: 'test_password',
  477. nickname: '其他企业用户',
  478. registrationSource: 'web',
  479. companyId: otherCompany.id
  480. });
  481. await userRepository.save(otherUser);
  482. // 生成其他企业用户的token
  483. const otherToken = JWTUtil.generateToken({
  484. id: otherUser.id,
  485. username: otherUser.username,
  486. roles: [{ name: 'enterprise_user' }]
  487. }, { companyId: otherCompany.id } as Partial<JWTPayload & { companyId: number }>);
  488. // 其他企业用户应该看不到任何数据(因为人员不属于他的企业)
  489. const response = await client.index.$get({
  490. query: {
  491. page: '1',
  492. limit: '10'
  493. }
  494. }, {
  495. headers: { Authorization: `Bearer ${otherToken}` }
  496. });
  497. expect(response.status).toBe(200);
  498. const data = await response.json() as { data: any[], pagination: any };
  499. // 可能返回空数组,因为人员不属于其他企业
  500. });
  501. });
  502. describe('GET /api/v1/yongren/disability-person/{id} (企业专用人才详情)', () => {
  503. it('应该返回企业人才详情', async () => {
  504. const response = await client[':id'].$get({
  505. param: { id: testDisabledPerson.id }
  506. }, {
  507. headers: {
  508. Authorization: `Bearer ${testToken}`
  509. }
  510. });
  511. expect(response.status).toBe(200);
  512. const data = await response.json() as any;
  513. // 验证响应结构
  514. expect(data).toHaveProperty('personId');
  515. expect(data).toHaveProperty('name');
  516. expect(data).toHaveProperty('gender');
  517. expect(data).toHaveProperty('idCard');
  518. expect(data).toHaveProperty('disabilityType');
  519. expect(data).toHaveProperty('disabilityLevel');
  520. expect(data).toHaveProperty('birthDate');
  521. expect(data).toHaveProperty('phone');
  522. expect(data).toHaveProperty('jobStatus');
  523. expect(data).toHaveProperty('bankCards');
  524. expect(data).toHaveProperty('photos');
  525. expect(Array.isArray(data.bankCards)).toBe(true);
  526. expect(Array.isArray(data.photos)).toBe(true);
  527. });
  528. it('访问其他企业人员应该返回404', async () => {
  529. // 创建另一个公司的残疾人
  530. const dataSource = await IntegrationTestDatabase.getDataSource();
  531. // 创建另一个公司
  532. const companyRepository = dataSource.getRepository(Company);
  533. const otherCompany = companyRepository.create({
  534. companyName: `其他公司_${Date.now()}_3`,
  535. contactPerson: '其他联系人3',
  536. contactPhone: '13900139003',
  537. contactEmail: 'other3@example.com',
  538. address: '其他地址3',
  539. platformId: testPlatform.id,
  540. status: 1
  541. });
  542. await companyRepository.save(otherCompany);
  543. // 创建另一个公司的残疾人(但不关联到当前企业)
  544. const disabledPersonRepo = dataSource.getRepository(DisabledPerson);
  545. const otherDisabledPerson = disabledPersonRepo.create({
  546. name: '其他公司残疾人详情测试',
  547. idCard: `110101${Date.now() % 100000000 + 2000}`,
  548. gender: '女',
  549. birthDate: new Date('1995-01-01'),
  550. disabilityType: '听力残疾',
  551. disabilityLevel: '二级',
  552. disabilityId: `DIS${Date.now() % 100000000 + 2000}`,
  553. idAddress: '其他地址',
  554. phone: '13900139003',
  555. province: '上海市',
  556. city: '上海市',
  557. detailedAddress: '其他地址'
  558. });
  559. await disabledPersonRepo.save(otherDisabledPerson);
  560. // 尝试访问其他公司人员数据
  561. const response = await client[':id'].$get({
  562. param: { id: otherDisabledPerson.id }
  563. }, {
  564. headers: {
  565. Authorization: `Bearer ${testToken}`
  566. }
  567. });
  568. expect(response.status).toBe(404);
  569. });
  570. it('访问不存在的人员应该返回404', async () => {
  571. const nonExistentId = 999999;
  572. const response = await client[':id'].$get({
  573. param: { id: nonExistentId }
  574. }, {
  575. headers: {
  576. Authorization: `Bearer ${testToken}`
  577. }
  578. });
  579. expect(response.status).toBe(404);
  580. });
  581. });
  582. });