Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress tests replace cy.wait with cy.intercept or dynamic waits #8963

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ REACT_PUBLIC_URL=https://care.ohc.network

# Care API URL without the /api prefix
REACT_CARE_API_URL=https://careapi.ohc.network
# REACT_CARE_API_URL=http://localhost:9000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this change


# Dev envs
ESLINT_NO_DEV_ERRORS=true
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/assets_spec/AssetHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ describe("Asset Tab", () => {

it("Export asset", () => {
assetPage.selectassetimportbutton();
cy.wait(2000);
assetPage.selectJsonExportButton();
assetPage.selectassetimportbutton();
assetPage.selectCsvExportButton();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/FacilityCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Facility Creation", () => {
const facilityAddress = "cypress address";
const facilityUpdateAddress = "cypress updated address";
const facilityNumber = "9898469865";
const triageDate = "02122023";
const triageDate = "03122023";
const initialTriageValue = "60";
const modifiedTriageValue = "50";
const facilityErrorMessage = [
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/facility_spec/FacilityInventory.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ describe("Inventory Management Section", () => {
// 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");
Expand All @@ -43,7 +45,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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the intercept and API Verification is missing here

facilityHome.navigateBack();
facilityPage.verifyPpeQuantity("PPE");
});
Expand All @@ -59,7 +60,6 @@ describe("Inventory Management Section", () => {
facilityPage.verifyBadgeWithText(".badge-danger", "Low Stock");
// modify with manual minimum badge
facilityPage.clickAddMinimumQuanitity();
cy.wait(3000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the intercept and API Verification is missing here

cy.get("body").then(($body) => {
if ($body.find("#update-minimum-quantity").is(":visible")) {
// If the 'update-minimum-quantity' element is visible, click it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ describe("Patient Consultation in multiple combination", () => {
patientPrescription.enterDosage("3");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.wait(2000);
cy.verifyNotification("Medicine prescribed");
patientPrescription.clickReturnToDashboard();
// Verify the data's across the dashboard
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/patient_spec/PatientConsultationDischarge.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ 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.submitButton("Confirm Discharge");
cy.submitButton("Acknowledge & Submit");
cy.wait(2000);
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
Expand All @@ -106,12 +104,10 @@ describe("Patient Discharge based on multiple reason", () => {
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.wait(2000);
cy.closeNotification();
// submit the discharge pop-up
cy.submitButton("Confirm Discharge");
cy.submitButton("Acknowledge & Submit");
cy.wait(2000);
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
Expand Down
2 changes: 0 additions & 2 deletions cypress/e2e/patient_spec/PatientLogUpdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
cy.closeNotification();
// Submit the doctors log update
cy.submitButton("Save and Continue");
cy.wait(2000);
cy.verifyNotification("Progress Note created successfully");
cy.closeNotification();
// modify the relevant critical care log update
Expand Down Expand Up @@ -252,7 +251,6 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientLogupdate.typeRhythm(patientRhythm);
cy.get("#consciousness_level-option-RESPONDS_TO_PAIN").click();
cy.submitButton("Save");
cy.wait(2000);
cy.verifyNotification("Brief Update created successfully");
// Verify the card content
cy.get("#basic-information").scrollIntoView();
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/patient_spec/PatientPrescription.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.submitButton("Administer Medicine");
Expand Down
6 changes: 0 additions & 6 deletions cypress/e2e/patient_spec/PatientRegistration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ describe("Patient Creation with consultation", () => {
patientPage.verifyPatientIsCreated();
// Verify the patient details
patientPage.clickCancelButton();
cy.wait(3000);
patientPage.savePatientUrl();
patientPage.verifyPatientDashboardDetails(
patientOneGender,
Expand Down Expand Up @@ -157,7 +156,6 @@ describe("Patient Creation with consultation", () => {
patientPage.verifyStatusCode();
patientPage.patientformvisibility();
// change the gender to female and input data to related changed field
cy.wait(3000);
patientPage.selectPatientGender(patientOneUpdatedGender);
patientPage.typePatientDateOfBirth(patientDateOfBirth);
patientPage.clickPatientAntenatalStatusYes();
Expand Down Expand Up @@ -220,11 +218,9 @@ describe("Patient Creation with consultation", () => {
}

patientPage.clickUpdatePatient();
cy.wait(3000);
patientPage.verifyPatientUpdated();
patientPage.visitPatientUrl();
// Verify Female Gender change reflection, No Medical History and Insurance Details
cy.wait(5000);
patientPage.verifyPatientDashboardDetails(
patientOneUpdatedGender,
age,
Expand All @@ -241,9 +237,7 @@ describe("Patient Creation with consultation", () => {
cy.get("[data-testid=patient-details]")
.contains("member id")
.scrollIntoView();
cy.wait(2000);
patientInsurance.clickPatientInsuranceViewDetail();
cy.wait(3000);
patientInsurance.verifyPatientPolicyDetails(
patientOneFirstSubscriberId,
patientOneFirstPolicyId,
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/users_spec/UsersCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ describe("User Creation", () => {
it("create new user form throwing mandatory field error", () => {
userCreationPage.clickElementById("addUserButton");
userCreationPage.clickElementById("submit");
cy.wait(2000);
userCreationPage.verifyErrorMessages(EXPECTED_ERROR_MESSAGES);
});

Expand Down
3 changes: 0 additions & 3 deletions cypress/e2e/users_spec/UsersManage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ describe("Manage User", () => {
manageUserPage.selectSkillFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
cy.wait(5000);
manageUserPage.clicklinkedskillbutton();
manageUserPage.assertSkillInAddedUserSkills(linkedskill);
manageUserPage.clickCloseSlideOver();
cy.wait(5000);
manageUserPage.navigateToProfile();
userCreationPage.verifyElementContainsText(
"username-profile-details",
Expand All @@ -59,7 +57,6 @@ describe("Manage User", () => {
manageUserPage.selectSkillFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
cy.wait(5000); // temporary hack to fix the failure
manageUserPage.clicklinkedskillbutton();
manageUserPage.assertSkillInAddedUserSkills(linkedskill);
manageUserPage.clickUnlinkSkill();
Expand Down
1 change: 0 additions & 1 deletion cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ 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();
}

Expand Down
2 changes: 0 additions & 2 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -109,6 +108,5 @@ export class PatientConsultationPage {
"#consultation-buttons",
"Edit Consultation Details",
);
cy.wait(3000);
}
}
1 change: 0 additions & 1 deletion cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class PatientPage {
cy.get("#name").click().type(patientName);
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")
Expand Down
1 change: 0 additions & 1 deletion cypress/pageobject/Patient/PatientDoctorNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export class PatientDoctorNotes {
}

addDiscussionNotes(notes: string) {
cy.wait(2000);
cy.get("#discussion_notes_textarea").scrollIntoView();
cy.get("#discussion_notes_textarea").click().type(notes);
}
Expand Down
7 changes: 2 additions & 5 deletions cypress/pageobject/Patient/PatientFileupload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ export class PatientFileUpload {

recordAudio() {
cy.get("#record-audio").click();
cy.wait(5000);
cy.get("#stop-recording").click();
cy.wait(1000);
cy.get("#save-recording").click();
cy.get("#stop-recording").should("be.enabled").click();
cy.get("#save-recording").should("be.enabled").click();
}

clickUploadAudioFile() {
Expand All @@ -33,7 +31,6 @@ export class PatientFileUpload {
}

verifyUploadFilePresence(fileName: string) {
cy.wait(2000);
cy.get("#file-div").scrollIntoView();
cy.verifyContentPresence("#file-div", [fileName]);
}
Expand Down
5 changes: 0 additions & 5 deletions cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class PatientLogupdate {
clickLogupdate() {
cy.get("#log-update").scrollIntoView();
cy.verifyAndClickElement("#log-update", "Log Update");
cy.wait(2000);
}

clickSwitchBed() {
Expand All @@ -16,7 +15,6 @@ class PatientLogupdate {
selectBed(bed: string) {
cy.typeAndSelectOption("input[name='bed']", bed);
cy.get("#update-switchbed").click();
cy.wait(2000);
}

selectPatientCategory(category: string) {
Expand Down Expand Up @@ -78,19 +76,16 @@ class PatientLogupdate {
cy.get(element).scrollIntoView();
cy.verifyContentPresence(element, [patientCategory]);
cy.get(element).first().contains("View Details").click();
cy.wait(3000);
}

clickLogUpdateUpdateLog(element: string, patientCategory: string) {
cy.get(element).scrollIntoView();
cy.verifyContentPresence(element, [patientCategory]);
cy.get(element).first().contains("Update Log").click();
cy.wait(3000);
}

clickUpdateDetail() {
cy.verifyAndClickElement("#consultation-preview", "Update Details");
cy.wait(3000);
}

clearIntoElementById(elementId) {
Expand Down
3 changes: 1 addition & 2 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions cypress/pageobject/Patient/PatientTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ManageUserPage {
}

clickCloseSlideOver() {
cy.get("#close-slide-over").click({ force: true });
cy.get("#close-slide-over").should("be.visible").click();
}

clickHomeFacilityIcon() {
Expand Down
Loading