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

Fixed Flaky Test in cypress develop branch #9492

Merged
merged 17 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
14 changes: 9 additions & 5 deletions cypress/e2e/patient_spec/PatientLogUpdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
const patientInvestigation = new PatientInvestigation();
const patientPrescription = new PatientPrescription();
const patientCategory = "Moderate";
const patientModifiedCategory = "Critical";
const additionalSymptoms = "Fever";
const physicalExamination = "physical examination details";
const otherExamination = "Other";
Expand Down Expand Up @@ -150,6 +151,9 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
]);
// verify the edit functionality
patientLogupdate.clickUpdateDetail();
patientLogupdate.verifyPatientCategory(patientCategory);
patientLogupdate.verifyRoundType("Progress Note");
patientLogupdate.selectPatientCategory(patientModifiedCategory);
patientLogupdate.typeSystolic(patientModifiedSystolic);
patientLogupdate.typeDiastolic(patientModifiedDiastolic);
cy.clickSubmitButton("Continue");
Expand Down Expand Up @@ -282,11 +286,13 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
cy.verifyNotification("Consultation updated successfully");
cy.closeNotification();
patientLogupdate.clickLogupdate();
patientLogupdate.verifyRoundType("Brief Update"); // Verify the default round type
patientLogupdate.selectRoundType("Brief Update");
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typePhysicalExamination(physicalExamination);
patientLogupdate.typeOtherDetails(otherExamination);
patientLogupdate.selectSymptomsDate("01012024");
patientLogupdate.typeAndMultiSelectSymptoms("fe", ["Fever"]);
patientLogupdate.selectPatientCategory(patientCategory);
patientLogupdate.typeSystolic(patientSystolic);
patientLogupdate.typeDiastolic(patientDiastolic);
patientLogupdate.typePulse(patientPulse);
Expand Down Expand Up @@ -318,10 +324,8 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
patientRhythm,
]);
patientLogupdate.clickUpdateDetail();
patientLogupdate.clearIntoElementById("#systolic");
patientLogupdate.typeSystolic(patientModifiedSystolic);
patientLogupdate.clearIntoElementById("#diastolic");
patientLogupdate.typeDiastolic(patientModifiedDiastolic);
patientLogupdate.typeSystolic(patientModifiedSystolic, true);
patientLogupdate.typeDiastolic(patientModifiedDiastolic, true);
cy.clickSubmitButton("Continue");
cy.verifyNotification("Brief Update updated successfully");
cy.contains("button", "Log Updates").click();
Expand Down
67 changes: 17 additions & 50 deletions cypress/e2e/patient_spec/PatientRegistration.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation";

