/** * ExamPage - 检查页面Page Object Model * 用于检查界面的元素选择器和操作方法 */ class ExamPage { /** * 获取检查页面主容器 */ getExamPage() { return cy.get('[data-testid="exam-page"]'); } /** * 获取工具栏(设备区域) */ getToolbar() { return cy.get('[data-testid="exam-toolbar"]'); } /** * 获取内容区域 */ getContentArea() { return cy.get('[data-testid="exam-content-area"]'); } /** * 获取患者信息区域 * TODO: 需要在ContentAreaLarge中添加此data-testid */ getPatientInfo() { return cy.get('[data-testid="exam-patient-info"]'); } /** * 获取患者姓名 * TODO: 需要在患者信息组件中添加此data-testid */ getPatientName() { return cy.get('[data-testid="exam-patient-name"]'); } /** * 获取检查ID * TODO: 需要在患者信息组件中添加此data-testid */ getStudyId() { return cy.get('[data-testid="exam-study-id"]'); } /** * 验证检查界面已加载 */ verifyExamPageLoaded() { // 验证检查页面主容器可见 this.getExamPage().should('be.visible'); // 验证工具栏可见 this.getToolbar().should('be.visible'); // 验证内容区域可见 this.getContentArea().should('be.visible'); } /** * 获取重置高压发生器按钮 */ getResetGeneratorButton() { return cy.get('[data-testid="reset-generator-btn"]'); } /** * 点击重置按钮 */ clickResetGenerator() { this.getResetGeneratorButton().click(); } /** * 验证重置按钮为启用状态 */ verifyResetButtonEnabled() { this.getResetGeneratorButton() .should('be.visible') .should('not.be.disabled'); } /** * 验证重置按钮为禁用状态 */ verifyResetButtonDisabled() { this.getResetGeneratorButton() .should('be.visible') .should('be.disabled'); } /** * 等待重置操作完成 */ waitForResetComplete() { cy.wait('@resetDevice'); this.verifyResetButtonEnabled(); } /** * 验证Redux设备状态 * @param expectedStatus - 期望的状态: 'idle' | 'loading' | 'succeeded' | 'failed' */ verifyDeviceStatus(expectedStatus: string) { cy.window() .its('store') .invoke('getState') .its('device') .its('status') .should('eq', expectedStatus); } /** * 验证设备错误信息 * @param expectedError - 期望的错误信息,null表示无错误 */ verifyDeviceError(expectedError: string | null) { cy.window() .its('store') .invoke('getState') .its('device') .its('error') .should('eq', expectedError); } } export default ExamPage;