diff --git a/cypress/e2e/shifting_spec/ShiftingRequest.cy.ts b/cypress/e2e/shifting_spec/ShiftingRequest.cy.ts new file mode 100644 index 00000000000..dc731765242 --- /dev/null +++ b/cypress/e2e/shifting_spec/ShiftingRequest.cy.ts @@ -0,0 +1,80 @@ +import LoginPage from "pageobject/Login/LoginPage" +import { PatientConsultationPage } from "pageobject/Patient/PatientConsultation"; +import { PatientPage } from "pageobject/Patient/PatientCreation"; +import ShiftCreation from "pageobject/Shift/ShiftCreation"; +import { ShiftDetails } from "pageobject/Shift/ShiftDetails"; +import { ShiftingBoard } from "pageobject/Shift/ShiftingBoard"; +import ShiftUpdate from "pageobject/Shift/ShiftUpdate"; + +describe("New shifting request",() =>{ + const loginPage = new LoginPage(); + const shiftCreation = new ShiftCreation() + const shiftingBoard = new ShiftingBoard() + const shiftDetails = new ShiftDetails() + const shiftUpdate = new ShiftUpdate() + const patientPage = new PatientPage() + const patientConsultationPage = new PatientConsultationPage() + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + }); + + it("Creating and verifying new shifting request", () => { + cy.intercept("POST", "api/v1/shift").as("shiftRequest"); + + cy.visit('/patients') + patientPage.visitPatient("Dummy Patient 16") + patientConsultationPage.clickShiftPatientButton() + + shiftCreation.typeCurrentFacilityPerson("new"); + shiftCreation.typeCurrentFacilityPhone("9465666768"); + shiftCreation.typeShiftReason("emmergency"); + shiftCreation.typeAmbulanceDriverName("Rahul"); + shiftCreation.typeAmbulancePhone("9865666768") + shiftCreation.typeAmbulanceNumber("1") + shiftCreation.typeComment("Some comment") + shiftCreation.submitShiftForm(); + + cy.wait("@shiftRequest").its("response.statusCode").should("eq", 201); + + cy.visit("/shifting/board"); + cy.contains("Dummy Patient 16").should("exist"); + }); + + it("Editing and verifying refelctions in existing request", () => { + cy.intercept("PUT", "**/api/v1/shift/**").as("shiftUpdateRequest"); + cy.visit("/shifting/board"); + cy.contains("Dummy Patient 16").should("exist"); + + shiftingBoard.openDetails("Dummy Patient 16") + shiftDetails.clickUpdateStatusButton() + + shiftUpdate.typeShiftReason("new reason"); + shiftUpdate.typeAmbulanceDriverName("Ramesh"); + shiftUpdate.typeAmbulancePhone("9755443232") + shiftUpdate.typeAmbulanceNumber("2") + shiftUpdate.typeComment("New comment") + shiftUpdate.submitShiftForm(); + + cy.wait('@shiftUpdateRequest').then((interception) => { + const responseData = interception.response.body; + + expect(responseData.patient_object.name).to.eq("Dummy Patient 16"); + expect(responseData.ambulance_phone_number).to.eq("+919755443232"); + expect(responseData.comments).to.eq("New comment"); + expect(responseData.reason).to.eq("new reason"); + expect(responseData.ambulance_driver_name).to.eq("Ramesh"); + expect(responseData.ambulance_number).to.eq("2"); + }); + + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}) \ No newline at end of file diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index e0b51b9265e..5a8d3adaf46 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -13,6 +13,7 @@ export class PatientConsultationPage { selectSymptomsDate(date: string) { cy.clickAndTypeDate("#symptoms_onset_date", date); } + clickAddSymptom() { cy.get("#add-symptom").click(); } @@ -111,4 +112,14 @@ export class PatientConsultationPage { ); cy.wait(3000); } + + clickShiftPatientButton() { + cy.get("#consultation-buttons").scrollIntoView(); + cy.get("button").contains("Manage Patient").click(); + cy.verifyAndClickElement( + "#consultation-buttons", + "Shift Patient", + ); + cy.wait(3000); + } } diff --git a/cypress/pageobject/Shift/ShiftCreation.ts b/cypress/pageobject/Shift/ShiftCreation.ts index f0b133ed2f0..2ce5de9affa 100644 --- a/cypress/pageobject/Shift/ShiftCreation.ts +++ b/cypress/pageobject/Shift/ShiftCreation.ts @@ -11,6 +11,22 @@ export class ShiftCreation { cy.get("#reason").click().type(reason); } + typeAmbulanceDriverName(name: string) { + cy.get("#ambulance_driver_name").click().type(name); + } + + typeAmbulancePhone(number: string) { + cy.get("#ambulance_phone_number").click().type(number); + } + + typeAmbulanceNumber(number: string) { + cy.get("#ambulance_number").click().type(number); + } + + typeComment(comment:string) { + cy.get('#comments').click().type(comment) + } + submitShiftForm() { cy.get("#submit").contains("Submit").click(); } diff --git a/cypress/pageobject/Shift/ShiftDetails.ts b/cypress/pageobject/Shift/ShiftDetails.ts new file mode 100644 index 00000000000..8816f0b4f95 --- /dev/null +++ b/cypress/pageobject/Shift/ShiftDetails.ts @@ -0,0 +1,6 @@ +export class ShiftDetails{ + clickUpdateStatusButton(){ + cy.contains("Update Status/Details").click() + } + +} \ No newline at end of file diff --git a/cypress/pageobject/Shift/ShiftUpdate.ts b/cypress/pageobject/Shift/ShiftUpdate.ts new file mode 100644 index 00000000000..a4ef1d7d240 --- /dev/null +++ b/cypress/pageobject/Shift/ShiftUpdate.ts @@ -0,0 +1,27 @@ +export class ShiftUpdate { + typeShiftReason(reason: string) { + cy.get("#reason").click().clear().type(reason); + } + + typeAmbulanceDriverName(name: string) { + cy.get("#ambulance_driver_name").click().clear().type(name); + } + + typeAmbulancePhone(number: string) { + cy.get("#ambulance_phone_number").click().clear().type(number); + } + + typeAmbulanceNumber(number: string) { + cy.get("#ambulance_number").click().clear().type(number); + } + + typeComment(comment: string) { + cy.get('#comments').click().clear().type(comment); + } + + submitShiftForm() { + cy.get("#submit").contains("Submit").click(); + } +} +export default ShiftUpdate; + \ No newline at end of file diff --git a/cypress/pageobject/Shift/ShiftingBoard.ts b/cypress/pageobject/Shift/ShiftingBoard.ts new file mode 100644 index 00000000000..9b8acb760d5 --- /dev/null +++ b/cypress/pageobject/Shift/ShiftingBoard.ts @@ -0,0 +1,8 @@ +export class ShiftingBoard { + openDetails(patientName) { + cy.get('#patient_name').type(patientName); + cy.intercept("GET", "**/api/v1/shift/**").as("getShiftingRequest"); + cy.wait("@getShiftingRequest").its("response.statusCode").should("eq", 200); + cy.contains("All Details").click(); + } +} \ No newline at end of file