epic012-routes-connectivity.integration.test.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import { describe, it, expect } from 'vitest';
  2. import { testClient } from 'hono/testing';
  3. // 导入史诗012新增的企业路由
  4. import { enterpriseAuthApiRoutes, enterpriseCompanyApiRoutes, enterpriseDisabilityApiRoutes, orderApiRoutes } from '../../src/index';
  5. describe('史诗012新增路由连通性集成测试', () => {
  6. describe('企业用户认证路由连通性测试', () => {
  7. it('应该能够访问企业用户登录端点 (POST /api/v1/yongren/auth/login)', async () => {
  8. const client = testClient(enterpriseAuthApiRoutes);
  9. const response = await client.api.v1.yongren.auth.login.$post({
  10. json: { phone: '13800138000', password: 'testpassword' }
  11. });
  12. // 只测试路由连通性,不测试具体业务逻辑
  13. // 可能返回401(需要认证)、200(成功)或400(请求无效)
  14. expect([200, 401, 400]).toContain(response.status);
  15. if (response.status === 200) {
  16. const responseData = await response.json();
  17. expect(responseData).toHaveProperty('success');
  18. expect(responseData).toHaveProperty('data');
  19. expect(responseData).toHaveProperty('message');
  20. }
  21. });
  22. it('应该能够访问企业用户登出端点 (POST /api/v1/yongren/auth/logout)', async () => {
  23. const client = testClient(enterpriseAuthApiRoutes);
  24. const response = await client.api.v1.yongren.auth.logout.$post({
  25. json: {}
  26. });
  27. expect([200, 401]).toContain(response.status);
  28. if (response.status === 200) {
  29. const responseData = await response.json();
  30. expect(responseData).toHaveProperty('success');
  31. expect(responseData).toHaveProperty('data');
  32. expect(responseData).toHaveProperty('message');
  33. }
  34. });
  35. it('应该能够访问企业用户信息端点 (GET /api/v1/yongren/auth/me)', async () => {
  36. const client = testClient(enterpriseAuthApiRoutes);
  37. const response = await client.api.v1.yongren.auth.me.$get();
  38. expect([200, 401]).toContain(response.status);
  39. if (response.status === 200) {
  40. const responseData = await response.json();
  41. expect(responseData).toHaveProperty('success');
  42. expect(responseData).toHaveProperty('data');
  43. expect(responseData).toHaveProperty('message');
  44. }
  45. });
  46. });
  47. describe('企业统计路由连通性测试', () => {
  48. it('应该能够访问企业统计概览端点 (GET /api/v1/yongren/company/overview)', async () => {
  49. const client = testClient(enterpriseCompanyApiRoutes);
  50. const response = await client.api.v1.yongren.company.overview.$get();
  51. // 只测试路由连通性,不测试具体业务逻辑
  52. // 可能返回401(需要认证)或200(如果端点不需要认证)
  53. expect([200, 401]).toContain(response.status);
  54. if (response.status === 200) {
  55. const responseData = await response.json();
  56. expect(responseData).toHaveProperty('success');
  57. expect(responseData).toHaveProperty('data');
  58. expect(responseData).toHaveProperty('message');
  59. }
  60. });
  61. it('应该能够访问企业人才统计端点 (GET /api/v1/yongren/company/{id}/talents)', async () => {
  62. const client = testClient(enterpriseCompanyApiRoutes);
  63. const response = await client.api.v1.yongren.company[':id'].talents.$get({
  64. param: { id: '1' }
  65. });
  66. expect([200, 401]).toContain(response.status);
  67. if (response.status === 200) {
  68. const responseData = await response.json();
  69. expect(responseData).toHaveProperty('success');
  70. expect(responseData).toHaveProperty('data');
  71. expect(responseData).toHaveProperty('message');
  72. }
  73. });
  74. });
  75. describe('残疾人扩展路由连通性测试', () => {
  76. it('应该能够访问残疾人工作历史端点 (GET /api/v1/yongren/disability-person/{id}/work-history)', async () => {
  77. const client = testClient(enterpriseDisabilityApiRoutes);
  78. const response = await client.api.v1.yongren['disability-person'][':id']['work-history'].$get({
  79. param: { id: '1' }
  80. });
  81. // 只测试路由连通性,不测试具体业务逻辑
  82. // 可能返回401(需要认证)或200(如果端点不需要认证)
  83. expect([200, 401]).toContain(response.status);
  84. if (response.status === 200) {
  85. const responseData = await response.json();
  86. expect(responseData).toHaveProperty('success');
  87. expect(responseData).toHaveProperty('data');
  88. expect(responseData).toHaveProperty('message');
  89. }
  90. });
  91. it('应该能够访问残疾人薪资历史端点 (GET /api/v1/yongren/disability-person/{id}/salary-history)', async () => {
  92. const client = testClient(enterpriseDisabilityApiRoutes);
  93. const response = await client.api.v1.yongren['disability-person'][':id']['salary-history'].$get({
  94. param: { id: '1' }
  95. });
  96. expect([200, 401]).toContain(response.status);
  97. if (response.status === 200) {
  98. const responseData = await response.json();
  99. expect(responseData).toHaveProperty('success');
  100. expect(responseData).toHaveProperty('data');
  101. expect(responseData).toHaveProperty('message');
  102. }
  103. });
  104. it('应该能够访问残疾人征信信息端点 (GET /api/v1/yongren/disability-person/{id}/credit-info)', async () => {
  105. const client = testClient(enterpriseDisabilityApiRoutes);
  106. const response = await client.api.v1.yongren['disability-person'][':id']['credit-info'].$get({
  107. param: { id: '1' }
  108. });
  109. expect([200, 401]).toContain(response.status);
  110. if (response.status === 200) {
  111. const responseData = await response.json();
  112. expect(responseData).toHaveProperty('success');
  113. expect(responseData).toHaveProperty('data');
  114. expect(responseData).toHaveProperty('message');
  115. }
  116. });
  117. it('应该能够访问残疾人视频关联端点 (GET /api/v1/yongren/disability-person/{id}/videos)', async () => {
  118. const client = testClient(enterpriseDisabilityApiRoutes);
  119. const response = await client.api.v1.yongren['disability-person'][':id'].videos.$get({
  120. param: { id: '1' }
  121. });
  122. expect([200, 401]).toContain(response.status);
  123. if (response.status === 200) {
  124. const responseData = await response.json();
  125. expect(responseData).toHaveProperty('success');
  126. expect(responseData).toHaveProperty('data');
  127. expect(responseData).toHaveProperty('message');
  128. }
  129. });
  130. });
  131. describe('订单模块企业功能路由连通性测试', () => {
  132. it('应该能够访问打卡统计端点 (GET /api/v1/order/checkin-statistics)', async () => {
  133. const client = testClient(orderApiRoutes);
  134. const response = await client.api.v1.order['checkin-statistics'].$get({ query: {} });
  135. // 只测试路由连通性,不测试具体业务逻辑
  136. // 可能返回401(需要认证)或200(如果端点不需要认证)
  137. expect([200, 401]).toContain(response.status);
  138. if (response.status === 200) {
  139. const responseData = await response.json();
  140. expect(responseData).toHaveProperty('success');
  141. expect(responseData).toHaveProperty('data');
  142. expect(responseData).toHaveProperty('message');
  143. }
  144. });
  145. it('应该能够访问视频统计端点 (GET /api/v1/order/video-statistics)', async () => {
  146. const client = testClient(orderApiRoutes);
  147. const response = await client.api.v1.order['video-statistics'].$get({ query: {} });
  148. expect([200, 401]).toContain(response.status);
  149. if (response.status === 200) {
  150. const responseData = await response.json();
  151. expect(responseData).toHaveProperty('success');
  152. expect(responseData).toHaveProperty('data');
  153. expect(responseData).toHaveProperty('message');
  154. }
  155. });
  156. it('应该能够访问企业订单端点 (GET /api/v1/order/company-orders)', async () => {
  157. const client = testClient(orderApiRoutes);
  158. const response = await client.api.v1.order['company-orders'].$get({ query: {} });
  159. expect([200, 401]).toContain(response.status);
  160. if (response.status === 200) {
  161. const responseData = await response.json();
  162. expect(responseData).toHaveProperty('success');
  163. expect(responseData).toHaveProperty('data');
  164. expect(responseData).toHaveProperty('message');
  165. }
  166. });
  167. it('应该能够访问企业视频端点 (GET /api/v1/order/company-videos)', async () => {
  168. const client = testClient(orderApiRoutes);
  169. const response = await client.api.v1.order['company-videos'].$get({ query: {} });
  170. expect([200, 401]).toContain(response.status);
  171. if (response.status === 200) {
  172. const responseData = await response.json();
  173. expect(responseData).toHaveProperty('success');
  174. expect(responseData).toHaveProperty('data');
  175. expect(responseData).toHaveProperty('message');
  176. }
  177. });
  178. it('应该能够访问批量下载端点 (POST /api/v1/order/batch-download)', async () => {
  179. const client = testClient(orderApiRoutes);
  180. const response = await client.api.v1.order['batch-download'].$post({
  181. json: { downloadScope: 'company' as any }
  182. });
  183. expect([200, 401]).toContain(response.status);
  184. if (response.status === 200) {
  185. const responseData = await response.json();
  186. expect(responseData).toHaveProperty('success');
  187. expect(responseData).toHaveProperty('data');
  188. expect(responseData).toHaveProperty('message');
  189. }
  190. });
  191. it('应该能够访问视频状态更新端点 (PUT /api/v1/order/videos/{id}/status)', async () => {
  192. const client = testClient(orderApiRoutes);
  193. const response = await client.api.v1.order.videos[':id'].status.$put({
  194. param: { id: '1' },
  195. json: { status: 'completed' as any }
  196. });
  197. expect([200, 401]).toContain(response.status);
  198. if (response.status === 200) {
  199. const responseData = await response.json();
  200. expect(responseData).toHaveProperty('success');
  201. expect(responseData).toHaveProperty('data');
  202. expect(responseData).toHaveProperty('message');
  203. }
  204. });
  205. });
  206. });