123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- /**
- * Exam Mock Handlers
- * 检查执行相关的 mock 处理器
- */
- /**
- * 开始检查 - 成功场景
- *
- * @description 进入曝光页面时调用,告知后端当前开始的检查
- * @method POST
- * @url /api/v1/auth/task/inspection/start
- * @access 需要认证
- *
- * @param {Object} requestBody - 请求体
- * @param {string} requestBody.instance_uid - 图像实例UID
- *
- * @returns {Object} 成功响应
- *
- * @example
- * mockStartInspectionSuccess();
- * cy.wait('@startInspectionSuccess');
- *
- * @see docs/DR.md - 章节31
- */
- export function mockStartInspectionSuccess() {
- cy.intercept('POST', '/api/v1/auth/task/inspection/start', {
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {
- "@type": "type.googleapis.com/google.protobuf.Empty",
- value: {}
- }
- }
- }).as('startInspectionSuccess');
- }
- /**
- * 获取全局状态 - 所有设备就绪
- *
- * @description 获取当前发生器、探测器和后端服务的状态(全部就绪)
- * @method GET
- * @url /api/v1/auth/task/inspection/status
- * @access 需要认证
- *
- * @returns {Object} data - 全局状态
- * @returns {string} data.gen_status - 发生器状态
- * @returns {boolean} data.gen_ready - 发生器是否就绪
- * @returns {string} data.fpd_status - 探测器状态
- * @returns {boolean} data.fpd_ready - 探测器是否就绪
- * @returns {boolean} data.all_ready - 全部设备是否就绪
- *
- * @example
- * mockGetGlobalStatusAllReady();
- * cy.wait('@getGlobalStatusAllReady');
- *
- * @see docs/DR.md - 章节32
- */
- export function mockGetGlobalStatusAllReady() {
- cy.intercept('GET', '/api/v1/auth/task/inspection/status', {
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {
- "@type": "type.googleapis.com/dr.task.TaskGlobalStatus",
- gen_status: "GENERATOR_STATUS_STANDBY",
- gen_ready: true,
- fpd_status: "DETECTOR_STATUS_STANDBY",
- fpd_ready: true,
- insp_status: "TASK_Ready",
- insp_ready: true,
- all_ready: true
- }
- }
- }).as('getGlobalStatusAllReady');
- }
- /**
- * 获取全局状态 - 设备未就绪
- *
- * @description 获取全局状态(设备未就绪)
- * @method GET
- * @url /api/v1/auth/task/inspection/status
- * @access 需要认证
- *
- * @returns {Object} data - 全局状态
- * @returns {boolean} data.all_ready - 全部设备未就绪
- *
- * @example
- * mockGetGlobalStatusNotReady();
- * cy.wait('@getGlobalStatusNotReady');
- *
- * @see docs/DR.md - 章节32
- */
- export function mockGetGlobalStatusNotReady() {
- cy.intercept('GET', '/api/v1/auth/task/inspection/status', {
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {
- "@type": "type.googleapis.com/dr.task.TaskGlobalStatus",
- gen_status: "GENERATOR_STATUS_BUSY",
- gen_ready: false,
- fpd_status: "DETECTOR_STATUS_BUSY",
- fpd_ready: false,
- insp_status: "TASK_Busy",
- insp_ready: false,
- all_ready: false
- }
- }
- }).as('getGlobalStatusNotReady');
- }
- /**
- * 软曝光 - 成功场景
- *
- * @description 触发曝光操作
- * @method POST
- * @url /api/v1/auth/task/inspection/trigger
- * @access 需要认证
- *
- * @returns {Object} 成功响应
- *
- * @example
- * mockTriggerInspectionSuccess();
- * cy.wait('@triggerInspectionSuccess');
- *
- * @see docs/DR.md - 章节33
- */
- export function mockTriggerInspectionSuccess() {
- cy.intercept('POST', '/api/v1/auth/task/inspection/trigger', {
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {}
- }
- }).as('triggerInspectionSuccess');
- }
- /**
- * 接受图像 - 成功场景
- *
- * @description 接受当前图像
- * @method POST
- * @url /api/v1/auth/task/inspection/judge
- * @access 需要认证
- *
- * @param {Object} requestBody - 请求体
- * @param {string} requestBody.instance_uid - 图像实例UID
- * @param {boolean} requestBody.accept - true表示接受
- *
- * @returns {Object} 成功响应
- *
- * @example
- * mockJudgeImageAccept();
- * cy.wait('@judgeImageAccept');
- *
- * @see docs/DR.md - 章节34
- */
- export function mockJudgeImageAccept() {
- cy.intercept('POST', '/api/v1/auth/task/inspection/judge', (req) => {
- if (req.body.accept === true) {
- req.reply({
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {}
- }
- });
- }
- }).as('judgeImageAccept');
- }
- /**
- * 拒绝图像 - 成功场景
- *
- * @description 拒绝当前图像
- * @method POST
- * @url /api/v1/auth/task/inspection/judge
- * @access 需要认证
- *
- * @param {Object} requestBody - 请求体
- * @param {string} requestBody.instance_uid - 图像实例UID
- * @param {boolean} requestBody.accept - false表示拒绝
- *
- * @returns {Object} 成功响应
- *
- * @example
- * mockJudgeImageReject();
- * cy.wait('@judgeImageReject');
- *
- * @see docs/DR.md - 章节34
- */
- export function mockJudgeImageReject() {
- cy.intercept('POST', '/api/v1/auth/task/inspection/judge', (req) => {
- if (req.body.accept === false) {
- req.reply({
- statusCode: 200,
- body: {
- code: "0x000000",
- description: "Success",
- solution: "",
- data: {}
- }
- });
- }
- }).as('judgeImageReject');
- }
|