From e3abc115edec699291cd8bcf5d2cfb5062b57306 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Fri, 9 Feb 2024 02:07:58 +0530 Subject: [PATCH 01/20] add cypress testing --- .../e2e/patient_spec/patient_detailpage.cy.ts | 72 +++++++++++++++++++ .../pageobject/Patient/PatientFileupload.ts | 72 +++++++++++++++++++ src/Components/Common/HeadedTabs.tsx | 1 + .../Facility/ConsultationDetails/index.tsx | 1 + src/Components/Patient/FileUpload.tsx | 9 ++- src/Components/Patient/PatientHome.tsx | 1 + src/Utils/VoiceRecorder.tsx | 3 + 7 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 cypress/e2e/patient_spec/patient_detailpage.cy.ts create mode 100644 cypress/pageobject/Patient/PatientFileupload.ts 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..dc3c82cd93c --- /dev/null +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -0,0 +1,72 @@ +import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { PatientPage } from "../../pageobject/Patient/PatientCreation"; +import { PatientFileUploadPage } from "../../pageobject/Patient/PatientFileupload"; + +describe("Patient Details", () => { + const loginPage = new LoginPage(); + const patientPage = new PatientPage(); + const patientFileUploadPage = new PatientFileUploadPage(); + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("Record an audio and save it", () => { + patientPage.visitPatient("Cypress Patient"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.recordAudio(); + patientFileUploadPage.clickUploadAudioFile(); + patientFileUploadPage.verifySuccessNotification( + "File Uploaded Successfully" + ); + }); + + it("Upload a file", () => { + patientPage.visitPatient("Cypress Patient"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.uploadFile(); + patientFileUploadPage.clickUploadFile(); + patientFileUploadPage.verifySuccessNotification( + "File Uploaded Successfully" + ); + }); + + it("Edit file name", () => { + patientPage.visitPatient("Cypress Patient"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.clickEditFileName( + `Cypress File ${new Date().getTime().toString().slice(9)}` + ); + patientFileUploadPage.clickSaveFileName(); + patientFileUploadPage.verifySuccessNotification( + "File name changed successfully" + ); + }); + + it("Archive file", () => { + patientPage.visitPatient("Cypress Patient"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.clickArchiveFile(); + patientFileUploadPage.clickSaveArchiveFile(); + patientFileUploadPage.verifySuccessNotification( + "File archived successfully" + ); + patientFileUploadPage.verifyArchiveFile(); + }); + + //TODO : Verify the uploaded file can only be modified by the author, district admin, and above users. + + //TODO : Verify file download is possible for all users. + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts new file mode 100644 index 00000000000..47ba0e70f6d --- /dev/null +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -0,0 +1,72 @@ +let fileName = ""; + +export class PatientFileUploadPage { + visitPatientDetailsPage() { + cy.get("#patient-details").click(); + cy.get("#upload-patient-files").click(); + } + + recordAudio() { + cy.get("#record-audio").click(); + cy.wait(5000); + cy.get("#stop-recording").click(); + } + + clickUploadAudioFile() { + cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); + cy.get("#upload-audio-file").click(); + cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); + } + + 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); + } + + clickEditFileName(newFileName: string) { + cy.get("#edit-file-name").click().scrollIntoView(); + cy.get("#editFileName").clear().type(newFileName); + } + + clickSaveFileName() { + cy.intercept("PATCH", "**/api/v1/files/**").as("saveFileName"); + cy.get("#submit").click(); + cy.wait("@saveFileName").its("response.statusCode").should("eq", 200); + } + + clickArchiveFile() { + cy.intercept("GET", "**/api/v1/files/**").as("getFiles"); + cy.wait("@getFiles").its("response.statusCode").should("eq", 200); + cy.get("#file-name").then(($el: string) => { + fileName = $el.text().split(":")[1].trim(); + }); + cy.get("#archive-file").click().scrollIntoView(); + cy.get("#editFileName").clear().type("Cypress File Archive"); + } + + clickSaveArchiveFile() { + cy.intercept("PATCH", "**/api/v1/files/**").as("saveArchiveFile"); + cy.get("#submit").click(); + cy.wait("@saveArchiveFile").its("response.statusCode").should("eq", 200); + } + + verifyArchiveFile() { + cy.get("#archived-files").click(); + cy.get("#file-name").then(($el) => { + const text = $el.text().split(":")[1].trim(); + cy.expect(text).to.eq(fileName); + }); + } + + verifySuccessNotification(msg: string) { + cy.verifyNotification(msg); + } +} 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 77c67abeadd..76023862ad1 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -653,6 +653,7 @@ export const FileUpload = (props: FileUploadProps) => { authUser.user_type === "StateAdmin" ? ( <> { setModalDetails({ name: item.name, @@ -675,6 +676,7 @@ export const FileUpload = (props: FileUploadProps) => { authUser.user_type === "StateAdmin" ? ( <> { setArchiveReason(""); setModalDetails({ @@ -710,7 +712,7 @@ export const FileUpload = (props: FileUploadProps) => { >
-
+
File Name:{" "} {" "} @@ -753,6 +755,7 @@ export const FileUpload = (props: FileUploadProps) => { <> {" "} { setModalDetails({ name: item.name, id: item.id }); setEditFileName(item?.name); @@ -773,6 +776,7 @@ export const FileUpload = (props: FileUploadProps) => { authUser.user_type === "StateAdmin") ? ( <> { setArchiveReason(""); setModalDetails({ name: item.name, id: item.id }); @@ -841,7 +845,7 @@ export const FileUpload = (props: FileUploadProps) => { )}
-
+
File Name:{" "} {" "} @@ -1492,6 +1496,7 @@ export const FileUpload = (props: FileUploadProps) => { {audioBlobExists && (
{ handleAudioUpload(); }} diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 9b719ba31dd..bdbced0f179 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -1406,6 +1406,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 f816a700154..ca72e81a911 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 } = @@ -46,6 +47,7 @@ export const VoiceRecorder = (props: any) => { {t("recording") + "..."}
{ stopRecording(); confirmAudioBlobExists(); @@ -66,6 +68,7 @@ export const VoiceRecorder = (props: any) => { From b0c92c1761b2778ae8a2cc4afc8ba85c8a6cf635 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed <98876115+AshrafMd-1@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:32:57 +0530 Subject: [PATCH 02/20] Update patient_detailpage.cy.ts --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index dc3c82cd93c..665832cd823 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -20,7 +20,7 @@ describe("Patient Details", () => { }); it("Record an audio and save it", () => { - patientPage.visitPatient("Cypress Patient"); + patientPage.visitPatient("Dummy Patient 3"); patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.recordAudio(); patientFileUploadPage.clickUploadAudioFile(); @@ -30,7 +30,7 @@ describe("Patient Details", () => { }); it("Upload a file", () => { - patientPage.visitPatient("Cypress Patient"); + patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.uploadFile(); patientFileUploadPage.clickUploadFile(); @@ -40,7 +40,7 @@ describe("Patient Details", () => { }); it("Edit file name", () => { - patientPage.visitPatient("Cypress Patient"); + patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.clickEditFileName( `Cypress File ${new Date().getTime().toString().slice(9)}` @@ -52,7 +52,7 @@ describe("Patient Details", () => { }); it("Archive file", () => { - patientPage.visitPatient("Cypress Patient"); + patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.clickArchiveFile(); patientFileUploadPage.clickSaveArchiveFile(); From 37b8a8e029c8efbcff5249b8e3586a13de5c5284 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed <98876115+AshrafMd-1@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:47:33 +0530 Subject: [PATCH 03/20] Update PatientFileupload.ts --- cypress/pageobject/Patient/PatientFileupload.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 47ba0e70f6d..f6c15032cfe 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -43,8 +43,7 @@ export class PatientFileUploadPage { } clickArchiveFile() { - cy.intercept("GET", "**/api/v1/files/**").as("getFiles"); - cy.wait("@getFiles").its("response.statusCode").should("eq", 200); + cy.wait(2000); cy.get("#file-name").then(($el: string) => { fileName = $el.text().split(":")[1].trim(); }); From 4df976efe14c3b2b6749b3c12975d7c719e0f479 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Sun, 18 Feb 2024 01:24:07 +0530 Subject: [PATCH 04/20] add cypress testing for file download --- .../e2e/patient_spec/patient_detailpage.cy.ts | 65 +++++++++++++++++-- .../pageobject/Patient/PatientFileupload.ts | 20 +++++- src/Components/Patient/FileUpload.tsx | 1 + 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 665832cd823..a82526c6bed 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -42,7 +42,7 @@ describe("Patient Details", () => { it("Edit file name", () => { patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.clickEditFileName( + patientFileUploadPage.editFileName( `Cypress File ${new Date().getTime().toString().slice(9)}` ); patientFileUploadPage.clickSaveFileName(); @@ -54,7 +54,7 @@ describe("Patient Details", () => { it("Archive file", () => { patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.clickArchiveFile(); + patientFileUploadPage.archiveFile(); patientFileUploadPage.clickSaveArchiveFile(); patientFileUploadPage.verifySuccessNotification( "File archived successfully" @@ -62,9 +62,66 @@ describe("Patient Details", () => { patientFileUploadPage.verifyArchiveFile(); }); - //TODO : Verify the uploaded file can only be modified by the author, district admin, and above users. + it("Verify the uploaded file be edited by author", () => { + loginPage.login("dummynurse1", "Coronasafe@123"); + patientPage.visitPatient("Dummy Patient 5"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.uploadFile(); + patientFileUploadPage.clickUploadFile(); + patientFileUploadPage.verifyFileEditOption(true); + patientFileUploadPage.editFileName( + `Cypress File ${new Date().getTime().toString().slice(9)}` + ); + patientFileUploadPage.clickSaveFileName(); + patientFileUploadPage.verifySuccessNotification( + "File name changed successfully" + ); + }); + + it("Verify the uploaded file be cannot edited by other users below district admin", () => { + loginPage.login("dummynurse2", "Coronasafe@123"); + patientPage.visitPatient("Dummy Patient 5"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.verifyFileEditOption(false); + }); + + it("Verify the uploaded file be can edited by district admin and above", () => { + loginPage.loginAsDisctrictAdmin(); + patientPage.visitPatient("Dummy Patient 5"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.verifyFileEditOption(true); + patientFileUploadPage.editFileName( + `Cypress File ${new Date().getTime().toString().slice(9)}` + ); + patientFileUploadPage.clickSaveFileName(); + patientFileUploadPage.verifySuccessNotification( + "File name changed successfully" + ); + }); + + it("Verify that file download is possible for author.", () => { + loginPage.login("dummynurse1", "Coronasafe@123"); + patientPage.visitPatient("Dummy Patient 5"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.verifyFileDownloadOption(true); + patientFileUploadPage.downloadFile(); + }); + + it("Verify that file download is possible for users below district admin.", () => { + loginPage.login("dummynurse2", "Coronasafe@123"); + patientPage.visitPatient("Dummy Patient 5"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.verifyFileDownloadOption(true); + patientFileUploadPage.downloadFile(); + }); - //TODO : Verify file download is possible for all users. + it("Verify that file download is possible for district admin and above.", () => { + loginPage.loginAsDisctrictAdmin(); + patientPage.visitPatient("Dummy Patient 5"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.verifyFileDownloadOption(true); + patientFileUploadPage.downloadFile(); + }); afterEach(() => { cy.saveLocalStorage(); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index f6c15032cfe..2b587fcd1f6 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -1,3 +1,5 @@ +import { cy } from "local-cypress"; + let fileName = ""; export class PatientFileUploadPage { @@ -31,7 +33,7 @@ export class PatientFileUploadPage { cy.wait("@uploadFile").its("response.statusCode").should("eq", 201); } - clickEditFileName(newFileName: string) { + editFileName(newFileName: string) { cy.get("#edit-file-name").click().scrollIntoView(); cy.get("#editFileName").clear().type(newFileName); } @@ -42,7 +44,7 @@ export class PatientFileUploadPage { cy.wait("@saveFileName").its("response.statusCode").should("eq", 200); } - clickArchiveFile() { + archiveFile() { cy.wait(2000); cy.get("#file-name").then(($el: string) => { fileName = $el.text().split(":")[1].trim(); @@ -65,6 +67,20 @@ export class PatientFileUploadPage { }); } + verifyFileEditOption(status: boolean) { + cy.get("#edit-file-name").should(status ? "be.visible" : "not.exist"); + } + + verifyFileDownloadOption(status: boolean) { + cy.get("#preview-file").should(status ? "be.visible" : "not.be.visible"); + } + + downloadFile() { + cy.intercept("GET", "**/api/v1/files/**").as("downloadFile"); + cy.get("#preview-file").click(); + cy.wait("@downloadFile").its("response.statusCode").should("eq", 200); + } + verifySuccessNotification(msg: string) { cy.verifyNotification(msg); } diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 76023862ad1..fb7825b130a 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -743,6 +743,7 @@ export const FileUpload = (props: FileUploadProps) => { onClick={() => { loadFile(item.id); }} + id="preview-file" className="m-1 w-full sm:w-auto" > {" "} From 386db473a12a494139e5d422f62c1069e245bd1a Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Sun, 18 Feb 2024 02:47:26 +0530 Subject: [PATCH 05/20] add cy wait --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index a82526c6bed..3f43df2816a 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -51,7 +51,7 @@ describe("Patient Details", () => { ); }); - it("Archive file", () => { + it("Archive file and verify it", () => { patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.archiveFile(); @@ -62,7 +62,7 @@ describe("Patient Details", () => { patientFileUploadPage.verifyArchiveFile(); }); - it("Verify the uploaded file be edited by author", () => { + it("Verify the uploaded file can be edited by author", () => { loginPage.login("dummynurse1", "Coronasafe@123"); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); @@ -78,14 +78,15 @@ describe("Patient Details", () => { ); }); - it("Verify the uploaded file be cannot edited by other users below district admin", () => { + it("Verify the uploaded file cannot be edited by other users below district admin", () => { loginPage.login("dummynurse2", "Coronasafe@123"); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); + cy.wait(2000); patientFileUploadPage.verifyFileEditOption(false); }); - it("Verify the uploaded file be can edited by district admin and above", () => { + it("Verify the uploaded file can be edited by district admin and above", () => { loginPage.loginAsDisctrictAdmin(); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); @@ -99,7 +100,7 @@ describe("Patient Details", () => { ); }); - it("Verify that file download is possible for author.", () => { + it("Verify that file download is possible for author", () => { loginPage.login("dummynurse1", "Coronasafe@123"); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); @@ -107,7 +108,7 @@ describe("Patient Details", () => { patientFileUploadPage.downloadFile(); }); - it("Verify that file download is possible for users below district admin.", () => { + it("Verify that file download is possible for users below district admin", () => { loginPage.login("dummynurse2", "Coronasafe@123"); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); @@ -115,7 +116,7 @@ describe("Patient Details", () => { patientFileUploadPage.downloadFile(); }); - it("Verify that file download is possible for district admin and above.", () => { + it("Verify that file download is possible for district admin and above", () => { loginPage.loginAsDisctrictAdmin(); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); From 50fba5e0b8cdd5c5faeeb30f1ed4dba36bec4c00 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Sun, 18 Feb 2024 14:15:53 +0530 Subject: [PATCH 06/20] add some rule change --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 5 ++++- cypress/pageobject/Patient/PatientFileupload.ts | 5 ++++- src/Components/Patient/FileUpload.tsx | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 3f43df2816a..58e56a56d6c 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -42,6 +42,7 @@ describe("Patient Details", () => { it("Edit file name", () => { patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.verifyFileEditOption(true); patientFileUploadPage.editFileName( `Cypress File ${new Date().getTime().toString().slice(9)}` ); @@ -68,6 +69,9 @@ describe("Patient Details", () => { patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.uploadFile(); patientFileUploadPage.clickUploadFile(); + patientFileUploadPage.verifySuccessNotification( + "File Uploaded Successfully" + ); patientFileUploadPage.verifyFileEditOption(true); patientFileUploadPage.editFileName( `Cypress File ${new Date().getTime().toString().slice(9)}` @@ -82,7 +86,6 @@ describe("Patient Details", () => { loginPage.login("dummynurse2", "Coronasafe@123"); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); - cy.wait(2000); patientFileUploadPage.verifyFileEditOption(false); }); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 2b587fcd1f6..83dec7f7dc7 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -68,7 +68,10 @@ export class PatientFileUploadPage { } verifyFileEditOption(status: boolean) { - cy.get("#edit-file-name").should(status ? "be.visible" : "not.exist"); + cy.get("#file-div").should( + `${status ? "contain" : "not.exist"}`, + "EDIT FILE NAME" + ); } verifyFileDownloadOption(status: boolean) { diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index fb7825b130a..ae2359a95b5 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -583,6 +583,7 @@ export const FileUpload = (props: FileUploadProps) => {
{!item.is_archived ? ( <> From 741f6eb2005cdc671c5c4b4935c6db55b83a9225 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Fri, 1 Mar 2024 23:47:53 +0530 Subject: [PATCH 07/20] revamp cypress test --- .../e2e/patient_spec/patient_detailpage.cy.ts | 146 ++++++++---------- .../pageobject/Patient/PatientFileupload.ts | 77 ++++----- src/Components/Patient/FileUpload.tsx | 11 +- 3 files changed, 108 insertions(+), 126 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 58e56a56d6c..1e5ff6184ef 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -19,112 +19,102 @@ describe("Patient Details", () => { cy.awaitUrl("/patients"); }); - it("Record an audio and save it", () => { + it("Upload the file and download it", () => { + // Upload the file patientPage.visitPatient("Dummy Patient 3"); patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.recordAudio(); - patientFileUploadPage.clickUploadAudioFile(); - patientFileUploadPage.verifySuccessNotification( - "File Uploaded Successfully" - ); - }); - - it("Upload a file", () => { - patientPage.visitPatient("Dummy Patient 4"); - patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.uploadFile(); + const fileName = `Cypress File ${new Date().getTime().toString().slice(9)}`; + cy.get("#consultation_file").clear().type(fileName); patientFileUploadPage.clickUploadFile(); - patientFileUploadPage.verifySuccessNotification( - "File Uploaded Successfully" - ); - }); - it("Edit file name", () => { - patientPage.visitPatient("Dummy Patient 4"); - patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.verifyFileEditOption(true); - patientFileUploadPage.editFileName( - `Cypress File ${new Date().getTime().toString().slice(9)}` - ); - patientFileUploadPage.clickSaveFileName(); - patientFileUploadPage.verifySuccessNotification( - "File name changed successfully" - ); + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.get("#file-name").should("contain.text", fileName); + + // Download the file + patientFileUploadPage.downloadFile(); }); - it("Archive file and verify it", () => { + it("Record an audio and archive it", () => { + // Record an audio patientPage.visitPatient("Dummy Patient 4"); patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.recordAudio(); + const fileName = `Cypress Audio ${new Date() + .getTime() + .toString() + .slice(9)}`; + cy.get("#consultation_audio_file") + .clear() + .type(`Cypress Audio ${fileName}`); + patientFileUploadPage.clickUploadAudioFile(); + + // Verify the audio file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.get("#audio-file-name").should("contain.text", fileName); + + // Archive the audio file patientFileUploadPage.archiveFile(); patientFileUploadPage.clickSaveArchiveFile(); - patientFileUploadPage.verifySuccessNotification( - "File archived successfully" - ); - patientFileUploadPage.verifyArchiveFile(); + cy.verifyNotification("File archived successfully"); + patientFileUploadPage.verifyArchiveFile(fileName); }); - it("Verify the uploaded file can be edited by author", () => { + it("User-level Based Permission for File Modification", () => { + // Login as Nurse 1 loginPage.login("dummynurse1", "Coronasafe@123"); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); + + // Upload the file patientFileUploadPage.uploadFile(); + const oldFileName = `Cypress File ${new Date() + .getTime() + .toString() + .slice(9)}`; + cy.get("#consultation_file").clear(); + cy.get("#consultation_file").type(oldFileName); patientFileUploadPage.clickUploadFile(); - patientFileUploadPage.verifySuccessNotification( - "File Uploaded Successfully" - ); + + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.get("#file-name").should("contain.text", oldFileName); patientFileUploadPage.verifyFileEditOption(true); - patientFileUploadPage.editFileName( - `Cypress File ${new Date().getTime().toString().slice(9)}` - ); + + // Edit the file name + const newFileName = `Cypress File ${new Date() + .getTime() + .toString() + .slice(9)}`; + patientFileUploadPage.editFileName(newFileName); patientFileUploadPage.clickSaveFileName(); - patientFileUploadPage.verifySuccessNotification( - "File name changed successfully" - ); - }); - it("Verify the uploaded file cannot be edited by other users below district admin", () => { + // Verify the file name is changed + cy.verifyNotification("File name changed successfully"); + cy.get("#file-name").should("contain.text", newFileName); + + // Login as Nurse 2 loginPage.login("dummynurse2", "Coronasafe@123"); - patientPage.visitPatient("Dummy Patient 5"); - patientFileUploadPage.visitPatientDetailsPage(); + cy.reload(); + + // Verify the file edit option is not available + cy.get("#file-name").should("contain.text", newFileName); patientFileUploadPage.verifyFileEditOption(false); - }); - it("Verify the uploaded file can be edited by district admin and above", () => { + // Login as District Admin loginPage.loginAsDisctrictAdmin(); - patientPage.visitPatient("Dummy Patient 5"); - patientFileUploadPage.visitPatientDetailsPage(); + cy.reload(); + + // Verify the file edit option is available + cy.get("#file-name").should("contain.text", newFileName); patientFileUploadPage.verifyFileEditOption(true); - patientFileUploadPage.editFileName( - `Cypress File ${new Date().getTime().toString().slice(9)}` - ); + patientFileUploadPage.editFileName(oldFileName); patientFileUploadPage.clickSaveFileName(); - patientFileUploadPage.verifySuccessNotification( - "File name changed successfully" - ); - }); - it("Verify that file download is possible for author", () => { - loginPage.login("dummynurse1", "Coronasafe@123"); - patientPage.visitPatient("Dummy Patient 5"); - patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.verifyFileDownloadOption(true); - patientFileUploadPage.downloadFile(); - }); - - it("Verify that file download is possible for users below district admin", () => { - loginPage.login("dummynurse2", "Coronasafe@123"); - patientPage.visitPatient("Dummy Patient 5"); - patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.verifyFileDownloadOption(true); - patientFileUploadPage.downloadFile(); - }); - - it("Verify that file download is possible for district admin and above", () => { - loginPage.loginAsDisctrictAdmin(); - patientPage.visitPatient("Dummy Patient 5"); - patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.verifyFileDownloadOption(true); - patientFileUploadPage.downloadFile(); + // Verify the file name is changed + cy.verifyNotification("File name changed successfully"); + cy.get("#file-name").should("contain.text", oldFileName); }); afterEach(() => { diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 83dec7f7dc7..64374ee635e 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -1,25 +1,11 @@ import { cy } from "local-cypress"; -let fileName = ""; - export class PatientFileUploadPage { visitPatientDetailsPage() { cy.get("#patient-details").click(); cy.get("#upload-patient-files").click(); } - recordAudio() { - cy.get("#record-audio").click(); - cy.wait(5000); - cy.get("#stop-recording").click(); - } - - clickUploadAudioFile() { - cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); - cy.get("#upload-audio-file").click(); - cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); - } - uploadFile() { cy.get("#file_upload_patient").selectFile( "cypress/fixtures/sampleAsset.xlsx", @@ -33,58 +19,59 @@ export class PatientFileUploadPage { cy.wait("@uploadFile").its("response.statusCode").should("eq", 201); } - editFileName(newFileName: string) { - cy.get("#edit-file-name").click().scrollIntoView(); - cy.get("#editFileName").clear().type(newFileName); + downloadFile() { + cy.intercept("GET", "**/api/v1/files/**").as("downloadFile"); + cy.get("#preview-file").click(); + cy.wait("@downloadFile").its("response.statusCode").should("eq", 200); } - clickSaveFileName() { - cy.intercept("PATCH", "**/api/v1/files/**").as("saveFileName"); - cy.get("#submit").click(); - cy.wait("@saveFileName").its("response.statusCode").should("eq", 200); + recordAudio() { + cy.get("#record-audio").click(); + cy.wait(5000); + cy.get("#stop-recording").click(); + } + + clickUploadAudioFile() { + cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); + cy.get("#upload-audio-file").click(); + cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); } archiveFile() { - cy.wait(2000); - cy.get("#file-name").then(($el: string) => { - fileName = $el.text().split(":")[1].trim(); - }); cy.get("#archive-file").click().scrollIntoView(); cy.get("#editFileName").clear().type("Cypress File Archive"); } clickSaveArchiveFile() { cy.intercept("PATCH", "**/api/v1/files/**").as("saveArchiveFile"); - cy.get("#submit").click(); + cy.submitButton("Proceed"); cy.wait("@saveArchiveFile").its("response.statusCode").should("eq", 200); } - verifyArchiveFile() { + verifyArchiveFile(fileName: string) { cy.get("#archived-files").click(); - cy.get("#file-name").then(($el) => { - const text = $el.text().split(":")[1].trim(); - cy.expect(text).to.eq(fileName); - }); + cy.get("button").contains("MORE DETAILS").click().scrollIntoView(); + cy.get("#archive-file-name").should("contain.text", fileName); } verifyFileEditOption(status: boolean) { - cy.get("#file-div").should( - `${status ? "contain" : "not.exist"}`, - "EDIT FILE NAME" - ); - } - - verifyFileDownloadOption(status: boolean) { - cy.get("#preview-file").should(status ? "be.visible" : "not.be.visible"); + cy.get("#file-div").then(($fileDiv) => { + if (status) { + expect($fileDiv.text()).to.contain("EDIT FILE"); + } else { + expect($fileDiv.text()).to.not.contain("EDIT FILE"); + } + }); } - downloadFile() { - cy.intercept("GET", "**/api/v1/files/**").as("downloadFile"); - cy.get("#preview-file").click(); - cy.wait("@downloadFile").its("response.statusCode").should("eq", 200); + editFileName(newFileName: string) { + cy.get("#edit-file-name").click().scrollIntoView(); + cy.get("#editFileName").clear().type(newFileName); } - verifySuccessNotification(msg: string) { - cy.verifyNotification(msg); + 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/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index a0d735fe69a..42791597397 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -535,7 +535,10 @@ export const FileUpload = (props: FileUploadProps) => { <> {item.file_category === "AUDIO" ? (
-
+
{ />
-
+
File Name:{" "} {" "} @@ -591,6 +594,7 @@ export const FileUpload = (props: FileUploadProps) => { Object.keys(url).length > 0 && (
{
- {modalDetails?.name} file is archived. + {modalDetails?.name} file is + archived.
Reason: {modalDetails?.reason} From eaba793834c86a1a367c54f43187a4cff4a11660 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Sat, 2 Mar 2024 00:05:31 +0530 Subject: [PATCH 08/20] resolve bugs --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 9 +++------ cypress/pageobject/Patient/PatientFileupload.ts | 3 +++ src/Components/Patient/FileUpload.tsx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 1e5ff6184ef..52dc7544b52 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -45,9 +45,7 @@ describe("Patient Details", () => { .getTime() .toString() .slice(9)}`; - cy.get("#consultation_audio_file") - .clear() - .type(`Cypress Audio ${fileName}`); + cy.get("#consultation_audio_file").clear().type(fileName); patientFileUploadPage.clickUploadAudioFile(); // Verify the audio file is uploaded @@ -73,16 +71,15 @@ describe("Patient Details", () => { .getTime() .toString() .slice(9)}`; - cy.get("#consultation_file").clear(); - cy.get("#consultation_file").type(oldFileName); + cy.get("#consultation_file").clear().type(oldFileName); patientFileUploadPage.clickUploadFile(); // Verify the file is uploaded cy.verifyNotification("File Uploaded Successfully"); cy.get("#file-name").should("contain.text", oldFileName); - patientFileUploadPage.verifyFileEditOption(true); // Edit the file name + patientFileUploadPage.verifyFileEditOption(true); const newFileName = `Cypress File ${new Date() .getTime() .toString() diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 64374ee635e..bfed8a83f4d 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -52,6 +52,9 @@ export class PatientFileUploadPage { 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"); + }); } verifyFileEditOption(status: boolean) { diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 42791597397..1951613af68 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -1373,7 +1373,7 @@ export const FileUpload = (props: FileUploadProps) => { {modalDetails?.name} file is archived.
-
+
Reason: {modalDetails?.reason}
From c69d013e2e1e43c6d636c754b431de21fe590a3f Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Sat, 2 Mar 2024 00:25:03 +0530 Subject: [PATCH 09/20] resolve bugs --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 52dc7544b52..ce35d40da90 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -62,6 +62,7 @@ describe("Patient Details", () => { it("User-level Based Permission for File Modification", () => { // Login as Nurse 1 loginPage.login("dummynurse1", "Coronasafe@123"); + cy.reload(); patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); From 8e966b444c1eed9928a5df0000682cd6450600f7 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Sun, 3 Mar 2024 12:50:30 +0530 Subject: [PATCH 10/20] fix bugs --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index ce35d40da90..df5b01200ac 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -25,7 +25,8 @@ describe("Patient Details", () => { patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.uploadFile(); const fileName = `Cypress File ${new Date().getTime().toString().slice(9)}`; - cy.get("#consultation_file").clear().type(fileName); + cy.get("#consultation_file").clear(); + cy.get("#consultation_file").type(fileName); patientFileUploadPage.clickUploadFile(); // Verify the file is uploaded @@ -63,6 +64,8 @@ describe("Patient Details", () => { // Login as Nurse 1 loginPage.login("dummynurse1", "Coronasafe@123"); cy.reload(); + + // Visit the patient details page patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); @@ -72,7 +75,8 @@ describe("Patient Details", () => { .getTime() .toString() .slice(9)}`; - cy.get("#consultation_file").clear().type(oldFileName); + cy.get("#consultation_file").clear(); + cy.get("#consultation_file").type(oldFileName); patientFileUploadPage.clickUploadFile(); // Verify the file is uploaded From 8d1a8b49c4539440464bb79ee1a47aaf653efe55 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Fri, 8 Mar 2024 12:08:47 +0530 Subject: [PATCH 11/20] add cypress test for redesigned file upload page --- .../e2e/patient_spec/patient_detailpage.cy.ts | 24 +++++++++---------- .../pageobject/Patient/PatientFileupload.ts | 16 ++++++------- src/Components/Patient/FileUpload.tsx | 16 +++++++++---- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index df5b01200ac..3f1d3ca4c38 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -31,7 +31,7 @@ describe("Patient Details", () => { // Verify the file is uploaded cy.verifyNotification("File Uploaded Successfully"); - cy.get("#file-name").should("contain.text", fileName); + cy.get("#file-div").should("contain.text", fileName); // Download the file patientFileUploadPage.downloadFile(); @@ -51,7 +51,7 @@ describe("Patient Details", () => { // Verify the audio file is uploaded cy.verifyNotification("File Uploaded Successfully"); - cy.get("#audio-file-name").should("contain.text", fileName); + cy.get("#file-div").should("contain.text", fileName); // Archive the audio file patientFileUploadPage.archiveFile(); @@ -81,42 +81,42 @@ describe("Patient Details", () => { // Verify the file is uploaded cy.verifyNotification("File Uploaded Successfully"); - cy.get("#file-name").should("contain.text", oldFileName); + cy.get("#file-div").should("contain.text", oldFileName); // Edit the file name - patientFileUploadPage.verifyFileEditOption(true); + patientFileUploadPage.verifyFileRenameOption(true); const newFileName = `Cypress File ${new Date() .getTime() .toString() .slice(9)}`; - patientFileUploadPage.editFileName(newFileName); + patientFileUploadPage.renameFile(newFileName); patientFileUploadPage.clickSaveFileName(); // Verify the file name is changed cy.verifyNotification("File name changed successfully"); - cy.get("#file-name").should("contain.text", newFileName); + cy.get("#file-div").should("contain.text", newFileName); // Login as Nurse 2 loginPage.login("dummynurse2", "Coronasafe@123"); cy.reload(); // Verify the file edit option is not available - cy.get("#file-name").should("contain.text", newFileName); - patientFileUploadPage.verifyFileEditOption(false); + cy.get("#file-div").should("contain.text", newFileName); + patientFileUploadPage.verifyFileRenameOption(false); // Login as District Admin loginPage.loginAsDisctrictAdmin(); cy.reload(); // Verify the file edit option is available - cy.get("#file-name").should("contain.text", newFileName); - patientFileUploadPage.verifyFileEditOption(true); - patientFileUploadPage.editFileName(oldFileName); + cy.get("#file-div").should("contain.text", newFileName); + patientFileUploadPage.verifyFileRenameOption(true); + patientFileUploadPage.renameFile(oldFileName); patientFileUploadPage.clickSaveFileName(); // Verify the file name is changed cy.verifyNotification("File name changed successfully"); - cy.get("#file-name").should("contain.text", oldFileName); + cy.get("#file-div").should("contain.text", oldFileName); }); afterEach(() => { diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index bfed8a83f4d..34ccff7dad4 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -20,8 +20,8 @@ export class PatientFileUploadPage { } downloadFile() { - cy.intercept("GET", "**/api/v1/files/**").as("downloadFile"); - cy.get("#preview-file").click(); + cy.intercept("GET", "**/patient-bucket/PATIENT/**").as("downloadFile"); + cy.get("#download-file").click(); cy.wait("@downloadFile").its("response.statusCode").should("eq", 200); } @@ -33,7 +33,7 @@ export class PatientFileUploadPage { clickUploadAudioFile() { cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); - cy.get("#upload-audio-file").click(); + cy.get("#upload_audio_file").click(); cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); } @@ -57,18 +57,18 @@ export class PatientFileUploadPage { }); } - verifyFileEditOption(status: boolean) { + verifyFileRenameOption(status: boolean) { cy.get("#file-div").then(($fileDiv) => { if (status) { - expect($fileDiv.text()).to.contain("EDIT FILE"); + expect($fileDiv.text()).to.contain("RENAME"); } else { - expect($fileDiv.text()).to.not.contain("EDIT FILE"); + expect($fileDiv.text()).to.not.contain("RENAME"); } }); } - editFileName(newFileName: string) { - cy.get("#edit-file-name").click().scrollIntoView(); + renameFile(newFileName: string) { + cy.get("button").contains("RENAME").click().scrollIntoView(); cy.get("#editFileName").clear().type(newFileName); } diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 5c070418faa..845bbe379b6 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -559,7 +559,11 @@ export const FileUpload = (props: FileUploadProps) => { const renderFileUpload = (item: FileUploadModel) => { const isPreviewSupported = previewExtensions.includes(item.extension ?? ""); return ( -
+
{!item.is_archived ? ( <> {item.file_category === "AUDIO" ? ( @@ -659,6 +663,7 @@ export const FileUpload = (props: FileUploadProps) => { authUser.user_type === "StateAdmin" ? ( <> { setArchiveReason(""); setModalDetails({ @@ -735,6 +740,7 @@ export const FileUpload = (props: FileUploadProps) => { ) : ( { triggerDownload( url[item.id!], @@ -1408,9 +1414,10 @@ export const FileUpload = (props: FileUploadProps) => {
- {modalDetails?.name} file is archived. + {modalDetails?.name} file is + archived.
-
+
Reason: {modalDetails?.reason}
@@ -1490,6 +1497,7 @@ export const FileUpload = (props: FileUploadProps) => { {audioBlobExists && (
{ handleAudioUpload(); }} @@ -1675,4 +1683,4 @@ export const FileUpload = (props: FileUploadProps) => {
); -}; \ No newline at end of file +}; From c4ea1d979eefe5c48fae98bbd1900914abbb4c98 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Tue, 12 Mar 2024 22:05:13 +0530 Subject: [PATCH 12/20] fix code --- .../e2e/patient_spec/patient_detailpage.cy.ts | 42 +++++++++---------- .../pageobject/Patient/PatientFileupload.ts | 32 ++++++-------- src/Components/Patient/FileUpload.tsx | 1 - 3 files changed, 34 insertions(+), 41 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 3f1d3ca4c38..39b7598b290 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -19,27 +19,9 @@ describe("Patient Details", () => { cy.awaitUrl("/patients"); }); - it("Upload the file and download it", () => { - // Upload the file - patientPage.visitPatient("Dummy Patient 3"); - patientFileUploadPage.visitPatientDetailsPage(); - patientFileUploadPage.uploadFile(); - const fileName = `Cypress File ${new Date().getTime().toString().slice(9)}`; - cy.get("#consultation_file").clear(); - cy.get("#consultation_file").type(fileName); - patientFileUploadPage.clickUploadFile(); - - // Verify the file is uploaded - cy.verifyNotification("File Uploaded Successfully"); - cy.get("#file-div").should("contain.text", fileName); - - // Download the file - patientFileUploadPage.downloadFile(); - }); - - it("Record an audio and archive it", () => { + it("Record an Audio and download the file", () => { // Record an audio - patientPage.visitPatient("Dummy Patient 4"); + patientPage.visitPatient("Dummy Patient 3"); patientFileUploadPage.visitPatientDetailsPage(); patientFileUploadPage.recordAudio(); const fileName = `Cypress Audio ${new Date() @@ -53,7 +35,25 @@ describe("Patient Details", () => { cy.verifyNotification("File Uploaded Successfully"); cy.get("#file-div").should("contain.text", fileName); - // Archive the audio file + // 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("Dummy Patient 4"); + patientFileUploadPage.visitPatientDetailsPage(); + patientFileUploadPage.uploadFile(); + const fileName = `Cypress File ${new Date().getTime().toString().slice(9)}`; + cy.get("#consultation_file").clear().type(fileName); + patientFileUploadPage.clickUploadFile(); + + // Verify the file is uploaded + cy.verifyNotification("File Uploaded Successfully"); + cy.get("#file-div").should("contain.text", fileName); + + // Archive the file patientFileUploadPage.archiveFile(); patientFileUploadPage.clickSaveArchiveFile(); cy.verifyNotification("File archived successfully"); diff --git a/cypress/pageobject/Patient/PatientFileupload.ts b/cypress/pageobject/Patient/PatientFileupload.ts index 34ccff7dad4..10bd4027ad1 100644 --- a/cypress/pageobject/Patient/PatientFileupload.ts +++ b/cypress/pageobject/Patient/PatientFileupload.ts @@ -6,6 +6,18 @@ export class PatientFileUploadPage { cy.get("#upload-patient-files").click(); } + recordAudio() { + cy.get("#record-audio").click(); + cy.wait(5000); + cy.get("#stop-recording").click(); + } + + clickUploadAudioFile() { + cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); + cy.get("#upload_audio_file").click(); + cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); + } + uploadFile() { cy.get("#file_upload_patient").selectFile( "cypress/fixtures/sampleAsset.xlsx", @@ -19,26 +31,8 @@ export class PatientFileUploadPage { cy.wait("@uploadFile").its("response.statusCode").should("eq", 201); } - downloadFile() { - cy.intercept("GET", "**/patient-bucket/PATIENT/**").as("downloadFile"); - cy.get("#download-file").click(); - cy.wait("@downloadFile").its("response.statusCode").should("eq", 200); - } - - recordAudio() { - cy.get("#record-audio").click(); - cy.wait(5000); - cy.get("#stop-recording").click(); - } - - clickUploadAudioFile() { - cy.intercept("POST", "**/api/v1/files/").as("uploadAudioFile"); - cy.get("#upload_audio_file").click(); - cy.wait("@uploadAudioFile").its("response.statusCode").should("eq", 201); - } - archiveFile() { - cy.get("#archive-file").click().scrollIntoView(); + cy.get("button").contains("ARCHIVE").click().scrollIntoView(); cy.get("#editFileName").clear().type("Cypress File Archive"); } diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index a9f8bad1ed1..d955b100d30 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -663,7 +663,6 @@ export const FileUpload = (props: FileUploadProps) => { authUser.user_type === "StateAdmin" ? ( <> { setArchiveReason(""); setModalDetails({ From bc14b268d8551f167236b69a2065533699fb180e Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Tue, 19 Mar 2024 21:20:14 +0530 Subject: [PATCH 13/20] test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 39b7598b290..3ced707ae5a 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -66,7 +66,7 @@ describe("Patient Details", () => { cy.reload(); // Visit the patient details page - patientPage.visitPatient("Dummy Patient 5"); + patientPage.visitPatient("Dummy Patient 7"); patientFileUploadPage.visitPatientDetailsPage(); // Upload the file From 1823b988e66ccd0e038fd792cae9d1e915d06dd3 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Tue, 19 Mar 2024 21:42:31 +0530 Subject: [PATCH 14/20] Test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 3ced707ae5a..d881a2bf458 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -66,7 +66,10 @@ describe("Patient Details", () => { cy.reload(); // Visit the patient details page - patientPage.visitPatient("Dummy Patient 7"); + // patientPage.visitPatient(""); + cy.get("#name").click().type(""); + cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); + cy.get("#this-is-for-testing").click(); patientFileUploadPage.visitPatientDetailsPage(); // Upload the file From 5662d074f0f36c3f3d6da07619fd8ec31e213311 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Tue, 19 Mar 2024 21:54:48 +0530 Subject: [PATCH 15/20] Test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index d881a2bf458..23971f64b36 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -67,8 +67,7 @@ describe("Patient Details", () => { // Visit the patient details page // patientPage.visitPatient(""); - cy.get("#name").click().type(""); - cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); + cy.visit("/users"); cy.get("#this-is-for-testing").click(); patientFileUploadPage.visitPatientDetailsPage(); From 2acf991eedc47fbef611140b682384cabd4f4b32 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Tue, 19 Mar 2024 22:09:13 +0530 Subject: [PATCH 16/20] Test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 23971f64b36..af16397545f 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -64,11 +64,10 @@ describe("Patient Details", () => { // Login as Nurse 1 loginPage.login("dummynurse1", "Coronasafe@123"); cy.reload(); + cy.wait(2000); // Visit the patient details page - // patientPage.visitPatient(""); - cy.visit("/users"); - cy.get("#this-is-for-testing").click(); + patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); // Upload the file From dd5afe83d95f4e208aba1e440f4a52ab65485390 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 20 Mar 2024 14:11:00 +0530 Subject: [PATCH 17/20] test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index af16397545f..87da61ec47f 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -23,6 +23,7 @@ describe("Patient Details", () => { // Record an audio patientPage.visitPatient("Dummy Patient 3"); patientFileUploadPage.visitPatientDetailsPage(); + cy.get("#this is a test").click(); patientFileUploadPage.recordAudio(); const fileName = `Cypress Audio ${new Date() .getTime() @@ -64,7 +65,8 @@ describe("Patient Details", () => { // Login as Nurse 1 loginPage.login("dummynurse1", "Coronasafe@123"); cy.reload(); - cy.wait(2000); + + cy.visit("/user/profile"); // Visit the patient details page patientPage.visitPatient("Dummy Patient 5"); From 21b218d0c0179f463e0b4893179d5e227ab7be31 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 20 Mar 2024 20:45:13 +0530 Subject: [PATCH 18/20] test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 87da61ec47f..0fc48a1861d 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -23,7 +23,6 @@ describe("Patient Details", () => { // Record an audio patientPage.visitPatient("Dummy Patient 3"); patientFileUploadPage.visitPatientDetailsPage(); - cy.get("#this is a test").click(); patientFileUploadPage.recordAudio(); const fileName = `Cypress Audio ${new Date() .getTime() @@ -66,7 +65,7 @@ describe("Patient Details", () => { loginPage.login("dummynurse1", "Coronasafe@123"); cy.reload(); - cy.visit("/user/profile"); + cy.visit("/facility"); // Visit the patient details page patientPage.visitPatient("Dummy Patient 5"); From de0a536ade9ee2ae876426600686120dc029a992 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 20 Mar 2024 21:01:02 +0530 Subject: [PATCH 19/20] test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 0fc48a1861d..5eee50f261b 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -65,7 +65,7 @@ describe("Patient Details", () => { loginPage.login("dummynurse1", "Coronasafe@123"); cy.reload(); - cy.visit("/facility"); + cy.visit("/users"); // Visit the patient details page patientPage.visitPatient("Dummy Patient 5"); From 192ce7079717dd68fc6706a913a89dda34ca98ec Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 20 Mar 2024 21:16:28 +0530 Subject: [PATCH 20/20] test --- cypress/e2e/patient_spec/patient_detailpage.cy.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_detailpage.cy.ts b/cypress/e2e/patient_spec/patient_detailpage.cy.ts index 5eee50f261b..e834042ba7e 100644 --- a/cypress/e2e/patient_spec/patient_detailpage.cy.ts +++ b/cypress/e2e/patient_spec/patient_detailpage.cy.ts @@ -62,11 +62,9 @@ describe("Patient Details", () => { it("User-level Based Permission for File Modification", () => { // Login as Nurse 1 - loginPage.login("dummynurse1", "Coronasafe@123"); + loginPage.login("dummynurse2", "Coronasafe@123"); cy.reload(); - cy.visit("/users"); - // Visit the patient details page patientPage.visitPatient("Dummy Patient 5"); patientFileUploadPage.visitPatientDetailsPage(); @@ -99,7 +97,7 @@ describe("Patient Details", () => { cy.get("#file-div").should("contain.text", newFileName); // Login as Nurse 2 - loginPage.login("dummynurse2", "Coronasafe@123"); + loginPage.login("dummynurse1", "Coronasafe@123"); cy.reload(); // Verify the file edit option is not available