diff --git a/cypress/e2e/facility_spec/inventory.cy.ts b/cypress/e2e/facility_spec/inventory.cy.ts index e7f1c35cb93..4c0a8cb5371 100644 --- a/cypress/e2e/facility_spec/inventory.cy.ts +++ b/cypress/e2e/facility_spec/inventory.cy.ts @@ -7,6 +7,7 @@ describe("Inventory Management Section", () => { const facilityPage = new FacilityPage(); const loginPage = new LoginPage(); const facilityHome = new FacilityHome(); + const inventoryName = "PPE"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -51,9 +52,10 @@ describe("Inventory Management Section", () => { it("Add New Inventory | Verify Backend and manual Minimum", () => { // Add Inventory facilityPage.clickManageInventory(); - facilityPage.fillInventoryDetails("PPE", "Add Stock", "5"); + facilityPage.fillInventoryDetails(inventoryName, "Add Stock", "5"); facilityPage.clickAddInventory(); facilityPage.verifySuccessNotification("Inventory created successfully"); + cy.closeNotification(); // Verify Backend minimum badge facilityPage.verifyBadgeWithText(".badge-danger", "Low Stock"); // modify with manual minimum badge @@ -68,7 +70,7 @@ describe("Inventory Management Section", () => { } else { // Otherwise, click the 'set-minimum-quantity' element facilityPage.clickSetMinimumQuantity(); - facilityPage.fillInventoryMinimumDetails("PPE", "1"); + facilityPage.fillInventoryMinimumDetails(inventoryName, "1"); facilityPage.clickSetButton(); facilityPage.verifySuccessNotification( "Minimum quantiy updated successfully" @@ -76,6 +78,7 @@ describe("Inventory Management Section", () => { } }); }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts new file mode 100644 index 00000000000..c3bc4b0cf8d --- /dev/null +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -0,0 +1,106 @@ +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/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 8cc340ce217..733546465a6 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -363,6 +363,7 @@ class FacilityPage { } fillInventoryDetails(name: string, status: string, quantity: string) { + cy.wait(2000); cy.get("div#id").click(); cy.get("div#id ul li").contains(name).click(); cy.get("div#isIncoming").click(); @@ -371,6 +372,7 @@ class FacilityPage { } fillInventoryMinimumDetails(name: string, quantity: string) { + cy.wait(2000); cy.get("div#id").click(); cy.get("div#id ul li").contains(name).click(); cy.get("[name='quantity']").type(quantity); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts new file mode 100644 index 00000000000..6a970e66578 --- /dev/null +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -0,0 +1,90 @@ +import { cy } from "local-cypress"; + +export class PatientFileUpload { + visitPatientDetailsPage() { + cy.get("#patient-details").click(); + cy.get("#upload-patient-files").click(); + } + + typeAudioName(name: string) { + cy.get("#consultation_audio_file").clear(); + cy.get("#consultation_audio_file").click().type(name); + } + + typeFileName(name: string) { + cy.get("#consultation_file").clear(); + cy.get("#consultation_file").click().type(name); + } + + recordAudio() { + cy.get("#record-audio").click(); + cy.wait(5000); + cy.get("#stop-recording").click(); + } + + clickUploadAudioFile() { + cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); + cy.verifyAndClickElement("#upload_audio_file", "Save"); + cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); + } + + verifyUploadFilePresence(fileName: string) { + cy.wait(2000); + cy.get("#file-div").scrollIntoView(); + cy.verifyContentPresence("#file-div", [fileName]); + } + + 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); + } + + archiveFile() { + cy.get("button").contains("ARCHIVE").click().scrollIntoView(); + cy.get("#editFileName").clear().type("Cypress File Archive"); + } + + clickSaveArchiveFile() { + cy.intercept("PATCH", "**/api/v1/files/**").as("saveArchiveFile"); + cy.submitButton("Proceed"); + cy.wait("@saveArchiveFile").its("response.statusCode").should("eq", 200); + } + + verifyArchiveFile(fileName: string) { + cy.get("#archived-files").click(); + cy.get("button").contains("MORE DETAILS").click().scrollIntoView(); + cy.get("#archive-file-name").should("contain.text", fileName); + cy.get("#archive-file-reason").then(($reason) => { + expect($reason.text().split(":")[1]).to.contain("Cypress File Archive"); + }); + } + + verifyFileRenameOption(status: boolean) { + cy.get("#file-div").then(($fileDiv) => { + if (status) { + expect($fileDiv.text()).to.contain("RENAME"); + } else { + expect($fileDiv.text()).to.not.contain("RENAME"); + } + }); + } + + renameFile(newFileName: string) { + cy.get("button").contains("RENAME").click().scrollIntoView(); + cy.get("#editFileName").clear().type(newFileName); + } + + clickSaveFileName() { + cy.intercept("PATCH", "**/api/v1/files/**").as("saveFileName"); + cy.submitButton("Proceed"); + cy.wait("@saveFileName").its("response.statusCode").should("eq", 200); + } +} diff --git a/src/Components/Common/HeadedTabs.tsx b/src/Components/Common/HeadedTabs.tsx index 1128c274af9..f3535041e56 100644 --- a/src/Components/Common/HeadedTabs.tsx +++ b/src/Components/Common/HeadedTabs.tsx @@ -42,6 +42,7 @@ export default function HeadedTabs(props: headedTabsProps) { {tabs.map((tab) => (
{ Patient Details diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 0c8cad60005..4f74d9f62f4 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -569,6 +569,7 @@ export const FileUpload = (props: FileUploadProps) => { return (
{!item.is_archived ? ( @@ -749,6 +750,7 @@ export const FileUpload = (props: FileUploadProps) => { ) : ( { triggerDownload( url[item.id!], @@ -1431,9 +1433,10 @@ export const FileUpload = (props: FileUploadProps) => {
- {modalDetails?.name} file is archived. + {modalDetails?.name} file is + archived.
-
+
Reason: {modalDetails?.reason}
@@ -1522,6 +1525,7 @@ export const FileUpload = (props: FileUploadProps) => { {audioBlobExists && (
{ handleAudioUpload(); }} diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 919a0048e22..d78008a204b 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -1282,6 +1282,7 @@ export const PatientHome = (props: any) => {
navigate( `/facility/${patientData?.facility}/patient/${id}/files` diff --git a/src/Utils/VoiceRecorder.tsx b/src/Utils/VoiceRecorder.tsx index ab14738df89..471c267e47d 100644 --- a/src/Utils/VoiceRecorder.tsx +++ b/src/Utils/VoiceRecorder.tsx @@ -4,6 +4,7 @@ import ButtonV2 from "../Components/Common/components/ButtonV2"; import CareIcon from "../CAREUI/icons/CareIcon"; import { NonReadOnlyUsers } from "./AuthorizeFor"; import { useTranslation } from "react-i18next"; + export const VoiceRecorder = (props: any) => { const { t } = useTranslation(); const { createAudioBlob, confirmAudioBlobExists, reset, setResetRecording } = @@ -49,6 +50,7 @@ export const VoiceRecorder = (props: any) => { {t("recording") + "..."}
{ stopRecording(); confirmAudioBlobExists(); @@ -67,6 +69,7 @@ export const VoiceRecorder = (props: any) => {
{!audioURL && (