Skip to content

Commit

Permalink
Merge branch 'develop' into issues/6503/displayCNSon4k
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Apr 3, 2024
2 parents 3a125ed + b9d0845 commit 8c629d5
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 4 deletions.
7 changes: 5 additions & 2 deletions cypress/e2e/facility_spec/inventory.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -68,14 +70,15 @@ 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"
);
}
});
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
106 changes: 106 additions & 0 deletions cypress/e2e/patient_spec/patient_detailpage.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
2 changes: 2 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
90 changes: 90 additions & 0 deletions cypress/pageobject/Patient/PatientFileupload.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions src/Components/Common/HeadedTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function HeadedTabs(props: headedTabsProps) {
{tabs.map((tab) => (
<div
key={tab.name}
id={tab.name.split(" ").join("-").toLowerCase()}
className={`${
tab.value === currentTabState
? "border-primary-500 text-primary-600"
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export const ConsultationDetails = (props: any) => {
<Link
href={`/facility/${patientData.facility}/patient/${patientData.id}`}
className="btn btn-primary m-1 w-full hover:text-white"
id="patient-details"
>
Patient Details
</Link>
Expand Down
8 changes: 6 additions & 2 deletions src/Components/Patient/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ export const FileUpload = (props: FileUploadProps) => {
return (
<div
className={"mt-4 rounded-lg border bg-white p-4 shadow "}
id="file-div"
key={item.id}
>
{!item.is_archived ? (
Expand Down Expand Up @@ -749,6 +750,7 @@ export const FileUpload = (props: FileUploadProps) => {
) : (
<ButtonV2
className="m-1 w-full sm:w-auto"
id="download-file"
onClick={() => {
triggerDownload(
url[item.id!],
Expand Down Expand Up @@ -1431,9 +1433,10 @@ export const FileUpload = (props: FileUploadProps) => {
<div className="flex flex-col">
<div>
<div className="text-md m-2 text-center">
<b>{modalDetails?.name}</b> file is archived.
<b id="archive-file-name">{modalDetails?.name}</b> file is
archived.
</div>
<div className="text-md text-center">
<div className="text-md text-center" id="archive-file-reason">
<b>Reason:</b> {modalDetails?.reason}
</div>
<div className="text-md text-center">
Expand Down Expand Up @@ -1522,6 +1525,7 @@ export const FileUpload = (props: FileUploadProps) => {
{audioBlobExists && (
<div className="flex w-full items-center md:w-auto">
<ButtonV2
id="upload_audio_file"
onClick={() => {
handleAudioUpload();
}}
Expand Down
1 change: 1 addition & 0 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ export const PatientHome = (props: any) => {
<div>
<ButtonV2
className="w-full"
id="upload-patient-files"
onClick={() =>
navigate(
`/facility/${patientData?.facility}/patient/${id}/files`
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/VoiceRecorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand Down Expand Up @@ -49,6 +50,7 @@ export const VoiceRecorder = (props: any) => {
{t("recording") + "..."}
</div>
<ButtonV2
id="stop-recording"
onClick={() => {
stopRecording();
confirmAudioBlobExists();
Expand All @@ -67,6 +69,7 @@ export const VoiceRecorder = (props: any) => {
<div>
{!audioURL && (
<ButtonV2
id="record-audio"
onClick={startRecording}
authorizeFor={NonReadOnlyUsers}
className="w-full md:w-fit"
Expand Down

0 comments on commit 8c629d5

Please sign in to comment.