import LoginPage from "../../pageobject/Login/LoginPage";
import {
PatientData,
Expand All @@ -6,7 +8,11 @@ import {
import PatientInsurance from "../../pageobject/Patient/PatientInsurance";
import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory";
import PatientTransfer from "../../pageobject/Patient/PatientTransfer";
import { generatePhoneNumber } from "../../pageobject/utils/constants";
import {
generatePatientName,
generatePhoneNumber,
generateRandomAddress,
} from "../../pageobject/utils/constants";

const yearOfBirth = "2001";

Expand All @@ -15,38 +21,21 @@ const calculateAge = () => {
return currentYear - parseInt(yearOfBirth);
};

const getRelativeDateString = (deltaDays = 0) => {
const date = new Date();
if (deltaDays) {
date.setDate(date.getDate() + deltaDays);
}
return date
.toLocaleDateString("en-IN", {
day: "2-digit",
month: "2-digit",
year: "numeric",
})
.replace(/\//g, "");
};

describe("Patient Creation with consultation", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientTransfer = new PatientTransfer();
const patientInsurance = new PatientInsurance();
const patientMedicalHistory = new PatientMedicalHistory();
const patientConsultationPage = new PatientConsultationPage();
const phone_number = generatePhoneNumber();
const age = calculateAge();
const patientFacility = "Dummy Facility 40";
const patientDateOfBirth = "01012001";
const patientMenstruationStartDate = getRelativeDateString(-10);
const patientDateOfDelivery = getRelativeDateString(-20);
const patientOneName = "Great Napolean 14";
const patientOneName = generatePatientName();
const patientOneGender = "Male";
const patientOneUpdatedGender = "Female";
const patientOneAddress = `149/J, 3rd Block,
Aluva
Ernakulam, Kerala - 682001`;
const patientOneAddress = generateRandomAddress(true);
const patientOnePincode = "682001";
const patientOneState = "Kerala";
const patientOneDistrict = "Ernakulam";
Expand Down Expand Up @@ -115,13 +104,11 @@ describe("Patient Creation with consultation", () => {

it("Create a new patient with all field in registration form and no consultation", () => {
patientPage.createPatientWithData(newPatientData);
// Verify the patient details
patientPage.clickCancelButton();
patientPage.savePatientUrl();
// Verify the patient details
patientPage.verifyPatientDashboardDetails(
patientOneGender,
age,
patientOneName,
phone_number,
phone_number,
yearOfBirth,
Expand Down Expand Up @@ -149,21 +136,15 @@ describe("Patient Creation with consultation", () => {
patientPage.verifyPatientNameList(patientOneName);
});

it("Edit the patient details with no consultation and verify", () => {
patientPage.interceptFacilities();
patientPage.visitUpdatePatientUrl();
patientPage.verifyStatusCode();
patientPage.patientformvisibility();
// change the gender to female and input data to related changed field
cy.wait(3000);
it("Edit the patient details and verify its reflection", () => {
const patientName = "Dummy Patient Two";
patientPage.visitPatient(patientName);
patientConsultationPage.clickPatientDetails();
patientPage.clickPatientUpdateDetails();
nihal467 marked this conversation as resolved.
Show resolved Hide resolved
patientPage.selectPatientGender(patientOneUpdatedGender);
patientPage.typePatientDateOfBirth(patientDateOfBirth);
patientPage.clickPatientAntenatalStatusYes();
patientPage.typeLastMenstruationStartDate(patientMenstruationStartDate);
patientPage.clickPatientPostPartumStatusYes();
patientPage.typeDateOfDelivery(patientDateOfDelivery);
patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup);
// Edit the patient consultation , select none medical history and multiple health ID
// select none medical history and add multiple health ID
patientMedicalHistory.clickNoneMedicialHistory();
patientInsurance.clickAddInsruanceDetails();
patientInsurance.typePatientInsuranceDetail(
Expand Down Expand Up @@ -197,20 +178,6 @@ describe("Patient Creation with consultation", () => {
);
patientPage.clickUpdatePatient();
patientPage.verifyPatientUpdated();
patientPage.interceptGetPatient();
patientPage.visitPatientUrl();
patientPage.verifyGetPatientResponse();
// Verify Female Gender change reflection, No Medical History and Insurance Details
patientPage.verifyPatientDashboardDetails(
patientOneUpdatedGender,
age,
patientOneName,
phone_number,
phone_number,
yearOfBirth,
patientOneUpdatedBloodGroup,
patientOccupation,
);
// Verify No medical history
patientMedicalHistory.verifyNoSymptosPresent("Diabetes");
// verify insurance details and dedicatd page
Expand Down
5 changes: 4 additions & 1 deletion cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class FacilityPage {
phoneNumber: string,
clearBeforeTyping: boolean = false,
) {
cy.typeIntoField("#phone_number", phoneNumber, { clearBeforeTyping });
cy.typeIntoField("#phone_number", phoneNumber, {
clearBeforeTyping,
skipVerification: true,
});
}

clickSaveFacilityButton() {
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Hcx/HcxClaims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export class HcxClaims {
cy.get("#select-insurance-policy", { timeout: 10000 })
.should("be.visible")
.and("not.be.disabled");
cy.clickAndSelectOption("#select-insurance-policy", policy);
cy.clickAndSelectOption("#select-insurance-policy", policy, true);
}

verifyPolicyEligibility() {
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class PatientConsultationPage {
}

clickPatientDetails() {
cy.verifyAndClickElement("#consultationpage-header", "Patient Details");
cy.verifyAndClickElement("#patient-details", "Patient Details");
nihal467 marked this conversation as resolved.
Show resolved Hide resolved
}

typePatientIllnessHistory(history: string) {
Expand Down
25 changes: 1 addition & 24 deletions cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import FacilityPage from "pageobject/Facility/FacilityCreation";

import PatientMedicalHistory from "./PatientMedicalHistory";

let patient_url = "";
const facilityPage = new FacilityPage();
const patientMedicalHistory = new PatientMedicalHistory();

Expand Down Expand Up @@ -96,7 +95,7 @@ export class PatientPage {
}

typePatientAge(age: string) {
cy.clickAndSelectOption("#patientAge", "Age");
cy.clickAndSelectOption("#patientAge", "Age", true);
cy.clickSubmitButton("Confirm");
cy.get("#age").clear().type(age);
}
Expand Down Expand Up @@ -175,22 +174,6 @@ export class PatientPage {
cy.url().should("include", "/patient");
}

savePatientUrl() {
cy.url().then((url) => {
patient_url = url;
});
}

visitPatientUrl() {
this.interceptGetPatient();
cy.awaitUrl(patient_url);
this.verifyGetPatientResponse();
}

visitConsultationPage() {
cy.visit(patient_url + "/consultation");
}

clickUpdatePatient() {
cy.intercept("PUT", "**/api/v1/patient/**").as("updatePatient");
cy.get("button").get("[data-testid=submit-button]").click();
Expand Down Expand Up @@ -220,7 +203,6 @@ export class PatientPage {
verifyPatientDashboardDetails(
gender: string,
age: number,
patientName: string,
phoneNumber: string,
emergencyPhoneNumber: string,
yearOfBirth: string,
Expand All @@ -237,7 +219,6 @@ export class PatientPage {
.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);
Expand Down Expand Up @@ -276,10 +257,6 @@ export class PatientPage {
});
}

visitUpdatePatientUrl() {
cy.visit(patient_url + "/update");
}

clickPatientUpdateDetails() {
cy.verifyAndClickElement("#update-patient-details", "Edit Profile");
}
Expand Down
Loading
Loading