/** * Image Mock Handlers * 图像相关的 mock 处理器 */ /** * 批量添加体位和协议 - 成功场景 * * @description 批量添加体位和协议到检查中 * @method POST * @url /dr/api/v1/auth/image * @access 需要认证 * * @param {Object} requestBody - 请求体 * @param {string} requestBody.study_id - 检查ID * @param {Object[]} requestBody.views - 体位列表 * * @returns {Object} data - 创建的序列和图像信息 * @returns {Object[]} data.series - 序列列表 * * @example * mockAppendImagesSuccess(); * cy.wait('@appendImagesSuccess'); * * @see docs/DR.md - 章节20 */ export function mockAppendImagesSuccess() { cy.intercept('POST', '/dr/api/v1/auth/image', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.study.CreateImageReply", series: [] } } }).as('appendImagesSuccess'); } /** * 复制体位 - 成功场景 * * @description 复制选中的体位 * @method POST * @url /dr/api/v1/auth/image/copy * @access 需要认证 * * @param {Object} requestBody - 请求体 * @param {string} requestBody.instance_uid - 图像实例UID * * @returns {Object} data - 复制后的序列信息 * * @example * mockCopyImageSuccess(); * cy.wait('@copyImageSuccess'); * * @see docs/DR.md - 章节21 */ export function mockCopyImageSuccess() { cy.intercept('POST', '/dr/api/v1/auth/image/copy', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.study.CreateImageReply", series: [] } } }).as('copyImageSuccess'); } /** * 体位重新排序 - 成功场景 * * @description 重新排序体位顺序 * @method POST * @url /dr/api/v1/auth/image/sort * @access 需要认证 * * @param {Object} requestBody - 请求体 * @param {string} requestBody.study_id - 检查ID * @param {string[]} requestBody.sop_instance_uids - 排序后的实例UID列表 * * @returns {Object} 成功响应 * * @example * mockSortImagesSuccess(); * cy.wait('@sortImagesSuccess'); * * @see docs/DR.md - 章节22 */ export function mockSortImagesSuccess() { cy.intercept('POST', '/dr/api/v1/auth/image/sort', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/google.protobuf.Empty", value: {} } } }).as('sortImagesSuccess'); } /** * 删除体位 - 成功场景 * * @description 删除study中的体位 * @method DELETE * @url /dr/api/v1/auth/image/{id} * @access 需要认证 * * @param {string} id - 图像实例UID(路径参数) * * @returns {Object} 成功响应 * * @example * mockDeleteImageSuccess(); * cy.wait('@deleteImageSuccess'); * * @see docs/DR.md - 章节23 */ export function mockDeleteImageSuccess() { cy.intercept('DELETE', '/dr/api/v1/auth/image/*', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/google.protobuf.Empty", value: {} } } }).as('deleteImageSuccess'); } /** * 存储后处理DCM - 成功场景 * * @description 存储后处理的DICOM图像 * @method POST * @url /api/v1/auth/image/post_proc * @access 需要认证 * * @param {Object} formData - 表单数据 * @param {string} formData.instance_uid - 实例UID * @param {File} formData.data - 图像文件 * @param {number} formData.window_center - 窗位 * @param {number} formData.window_width - 窗宽 * * @returns {Object} data - DCM文件路径 * * @example * mockStorePostProcSuccess(); * cy.wait('@storePostProcSuccess'); * * @see docs/DR.md - 章节24 */ export function mockStorePostProcSuccess() { cy.intercept('POST', '/api/v1/auth/image/post_proc', { statusCode: 200, body: { code: "0x000000", description: "Success", solution: "", data: { "@type": "type.googleapis.com/dr.task.DcmPath", path: "1.2.276.0.1000000.5.1.5.701601461.33458.1750830395.482043.dcm" } } }).as('storePostProcSuccess'); } /** * 获取DCM文件 - 成功场景 * * @description 获取DICOM文件 * @method GET * @url /api/v1/auth/image/dcm/{dcmfilename} * @access 需要认证 * * @param {string} dcmfilename - DCM文件名(路径参数) * * @returns {File} DICOM文件 * * @example * mockGetDcmFileSuccess(); * cy.wait('@getDcmFileSuccess'); * * @see docs/DR.md - 章节36 */ export function mockGetDcmFileSuccess() { cy.intercept('GET', '/api/v1/auth/image/dcm/*', { statusCode: 200, headers: { 'content-type': 'application/dicom' }, body: '' // 空DCM数据 }).as('getDcmFileSuccess'); } /** * 获取缩略图文件 - 成功场景 * * @description 获取图像缩略图 * @method GET * @url /api/v1/auth/image/thumbnail/{filename} * @access 需要认证 * * @param {string} filename - 缩略图文件名(路径参数) * * @returns {File} 缩略图文件 * * @example * mockGetThumbnailSuccess(); * cy.wait('@getThumbnailSuccess'); * * @see docs/DR.md - 章节37 */ export function mockGetThumbnailSuccess() { cy.intercept('GET', '/api/v1/auth/image/thumbnail/*', { statusCode: 200, headers: { 'content-type': 'image/webp' }, body: '' // 空图像数据 }).as('getThumbnailSuccess'); }