-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cypress test for new patient creation (#5549)
* Added test for patient creation * Fixed patient creation suite * Fixed edit and update test cases and removed unwanted changes * Tried a fix * submit patient form in edit test in patient crud --------- Co-authored-by: Khavin Shankar <[email protected]>
- Loading branch information
1 parent
fb07099
commit 5982c94
Showing
5 changed files
with
133 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,135 @@ | ||
// import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; | ||
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; | ||
|
||
// const username = "devdistrictadmin"; | ||
// const password = "Coronasafe@123"; | ||
// const phone_number = "9" + parseInt((Math.random() * 10 ** 9).toString()); | ||
// const emergency_phone_number = "9430123487"; | ||
// const yearOfBirth = "1999"; | ||
// let patient_url = ""; | ||
const username = "devdistrictadmin"; | ||
const password = "Coronasafe@123"; | ||
const phone_number = "9" + parseInt((Math.random() * 10 ** 9).toString()); | ||
const emergency_phone_number = "9430123487"; | ||
const yearOfBirth = "2023"; | ||
let patient_url = ""; | ||
|
||
// const calculateAge = () => { | ||
// const currentYear = new Date().getFullYear(); | ||
// return currentYear - parseInt(yearOfBirth); | ||
// }; | ||
const calculateAge = () => { | ||
const currentYear = new Date().getFullYear(); | ||
return currentYear - parseInt(yearOfBirth); | ||
}; | ||
|
||
// describe("Patient Creation", () => { | ||
// before(() => { | ||
// cy.loginByApi(username, password); | ||
// cy.saveLocalStorage(); | ||
// }); | ||
describe("Patient Creation", () => { | ||
before(() => { | ||
cy.loginByApi(username, password); | ||
cy.saveLocalStorage(); | ||
}); | ||
|
||
// beforeEach(() => { | ||
// cy.restoreLocalStorage(); | ||
// cy.awaitUrl("/"); | ||
// }); | ||
beforeEach(() => { | ||
cy.restoreLocalStorage(); | ||
cy.awaitUrl("/patients"); | ||
}); | ||
|
||
// it("Create", () => { | ||
// cy.get("[id='facility-details']").first().click(); | ||
// cy.get("button").should("contain", "Add Details of a Patient"); | ||
// cy.get("button") | ||
// .contains("Add Details of a Patient") | ||
// .click({ force: true }); | ||
// cy.get("[data-testid=phone-number] input").type(phone_number); | ||
// cy.get("[data-testid=date-of-birth] svg").click(); | ||
// cy.get("div").contains(yearOfBirth).click(); | ||
// cy.get("span").contains("OK").click(); | ||
// cy.get("[data-testid=name] input").type("Test E2E User"); | ||
// cy.get("[data-testid=Gender] select").select("Male"); | ||
// cy.get("[data-testid=state] select").select("Kerala"); | ||
// cy.get("[data-testid=district] select").select("Ernakulam"); | ||
// cy.get("[data-testid=localbody] select").select( | ||
// "Alangad Block Panchayat, Ernakulam District" | ||
// ); | ||
// cy.get("[data-testid=current-address] textarea").type( | ||
// "Test Patient Address" | ||
// ); | ||
// cy.get("[data-testid=permanent-address] input").check(); | ||
// cy.get("[data-testid=ward-respective-lsgi] select").select( | ||
// "1: MANAKKAPADY" | ||
// ); | ||
// cy.get("h1").contains("COVID Details").click({ force: true }); | ||
// cy.get("select#test_type").select("ANTIGEN"); | ||
// cy.get("[name='is_vaccinated']").check(); | ||
// cy.get("[data-testid=pincode] input").type("159015"); | ||
// cy.get("[name=medical_history_check_1]").check(); | ||
// cy.get("[data-testid=blood-group] select").select("O+"); | ||
// cy.get("[data-testid=emergency-phone-number] input").type( | ||
// emergency_phone_number, | ||
// { delay: 100 } | ||
// ); | ||
// cy.wait(1000); | ||
// cy.get("button").get("[data-testid=submit-button]").click(); | ||
// cy.url().should("include", "/consultation"); | ||
// cy.url().then((url) => { | ||
// cy.log(url); | ||
// patient_url = url.split("/").slice(0, -1).join("/"); | ||
// cy.log(patient_url); | ||
// }); | ||
// }); | ||
it("Create a patient", () => { | ||
cy.get("button").should("contain", "Add Patient Details"); | ||
cy.get("#add-patient-div").click(); | ||
cy.get("input[name='facilities']") | ||
.type("ABCD Hospital, Ernakulam") | ||
.then(() => { | ||
cy.get("[role='option']").contains("ABCD Hospital, Ernakulam").click(); | ||
}); | ||
cy.get("button").should("contain", "Select"); | ||
cy.get("button").get("#submit").click(); | ||
cy.get("#phone_number-div").type(phone_number); | ||
cy.get("#emergency_phone_number-div").type(emergency_phone_number); | ||
cy.get("[data-testid=date-of-birth] button").click(); | ||
cy.get("div").contains("1").click(); | ||
cy.get("[data-testid=name] input").type("Test E2E User"); | ||
cy.get("[data-testid=Gender] button") | ||
.click() | ||
.then(() => { | ||
cy.get("[role='option']").contains("Male").click(); | ||
}); | ||
cy.get("[data-testid=state] button") | ||
.click() | ||
.then(() => { | ||
cy.get("[role='option']").contains("Kerala").click(); | ||
}); | ||
cy.get("[data-testid=district] button") | ||
.click() | ||
.then(() => { | ||
cy.get("[role='option']").contains("Ernakulam").click(); | ||
}); | ||
cy.get("[data-testid=localbody] button") | ||
.click() | ||
.then(() => { | ||
cy.get("[role='option']").first().click(); | ||
}); | ||
cy.get("[data-testid=current-address] textarea").type( | ||
"Test Patient Address" | ||
); | ||
cy.get("[data-testid=permanent-address] input").check(); | ||
cy.get("[data-testid=ward-respective-lsgi] button") | ||
.click() | ||
.then(() => { | ||
cy.get("[role='option']").contains("1: PAZHAMTHOTTAM").click(); | ||
}); | ||
cy.get("button").contains("COVID Details").click(); | ||
cy.get("select#test_type").select("ANTIGEN"); | ||
cy.get("[name='is_vaccinated']").check(); | ||
cy.get("[data-testid=pincode] input").type("159015"); | ||
cy.get("[name=medical_history_check_1]").check(); | ||
cy.get("[data-testid=blood-group] button") | ||
.click() | ||
.then(() => { | ||
cy.get("[role='option']").contains("O+").click(); | ||
}); | ||
cy.get("button").get("[data-testid=submit-button]").click(); | ||
cy.get("h2").should("contain", "Create Consultation"); | ||
cy.url().should("include", "/patient"); | ||
cy.url().then((url) => { | ||
cy.log(url); | ||
patient_url = url.split("/").slice(0, -1).join("/"); | ||
cy.log(patient_url); | ||
}); | ||
}); | ||
|
||
// it("Dashboard", () => { | ||
// cy.awaitUrl(patient_url); | ||
// cy.url().should("include", "/patient/"); | ||
// cy.get("[data-testid=patient-dashboard]").should("contain", calculateAge()); | ||
// cy.get("[data-testid=patient-dashboard]").should( | ||
// "contain", | ||
// "Test E2E User" | ||
// ); | ||
// cy.get("[data-testid=patient-dashboard]").should("contain", phone_number); | ||
// cy.get("[data-testid=patient-dashboard]").should( | ||
// "contain", | ||
// emergency_phone_number | ||
// ); | ||
// cy.get("[data-testid=patient-dashboard]").should("contain", "1999"); | ||
// cy.get("[data-testid=patient-dashboard]").should("contain", "O+"); | ||
// }); | ||
it("Dashboard", () => { | ||
cy.log(patient_url); | ||
cy.awaitUrl(patient_url); | ||
cy.url().should("include", "/facility/"); | ||
cy.get("[data-testid=patient-dashboard]").should("contain", calculateAge()); | ||
cy.get("[data-testid=patient-dashboard]").should( | ||
"contain", | ||
"Test E2E User" | ||
); | ||
cy.get("[data-testid=patient-dashboard]").should("contain", phone_number); | ||
cy.get("[data-testid=patient-dashboard]").should( | ||
"contain", | ||
emergency_phone_number | ||
); | ||
cy.get("[data-testid=patient-dashboard]").should("contain", yearOfBirth); | ||
cy.get("[data-testid=patient-dashboard]").should("contain", "O+"); | ||
}); | ||
|
||
// it("Edit", () => { | ||
// cy.awaitUrl(patient_url + "/update"); | ||
// cy.get("[data-testid=state] select").should("contain", "Kerala"); | ||
// cy.get("[data-testid=district] select").should("contain", "Ernakulam"); | ||
// cy.get("[data-testid=localbody] select").should("contain", "Alangad"); | ||
// cy.get("[data-testid=current-address] textarea").should( | ||
// "contain", | ||
// "Test Patient Address" | ||
// ); | ||
// // cy.get("[data-testid=permanent-address] input").should("be.checked") | ||
// cy.get("[data-testid=ward-respective-lsgi] select").should( | ||
// "contain", | ||
// "MANAKKAPADY" | ||
// ); | ||
// cy.get("[data-testid=pincode] input").should("have.value", "159015"); | ||
// }); | ||
it("Edit", () => { | ||
cy.awaitUrl(patient_url + "/update"); | ||
cy.get("[data-testid=state] button").should("contain", "Kerala"); | ||
cy.get("[data-testid=district] button").should("contain", "Ernakulam"); | ||
cy.get("[data-testid=localbody] button").should("contain", "Aikaranad"); | ||
cy.get("[data-testid=current-address] textarea").should( | ||
"contain", | ||
"Test Patient Address" | ||
); | ||
cy.get("[data-testid=permanent-address] input").should("be.checked"); | ||
cy.get("[data-testid=ward-respective-lsgi] button").should( | ||
"contain", | ||
"PAZHAMTHOTTAM" | ||
); | ||
cy.get("[data-testid=pincode] input").should("have.value", "159015"); | ||
cy.get("button").get("[data-testid=submit-button]").click(); | ||
cy.url().should("include", "/patient"); | ||
cy.url().then((url) => { | ||
cy.log(url); | ||
patient_url = url.split("/").slice(0, -1).join("/"); | ||
cy.log(patient_url); | ||
}); | ||
}); | ||
|
||
// afterEach(() => { | ||
// cy.saveLocalStorage(); | ||
// }); | ||
// }); | ||
afterEach(() => { | ||
cy.saveLocalStorage(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters