diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts index c5f56f97170..ce459d2d66b 100644 --- a/cypress/e2e/facility_spec/facility_manage.cy.ts +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -141,6 +141,7 @@ describe("Facility Manage Functions", () => { facilityManage.verifySuccessMessageVisibilityAndContent( "Bed capacity added successfully" ); + cy.closeNotification(); facilityManage.verifyFacilityBedCapacity(totalCapacity); facilityManage.verifyFacilityBedCapacity(currentOccupied); // edit a existing bed @@ -151,6 +152,7 @@ describe("Facility Manage Functions", () => { facilityManage.verifySuccessMessageVisibilityAndContent( "Bed capacity updated successfully" ); + cy.closeNotification(); facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity); facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied); // delete a bed diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts deleted file mode 100644 index c3bc4b0cf8d..00000000000 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; -import LoginPage from "../../pageobject/Login/LoginPage"; -import { PatientPage } from "../../pageobject/Patient/PatientCreation"; -import { PatientFileUpload } from "../../pageobject/Patient/PatientFileupload"; - -describe("Patient Details", () => { - const loginPage = new LoginPage(); - const patientPage = new PatientPage(); - const patientFileUpload = new PatientFileUpload(); - const cypressAudioName = "cypress audio"; - const cypressFileName = "cypress name"; - const newFileName = "cypress modified name"; - const patientNameOne = "Dummy Patient 3"; - const patientNameTwo = "Dummy Patient 4"; - const patientNameThree = "Dummy Patient 5"; - before(() => { - loginPage.loginAsDisctrictAdmin(); - cy.saveLocalStorage(); - }); - - beforeEach(() => { - cy.restoreLocalStorage(); - cy.clearLocalStorage(/filters--.+/); - cy.awaitUrl("/patients"); - }); - - it("Record an Audio and download the file", () => { - // Record an audio - patientPage.visitPatient(patientNameOne); - patientFileUpload.visitPatientDetailsPage(); - patientFileUpload.recordAudio(); - patientFileUpload.typeAudioName(cypressAudioName); - patientFileUpload.clickUploadAudioFile(); - // Verify the audio file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - patientFileUpload.verifyUploadFilePresence(cypressAudioName); - // Verify the download of the audio file - cy.get("button").contains("DOWNLOAD").click(); - cy.verifyNotification("Downloading file..."); - }); - - it("Upload a File and archive it", () => { - // Upload the file - patientPage.visitPatient(patientNameTwo); - patientFileUpload.visitPatientDetailsPage(); - patientFileUpload.uploadFile(); - patientFileUpload.typeFileName(cypressFileName); - patientFileUpload.clickUploadFile(); - // Verify the file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(cypressFileName); - // Archive the file - patientFileUpload.archiveFile(); - patientFileUpload.clickSaveArchiveFile(); - cy.verifyNotification("File archived successfully"); - patientFileUpload.verifyArchiveFile(cypressFileName); - }); - - it("User-level Based Permission for File Modification", () => { - // Login as Nurse 1 - loginPage.login("dummynurse1", "Coronasafe@123"); - cy.reload(); - // Visit the patient details page - patientPage.visitPatient(patientNameThree); - patientFileUpload.visitPatientDetailsPage(); - // Upload the file - patientFileUpload.uploadFile(); - patientFileUpload.typeFileName(cypressFileName); - patientFileUpload.clickUploadFile(); - // Verify the file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(cypressFileName); - // Edit the file name - patientFileUpload.verifyFileRenameOption(true); - patientFileUpload.renameFile(newFileName); - patientFileUpload.clickSaveFileName(); - // Verify the file name is changed - cy.verifyNotification("File name changed successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(newFileName); - // Login as Nurse 2 - loginPage.login("dummynurse2", "Coronasafe@123"); - cy.reload(); - // Verify the file edit option is not available - patientFileUpload.verifyUploadFilePresence(newFileName); - patientFileUpload.verifyFileRenameOption(false); - // Login as District Admin - loginPage.loginAsDisctrictAdmin(); - cy.reload(); - // Verify the file edit option is available - patientFileUpload.verifyUploadFilePresence(newFileName); - patientFileUpload.verifyFileRenameOption(true); - patientFileUpload.renameFile(cypressFileName); - patientFileUpload.clickSaveFileName(); - // Verify the file name is changed - cy.verifyNotification("File name changed successfully"); - cy.closeNotification(); - patientFileUpload.verifyUploadFilePresence(cypressFileName); - }); - - afterEach(() => { - cy.saveLocalStorage(); - }); -}); diff --git a/cypress/e2e/patient_spec/patient_fileupload.cy.ts b/cypress/e2e/patient_spec/patient_fileupload.cy.ts new file mode 100644 index 00000000000..20a884fd149 --- /dev/null +++ b/cypress/e2e/patient_spec/patient_fileupload.cy.ts @@ -0,0 +1,117 @@ +import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { PatientPage } from "../../pageobject/Patient/PatientCreation"; +import { PatientFileUpload } from "../../pageobject/Patient/PatientFileupload"; +const loginPage = new LoginPage(); +const patientPage = new PatientPage(); +const patientFileUpload = new PatientFileUpload(); + +function runTests(testDescription, visitPatientFileUploadSection) { + describe(testDescription, () => { + const cypressAudioName = "cypress audio"; + const cypressFileName = "cypress name"; + const newFileName = "cypress modified name"; + const patientNameOne = "Dummy Patient 3"; + const patientNameTwo = "Dummy Patient 4"; + const patientNameThree = "Dummy Patient 5"; + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("Record an Audio and download the file", () => { + // Record an audio + patientPage.visitPatient(patientNameOne); + visitPatientFileUploadSection.call(patientFileUpload); + patientFileUpload.recordAudio(); + patientFileUpload.typeAudioName(cypressAudioName); + patientFileUpload.clickUploadAudioFile(); + // Verify the audio file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + patientFileUpload.verifyUploadFilePresence(cypressAudioName); + // Verify the download of the audio file + cy.get("button").contains("DOWNLOAD").click(); + cy.verifyNotification("Downloading file..."); + }); + + it("Upload a File and archive it", () => { + // Upload the file + patientPage.visitPatient(patientNameTwo); + visitPatientFileUploadSection.call(patientFileUpload); + patientFileUpload.uploadFile(); + patientFileUpload.typeFileName(cypressFileName); + patientFileUpload.clickUploadFile(); + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(cypressFileName); + // Archive the file + patientFileUpload.archiveFile(); + patientFileUpload.clickSaveArchiveFile(); + cy.verifyNotification("File archived successfully"); + patientFileUpload.verifyArchiveFile(cypressFileName); + }); + + it("User-level Based Permission for File Modification", () => { + // Login as Nurse 1 + loginPage.login("dummynurse1", "Coronasafe@123"); + cy.reload(); + // Visit the patient details page + patientPage.visitPatient(patientNameThree); + visitPatientFileUploadSection.call(patientFileUpload); + // Upload the file + patientFileUpload.uploadFile(); + patientFileUpload.typeFileName(cypressFileName); + patientFileUpload.clickUploadFile(); + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(cypressFileName); + // Edit the file name + patientFileUpload.verifyFileRenameOption(true); + patientFileUpload.renameFile(newFileName); + patientFileUpload.clickSaveFileName(); + // Verify the file name is changed + cy.verifyNotification("File name changed successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(newFileName); + // Login as Nurse 2 + loginPage.login("dummynurse2", "Coronasafe@123"); + cy.reload(); + // Verify the file edit option is not available + patientFileUpload.verifyUploadFilePresence(newFileName); + patientFileUpload.verifyFileRenameOption(false); + // Login as District Admin + loginPage.loginAsDisctrictAdmin(); + cy.reload(); + // Verify the file edit option is available + patientFileUpload.verifyUploadFilePresence(newFileName); + patientFileUpload.verifyFileRenameOption(true); + patientFileUpload.renameFile(cypressFileName); + patientFileUpload.clickSaveFileName(); + // Verify the file name is changed + cy.verifyNotification("File name changed successfully"); + cy.closeNotification(); + patientFileUpload.verifyUploadFilePresence(cypressFileName); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); + }); +} + +runTests( + "Patient File upload in patient details page", + patientFileUpload.clickFileUploadIcon +); +runTests( + "Patient File upload in patient consultation page", + patientFileUpload.clickFileTab +); diff --git a/cypress/e2e/patient_spec/patient_manage.cy.ts b/cypress/e2e/patient_spec/patient_manage.cy.ts index 32e6faf880e..35b89aedb7f 100644 --- a/cypress/e2e/patient_spec/patient_manage.cy.ts +++ b/cypress/e2e/patient_spec/patient_manage.cy.ts @@ -58,13 +58,6 @@ describe("Patient", () => { cy.verifyNotification("Medicine prescribed"); }); - it("Upload consultations file ", () => { - patientPage.visitPatient("Dummy Patient 5"); - patientConsultationPage.visitFilesPage(); - patientConsultationPage.uploadFile(); - patientConsultationPage.clickUploadFile(); - }); - it("Discharge a patient", () => { patientPage.visitPatient("Dummy Patient 6"); patientConsultationPage.clickDischargePatient(); diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 76c3e2b7199..05f0fb7a35e 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -5,7 +5,7 @@ import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { generatePhoneNumber, generateEmergencyPhoneNumber, -} from "../../pageobject/constants"; +} from "../../pageobject/utils/constants"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; import PatientExternal from "../../pageobject/Patient/PatientExternal"; import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index 33fd7cb958d..e40ebbbc71f 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -7,7 +7,7 @@ import { UserCreationPage } from "../../pageobject/Users/UserCreation"; import { generatePhoneNumber, generateEmergencyPhoneNumber, -} from "../../pageobject/constants"; +} from "../../pageobject/utils/constants"; describe("User Creation", () => { const userPage = new UserPage(); diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index db72765444f..0a39a1f839a 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -95,24 +95,6 @@ export class PatientConsultationPage { cy.searchAndSelectOption("#referred_from_facility", referringFacility); } - visitFilesPage() { - cy.get("#consultation_tab_nav").scrollIntoView(); - cy.get("#consultation_tab_nav").contains("Files").click(); - } - - uploadFile() { - cy.get("#file_upload_patient").selectFile( - "cypress/fixtures/sampleAsset.xlsx", - { force: true } - ); - } - - clickUploadFile() { - cy.intercept("POST", "**/api/v1/files/").as("uploadFile"); - cy.get("#upload_file_button").click(); - cy.wait("@uploadFile").its("response.statusCode").should("eq", 201); - } - clickEditConsultationButton() { cy.get("#consultation-buttons").scrollIntoView(); cy.get("button").contains("Manage Patient").click(); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 6a970e66578..0250ffcc07d 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -1,7 +1,7 @@ import { cy } from "local-cypress"; export class PatientFileUpload { - visitPatientDetailsPage() { + clickFileUploadIcon() { cy.get("#patient-details").click(); cy.get("#upload-patient-files").click(); } @@ -11,6 +11,10 @@ export class PatientFileUpload { cy.get("#consultation_audio_file").click().type(name); } + clickFileTab() { + cy.verifyAndClickElement("#consultation_tab_nav", "Files"); + } + typeFileName(name: string) { cy.get("#consultation_file").clear(); cy.get("#consultation_file").click().type(name); diff --git a/cypress/pageobject/Patient/PatientPredefined.ts b/cypress/pageobject/Patient/PatientPredefined.ts index 6b2bcc0d472..f0a005ec97b 100644 --- a/cypress/pageobject/Patient/PatientPredefined.ts +++ b/cypress/pageobject/Patient/PatientPredefined.ts @@ -6,7 +6,7 @@ import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistor import { generatePhoneNumber, generateEmergencyPhoneNumber, -} from "../../pageobject/constants"; +} from "../utils/constants"; class PatientPredefined { createPatient() { diff --git a/cypress/pageobject/constants.ts b/cypress/pageobject/utils/constants.ts similarity index 100% rename from cypress/pageobject/constants.ts rename to cypress/pageobject/utils/constants.ts