diff --git a/cypress/e2e/assets_spec/AssetHomepage.cy.ts b/cypress/e2e/assets_spec/AssetHomepage.cy.ts index e19f885db72..fc195c7a803 100644 --- a/cypress/e2e/assets_spec/AssetHomepage.cy.ts +++ b/cypress/e2e/assets_spec/AssetHomepage.cy.ts @@ -113,7 +113,6 @@ rolesToTest.forEach((role) => { it("Export the list of assets in CSV & Json", () => { if (role === "districtAdmin") { assetHome.selectAssetImportButton("click"); - cy.wait(2000); assetHome.selectJsonExportButton(); assetHome.selectAssetImportButton("click"); assetHome.selectCsvExportButton(); diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index d2893166745..4a07a665896 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -65,7 +65,6 @@ describe("Facility Creation with multiple user roles", () => { beforeEach(() => { cy.viewport(1280, 720); cy.restoreLocalStorage(); - cy.awaitUrl("/facility"); }); it("Create a new facility with all fields | Edit Existing Data | Verify its reflection", () => { diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index 0aa8518a6d1..c43106ba869 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -196,7 +196,9 @@ describe("Facility Homepage Function", () => { }); it("Verify the bed capacity badge reflection", () => { + facilityHome.interceptFacilitySearchReq(); facilityHome.typeFacilitySearch(facilityWithNoAvailableBeds); + facilityHome.verifyFacilitySearchReq(); facilityHome.assertFacilityInCard(facilityWithNoAvailableBeds); cy.url().then((url) => { const facilityUrl = url.toString(); diff --git a/cypress/e2e/facility_spec/FacilityInventory.cy.ts b/cypress/e2e/facility_spec/FacilityInventory.cy.ts index b3f77479763..b79998fd5cd 100644 --- a/cypress/e2e/facility_spec/FacilityInventory.cy.ts +++ b/cypress/e2e/facility_spec/FacilityInventory.cy.ts @@ -25,15 +25,20 @@ describe("Inventory Management Section", () => { it("Add New Inventory | Modify data and delete last entry ", () => { // add a new item + facilityPage.interceptManageInventoryItem(); facilityPage.clickManageInventory(); + facilityPage.verifyManageInventoryItem(); facilityPage.fillInventoryDetails("PPE", "Add Stock", "10"); facilityPage.clickAddInventory(); facilityPage.verifySuccessNotification("Inventory created successfully"); + cy.closeNotification(); facilityPage.clickManageInventory(); // modify the new item facilityPage.fillInventoryDetails("PPE", "Use Stock", "5"); facilityPage.clickAddInventory(); - facilityPage.verifySuccessNotification("Inventory created successfully"); + facilityPage.verifySuccessNotification( + "Inventory use stock updated successfully", + ); // verify the new modification facilityPage.verifyPpeQuantity("PPE"); facilityPage.verifyPpeQuantity("5"); @@ -43,7 +48,6 @@ describe("Inventory Management Section", () => { // verify the last entry deletion facilityPage.verifyStockInRow("#row-0", "Added Stock"); facilityPage.verifyStockInRow("#row-1", "Used Stock"); - cy.wait(3000); facilityHome.navigateBack(); facilityPage.verifyPpeQuantity("PPE"); }); @@ -57,9 +61,10 @@ describe("Inventory Management Section", () => { cy.closeNotification(); // Verify Backend minimum badge facilityPage.verifyBadgeWithText(".badge-danger", "Low Stock"); + facilityPage.interceptMinimumQuantity(); // modify with manual minimum badge - facilityPage.clickAddMinimumQuanitity(); - cy.wait(3000); + facilityPage.clickAddMinimumQuantity(); + facilityPage.verifyMinimumQuantity(); cy.get("body").then(($body) => { if ($body.find("#update-minimum-quantity").is(":visible")) { // If the 'update-minimum-quantity' element is visible, click it diff --git a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts index a257d127942..2969d2ddb93 100644 --- a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts @@ -104,8 +104,9 @@ describe("Patient Consultation in multiple combination", () => { patientPrescription.selectMedicine(medicineOne); patientPrescription.enterDosage("3"); patientPrescription.selectDosageFrequency("Twice daily"); + patientPrescription.interceptPrescriptions(); cy.clickSubmitButton("Submit"); - cy.wait(2000); + patientPrescription.verifyPrescription(); cy.verifyNotification("Medicine prescribed"); patientPrescription.clickReturnToDashboard(); // Verify the data's across the dashboard @@ -376,7 +377,9 @@ describe("Patient Consultation in multiple combination", () => { it("Edit created consultation to existing patient", () => { patientPage.visitPatient("Dummy Patient Thirteen"); + patientConsultationPage.interceptConsultation(); patientConsultationPage.clickEditConsultationButton(); + patientConsultationPage.verifyConsultation(); patientConsultationPage.typePatientIllnessHistory("editted"); patientConsultationPage.selectPatientDiagnosis( diagnosis5, diff --git a/cypress/e2e/patient_spec/PatientConsultationDischarge.cy.ts b/cypress/e2e/patient_spec/PatientConsultationDischarge.cy.ts index b7ef6936804..50af6052581 100644 --- a/cypress/e2e/patient_spec/PatientConsultationDischarge.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationDischarge.cy.ts @@ -35,7 +35,9 @@ describe("Patient Discharge based on multiple reason", () => { patientDischarge.clickDischarge(); patientDischarge.selectDischargeReason(patientDischargeReason4); cy.clickSubmitButton("Confirm Discharge"); + patientDischarge.interceptDischargePatient(); cy.clickSubmitButton("Acknowledge & Submit"); + patientDischarge.verifyDischargePatient(); cy.verifyNotification("Patient Discharged Successfully"); cy.closeNotification(); // Verify the consultation dashboard reflection @@ -53,7 +55,9 @@ describe("Patient Discharge based on multiple reason", () => { patientDischarge.typeDischargeNote(patientDeathCause); patientDischarge.typeDoctorName(doctorName); cy.clickSubmitButton("Confirm Discharge"); + patientDischarge.interceptDischargePatient(); cy.clickSubmitButton("Acknowledge & Submit"); + patientDischarge.verifyDischargePatient(); cy.verifyNotification("Patient Discharged Successfully"); cy.closeNotification(); // Verify the consultation dashboard reflection @@ -76,10 +80,10 @@ describe("Patient Discharge based on multiple reason", () => { patientDischarge.clickClearButton(); // select a non-registered facility and perform the discharge patientDischarge.typeReferringFacility(referringFreetextFacility); - cy.wait(2000); cy.clickSubmitButton("Confirm Discharge"); + patientDischarge.interceptDischargePatient(); cy.clickSubmitButton("Acknowledge & Submit"); - cy.wait(2000); + patientDischarge.verifyDischargePatient(); cy.verifyNotification("Patient Discharged Successfully"); cy.closeNotification(); // Verify the consultation dashboard reflection @@ -106,12 +110,12 @@ describe("Patient Discharge based on multiple reason", () => { patientPrescription.selectDosageFrequency("Twice daily"); cy.clickSubmitButton("Submit"); cy.verifyNotification("Medicine prescribed"); - cy.wait(2000); cy.closeNotification(); // submit the discharge pop-up cy.clickSubmitButton("Confirm Discharge"); + patientDischarge.interceptDischargePatient(); cy.clickSubmitButton("Acknowledge & Submit"); - cy.wait(2000); + patientDischarge.verifyDischargePatient(); cy.verifyNotification("Patient Discharged Successfully"); cy.closeNotification(); // Verify the consultation dashboard reflection diff --git a/cypress/e2e/patient_spec/PatientHomepage.cy.ts b/cypress/e2e/patient_spec/PatientHomepage.cy.ts index 8949fc3e324..8f5ac03a9ef 100644 --- a/cypress/e2e/patient_spec/PatientHomepage.cy.ts +++ b/cypress/e2e/patient_spec/PatientHomepage.cy.ts @@ -161,7 +161,6 @@ describe("Patient Homepage present functionalities", () => { .then((patientOne: string) => { firstPatientPageOne = patientOne.trim(); pageNavigation.navigateToNextPage(); - cy.wait(2000); pageNavigation.verifyCurrentPageNumber(2); cy.get('[data-cy="patient"]') .first() diff --git a/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts b/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts index ec5aef250dc..da46a6c093e 100644 --- a/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts +++ b/cypress/e2e/patient_spec/PatientLogUpdate.cy.ts @@ -58,7 +58,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { cy.clickSubmitButton("Update Consultation"); cy.verifyNotification("Consultation updated successfully"); cy.closeNotification(); + patientPage.interceptGetPatient(); patientLogupdate.clickLogupdate(); + patientPage.verifyGetPatientResponse(); patientLogupdate.typePhysicalExamination(physicalExamination); patientLogupdate.selectRoundType("Tele-medicine Log"); patientLogupdate.selectPatientCategory(patientCategory); @@ -80,11 +82,15 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { it("Create a new Progress log update for a admitted patient and edit it", () => { patientPage.visitPatient(patientOne); + patientLogupdate.interceptConsultationBed(); patientLogupdate.clickLogupdate(); + patientLogupdate.verifyConsultationBed(); cy.verifyNotification("Please assign a bed to the patient"); patientLogupdate.selectBed(bedOne); cy.closeNotification(); + patientPage.interceptGetPatient(); patientLogupdate.clickLogupdate(); + patientPage.verifyGetPatientResponse(); // Only will be using random non-unique progress note fields patientLogupdate.selectRoundType("Progress Note"); patientLogupdate.selectPatientCategory(patientCategory); @@ -112,15 +118,18 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { cy.verifyNotification("Medicine prescribed"); cy.closeNotification(); // Submit the doctors log update + patientLogupdate.interceptDailyRounds(); cy.clickSubmitButton("Save and Continue"); - cy.wait(2000); + patientLogupdate.verifyDailyRounds(); cy.verifyNotification("Progress Note created successfully"); cy.closeNotification(); // modify the relevant critical care log update patientLogupdate.selectCriticalCareSection("Neurological Monitoring"); cy.get("#consciousness_level-option-RESPONDS_TO_PAIN").click(); cy.get("#left_pupil_light_reaction-option-FIXED").click(); + patientLogupdate.interceptpatchDailyRounds(); cy.clickSubmitButton("Update Details"); + patientLogupdate.verifypatchDailyRounds(); cy.verifyNotification( "Neurological Monitoring details succesfully updated.", ); @@ -156,7 +165,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { patientLogupdate.clickLogupdate(); patientLogupdate.selectRoundType("Detailed Update"); patientLogupdate.selectPatientCategory(patientCategory); + patientLogupdate.interceptDailyRounds(); cy.clickSubmitButton("Save and Continue"); + patientLogupdate.verifyDailyRounds(); cy.verifyNotification("Detailed Update created successfully"); cy.closeNotification(); // Select two Section - First One is Respiratory Support @@ -235,7 +246,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { cy.verifyNotification("Please assign a bed to the patient"); patientLogupdate.selectBed(bedThree); cy.closeNotification(); + patientPage.interceptGetPatient(); patientLogupdate.clickLogupdate(); + patientPage.verifyGetPatientResponse(); patientLogupdate.typePhysicalExamination(physicalExamination); patientLogupdate.selectPatientCategory(patientCategory); patientLogupdate.typeOtherDetails(otherExamination); @@ -251,9 +264,11 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { patientLogupdate.selectRhythm(patientRhythmType); patientLogupdate.typeRhythm(patientRhythm); cy.get("#consciousness_level-option-RESPONDS_TO_PAIN").click(); + patientConsultationPage.interceptConsultation(); cy.clickSubmitButton("Save"); - cy.wait(2000); + patientConsultationPage.verifyConsultation(); cy.verifyNotification("Brief Update created successfully"); + cy.closeNotification(); // Verify the card content cy.get("#basic-information").scrollIntoView(); cy.verifyContentPresence("#encounter-symptoms", [additionalSymptoms]); diff --git a/cypress/e2e/patient_spec/PatientPrescription.cy.ts b/cypress/e2e/patient_spec/PatientPrescription.cy.ts index 61f8067eea0..bc883e7a5fd 100644 --- a/cypress/e2e/patient_spec/PatientPrescription.cy.ts +++ b/cypress/e2e/patient_spec/PatientPrescription.cy.ts @@ -113,7 +113,6 @@ describe("Patient Medicine Administration", () => { cy.closeNotification(); // Administer the medicine in edit form patientPrescription.clickAdministerButton(); - cy.wait(2000); patientPrescription.enterAdministerDosage(medicineBaseDosage); patientPrescription.enterAdministerNotes(medicineAdministerNote); cy.clickSubmitButton("Administer Medicine"); diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index b11d0f8f585..5601f994c53 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -117,7 +117,6 @@ describe("Patient Creation with consultation", () => { patientPage.createPatientWithData(newPatientData); // Verify the patient details patientPage.clickCancelButton(); - cy.wait(3000); patientPage.savePatientUrl(); patientPage.verifyPatientDashboardDetails( patientOneGender, @@ -197,11 +196,11 @@ describe("Patient Creation with consultation", () => { patientOneSecondInsurerName, ); patientPage.clickUpdatePatient(); - cy.wait(3000); patientPage.verifyPatientUpdated(); + patientPage.interceptGetPatient(); patientPage.visitPatientUrl(); + patientPage.verifyGetPatientResponse(); // Verify Female Gender change reflection, No Medical History and Insurance Details - cy.wait(5000); patientPage.verifyPatientDashboardDetails( patientOneUpdatedGender, age, @@ -218,7 +217,6 @@ describe("Patient Creation with consultation", () => { cy.get("[data-testid=patient-details]") .contains("Member ID") .scrollIntoView(); - cy.wait(2000); patientInsurance.verifyPatientPolicyDetails( patientOneFirstSubscriberId, patientOneFirstPolicyId, @@ -249,7 +247,7 @@ describe("Patient Creation with consultation", () => { // allow the transfer button of a patient patientTransfer.clickAllowPatientTransferButton(); // Verify the patient error message for the same facility - cy.awaitUrl("/patients"); + cy.visit("/patients"); patientPage.createPatient(); patientPage.selectFacility(patientTransferFacility); patientPage.patientformvisibility(); diff --git a/cypress/e2e/users_spec/UsersCreation.cy.ts b/cypress/e2e/users_spec/UsersCreation.cy.ts index d93707617ff..38ad0c907c4 100644 --- a/cypress/e2e/users_spec/UsersCreation.cy.ts +++ b/cypress/e2e/users_spec/UsersCreation.cy.ts @@ -108,9 +108,9 @@ describe("User Creation", () => { userProfilePage.clearWorkingHours(); userProfilePage.typeWorkingHours(weeklyWorkingHrs); userProfilePage.typeDateOfBirth(dob); - cy.intercept("PATCH", "/api/v1/users/*").as("updateUser"); + userProfilePage.interceptUpdateUsers(); userProfilePage.clickUpdateButton(); - cy.wait("@updateUser").its("response.statusCode").should("eq", 200); + userProfilePage.verifyUpdateUsersResponse(); cy.verifyContentPresence("#contactno-profile-details", [ "+91" + phoneNumber, ]); @@ -158,9 +158,9 @@ describe("User Creation", () => { userCreationPage.selectGender(gender); userCreationPage.selectState(state); userCreationPage.selectDistrict(district); - cy.intercept("POST", "/api/v1/users/add_user/").as("createUser"); + userCreationPage.interceptCreateUser(); userCreationPage.clickSaveUserButton(); - cy.wait("@createUser").its("response.statusCode").should("eq", 201); + userCreationPage.verifyCreateUser(); cy.verifyNotification("User added successfully"); userPage.typeInSearchInput(username); userPage.checkUsernameText(username); diff --git a/cypress/e2e/users_spec/UsersManage.cy.ts b/cypress/e2e/users_spec/UsersManage.cy.ts index 8d7ac8695c6..b1968ed2b4c 100644 --- a/cypress/e2e/users_spec/UsersManage.cy.ts +++ b/cypress/e2e/users_spec/UsersManage.cy.ts @@ -230,14 +230,15 @@ describe("Manage User", () => { userPage.checkUsernameText(usernameforworkinghour); manageUserPage.clickMoreDetailsButton(usernameforworkinghour); manageUserPage.verifyMoreDetailsPage(); + manageUserPage.interceptLinkedSkillTab(); manageUserPage.clickLinkedSkillTab(); - cy.wait(500); + manageUserPage.verifyLinkedSkillResponse(); manageUserPage.verifyLinkedSkillsTabPage(); manageUserPage.selectSkillFromDropdown(linkedskill); + manageUserPage.interceptAddSkill(); manageUserPage.clickAddSkillButton(usernameforworkinghour); - cy.wait(500); + manageUserPage.verifyAddSkillResponse(); manageUserPage.assertSkillInAddedUserSkills(linkedskill); - cy.wait(500); manageUserPage.navigateToProfile(); cy.verifyContentPresence("#username-profile-details", [ usernameforworkinghour, diff --git a/cypress/pageobject/Asset/AssetHome.ts b/cypress/pageobject/Asset/AssetHome.ts index e127b785100..1c3cdd20399 100644 --- a/cypress/pageobject/Asset/AssetHome.ts +++ b/cypress/pageobject/Asset/AssetHome.ts @@ -69,7 +69,7 @@ export class AssetHome { selectAssetImportButton(action: "click" | "verifyNotExist"): void { const selector = "[data-testid=import-asset-button]"; if (action === "click") { - cy.get(selector).click(); + cy.get(selector).scrollIntoView().should("be.visible").click(); } else if (action === "verifyNotExist") { cy.get(selector).should("not.exist"); } @@ -77,13 +77,13 @@ export class AssetHome { selectJsonExportButton() { cy.intercept("GET", "**/api/v1/asset/?**json=true**").as("getJsonexport"); - cy.get("#export-json-option").click(); + cy.get("#export-json-option").should("be.visible").click(); cy.wait("@getJsonexport").its("response.statusCode").should("eq", 200); } selectCsvExportButton() { cy.intercept("GET", "**/api/v1/asset/?**csv=true**").as("getCsvexport"); - cy.get("#export-csv-option").click(); + cy.get("#export-csv-option").should("be.visible").click(); cy.wait("@getCsvexport").its("response.statusCode").should("eq", 200); } diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 9776433e523..969023c6dc0 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -21,7 +21,7 @@ export interface FacilityData { class FacilityPage { visitCreateFacilityPage() { cy.intercept("GET", "**/facility/create").as("getCreateFacilities"); - cy.visit("/facility/create"); + cy.awaitUrl("/facility/create"); cy.wait("@getCreateFacilities") .its("response.statusCode") .should("eq", 200); @@ -44,8 +44,7 @@ class FacilityPage { } selectWard(ward: string) { - cy.get("div#ward button").click(); - cy.get("[role='option']").contains(ward).click(); + advanceFilters.selectWard(ward); } typeFacilityAddress(address: string, clearBeforeTyping: boolean = false) { @@ -63,6 +62,14 @@ class FacilityPage { cy.verifyAndClickElement("#submit", "Save Facility"); } + interceptFacility() { + cy.intercept("POST", "**/api/v1/facility/").as("postFacility"); + } + + verifyErrorFacility() { + cy.wait("@postFacility").its("response.statusCode").should("eq", 403); + } + verifyFacilityCreatedNotification() { cy.verifyNotification("Facility added successfully"); cy.closeNotification(); @@ -159,8 +166,7 @@ class FacilityPage { cy.get("#facility-location-button").click(); cy.wait("@mapApi").its("response.statusCode").should("eq", 200); cy.get("input#pac-input").type(location).type("{enter}"); - cy.wait(2000); - cy.get("div#map-close").click(); + cy.get("div#map-close").should("be.visible").click(); } fillMiddleWareAddress(url: string) { @@ -202,21 +208,27 @@ class FacilityPage { cy.url().should("include", "/assets?facility="); } + interceptManageInventoryItem() { + cy.intercept("GET", "/api/v1/items/**").as("getItems"); + } + clickManageInventory() { cy.contains("Manage Inventory").click(); } + verifyManageInventoryItem() { + cy.wait("@getItems").its("response.statusCode").should("eq", 200); + } + fillInventoryDetails(name: string, status: string, quantity: string) { - cy.wait(2000); - cy.get("div#id").click(); - cy.get("div#id ul li").contains(name).click(); cy.get("div#isIncoming").click(); cy.get("div#isIncoming ul li").contains(status).click(); + cy.get("div#id").click(); + cy.get("div#id ul li").contains(name).click(); cy.get("[name='quantity']").type(quantity); } fillInventoryMinimumDetails(name: string, quantity: string) { - cy.wait(2000); cy.get("div#id").click(); cy.get("div#id ul li").contains(name).click(); cy.get("[name='quantity']").type(quantity); @@ -262,39 +274,12 @@ class FacilityPage { .should("eq", 201); } - getStateElement() { - return cy.get("#state"); - } - - getDistrictElement() { - return cy.get("#district"); - } - selectStateOnPincode(stateName: string) { - this.getStateElement() - .scrollIntoView() - .wait(2000) - .should("be.visible") - .then(($element) => { - const text = $element.text(); - if (!text.includes(stateName)) { - this.getStateElement().click(); - cy.get("li[role=option]").contains(stateName).click(); - } - }); + advanceFilters.selectState(stateName); } selectDistrictOnPincode(districtName: string) { - this.getDistrictElement().as("district").scrollIntoView().wait(2000); - cy.get("@district") - .should("be.visible") - .then(($element) => { - const text = $element.text(); - if (!text.includes(districtName)) { - this.getDistrictElement().click(); - cy.get("li[role=option]").contains(districtName).click(); - } - }); + advanceFilters.selectDistrict(districtName); } verifyPpeQuantity(text: string) { @@ -317,10 +302,20 @@ class FacilityPage { cy.get(badgeClass).contains(text).should("exist"); } - clickAddMinimumQuanitity() { + interceptMinimumQuantity() { + cy.intercept("GET", "**/api/v1/facility/*/min_quantity/**").as( + "getMinQuantity", + ); + } + + clickAddMinimumQuantity() { cy.get("#add-minimum-quantity").click(); } + verifyMinimumQuantity() { + cy.wait("@getMinQuantity").its("response.statusCode").should("eq", 200); + } + clickUpdateMinimumQuantity() { cy.get("#update-minimum-quantity").first().click(); } diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index edd8ae135a4..8ef4554277f 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -1,6 +1,5 @@ export class PatientConsultationPage { selectConsultationStatus(status: string) { - cy.wait(5000); cy.get("#route_to_facility").scrollIntoView(); cy.get("#route_to_facility").should("be.visible"); cy.clickAndSelectOption("#route_to_facility", status); @@ -110,7 +109,14 @@ export class PatientConsultationPage { "#consultation-buttons", "Edit Consultation Details", ); - cy.wait(3000); + } + + interceptConsultation() { + cy.intercept("GET", "**/api/v1/consultation/*").as("getConsultation"); + } + + verifyConsultation() { + cy.wait("@getConsultation").its("response.statusCode").should("eq", 200); } interceptPatientDetailsAPI(): void { diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 635aac3c4d2..bdc65c7d431 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -45,7 +45,6 @@ export class PatientPage { cy.get("#patient-search").click().type(patientName); // Type the patient name cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); cy.get("#patient-name-list").contains(patientName).click(); - cy.wait(2000); cy.wait("@getPatient").its("response.statusCode").should("eq", 200); cy.get("#patient-name-consultation") .should("be.visible") @@ -140,7 +139,9 @@ export class PatientPage { } clickCancelButton() { + cy.intercept("GET", "**/api/v1/patient/*/").as("getPatient"); cy.get("#cancel").click(); + cy.wait("@getPatient"); } selectPatientGender(gender: string) { @@ -181,7 +182,9 @@ export class PatientPage { } visitPatientUrl() { - cy.visit(patient_url); + this.interceptGetPatient(); + cy.awaitUrl(patient_url); + this.verifyGetPatientResponse(); } visitConsultationPage() { @@ -194,6 +197,14 @@ export class PatientPage { cy.wait("@updatePatient").its("response.statusCode").should("eq", 200); } + interceptGetPatient() { + cy.intercept("GET", "**/api/v1/patient/*").as("getPatient"); + } + + verifyGetPatientResponse() { + cy.wait("@getPatient").its("response.statusCode").should("eq", 200); + } + clickCreateConsultationOnPatientPageWithNoConsultation() { cy.get("#create-consultation").should("be.visible").click(); } @@ -221,26 +232,29 @@ export class PatientPage { isPostPartum = false, ) { cy.url().should("include", "/facility/"); - cy.get("[data-testid=patient-dashboard]").then(($dashboard) => { - expect($dashboard).to.contain(gender); - expect($dashboard).to.contain(age); - expect($dashboard).to.contain(patientName); - expect($dashboard).to.contain(phoneNumber); - expect($dashboard).to.contain(emergencyPhoneNumber); - //expect($dashboard).to.contain(yearOfBirth); //Commented out because new proposed UI does not have DOB. Can change later. - expect($dashboard).to.contain(bloodGroup); - expect($dashboard).to.contain(occupation); - socioeconomicStatus && expect($dashboard).to.contain(socioeconomicStatus); - domesticHealthcareSupport && - expect($dashboard).to.contain(domesticHealthcareSupport); - - if (isAntenatal) { - expect($dashboard).to.contain("Antenatal"); - } - if (isPostPartum) { - expect($dashboard).to.contain("Post-partum"); - } - }); + cy.get("[data-testid=patient-dashboard]") + .should("be.visible") + .then(($dashboard) => { + expect($dashboard).to.contain(gender); + expect($dashboard).to.contain(age); + expect($dashboard).to.contain(patientName); + expect($dashboard).to.contain(phoneNumber); + expect($dashboard).to.contain(emergencyPhoneNumber); + expect($dashboard).to.contain(yearOfBirth); + expect($dashboard).to.contain(bloodGroup); + expect($dashboard).to.contain(occupation); + socioeconomicStatus && + expect($dashboard).to.contain(socioeconomicStatus); + domesticHealthcareSupport && + expect($dashboard).to.contain(domesticHealthcareSupport); + + if (isAntenatal) { + expect($dashboard).to.contain("Antenatal"); + } + if (isPostPartum) { + expect($dashboard).to.contain("Post-partum"); + } + }); } verifyPatientLocationDetails( diff --git a/cypress/pageobject/Patient/PatientDischarge.ts b/cypress/pageobject/Patient/PatientDischarge.ts index 70a6d550887..58805255088 100644 --- a/cypress/pageobject/Patient/PatientDischarge.ts +++ b/cypress/pageobject/Patient/PatientDischarge.ts @@ -6,7 +6,19 @@ class PatientDischarge { } selectDischargeReason(reason: string) { - cy.clickAndSelectOption("#discharge_reason", reason); + if (reason == "Recovered") { + cy.intercept("GET", "**/api/v1/consultation/*/prescriptions/*").as( + "getPrescriptions", + ); + cy.clickAndSelectOption("#discharge_reason", reason); + cy.wait("@getPrescriptions").its("response.statusCode").should("eq", 200); + } else if (reason == "Referred") { + cy.intercept("GET", "**/api/v1/getallfacilities/**").as("getFacilities"); + cy.clickAndSelectOption("#discharge_reason", reason); + cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); + } else { + cy.clickAndSelectOption("#discharge_reason", reason); + } } typeDischargeNote(note: string) { @@ -24,6 +36,16 @@ class PatientDischarge { typeDoctorName(doctorName: string) { cy.get("#death_confirmed_by").type(doctorName); } + + interceptDischargePatient() { + cy.intercept("POST", "**/api/v1/consultation/*/discharge_patient/").as( + "postDischarge", + ); + } + + verifyDischargePatient() { + cy.wait("@postDischarge").its("response.statusCode").should("eq", 200); + } } export default PatientDischarge; diff --git a/cypress/pageobject/Patient/PatientDoctorNotes.ts b/cypress/pageobject/Patient/PatientDoctorNotes.ts index 157f35d47d9..f1ac6b87bc5 100644 --- a/cypress/pageobject/Patient/PatientDoctorNotes.ts +++ b/cypress/pageobject/Patient/PatientDoctorNotes.ts @@ -5,14 +5,15 @@ export class PatientDoctorNotes { } addDiscussionNotes(notes: string) { - cy.wait(2000); cy.get("#discussion_notes_textarea").scrollIntoView(); cy.get("#discussion_notes_textarea").click().type(notes); } selectNurseDiscussion() { cy.get("#patient-note-tab-Nurses").scrollIntoView(); + cy.intercept("GET", "/api/v1/patient/*/notes/*").as("getPatientNotes"); cy.get("#patient-note-tab-Nurses").click(); + cy.wait("@getPatientNotes").its("response.statusCode").should("eq", 200); } verifyDiscussionMessage(text: string) { diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index c70170a744d..140d5ca993b 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -23,9 +23,9 @@ export class PatientFileUpload { cy.wait(2000); cy.get("#start-recording").click(); cy.wait(2000); - cy.get("#stop-recording").click(); - cy.wait(1000); - cy.get("#save-recording").click(); + cy.get("#stop-recording").should("be.enabled").click(); + cy.wait(2000); + cy.get("#save-recording").should("be.enabled").click(); } clickUploadAudioFile() { diff --git a/cypress/pageobject/Patient/PatientLogupdate.ts b/cypress/pageobject/Patient/PatientLogupdate.ts index 45c1924e1a3..bbe7c157e15 100644 --- a/cypress/pageobject/Patient/PatientLogupdate.ts +++ b/cypress/pageobject/Patient/PatientLogupdate.ts @@ -2,7 +2,14 @@ class PatientLogupdate { clickLogupdate() { cy.get("#log-update").scrollIntoView(); cy.verifyAndClickElement("#log-update", "Log Update"); - cy.wait(2000); + } + + interceptConsultationBed() { + cy.intercept("GET", "**/api/v1/consultationbed/*").as("getBed"); + } + + verifyConsultationBed() { + cy.wait("@getBed").its("response.statusCode").should("eq", 200); } clickSwitchBed() { @@ -15,8 +22,13 @@ class PatientLogupdate { selectBed(bed: string) { cy.typeAndSelectOption("input[name='bed']", bed); + cy.intercept("POST", "**/api/v1/consultationbed/").as( + "postConsultationBed", + ); cy.get("#update-switchbed").click(); - cy.wait(2000); + cy.wait("@postConsultationBed") + .its("response.statusCode") + .should("eq", 201); } selectPatientCategory(category: string) { @@ -74,23 +86,46 @@ class PatientLogupdate { cy.get("#rhythm_detail").click().type(rhythm); } + interceptDailyRounds() { + cy.intercept("GET", "**/api/v1/consultation/*/daily_rounds/*/").as( + "getDailyRounds", + ); + } + + verifyDailyRounds() { + cy.wait("@getDailyRounds").its("response.statusCode").should("eq", 200); + } + + interceptpatchDailyRounds() { + cy.intercept("PATCH", "**/api/v1/consultation/*/daily_rounds/*/").as( + "patchDailyRounds", + ); + } + + verifypatchDailyRounds() { + cy.wait("@patchDailyRounds").its("response.statusCode").should("eq", 200); + } + clickLogUpdateViewDetails(element: string, patientCategory: string) { cy.get(element).scrollIntoView(); cy.verifyContentPresence(element, [patientCategory]); + this.interceptDailyRounds(); cy.get(element).first().contains("View Details").click(); - cy.wait(3000); + this.verifyDailyRounds(); } clickLogUpdateUpdateLog(element: string, patientCategory: string) { cy.get(element).scrollIntoView(); cy.verifyContentPresence(element, [patientCategory]); + this.interceptDailyRounds(); cy.get(element).first().contains("Update Log").click(); - cy.wait(3000); + this.verifyDailyRounds(); } clickUpdateDetail() { + this.interceptDailyRounds(); cy.verifyAndClickElement("#consultation-preview", "Update Log"); - cy.wait(3000); + this.verifyDailyRounds(); } clearIntoElementById(elementId) { diff --git a/cypress/pageobject/Patient/PatientMedicalHistory.ts b/cypress/pageobject/Patient/PatientMedicalHistory.ts index bf2296b4471..94c06790fbf 100644 --- a/cypress/pageobject/Patient/PatientMedicalHistory.ts +++ b/cypress/pageobject/Patient/PatientMedicalHistory.ts @@ -34,7 +34,7 @@ class PatientMedicalHistory { patientSymptoms7: string, ) { cy.get("a").contains("Health Profile").click(); - cy.wait(2000); + cy.url().should("include", "/health-profile"); cy.get("[data-test-id=patient-health-profile]").then(($dashboard) => { cy.url().should("include", "/facility/"); expect($dashboard).to.contain(patientPresentHealth); diff --git a/cypress/pageobject/Patient/PatientPrescription.ts b/cypress/pageobject/Patient/PatientPrescription.ts index d801b360aba..89b14efc7b7 100644 --- a/cypress/pageobject/Patient/PatientPrescription.ts +++ b/cypress/pageobject/Patient/PatientPrescription.ts @@ -61,8 +61,7 @@ export class PatientPrescription { } enterDiscontinueReason(reason: string) { - cy.wait(2000); - cy.get("#discontinuedReason").type(reason); + cy.get("#discontinuedReason").should("be.visible").type(reason); } enterAdministerDosage(dosage: string) { @@ -81,6 +80,16 @@ export class PatientPrescription { cy.clickAndSelectOption("#frequency", frequency); } + interceptPrescriptions() { + cy.intercept("GET", "**/api/v1/consultation/*/prescriptions/*").as( + "getPrescriptions", + ); + } + + verifyPrescription() { + cy.wait("@getPrescriptions").its("response.statusCode").should("eq", 200); + } + clickReturnToDashboard() { cy.verifyAndClickElement( "[data-testid='return-to-patient-dashboard']", diff --git a/cypress/pageobject/Patient/PatientTransfer.ts b/cypress/pageobject/Patient/PatientTransfer.ts index 0bdd55e9880..5ad49b40b5f 100644 --- a/cypress/pageobject/Patient/PatientTransfer.ts +++ b/cypress/pageobject/Patient/PatientTransfer.ts @@ -19,13 +19,11 @@ class PatientTransfer { clickTransferSubmitButton() { cy.get("#submit-transferpatient").click(); - cy.wait(2000); } clickConsultationCancelButton() { cy.get("#cancel").scrollIntoView(); cy.get("#cancel").click(); - cy.wait(2000); } clickAllowPatientTransferButton() { diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index 24c056a70eb..027357a0321 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -8,7 +8,9 @@ export class ManageUserPage { } selectSkillFromDropdown(skill: string) { + cy.intercept("GET", "/api/v1/skill/*").as("getSkills"); cy.typeAndSelectOption("input[name='skill']", skill); + cy.wait("@getSkills").its("response.statusCode").should("eq", 200); } assertLinkedFacility(facilityName: string) { @@ -213,6 +215,14 @@ export class ManageUserPage { cy.get("#facility-patients").click(); } + interceptLinkedSkillTab() { + cy.intercept("GET", "**/api/v1/users/*/skill").as("getUserSkill"); + } + + verifyLinkedSkillResponse() { + cy.wait("@getUserSkill").its("response.statusCode").should("eq", 200); + } + clickLinkedSkillTab() { cy.get("#skills").click(); } @@ -361,9 +371,15 @@ export class ManageUserPage { clickAddSkillButton(username: string) { cy.intercept("GET", `**/api/v1/users/${username}/skill/**`).as("getSkills"); cy.get("#add-skill-button").click(); - cy.wait("@getSkills").its("response.statusCode").should("eq", 200); } + interceptAddSkill() { + cy.intercept("GET", "**/api/v1/users/*/skill").as("getUserSkills"); + } + + verifyAddSkillResponse() { + cy.wait("@getUserSkills").its("response.statusCode").should("eq", 200); + } assertSkillInAlreadyLinkedSkills(skillName: string) { cy.get("#already-linked-skills") .contains(skillName) diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 26eaa088e23..527cd82fa1e 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -48,4 +48,12 @@ export class UserCreationPage { clickSaveUserButton() { cy.clickSubmitButton("Submit"); } + + interceptCreateUser() { + cy.intercept("POST", "/api/v1/users/add_user/").as("createUser"); + } + + verifyCreateUser() { + cy.wait("@createUser").its("response.statusCode").should("eq", 201); + } } diff --git a/cypress/pageobject/Users/UserProfilePage.ts b/cypress/pageobject/Users/UserProfilePage.ts index 882be0b7b9b..50959bb7cf7 100644 --- a/cypress/pageobject/Users/UserProfilePage.ts +++ b/cypress/pageobject/Users/UserProfilePage.ts @@ -11,6 +11,14 @@ export default class UserProfilePage { cy.get("#video_connect_link").click().clear().type(link); } + interceptUpdateUsers() { + cy.intercept("PATCH", "/api/v1/users/*").as("updateUser"); + } + + verifyUpdateUsersResponse() { + cy.wait("@updateUser").its("response.statusCode").should("eq", 200); + } + clickUpdateButton() { cy.clickSubmitButton("Update"); } diff --git a/cypress/pageobject/utils/advanceFilterHelpers.ts b/cypress/pageobject/utils/advanceFilterHelpers.ts index 22925fc2c23..613f4af2f23 100644 --- a/cypress/pageobject/utils/advanceFilterHelpers.ts +++ b/cypress/pageobject/utils/advanceFilterHelpers.ts @@ -4,17 +4,25 @@ export const advanceFilters = { }, selectState(state: string) { + cy.wait(200); cy.clickAndSelectOption("#state", state); }, selectDistrict(district: string) { + cy.wait(200); cy.clickAndSelectOption("#district", district); }, selectLocalBody(localBody: string) { + cy.wait(200); cy.clickAndSelectOption("#local_body", localBody); }, + selectWard(ward: string) { + cy.wait(200); + cy.clickAndSelectOption("#ward", ward); + }, + applySelectedFilter() { cy.verifyAndClickElement("#apply-filter", "Apply"); },