Selaa lähdekoodia

test(task-list): add test cases for accessing task list, using cypress to mock backend and register fake data for testing

dengdx 1 kuukausi sitten
vanhempi
commit
e28d4aee95

+ 152 - 0
cypress/e2e/patient/worklist/enter_worklist.cy.ts

@@ -0,0 +1,152 @@
+/// <reference types="cypress" />
+import LoginPage from '../../../support/pageObjects/LoginPage';
+import MainPage from '../../../support/pageObjects/MainPage';
+import WorklistPage from '../../../support/pageObjects/WorklistPage';
+
+describe('Enter Worklist', () => {
+  const loginPage = new LoginPage();
+  const mainPage = new MainPage();
+  const worklistPage = new WorklistPage();
+
+  beforeEach(() => {
+cy.intercept('GET', '/dr/api/v1/auth/study*', {
+  statusCode: 200,
+  body: {
+    "code": "0x000000",
+    "description": "Success",
+    "solution": "",
+    "data": {
+        "@type": "type.googleapis.com/dr.study.StudyList",
+        "count": 1992,
+        "studies": [
+            {
+                "study_instance_uid": "2.25.156.999999.0000.1.2.2831189249.819691.1757656379.100635",
+                "study_id": "20250912135259444",
+                "public_study_id": "",
+                "specific_character_set": "ISO_IR 192",
+                "accession_number": "ACC0012345",
+                "ref_physician": "Dr. Smith (Vet)",
+                "patient_id": "PET007",
+                "patient_name": "乾隆-==皇上",
+                "patient_english_name": "Buddy en",
+                "patient_former_name": "Buddy f",
+                "patient_size": "Large",
+                "other_patient_ids": "",
+                "other_patient_names": "",
+                "patient_age": "5Y",
+                "patient_dob": "2025-06-10T03:12:36.181739Z",
+                "patient_sex": "M",
+                "sex_neutered": "",
+                "pregnancy_status": "",
+                "patient_state": "",
+                "admitting_time": null,
+                "priority": "",
+                "reg_source": "",
+                "study_description": "",
+                "study_start_datetime": "2025-09-12T05:52:59.699143Z",
+                "study_end_datetime": null,
+                "scheduled_procedure_step_start_date": null,
+                "performed_physician": "",
+                "study_lock": "Unlocked",
+                "folder_path": "",
+                "operator_name": "OP987",
+                "modality": "DX",
+                "weight": 25,
+                "thickness": 15,
+                "length": 60,
+                "patient_type": "Human",
+                "study_type": "Normal",
+                "owner_name": "owner1",
+                "chip_number": "CHIP123456789",
+                "variety": "Golden Retriever",
+                "is_anaesthesia": true,
+                "is_sedation": true,
+                "mwl": "",
+                "is_exported": false,
+                "is_edited": false,
+                "is_appended": false,
+                "department": "",
+                "mapped_status": false,
+                "qc_result": false,
+                "comment": "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四",
+                "study_status": "Arrived",
+                "sort": 0,
+                "product": "DROS",
+                "series": []
+            },
+            {
+                "study_instance_uid": "2.25.156.999999.0000.1.2.2831189249.819691.1757656379.100627",
+                "study_id": "20250912135259265",
+                "public_study_id": "",
+                "specific_character_set": "ISO_IR 192",
+                "accession_number": "ACC0012345",
+                "ref_physician": "Dr. Smith (Vet)",
+                "patient_id": "PET007",
+                "patient_name": "Buddy (Dog)",
+                "patient_english_name": "Buddy en",
+                "patient_former_name": "Buddy f",
+                "patient_size": "Large",
+                "other_patient_ids": "",
+                "other_patient_names": "",
+                "patient_age": "5Y",
+                "patient_dob": "2025-06-10T03:12:36.181739Z",
+                "patient_sex": "M",
+                "sex_neutered": "",
+                "pregnancy_status": "",
+                "patient_state": "",
+                "admitting_time": null,
+                "priority": "",
+                "reg_source": "",
+                "study_description": "",
+                "study_start_datetime": "2025-09-12T05:52:59.573182Z",
+                "study_end_datetime": null,
+                "scheduled_procedure_step_start_date": null,
+                "performed_physician": "",
+                "study_lock": "Unlocked",
+                "folder_path": "",
+                "operator_name": "OP987",
+                "modality": "DX",
+                "weight": 25,
+                "thickness": 15,
+                "length": 60,
+                "patient_type": "Human",
+                "study_type": "Normal",
+                "owner_name": "owner1",
+                "chip_number": "CHIP123456789",
+                "variety": "Golden Retriever",
+                "is_anaesthesia": true,
+                "is_sedation": true,
+                "mwl": "",
+                "is_exported": false,
+                "is_edited": false,
+                "is_appended": false,
+                "department": "",
+                "mapped_status": false,
+                "qc_result": false,
+                "comment": "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四",
+                "study_status": "Arrived",
+                "sort": 0,
+                "product": "DROS",
+                "series": []
+            },
+        ]
+    }
+  }
+}).as('getStudyList');
+    loginPage.visit();
+    loginPage.getUsernameInput().should('be.visible');
+    loginPage.getPasswordInput().should('be.visible');
+    loginPage.getSubmitButton().should('be.visible');
+  });
+
+  it('should navigate to the worklist and verify data', () => {
+    loginPage.login('admin', '123456');
+    cy.contains('登录成功').should('be.visible', { timeout: 10000 });
+
+    mainPage.clickPatientManagementButton();
+    mainPage.clickWorklistButton();
+    cy.wait('@getStudyList');
+    worklistPage.getTable().should('be.visible');
+    worklistPage.getTable().find('tr').should('have.length.at.least', 2); // Assuming there's a header row
+  });
+});

+ 0 - 0
cypress/e2e/patient/worklist/enter_worklist.ts


+ 4 - 0
cypress/support/pageObjects/WorklistPage.ts

@@ -1,4 +1,8 @@
 class WorklistPage {
+  getTable() {
+    return cy.get('table');
+  }
+
   findTableAndDoubleClickFirstRow() {
     cy.get('table').within(() => {
       cy.get('tbody tr[data-testid="row-0"]').scrollIntoView().should('be.visible').dblclick({ force: true });