| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 | /** * 测试文件: 进入检查 - History双击进入检查(未曝光) * 场景: 从History双击未曝光任务,系统应进入检查界面 *  * 路径分析: * - POM: LoginPage, MainPage, HistoryPage, ExamPage * - Mock:  *   - mockLoginSuccess() - 登录成功 *   - mockFetchHistoryDataWithUnlocked() - 获取History列表 *   - mockGetStudyDetailsUnexposed() - 获取未曝光检查详情 * - 规格:  *   ✓ 登录成功 *   ✓ 导航到History列表 *   ✓ History列表显示至少2条记录 *   ✓ 双击第一条未曝光记录 *   ✓ 系统加载任务详细信息(未曝光状态) *   ✓ 进入检查界面(businessFlow: 'exam') *   ✓ 验证Redux状态正确 *   ✓ 验证界面元素可见 *  * @see docs/测试/进入检查功能测试方案.md - 场景3 */import { mockLoginSuccess } from '../../support/mock/handlers/user';import { mockFetchHistoryDataWithUnlocked } from '../../support/mock/handlers/worklist';import { mockGetStudyDetailsUnexposed } from '../../support/mock/handlers/study';import LoginPage from '../../support/pageObjects/LoginPage';import MainPage from '../../support/pageObjects/MainPage';import HistoryPage from '../../support/pageObjects/HistoryPage';import ExamPage from '../../support/pageObjects/ExamPage';describe('进入检查:History双击进入检查(未曝光)', () => {  const loginPage = new LoginPage();  const mainPage = new MainPage();  const historyPage = new HistoryPage();  const examPage = new ExamPage();  beforeEach(() => {    // 设置所有必要的Mock    mockLoginSuccess();    mockFetchHistoryDataWithUnlocked();    // 使用第一条History记录的StudyID    mockGetStudyDetailsUnexposed('HIST20250912001');  });  it('应该通过双击History未曝光条目进入检查界面', () => {    /**     * Given: 用户已登录     * 步骤1(前置): 打开登录界面,完成登录     */    loginPage.visit();    loginPage.getUsernameInput().should('be.visible');    loginPage.login('admin', '123456');        // 等待登录成功    cy.wait('@loginSuccess');    cy.contains('登录成功').should('be.visible', { timeout: 10000 });    /**     * When: 导航到History     * 步骤1: 打开 History     */    mainPage.clickPatientManagementButton();    mainPage.clickHistorylistButton();    /**     * Then: 系统加载History任务信息     * 步骤2(前置): 验证History列表加载     */    cy.wait('@getHistoryUnlocked').then((interception) => {      expect(interception.response?.statusCode).to.eq(200);    });    // 验证History列表显示(至少2条记录)    historyPage.getTable().should('be.visible');    historyPage.getTable().find('tr').should('have.length.at.least', 2);    /**     * When: 用户双击第一条未曝光任务     * 步骤2: 双击任务条目     */    historyPage.findTableAndDoubleClickFirstRow();    /**     * Then: 系统加载任务详细信息(未曝光状态)     * 步骤3: 验证API调用和返回数据     */    cy.wait('@getStudyDetailsUnexposed').then((interception) => {      expect(interception.response?.statusCode).to.eq(200);            // 验证返回的数据包含未曝光的检查信息      const studyData = interception.response?.body.data;      expect(studyData).to.have.property('study_id');      expect(studyData).to.have.property('series');      expect(studyData.series).to.be.an('array');            // 验证所有images的expose_status为'Unexposed'      studyData.series.forEach((series: any) => {        series.images.forEach((image: any) => {          expect(image.expose_status).to.eq('Unexposed');        });      });    });    /**     * Then: 验证Redux状态 - examWorksCache     * 步骤4: 验证任务数据已缓存     */    cy.window()      .its('store')      .invoke('getState')      .its('examWorksCache')      .its('works')      .should('have.length', 1)      .its(0)      .should('have.property', 'StudyID', 'HIST20250912001');    /**     * Then: 验证Redux状态 - businessFlow     * 步骤5: 验证进入检查流程(exam模式)     */    cy.window()      .its('store')      .invoke('getState')      .its('businessFlow')      .its('currentFlow')      .should('eq', 'exam');    /**     * Then: 验证检查界面元素可见     * 步骤6: 验证目标界面加载     */    examPage.verifyExamPageLoaded();    examPage.getToolbar().should('be.visible');    examPage.getContentArea().should('be.visible');  });  it('应该在Redux中正确保存任务的Views数据', () => {    /**     * 这个测试用例专注于验证数据转换的正确性     */    loginPage.visit();    loginPage.login('admin', '123456');    cy.wait('@loginSuccess');    mainPage.clickPatientManagementButton();    mainPage.clickHistorylistButton();    cy.wait('@getHistoryUnlocked');    historyPage.findTableAndDoubleClickFirstRow();    cy.wait('@getStudyDetailsUnexposed');    /**     * 验证Views数组被正确构建     */    cy.window()      .its('store')      .invoke('getState')      .its('examWorksCache')      .its('works')      .its(0)      .its('Views')      .should('be.an', 'array')      .should('have.length.greaterThan', 0)      .then((views: any[]) => {        // 验证每个View包含必要的属性        views.forEach((view) => {          expect(view).to.have.property('view_id');          expect(view).to.have.property('view_description');          expect(view).to.have.property('expose_status', 'Unexposed');          expect(view).to.have.property('study_id');          expect(view).to.have.property('series_instance_uid');        });      });  });  it('应该正确从History进入检查流程', () => {    /**     * 验证从History进入检查的完整流程     */    loginPage.visit();    loginPage.login('admin', '123456');    cy.wait('@loginSuccess');    mainPage.clickPatientManagementButton();    mainPage.clickHistorylistButton();    cy.wait('@getHistoryUnlocked');    // 验证History记录的状态    cy.window()      .its('store')      .invoke('getState')      .its('historyEntities')      .its('data')      .should('have.length.greaterThan', 0)      .its(0)      .should('have.property', 'study_status', 'Completed');    historyPage.findTableAndDoubleClickFirstRow();    cy.wait('@getStudyDetailsUnexposed');    // 验证进入检查流程后,businessFlow正确    cy.window()      .its('store')      .invoke('getState')      .its('businessFlow')      .its('currentFlow')      .should('eq', 'exam');    // 验证examWorksCache包含从History加载的数据    cy.window()      .its('store')      .invoke('getState')      .its('examWorksCache')      .its('works')      .its(0)      .should('have.property', 'StudyID', 'HIST20250912001');  });});
 |