123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /**
- * 测试文件: 阶段3-进入检查
- * 路径: 路径1.1-Worklist双击进入
- *
- * 路径分析:
- * - POM: LoginPage, MainPage, WorklistPage, ExamPage
- * - Mock:
- * - mockLoginSuccess() - 登录成功
- * - mockFetchTwoWorks() - 获取工作列表
- * - mockGetStudyArrived() - 获取检查信息
- * - 规格:
- * ✓ 登录成功
- * ✓ 导航到工作列表
- * ✓ 工作列表显示至少2条记录
- * ✓ 双击第一条记录
- * ✓ 系统加载任务信息
- * ✓ 进入检查界面
- * - 需要新建: ExamPage POM(已创建)
- * - 需要添加: 检查界面元素的data-testid: exam-patient-info, exam-toolbar等
- * - 已有的data-testid:
- * - WorklistTable: row-0, row-1 - 表格行
- * - MainPage: patient_management, worklist, exam - 导航按钮
- */
- import { mockLoginSuccess } from '../../support/mock/handlers/user';
- import { mockFetchTwoWorks } from '../../support/mock/handlers/worklist';
- import { mockGetStudyArrived } from '../../support/mock/handlers/study';
- import LoginPage from '../../support/pageObjects/LoginPage';
- import MainPage from '../../support/pageObjects/MainPage';
- import WorklistPage from '../../support/pageObjects/WorklistPage';
- import ExamPage from '../../support/pageObjects/ExamPage';
- describe('阶段3:进入检查 - 路径1.1:Worklist双击进入', () => {
- const loginPage = new LoginPage();
- const mainPage = new MainPage();
- const worklistPage = new WorklistPage();
- const examPage = new ExamPage();
- beforeEach(() => {
- // 设置所有必要的Mock
- mockLoginSuccess();
- mockFetchTwoWorks();
- mockGetStudyArrived();
- });
- it('应该通过双击Worklist条目进入检查界面', () => {
- /**
- * Given: 用户已登录
- * 步骤1(前置): 打开登录界面,完成登录
- */
- loginPage.visit();
- loginPage.getUsernameInput().should('be.visible');
- loginPage.login('admin', '123456');
-
- // 等待登录成功
- cy.wait('@loginSuccess');
- cy.contains('登录成功').should('be.visible', { timeout: 10000 });
- /**
- * When: 导航到Worklist
- * 步骤1: 打开 Worklist
- */
- mainPage.clickPatientManagementButton();
- mainPage.clickWorklistButton();
- /**
- * Then: 系统加载Worklist任务信息
- * 步骤2(前置): 验证工作列表加载
- */
- cy.wait('@fetchTwoWorks').then((interception) => {
- expect(interception.response?.statusCode).to.eq(200);
- });
- // 验证工作列表显示(至少2条记录)
- worklistPage.getTable().should('be.visible');
- worklistPage.getTable().find('tr').should('have.length.at.least', 2);
- /**
- * When: 用户双击第一条任务
- * 步骤2: 双击任务条目
- */
- worklistPage.findTableAndDoubleClickFirstRow();
- /**
- * Then: 系统加载任务信息,进入检查界面
- * 步骤3: 系统加载任务信息
- * 步骤4: 进入检查界面
- */
- cy.wait('@getStudyArrived').then((interception) => {
- expect(interception.response?.statusCode).to.eq(200);
- // 验证返回的数据包含检查信息
- expect(interception.response?.body.data).to.have.property('StudyID');
- });
- /**
- * Then: 验证进入检查界面
- * 注意:当前需要在实际的检查页面组件中添加data-testid
- * TODO: 添加检查界面的实际验证
- *
- * 预期验证(待实现):
- * - examPage.verifyExamPageLoaded();
- * - examPage.getPatientInfo().should('be.visible');
- * - examPage.getToolbar().should('be.visible');
- */
-
- // 临时验证:确保离开了worklist页面
- // 一旦检查页面添加了data-testid,可以替换为具体的检查页面验证
- cy.url().should('not.include', 'worklist');
- });
- });
|