exam.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /**
  2. * Exam Mock Handlers
  3. * 检查执行相关的 mock 处理器
  4. */
  5. /**
  6. * 开始检查 - 成功场景
  7. *
  8. * @description 进入曝光页面时调用,告知后端当前开始的检查
  9. * @method POST
  10. * @url /api/v1/auth/task/inspection/start
  11. * @access 需要认证
  12. *
  13. * @param {Object} requestBody - 请求体
  14. * @param {string} requestBody.instance_uid - 图像实例UID
  15. *
  16. * @returns {Object} 成功响应
  17. *
  18. * @example
  19. * mockStartInspectionSuccess();
  20. * cy.wait('@startInspectionSuccess');
  21. *
  22. * @see docs/DR.md - 章节31
  23. */
  24. export function mockStartInspectionSuccess() {
  25. cy.intercept('POST', '/api/v1/auth/task/inspection/start', {
  26. statusCode: 200,
  27. body: {
  28. code: "0x000000",
  29. description: "Success",
  30. solution: "",
  31. data: {
  32. "@type": "type.googleapis.com/google.protobuf.Empty",
  33. value: {}
  34. }
  35. }
  36. }).as('startInspectionSuccess');
  37. }
  38. /**
  39. * 获取全局状态 - 所有设备就绪
  40. *
  41. * @description 获取当前发生器、探测器和后端服务的状态(全部就绪)
  42. * @method GET
  43. * @url /api/v1/auth/task/inspection/status
  44. * @access 需要认证
  45. *
  46. * @returns {Object} data - 全局状态
  47. * @returns {string} data.gen_status - 发生器状态
  48. * @returns {boolean} data.gen_ready - 发生器是否就绪
  49. * @returns {string} data.fpd_status - 探测器状态
  50. * @returns {boolean} data.fpd_ready - 探测器是否就绪
  51. * @returns {boolean} data.all_ready - 全部设备是否就绪
  52. *
  53. * @example
  54. * mockGetGlobalStatusAllReady();
  55. * cy.wait('@getGlobalStatusAllReady');
  56. *
  57. * @see docs/DR.md - 章节32
  58. */
  59. export function mockGetGlobalStatusAllReady() {
  60. cy.intercept('GET', '/api/v1/auth/task/inspection/status', {
  61. statusCode: 200,
  62. body: {
  63. code: "0x000000",
  64. description: "Success",
  65. solution: "",
  66. data: {
  67. "@type": "type.googleapis.com/dr.task.TaskGlobalStatus",
  68. gen_status: "GENERATOR_STATUS_STANDBY",
  69. gen_ready: true,
  70. fpd_status: "DETECTOR_STATUS_STANDBY",
  71. fpd_ready: true,
  72. insp_status: "TASK_Ready",
  73. insp_ready: true,
  74. all_ready: true
  75. }
  76. }
  77. }).as('getGlobalStatusAllReady');
  78. }
  79. /**
  80. * 获取全局状态 - 设备未就绪
  81. *
  82. * @description 获取全局状态(设备未就绪)
  83. * @method GET
  84. * @url /api/v1/auth/task/inspection/status
  85. * @access 需要认证
  86. *
  87. * @returns {Object} data - 全局状态
  88. * @returns {boolean} data.all_ready - 全部设备未就绪
  89. *
  90. * @example
  91. * mockGetGlobalStatusNotReady();
  92. * cy.wait('@getGlobalStatusNotReady');
  93. *
  94. * @see docs/DR.md - 章节32
  95. */
  96. export function mockGetGlobalStatusNotReady() {
  97. cy.intercept('GET', '/api/v1/auth/task/inspection/status', {
  98. statusCode: 200,
  99. body: {
  100. code: "0x000000",
  101. description: "Success",
  102. solution: "",
  103. data: {
  104. "@type": "type.googleapis.com/dr.task.TaskGlobalStatus",
  105. gen_status: "GENERATOR_STATUS_BUSY",
  106. gen_ready: false,
  107. fpd_status: "DETECTOR_STATUS_BUSY",
  108. fpd_ready: false,
  109. insp_status: "TASK_Busy",
  110. insp_ready: false,
  111. all_ready: false
  112. }
  113. }
  114. }).as('getGlobalStatusNotReady');
  115. }
  116. /**
  117. * 软曝光 - 成功场景
  118. *
  119. * @description 触发曝光操作
  120. * @method POST
  121. * @url /api/v1/auth/task/inspection/trigger
  122. * @access 需要认证
  123. *
  124. * @returns {Object} 成功响应
  125. *
  126. * @example
  127. * mockTriggerInspectionSuccess();
  128. * cy.wait('@triggerInspectionSuccess');
  129. *
  130. * @see docs/DR.md - 章节33
  131. */
  132. export function mockTriggerInspectionSuccess() {
  133. cy.intercept('POST', '/api/v1/auth/task/inspection/trigger', {
  134. statusCode: 200,
  135. body: {
  136. code: "0x000000",
  137. description: "Success",
  138. solution: "",
  139. data: {}
  140. }
  141. }).as('triggerInspectionSuccess');
  142. }
  143. /**
  144. * 接受图像 - 成功场景
  145. *
  146. * @description 接受当前图像
  147. * @method POST
  148. * @url /api/v1/auth/task/inspection/judge
  149. * @access 需要认证
  150. *
  151. * @param {Object} requestBody - 请求体
  152. * @param {string} requestBody.instance_uid - 图像实例UID
  153. * @param {boolean} requestBody.accept - true表示接受
  154. *
  155. * @returns {Object} 成功响应
  156. *
  157. * @example
  158. * mockJudgeImageAccept();
  159. * cy.wait('@judgeImageAccept');
  160. *
  161. * @see docs/DR.md - 章节34
  162. */
  163. export function mockJudgeImageAccept() {
  164. cy.intercept('POST', '/api/v1/auth/task/inspection/judge', (req) => {
  165. if (req.body.accept === true) {
  166. req.reply({
  167. statusCode: 200,
  168. body: {
  169. code: "0x000000",
  170. description: "Success",
  171. solution: "",
  172. data: {}
  173. }
  174. });
  175. }
  176. }).as('judgeImageAccept');
  177. }
  178. /**
  179. * 拒绝图像 - 成功场景
  180. *
  181. * @description 拒绝当前图像
  182. * @method POST
  183. * @url /api/v1/auth/task/inspection/judge
  184. * @access 需要认证
  185. *
  186. * @param {Object} requestBody - 请求体
  187. * @param {string} requestBody.instance_uid - 图像实例UID
  188. * @param {boolean} requestBody.accept - false表示拒绝
  189. *
  190. * @returns {Object} 成功响应
  191. *
  192. * @example
  193. * mockJudgeImageReject();
  194. * cy.wait('@judgeImageReject');
  195. *
  196. * @see docs/DR.md - 章节34
  197. */
  198. export function mockJudgeImageReject() {
  199. cy.intercept('POST', '/api/v1/auth/task/inspection/judge', (req) => {
  200. if (req.body.accept === false) {
  201. req.reply({
  202. statusCode: 200,
  203. body: {
  204. code: "0x000000",
  205. description: "Success",
  206. solution: "",
  207. data: {}
  208. }
  209. });
  210. }
  211. }).as('judgeImageReject');
  212. }