worklist-nav-button-enter-exam.cy.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * 测试文件: 阶段3-进入检查
  3. * 路径: 路径1.2-Worklist导航按钮进入
  4. *
  5. * 路径分析:
  6. * - POM: LoginPage, MainPage, WorklistPage, ExamPage
  7. * - Mock:
  8. * - mockLoginSuccess()
  9. * - mockFetchTwoWorks()
  10. * - mockGetStudyArrived()
  11. * - 规格:
  12. * ✓ 登录成功
  13. * ✓ 导航到工作列表
  14. * ✓ 选中第一条记录(单击)
  15. * ✓ 点击导航按钮 "exam"
  16. * ✓ 系统加载任务信息
  17. * ✓ 进入检查界面
  18. * - 需要新建: ExamPage POM(已创建)
  19. * - 需要添加: 检查界面元素的data-testid
  20. * - 已有的data-testid:
  21. * - MainPage: exam - 导航到检查的按钮
  22. * - WorklistTable: row-{index} - 表格行
  23. */
  24. import { mockLoginSuccess } from '../../support/mock/handlers/user';
  25. import { mockFetchTwoWorks } from '../../support/mock/handlers/worklist';
  26. import { mockGetStudyArrived } from '../../support/mock/handlers/study';
  27. import LoginPage from '../../support/pageObjects/LoginPage';
  28. import MainPage from '../../support/pageObjects/MainPage';
  29. import WorklistPage from '../../support/pageObjects/WorklistPage';
  30. import ExamPage from '../../support/pageObjects/ExamPage';
  31. describe('阶段3:进入检查 - 路径1.2:Worklist导航按钮进入', () => {
  32. const loginPage = new LoginPage();
  33. const mainPage = new MainPage();
  34. const worklistPage = new WorklistPage();
  35. const examPage = new ExamPage();
  36. beforeEach(() => {
  37. // 设置Mock
  38. mockLoginSuccess();
  39. mockFetchTwoWorks();
  40. mockGetStudyArrived();
  41. });
  42. it('应该通过选中条目并点击导航按钮进入检查界面', () => {
  43. /**
  44. * Given: 用户已登录并在Worklist页面
  45. * 步骤1(前置): 完成登录并导航到Worklist
  46. */
  47. loginPage.visit();
  48. loginPage.login('admin', '123456');
  49. cy.wait('@loginSuccess');
  50. /**
  51. * When: 导航到Worklist
  52. * 步骤1: 打开 Worklist
  53. */
  54. mainPage.clickPatientManagementButton();
  55. mainPage.clickWorklistButton();
  56. cy.wait('@fetchTwoWorks');
  57. // 验证Worklist显示
  58. worklistPage.getTable().should('be.visible');
  59. /**
  60. * When: 选中第一条任务条目(单击)
  61. * 步骤2: 选中任务条目
  62. */
  63. cy.get('tbody tr[data-testid="row-0"]').click();
  64. /**
  65. * Then: 验证行被选中(背景色变化)
  66. */
  67. cy.get('tbody tr[data-testid="row-0"]')
  68. .should('have.class', 'bg-yellow-500');
  69. /**
  70. * When: 点击导航按钮"exam"
  71. * 步骤3: 点击导航按钮"exam"
  72. */
  73. mainPage.clickExamButton();
  74. /**
  75. * Then: 系统加载任务信息,进入检查界面
  76. * 步骤4: 系统加载任务信息
  77. * 步骤5: 进入检查界面
  78. */
  79. cy.wait('@getStudyArrived').then((interception) => {
  80. expect(interception.response?.statusCode).to.eq(200);
  81. // 验证返回的检查数据
  82. expect(interception.response?.body.data).to.have.property('StudyID');
  83. expect(interception.response?.body.data.StudyStatus).to.eq('Arrived');
  84. });
  85. /**
  86. * Then: 验证进入检查界面
  87. * 注意:当前需要在实际的检查页面组件中添加data-testid
  88. * TODO: 添加检查界面的实际验证
  89. *
  90. * 预期验证(待实现):
  91. * - examPage.verifyExamPageLoaded();
  92. * - examPage.getPatientInfo().should('be.visible');
  93. * - examPage.getStudyId().should('contain', 'expected-study-id');
  94. */
  95. // 临时验证:确保离开了worklist页面
  96. cy.url().should('not.include', 'worklist');
  97. });
  98. });