From 46153cd3f26d4b48afbd7644d85405e5b1ed13c3 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 14:43:49 +0530 Subject: [PATCH 01/84] e2e for result --- frontend/cypress.config.js | 2 + frontend/cypress/e2e/result.cy.js | 265 ++++++++++++++++++++++++++ frontend/cypress/pages/HomePage.js | 43 +++++ frontend/cypress/pages/ResultsPage.js | 16 ++ 4 files changed, 326 insertions(+) create mode 100644 frontend/cypress/e2e/result.cy.js create mode 100644 frontend/cypress/pages/ResultsPage.js diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index ee50118896..9bdd73c5a1 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -4,6 +4,7 @@ module.exports = defineConfig({ defaultCommandTimeout: 8000, viewportWidth: 1200, viewportHeight: 700, + watchForFileChanges:false, e2e: { setupNodeEvents(on, config) { // implement node event listeners here @@ -14,6 +15,7 @@ module.exports = defineConfig({ "cypress/e2e/workplan.cy.js", "cypress/e2e/nonConform.cy.js", "cypress/e2e/modifyOrder.cy.js", + "cypress/e2e/result.cy.js" ]; return config; }, diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js new file mode 100644 index 0000000000..cf0d97632c --- /dev/null +++ b/frontend/cypress/e2e/result.cy.js @@ -0,0 +1,265 @@ +import LoginPage from "../pages/LoginPage"; +import HomePage from "../pages/HomePage"; +import Result from "../pages/ResultsPage"; +import PatientEntryPage from "../pages/PatientEntryPage"; + +let homePage = null; +let loginPage = null; +let result = null; +let patientPage = new PatientEntryPage(); + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +describe("Result By Unit", function () { + before("navigate to Result By Unit", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByUnit(); + }); + + it("User visits Results Page", function () { + result.getResultTitle().should("contain.text", "Results"); + }); + + it("Should Search by Unit", function () { + cy.fixture("workplan").then((order) => { + cy.get("#unitType").select(order.unitType); + }); + }); + + it("should accept the sample , refer the sample and save the result", function () { + // result.acceptSample(); + cy.get(".cds--checkbox-label").click(); + cy.get('[data-testid="expander-button-0"]').click(); + cy.get("#testMethod0").select("PCR"); + cy.get(":nth-child(3) > .cds--form-item > .cds--checkbox-label").click(); //refer test + cy.get("#referralReason0").select("Test not performed"); + cy.get("#institute0").select("CEDRES"); + cy.get("#resultValue0").select("Positive HIV1"); + cy.get("#submit").click(); + }); +}); + +describe("Result By Patient", function () { + before("navigate to Result By Unit", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByPatient(); + }); + + it("User visits Results Page", function () { + result.getResultTitle().should("contain.text", "Results"); + }); + it("Should search Patient By First and LastName and validate", function () { + cy.wait(1000); + cy.fixture("Patient").then((patient) => { + patientPage.searchPatientByFirstAndLastName( + patient.firstName, + patient.lastName, + ); + patientPage.getFirstName().should("have.value", patient.firstName); + patientPage.getLastName().should("have.value", patient.lastName); + + patientPage.getLastName().should("not.have.value", patient.inValidName); + + patientPage.clickSearchPatientButton(); + patientPage.validatePatientSearchTable( + patient.firstName, + patient.inValidName, + ); + }); + cy.wait(200).reload(); + }); + + it("should search patient By PatientId and validate", function () { + cy.wait(1000); + cy.fixture("Patient").then((patient) => { + patientPage.searchPatientByPatientId(patient.nationalId); + patientPage.clickSearchPatientButton(); + patientPage.validatePatientSearchTable( + patient.firstName, + patient.inValidName, + ); + }); + }); + + it("Should be able to search by respective patient and accept the result", function () { + cy.wait(1000); + cy.get( + "tbody > :nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance", + ).click(); + cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); + cy.get('[data-testid="expander-button-0"]').click(); + cy.get("#testMethod0").select("STAIN"); + cy.get("#submit").click(); + }); +}); + +describe("Result By Order", function () { + before("navigate to Result By Unit", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByOrder(); + }); + + it("User visits Results Page", function () { + result.getResultTitle().should("contain.text", "Results"); + }); + + it("Should Search by Unit", function () { + cy.fixture("EnteredOrder").then((order) => { + cy.get("#accessionNumber").type(order.labNo); + }); + cy.get(":nth-child(4) > #submit").click(); + }); + + it("should accept the sample and save the result", function () { + // result.acceptSample(); + cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); + cy.get('[data-testid="expander-button-0"]').click(); + cy.get("#testMethod0").select("STAIN"); + cy.get(":nth-child(5) > #submit").click(); + }); +}); + +describe("Result By Reffered Out Tests", function () { + before("navigate to Result By Unit", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsForRefferedOut(); + }); + + it("User visits Results Page", function () { + result.getResultTitle().should("contain.text", "Referrals"); + }); + + it("should search Referrals By PatientId and validate", function () { + cy.wait(1000); + cy.fixture("Patient").then((patient) => { + patientPage.searchPatientByPatientId(patient.nationalId); + patientPage.clickSearchPatientButton(); + patientPage.validatePatientSearchTable( + patient.firstName, + patient.inValidName, + ); + }); + }); + + it("should click respective patient and search for referred out tests", function () { + cy.wait(1000); + cy.get( + "tbody > :nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance", + ).click(); + cy.get(":nth-child(1) > :nth-child(5) > .cds--btn").click(); + }); + + it("should validate the results", function () { + cy.fixture("Patient").then((patient) => { + cy.get( + ".gridBoundary > .cds--sm\\:col-span-4 > .cds--data-table-container > .cds--data-table-content > .cds--data-table > tbody > tr > :nth-child(6)", + ).should("contain.text", patient.lastName); + cy.get( + ".gridBoundary > .cds--sm\\:col-span-4 > .cds--data-table-container > .cds--data-table-content > .cds--data-table > tbody > tr > :nth-child(7)", + ).should("contain.text", patient.firstName); + }); + cy.reload(); + }); + + it("should search Referrals By Test Unit and validate", function () { + cy.wait(1000); + cy.fixture("workplan").then((result) => { + cy.get("#testnames-input").type(result.testName); + cy.get("#testnames-item-0-item").click(); + cy.get(":nth-child(15) > .cds--btn").click({ force: true }); + }); + + cy.get("tbody > tr > :nth-child(8)").should( + "contain.text", + "Western blot HIV", + ); + + cy.reload(); + }); + + it("should search Referrals By LabNumber and validate", function () { + cy.wait(1000); + cy.fixture("EnteredOrder").then((order) => { + cy.get("#labNumberInput").type(order.labNo); + }); + cy.get(":nth-child(4) > .cds--lg\\:col-span-4 > .cds--btn") + .should("be.visible") + .click(); + cy.fixture("EnteredOrder").then((patient) => { + cy.get("tbody > tr > :nth-child(3)").should( + "contain.text", + patient.labNo, + ); + }); + }); + + it("should select the respecting reffered test and print the selected patient reports", function () { + cy.get( + "tbody > tr > .cds--table-column-checkbox > .cds--checkbox--inline > .cds--checkbox-label", + ).click(); + cy.get(":nth-child(6) > :nth-child(2) > .cds--btn") + .should("be.visible") + .click(); + }); +}); + +describe("Result By Range Of Order", function () { + before("navigate to Result By Unit", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByRangeOrder(); + }); + + it("User visits Results Page", function () { + result.getResultTitle().should("contain.text", "Results"); + }); + + it("Should Enter Lab Number Number and perform Search", function () { + cy.fixture("EnteredOrder").then((order) => { + cy.get("#startLabNo").type(order.labNo); + }); + cy.get(":nth-child(5) > #submit").click(); + }); + + it("Should Accept And Save the result", function () { + cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); + cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").select( + "Invalid", + ); + cy.get(".orderLegendBody > :nth-child(5) > #submit").click(); + }); +}); + +describe("Result By Test And Status", function () { + before("navigate to Result By Unit", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByTestAndStatus(); + }); + + it("User visits Results Page", function () { + result.getResultTitle().should("contain.text", "Results"); + }); + + it("Should select testName, analysis status perform Search", function () { + cy.fixture("workplan").then((order) => { + cy.get("#testName").select(order.testName); + }); + cy.get("#analysisStatus").select("Accepted by technician"); + cy.get(":nth-child(8) > #submit").click(); + }); + + it("Should Validate And accept the result", function () { + cy.fixture("workplan").then((order) => { + cy.get("#cell-testName-0 > .sampleInfo").should( + "contain.text", + order.testName, + ); + }); + cy.get(".cds--checkbox-label").click(); + cy.get('[data-testid="expander-button-0"]').click(); + cy.get("#testMethod0").select("EIA"); + cy.get(":nth-child(5) > #submit").click(); + }); +}); diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index c6cbcd5470..5eefd9974a 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -4,6 +4,7 @@ import OrderEntityPage from "./OrderEntityPage"; import ModifyOrderPage from "./ModifyOrderPage"; import WorkPlan from "./WorkPlan"; import NonConform from "./NonConformPage"; +import Result from "./ResultsPage"; class HomePage { constructor() {} @@ -89,6 +90,48 @@ class HomePage { cy.get("#menu_non_conforming_corrective_actions").click(); return new NonConform(); } + + goToResultsByUnit(){ + this.openNavigationMenu(); + cy.get('#menu_results').click(); + cy.get('#menu_results_logbook').click(); + return new Result(); + } + + goToResultsByOrder(){ + this.openNavigationMenu(); + cy.get('#menu_results').click(); + cy.get('#menu_results_accession').click(); + return new Result(); + } + + goToResultsByPatient(){ + this.openNavigationMenu(); + cy.get('#menu_results').click(); + cy.get('#menu_results_patient').click(); + return new Result(); + } + + goToResultsForRefferedOut(){ + this.openNavigationMenu(); + cy.get('#menu_results').click(); + cy.get('#menu_results_referred ').click(); + return new Result(); + } + + goToResultsByRangeOrder(){ + this.openNavigationMenu(); + cy.get('#menu_results').click(); + cy.get('#menu_results_range').click(); + return new Result(); + } + + goToResultsByTestAndStatus(){ + this.openNavigationMenu(); + cy.get('#menu_results').click(); + cy.get('#menu_results_status').click(); + return new Result(); + } } export default HomePage; diff --git a/frontend/cypress/pages/ResultsPage.js b/frontend/cypress/pages/ResultsPage.js new file mode 100644 index 0000000000..9c3ecbba61 --- /dev/null +++ b/frontend/cypress/pages/ResultsPage.js @@ -0,0 +1,16 @@ + + +class Result { + + + getResultTitle(){ + return cy.get('section > h3'); + } + + + + + } + + export default Result; + \ No newline at end of file From 979f9361befa2dd4783bdfb24cb407e52d9d803f Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 15:29:41 +0530 Subject: [PATCH 02/84] minor fixes --- frontend/cypress/e2e/result.cy.js | 121 ++++++++++---------------- frontend/cypress/pages/ResultsPage.js | 82 +++++++++++++++-- 2 files changed, 121 insertions(+), 82 deletions(-) diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index cf0d97632c..60860ccd3f 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -4,12 +4,11 @@ import Result from "../pages/ResultsPage"; import PatientEntryPage from "../pages/PatientEntryPage"; let homePage = null; -let loginPage = null; +let loginPage = new LoginPage(); let result = null; let patientPage = new PatientEntryPage(); before("login", () => { - loginPage = new LoginPage(); loginPage.visit(); }); @@ -25,25 +24,22 @@ describe("Result By Unit", function () { it("Should Search by Unit", function () { cy.fixture("workplan").then((order) => { - cy.get("#unitType").select(order.unitType); + result.selectUnitType(order.unitType); }); }); - it("should accept the sample , refer the sample and save the result", function () { - // result.acceptSample(); - cy.get(".cds--checkbox-label").click(); - cy.get('[data-testid="expander-button-0"]').click(); - cy.get("#testMethod0").select("PCR"); - cy.get(":nth-child(3) > .cds--form-item > .cds--checkbox-label").click(); //refer test - cy.get("#referralReason0").select("Test not performed"); - cy.get("#institute0").select("CEDRES"); - cy.get("#resultValue0").select("Positive HIV1"); - cy.get("#submit").click(); + it("should accept the sample, refer the sample, and save the result", function () { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, "PCR"); + result.referSample(0, "Test not performed", "CEDRES"); + result.setResultValue(0, "Positive HIV1"); + result.submitResults(); }); }); describe("Result By Patient", function () { - before("navigate to Result By Unit", function () { + before("navigate to Result By Patient", function () { homePage = loginPage.goToHomePage(); result = homePage.goToResultsByPatient(); }); @@ -51,8 +47,8 @@ describe("Result By Patient", function () { it("User visits Results Page", function () { result.getResultTitle().should("contain.text", "Results"); }); + it("Should search Patient By First and LastName and validate", function () { - cy.wait(1000); cy.fixture("Patient").then((patient) => { patientPage.searchPatientByFirstAndLastName( patient.firstName, @@ -69,11 +65,10 @@ describe("Result By Patient", function () { patient.inValidName, ); }); - cy.wait(200).reload(); + cy.reload(); }); it("should search patient By PatientId and validate", function () { - cy.wait(1000); cy.fixture("Patient").then((patient) => { patientPage.searchPatientByPatientId(patient.nationalId); patientPage.clickSearchPatientButton(); @@ -85,19 +80,17 @@ describe("Result By Patient", function () { }); it("Should be able to search by respective patient and accept the result", function () { - cy.wait(1000); - cy.get( - "tbody > :nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance", - ).click(); - cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); - cy.get('[data-testid="expander-button-0"]').click(); - cy.get("#testMethod0").select("STAIN"); - cy.get("#submit").click(); + result.selectPatient(); + result.acceptResult(); + + result.expandSampleDetails(); + result.selectTestMethod(0, "STAIN"); + result.submitResults(); }); }); describe("Result By Order", function () { - before("navigate to Result By Unit", function () { + before("navigate to Result By Order", function () { homePage = loginPage.goToHomePage(); result = homePage.goToResultsByOrder(); }); @@ -106,7 +99,7 @@ describe("Result By Order", function () { result.getResultTitle().should("contain.text", "Results"); }); - it("Should Search by Unit", function () { + it("Should Search by Accession Number", function () { cy.fixture("EnteredOrder").then((order) => { cy.get("#accessionNumber").type(order.labNo); }); @@ -114,16 +107,15 @@ describe("Result By Order", function () { }); it("should accept the sample and save the result", function () { - // result.acceptSample(); - cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); - cy.get('[data-testid="expander-button-0"]').click(); - cy.get("#testMethod0").select("STAIN"); - cy.get(":nth-child(5) > #submit").click(); + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, "STAIN"); + result.submitResults(); }); }); -describe("Result By Reffered Out Tests", function () { - before("navigate to Result By Unit", function () { +describe("Result By Referred Out Tests", function () { + before("navigate to Result By Referred Out Tests", function () { homePage = loginPage.goToHomePage(); result = homePage.goToResultsForRefferedOut(); }); @@ -133,7 +125,6 @@ describe("Result By Reffered Out Tests", function () { }); it("should search Referrals By PatientId and validate", function () { - cy.wait(1000); cy.fixture("Patient").then((patient) => { patientPage.searchPatientByPatientId(patient.nationalId); patientPage.clickSearchPatientButton(); @@ -145,27 +136,18 @@ describe("Result By Reffered Out Tests", function () { }); it("should click respective patient and search for referred out tests", function () { - cy.wait(1000); - cy.get( - "tbody > :nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance", - ).click(); - cy.get(":nth-child(1) > :nth-child(5) > .cds--btn").click(); + result.selectPatient(); + result.search(); }); it("should validate the results", function () { cy.fixture("Patient").then((patient) => { - cy.get( - ".gridBoundary > .cds--sm\\:col-span-4 > .cds--data-table-container > .cds--data-table-content > .cds--data-table > tbody > tr > :nth-child(6)", - ).should("contain.text", patient.lastName); - cy.get( - ".gridBoundary > .cds--sm\\:col-span-4 > .cds--data-table-container > .cds--data-table-content > .cds--data-table > tbody > tr > :nth-child(7)", - ).should("contain.text", patient.firstName); + result.validatePatientResult(patient); }); cy.reload(); }); it("should search Referrals By Test Unit and validate", function () { - cy.wait(1000); cy.fixture("workplan").then((result) => { cy.get("#testnames-input").type(result.testName); cy.get("#testnames-item-0-item").click(); @@ -176,12 +158,10 @@ describe("Result By Reffered Out Tests", function () { "contain.text", "Western blot HIV", ); - cy.reload(); }); it("should search Referrals By LabNumber and validate", function () { - cy.wait(1000); cy.fixture("EnteredOrder").then((order) => { cy.get("#labNumberInput").type(order.labNo); }); @@ -196,19 +176,14 @@ describe("Result By Reffered Out Tests", function () { }); }); - it("should select the respecting reffered test and print the selected patient reports", function () { - cy.get( - "tbody > tr > .cds--table-column-checkbox > .cds--checkbox--inline > .cds--checkbox-label", - ).click(); - cy.get(":nth-child(6) > :nth-child(2) > .cds--btn") - .should("be.visible") - .click(); + it("should select the respecting referred test and print the selected patient reports", function () { + result.selectRefferedTest(); + result.printReport(); }); }); describe("Result By Range Of Order", function () { - before("navigate to Result By Unit", function () { - homePage = loginPage.goToHomePage(); + before("navigate to Result By Range Of Order", function () { result = homePage.goToResultsByRangeOrder(); }); @@ -216,7 +191,7 @@ describe("Result By Range Of Order", function () { result.getResultTitle().should("contain.text", "Results"); }); - it("Should Enter Lab Number Number and perform Search", function () { + it("Should Enter Lab Number and perform Search", function () { cy.fixture("EnteredOrder").then((order) => { cy.get("#startLabNo").type(order.labNo); }); @@ -224,17 +199,15 @@ describe("Result By Range Of Order", function () { }); it("Should Accept And Save the result", function () { - cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); - cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").select( - "Invalid", - ); - cy.get(".orderLegendBody > :nth-child(5) > #submit").click(); + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, "Invalid"); + result.submitResults(); }); }); describe("Result By Test And Status", function () { - before("navigate to Result By Unit", function () { - homePage = loginPage.goToHomePage(); + before("navigate to Result By Test And Status", function () { result = homePage.goToResultsByTestAndStatus(); }); @@ -242,12 +215,12 @@ describe("Result By Test And Status", function () { result.getResultTitle().should("contain.text", "Results"); }); - it("Should select testName, analysis status perform Search", function () { + it("Should select testName, analysis status, and perform Search", function () { cy.fixture("workplan").then((order) => { - cy.get("#testName").select(order.testName); + result.selectTestName(order.testName); }); - cy.get("#analysisStatus").select("Accepted by technician"); - cy.get(":nth-child(8) > #submit").click(); + result.selectAnalysisStatus("Accepted by technician"); + result.searchByTest(); }); it("Should Validate And accept the result", function () { @@ -257,9 +230,9 @@ describe("Result By Test And Status", function () { order.testName, ); }); - cy.get(".cds--checkbox-label").click(); - cy.get('[data-testid="expander-button-0"]').click(); - cy.get("#testMethod0").select("EIA"); - cy.get(":nth-child(5) > #submit").click(); + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, "EIA"); + result.submitResults(); }); }); diff --git a/frontend/cypress/pages/ResultsPage.js b/frontend/cypress/pages/ResultsPage.js index 9c3ecbba61..d55e8f396d 100644 --- a/frontend/cypress/pages/ResultsPage.js +++ b/frontend/cypress/pages/ResultsPage.js @@ -1,16 +1,82 @@ +class Result { + getResultTitle() { + return cy.get("section > h3"); + } + selectUnitType(unitType) { + cy.get("#unitType").select(unitType); + } -class Result { + acceptSample(index = 0) { + cy.get(`.cds--checkbox-label`).eq(index).click(); + } + + acceptResult() { + cy.get("#cell-accept-0 > .cds--form-item > .cds--checkbox-label").click(); + } + expandSampleDetails(index = 0) { + cy.get(`[data-testid="expander-button-${index}"]`).click(); + } - getResultTitle(){ - return cy.get('section > h3'); - } + selectTestMethod(index = 0, method) { + cy.get(`#testMethod${index}`).select(method); + } - + selectPatient() { + cy.get( + "tbody > :nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance", + ).click(); + } + search() { + cy.get(":nth-child(1) > :nth-child(5) > .cds--btn").click(); + } + searchByTest() { + cy.get(":nth-child(8) > #submit").click(); } - - export default Result; - \ No newline at end of file + + validatePatientResult(patient) { + cy.get( + ".gridBoundary > .cds--sm\\:col-span-4 > .cds--data-table-container > .cds--data-table-content > .cds--data-table > tbody > tr > :nth-child(6)", + ).should("contain.text", patient.lastName); + cy.get( + ".gridBoundary > .cds--sm\\:col-span-4 > .cds--data-table-container > .cds--data-table-content > .cds--data-table > tbody > tr > :nth-child(7)", + ).should("contain.text", patient.firstName); + } + + referSample(index = 0, reason, institute) { + cy.get(`#referralReason${index}`).select(reason); + cy.get(`#institute${index}`).select(institute); + } + + selectRefferedTest() { + cy.get( + "tbody > tr > .cds--table-column-checkbox > .cds--checkbox--inline > .cds--checkbox-label", + ).click(); + } + + selectAnalysisStatus(status) { + cy.get("#analysisStatus").select(status); + } + selectTestName(testName) { + cy.get("#testName").select(testName); + } + + printReport() { + cy.get(":nth-child(6) > :nth-child(2) > .cds--btn") + .should("be.visible") + .click(); + } + + setResultValue(index = 0, value) { + cy.get(`#resultValue${index}`).select(value); + } + + submitResults() { + cy.get("#submit").click(); + } +} + +export default Result; From 2d74b4261e9c2e7da560c24df973d42901911073 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 15:53:35 +0530 Subject: [PATCH 03/84] fixture fix --- frontend/cypress.config.js | 4 +- frontend/cypress/e2e/result.cy.js | 116 ++++++++++++++++---------- frontend/cypress/fixtures/result.json | 14 ++++ 3 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 frontend/cypress/fixtures/result.json diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 9bdd73c5a1..6f0634aa7c 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -14,8 +14,8 @@ module.exports = defineConfig({ "cypress/e2e/orderEntity.cy.js", "cypress/e2e/workplan.cy.js", "cypress/e2e/nonConform.cy.js", - "cypress/e2e/modifyOrder.cy.js", - "cypress/e2e/result.cy.js" + "cypress/e2e/result.cy.js", + "cypress/e2e/modifyOrder.cy.js" ]; return config; }, diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index 60860ccd3f..873a8bad4e 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -19,7 +19,9 @@ describe("Result By Unit", function () { }); it("User visits Results Page", function () { - result.getResultTitle().should("contain.text", "Results"); + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); }); it("Should Search by Unit", function () { @@ -29,12 +31,15 @@ describe("Result By Unit", function () { }); it("should accept the sample, refer the sample, and save the result", function () { - result.acceptSample(); - result.expandSampleDetails(); - result.selectTestMethod(0, "PCR"); - result.referSample(0, "Test not performed", "CEDRES"); - result.setResultValue(0, "Positive HIV1"); - result.submitResults(); + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.pcrTestMethod); + cy.get(':nth-child(3) > .cds--form-item > .cds--checkbox-label').click(); + result.referSample(0, res.testNotPerformed, res.cedres); + result.setResultValue(0, res.positiveResult); + result.submitResults(); + }); }); }); @@ -45,24 +50,24 @@ describe("Result By Patient", function () { }); it("User visits Results Page", function () { - result.getResultTitle().should("contain.text", "Results"); + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); }); it("Should search Patient By First and LastName and validate", function () { cy.fixture("Patient").then((patient) => { patientPage.searchPatientByFirstAndLastName( patient.firstName, - patient.lastName, + patient.lastName ); patientPage.getFirstName().should("have.value", patient.firstName); patientPage.getLastName().should("have.value", patient.lastName); - patientPage.getLastName().should("not.have.value", patient.inValidName); - patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, - patient.inValidName, + patient.inValidName ); }); cy.reload(); @@ -74,18 +79,19 @@ describe("Result By Patient", function () { patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, - patient.inValidName, + patient.inValidName ); }); }); it("Should be able to search by respective patient and accept the result", function () { - result.selectPatient(); - result.acceptResult(); - - result.expandSampleDetails(); - result.selectTestMethod(0, "STAIN"); - result.submitResults(); + cy.fixture("result").then((res) => { + result.selectPatient(); + result.acceptResult(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.stainTestMethod); + result.submitResults(); + }); }); }); @@ -96,7 +102,9 @@ describe("Result By Order", function () { }); it("User visits Results Page", function () { - result.getResultTitle().should("contain.text", "Results"); + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); }); it("Should Search by Accession Number", function () { @@ -107,10 +115,12 @@ describe("Result By Order", function () { }); it("should accept the sample and save the result", function () { - result.acceptSample(); - result.expandSampleDetails(); - result.selectTestMethod(0, "STAIN"); - result.submitResults(); + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.stainTestMethod); + result.submitResults(); + }); }); }); @@ -121,7 +131,9 @@ describe("Result By Referred Out Tests", function () { }); it("User visits Results Page", function () { - result.getResultTitle().should("contain.text", "Referrals"); + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.referralPageTitle); + }); }); it("should search Referrals By PatientId and validate", function () { @@ -130,7 +142,7 @@ describe("Result By Referred Out Tests", function () { patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, - patient.inValidName, + patient.inValidName ); }); }); @@ -148,16 +160,18 @@ describe("Result By Referred Out Tests", function () { }); it("should search Referrals By Test Unit and validate", function () { - cy.fixture("workplan").then((result) => { - cy.get("#testnames-input").type(result.testName); + cy.fixture("workplan").then((res) => { + cy.get("#testnames-input").type(res.testName); cy.get("#testnames-item-0-item").click(); cy.get(":nth-child(15) > .cds--btn").click({ force: true }); }); - cy.get("tbody > tr > :nth-child(8)").should( - "contain.text", - "Western blot HIV", - ); + cy.fixture("result").then((res) => { + cy.get("tbody > tr > :nth-child(8)").should( + "contain.text", + res.westernBlotHiv + ); + }); cy.reload(); }); @@ -171,7 +185,7 @@ describe("Result By Referred Out Tests", function () { cy.fixture("EnteredOrder").then((patient) => { cy.get("tbody > tr > :nth-child(3)").should( "contain.text", - patient.labNo, + patient.labNo ); }); }); @@ -188,7 +202,9 @@ describe("Result By Range Of Order", function () { }); it("User visits Results Page", function () { - result.getResultTitle().should("contain.text", "Results"); + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); }); it("Should Enter Lab Number and perform Search", function () { @@ -199,10 +215,12 @@ describe("Result By Range Of Order", function () { }); it("Should Accept And Save the result", function () { - result.acceptSample(); - result.expandSampleDetails(); - result.selectTestMethod(0, "Invalid"); - result.submitResults(); + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.invalidTestMethod); + result.submitResults(); + }); }); }); @@ -212,27 +230,33 @@ describe("Result By Test And Status", function () { }); it("User visits Results Page", function () { - result.getResultTitle().should("contain.text", "Results"); + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); }); it("Should select testName, analysis status, and perform Search", function () { cy.fixture("workplan").then((order) => { result.selectTestName(order.testName); }); - result.selectAnalysisStatus("Accepted by technician"); - result.searchByTest(); + cy.fixture("result").then((res) => { + result.selectAnalysisStatus(res.acceptedStatus); + result.searchByTest(); + }); }); it("Should Validate And accept the result", function () { cy.fixture("workplan").then((order) => { cy.get("#cell-testName-0 > .sampleInfo").should( "contain.text", - order.testName, + order.testName ); }); - result.acceptSample(); - result.expandSampleDetails(); - result.selectTestMethod(0, "EIA"); - result.submitResults(); + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.eiaTestMethod); + result.submitResults(); + }); }); }); diff --git a/frontend/cypress/fixtures/result.json b/frontend/cypress/fixtures/result.json new file mode 100644 index 0000000000..d3331d7821 --- /dev/null +++ b/frontend/cypress/fixtures/result.json @@ -0,0 +1,14 @@ +{ + "pageTitle": "Results", + "pcrTestMethod": "PCR", + "stainTestMethod": "STAIN", + "positiveResult": "Positive HIV1", + "referralPageTitle": "Referrals", + "westernBlotHiv": "Western blot HIV", + "acceptedStatus": "Accepted by technician", + "eiaTestMethod": "EIA", + "invalidTestMethod": "Invalid", + "testNotPerformed": "Test not performed", + "cedres": "CEDRES" + } + \ No newline at end of file From 9ad946da3d0659f8e6d0ebf28ddda99cb60002f4 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 20:47:40 +0530 Subject: [PATCH 04/84] minor fix --- frontend/cypress/e2e/result.cy.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index 873a8bad4e..45fdf0cbb5 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -4,11 +4,12 @@ import Result from "../pages/ResultsPage"; import PatientEntryPage from "../pages/PatientEntryPage"; let homePage = null; -let loginPage = new LoginPage(); +let loginPage = null; let result = null; let patientPage = new PatientEntryPage(); before("login", () => { + loginPage = new LoginPage(); loginPage.visit(); }); @@ -85,6 +86,7 @@ describe("Result By Patient", function () { }); it("Should be able to search by respective patient and accept the result", function () { + cy.wait(1000); cy.fixture("result").then((res) => { result.selectPatient(); result.acceptResult(); @@ -153,6 +155,7 @@ describe("Result By Referred Out Tests", function () { }); it("should validate the results", function () { + cy.wait(1000); cy.fixture("Patient").then((patient) => { result.validatePatientResult(patient); }); @@ -198,6 +201,7 @@ describe("Result By Referred Out Tests", function () { describe("Result By Range Of Order", function () { before("navigate to Result By Range Of Order", function () { + homePage = loginPage.goToHomePage(); result = homePage.goToResultsByRangeOrder(); }); @@ -215,6 +219,7 @@ describe("Result By Range Of Order", function () { }); it("Should Accept And Save the result", function () { + cy.wait(1000); cy.fixture("result").then((res) => { result.acceptSample(); result.expandSampleDetails(); @@ -226,6 +231,7 @@ describe("Result By Range Of Order", function () { describe("Result By Test And Status", function () { before("navigate to Result By Test And Status", function () { + homePage = loginPage.goToHomePage() result = homePage.goToResultsByTestAndStatus(); }); From e67d783ffe11aaebbe68c2303bf4d9282dfa153b Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 21:05:46 +0530 Subject: [PATCH 05/84] minor fix check --- frontend/cypress/e2e/result.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index 45fdf0cbb5..24e1438f88 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -46,7 +46,6 @@ describe("Result By Unit", function () { describe("Result By Patient", function () { before("navigate to Result By Patient", function () { - homePage = loginPage.goToHomePage(); result = homePage.goToResultsByPatient(); }); From ebd32d6d987746e658b765adb462ee455219f01a Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 21:48:42 +0530 Subject: [PATCH 06/84] retrigger check --- frontend/cypress/e2e/result.cy.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index 24e1438f88..bc309dfe11 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -82,12 +82,20 @@ describe("Result By Patient", function () { patient.inValidName ); }); + cy.reload(); + }); + + it("should search patient By Lab Number and validate", function () { + cy.fixture("EnteredOrder").then((patient) => { + cy.get('#labNumber').type(patient.labNo); + patientPage.clickSearchPatientButton(); + }); }); it("Should be able to search by respective patient and accept the result", function () { cy.wait(1000); + result.selectPatient(); cy.fixture("result").then((res) => { - result.selectPatient(); result.acceptResult(); result.expandSampleDetails(); result.selectTestMethod(0, res.stainTestMethod); @@ -137,9 +145,15 @@ describe("Result By Referred Out Tests", function () { }); }); - it("should search Referrals By PatientId and validate", function () { + it("should search Referrals By Patient and validate", function () { cy.fixture("Patient").then((patient) => { patientPage.searchPatientByPatientId(patient.nationalId); + patientPage.searchPatientByFirstAndLastName( + patient.firstName, + patient.lastName + ); + patientPage.getFirstName().should("have.value", patient.firstName); + patientPage.getLastName().should("have.value", patient.lastName); patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, @@ -222,7 +236,7 @@ describe("Result By Range Of Order", function () { cy.fixture("result").then((res) => { result.acceptSample(); result.expandSampleDetails(); - result.selectTestMethod(0, res.invalidTestMethod); + result.selectTestMethod(0, res.eiaTestMethod); result.submitResults(); }); }); From 1ea17a11e9f286dec891bd11ca92ce45eeae6ef7 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Mon, 29 Jul 2024 22:28:43 +0530 Subject: [PATCH 07/84] formatting fix --- frontend/cypress.config.js | 4 +-- frontend/cypress/e2e/result.cy.js | 22 ++++++++-------- frontend/cypress/fixtures/result.json | 25 +++++++++---------- frontend/cypress/pages/HomePage.js | 36 +++++++++++++-------------- 4 files changed, 43 insertions(+), 44 deletions(-) diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 6f0634aa7c..1f3a3f7a9e 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -4,7 +4,7 @@ module.exports = defineConfig({ defaultCommandTimeout: 8000, viewportWidth: 1200, viewportHeight: 700, - watchForFileChanges:false, + watchForFileChanges: false, e2e: { setupNodeEvents(on, config) { // implement node event listeners here @@ -15,7 +15,7 @@ module.exports = defineConfig({ "cypress/e2e/workplan.cy.js", "cypress/e2e/nonConform.cy.js", "cypress/e2e/result.cy.js", - "cypress/e2e/modifyOrder.cy.js" + "cypress/e2e/modifyOrder.cy.js", ]; return config; }, diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index bc309dfe11..46124f9525 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -36,7 +36,7 @@ describe("Result By Unit", function () { result.acceptSample(); result.expandSampleDetails(); result.selectTestMethod(0, res.pcrTestMethod); - cy.get(':nth-child(3) > .cds--form-item > .cds--checkbox-label').click(); + cy.get(":nth-child(3) > .cds--form-item > .cds--checkbox-label").click(); result.referSample(0, res.testNotPerformed, res.cedres); result.setResultValue(0, res.positiveResult); result.submitResults(); @@ -59,7 +59,7 @@ describe("Result By Patient", function () { cy.fixture("Patient").then((patient) => { patientPage.searchPatientByFirstAndLastName( patient.firstName, - patient.lastName + patient.lastName, ); patientPage.getFirstName().should("have.value", patient.firstName); patientPage.getLastName().should("have.value", patient.lastName); @@ -67,7 +67,7 @@ describe("Result By Patient", function () { patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, - patient.inValidName + patient.inValidName, ); }); cy.reload(); @@ -79,7 +79,7 @@ describe("Result By Patient", function () { patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, - patient.inValidName + patient.inValidName, ); }); cy.reload(); @@ -87,7 +87,7 @@ describe("Result By Patient", function () { it("should search patient By Lab Number and validate", function () { cy.fixture("EnteredOrder").then((patient) => { - cy.get('#labNumber').type(patient.labNo); + cy.get("#labNumber").type(patient.labNo); patientPage.clickSearchPatientButton(); }); }); @@ -150,14 +150,14 @@ describe("Result By Referred Out Tests", function () { patientPage.searchPatientByPatientId(patient.nationalId); patientPage.searchPatientByFirstAndLastName( patient.firstName, - patient.lastName + patient.lastName, ); patientPage.getFirstName().should("have.value", patient.firstName); patientPage.getLastName().should("have.value", patient.lastName); patientPage.clickSearchPatientButton(); patientPage.validatePatientSearchTable( patient.firstName, - patient.inValidName + patient.inValidName, ); }); }); @@ -185,7 +185,7 @@ describe("Result By Referred Out Tests", function () { cy.fixture("result").then((res) => { cy.get("tbody > tr > :nth-child(8)").should( "contain.text", - res.westernBlotHiv + res.westernBlotHiv, ); }); cy.reload(); @@ -201,7 +201,7 @@ describe("Result By Referred Out Tests", function () { cy.fixture("EnteredOrder").then((patient) => { cy.get("tbody > tr > :nth-child(3)").should( "contain.text", - patient.labNo + patient.labNo, ); }); }); @@ -244,7 +244,7 @@ describe("Result By Range Of Order", function () { describe("Result By Test And Status", function () { before("navigate to Result By Test And Status", function () { - homePage = loginPage.goToHomePage() + homePage = loginPage.goToHomePage(); result = homePage.goToResultsByTestAndStatus(); }); @@ -268,7 +268,7 @@ describe("Result By Test And Status", function () { cy.fixture("workplan").then((order) => { cy.get("#cell-testName-0 > .sampleInfo").should( "contain.text", - order.testName + order.testName, ); }); cy.fixture("result").then((res) => { diff --git a/frontend/cypress/fixtures/result.json b/frontend/cypress/fixtures/result.json index d3331d7821..dc0bcbec8e 100644 --- a/frontend/cypress/fixtures/result.json +++ b/frontend/cypress/fixtures/result.json @@ -1,14 +1,13 @@ { - "pageTitle": "Results", - "pcrTestMethod": "PCR", - "stainTestMethod": "STAIN", - "positiveResult": "Positive HIV1", - "referralPageTitle": "Referrals", - "westernBlotHiv": "Western blot HIV", - "acceptedStatus": "Accepted by technician", - "eiaTestMethod": "EIA", - "invalidTestMethod": "Invalid", - "testNotPerformed": "Test not performed", - "cedres": "CEDRES" - } - \ No newline at end of file + "pageTitle": "Results", + "pcrTestMethod": "PCR", + "stainTestMethod": "STAIN", + "positiveResult": "Positive HIV1", + "referralPageTitle": "Referrals", + "westernBlotHiv": "Western blot HIV", + "acceptedStatus": "Accepted by technician", + "eiaTestMethod": "EIA", + "invalidTestMethod": "Invalid", + "testNotPerformed": "Test not performed", + "cedres": "CEDRES" +} diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index 5eefd9974a..37ea03ef6d 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -91,45 +91,45 @@ class HomePage { return new NonConform(); } - goToResultsByUnit(){ + goToResultsByUnit() { this.openNavigationMenu(); - cy.get('#menu_results').click(); - cy.get('#menu_results_logbook').click(); + cy.get("#menu_results").click(); + cy.get("#menu_results_logbook").click(); return new Result(); } - goToResultsByOrder(){ + goToResultsByOrder() { this.openNavigationMenu(); - cy.get('#menu_results').click(); - cy.get('#menu_results_accession').click(); + cy.get("#menu_results").click(); + cy.get("#menu_results_accession").click(); return new Result(); } - goToResultsByPatient(){ + goToResultsByPatient() { this.openNavigationMenu(); - cy.get('#menu_results').click(); - cy.get('#menu_results_patient').click(); + cy.get("#menu_results").click(); + cy.get("#menu_results_patient").click(); return new Result(); } - goToResultsForRefferedOut(){ + goToResultsForRefferedOut() { this.openNavigationMenu(); - cy.get('#menu_results').click(); - cy.get('#menu_results_referred ').click(); + cy.get("#menu_results").click(); + cy.get("#menu_results_referred ").click(); return new Result(); } - goToResultsByRangeOrder(){ + goToResultsByRangeOrder() { this.openNavigationMenu(); - cy.get('#menu_results').click(); - cy.get('#menu_results_range').click(); + cy.get("#menu_results").click(); + cy.get("#menu_results_range").click(); return new Result(); } - goToResultsByTestAndStatus(){ + goToResultsByTestAndStatus() { this.openNavigationMenu(); - cy.get('#menu_results').click(); - cy.get('#menu_results_status').click(); + cy.get("#menu_results").click(); + cy.get("#menu_results_status").click(); return new Result(); } } From 482ec16b8af9210c1b5d38990b88849f7d7bd2c1 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Wed, 7 Aug 2024 21:18:19 +0530 Subject: [PATCH 08/84] Coverage for Validation --- frontend/cypress.config.js | 1 + frontend/cypress/e2e/validation.cy.js | 72 +++++++++++++++++++++++++++ frontend/cypress/pages/HomePage.js | 20 ++++++++ frontend/cypress/pages/Validation.js | 28 +++++++++++ 4 files changed, 121 insertions(+) create mode 100644 frontend/cypress/e2e/validation.cy.js create mode 100644 frontend/cypress/pages/Validation.js diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 1f3a3f7a9e..e6396cb238 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -15,6 +15,7 @@ module.exports = defineConfig({ "cypress/e2e/workplan.cy.js", "cypress/e2e/nonConform.cy.js", "cypress/e2e/result.cy.js", + "cypress/e2e/validation.cy.js", "cypress/e2e/modifyOrder.cy.js", ]; return config; diff --git a/frontend/cypress/e2e/validation.cy.js b/frontend/cypress/e2e/validation.cy.js new file mode 100644 index 0000000000..4aecae333a --- /dev/null +++ b/frontend/cypress/e2e/validation.cy.js @@ -0,0 +1,72 @@ +import LoginPage from "../pages/LoginPage"; +import HomePage from "../pages/HomePage"; +import PatientEntryPage from "../pages/PatientEntryPage"; +import Validation from "../pages/Validation"; + +let homePage = null; +let loginPage = null; +let validation = null; +let patientPage = new PatientEntryPage(); + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +const navigateToValidationPage = (validationType) => { + homePage = loginPage.goToHomePage(); + validation = homePage[`goToValidationBy${validationType}`](); +}; + +describe("Validation By Routine", function () { + before("navigate to Validation Page", function () { + navigateToValidationPage("Routine"); + }); + + it("User visits Validation Page", function () { + validation.checkForHeading(); + }); + + it("Should Select Test Unit From Drop-Down And Validate", function () { + cy.fixture("workplan").then((order) => { + validation.selectTestUnit(order.unitType); + validation.validateTestUnit(order.testName); + }); + }); +}); + +describe("Validation By Order", function () { + before("navigate to Validation Page", function () { + navigateToValidationPage("Order"); + }); + + it("User visits Validation Page", function () { + validation.checkForHeading(); + }); + + it("Should Enter Lab Number, make a search and validate", function () { + cy.fixture("EnteredOrder").then((order) => { + validation.enterLabNumberAndSearch(order.labNo); + }); + }); +}); + +describe("Validation By Range Of Order", function () { + before("navigate to Validation Page", function () { + navigateToValidationPage("RangeOrder"); + }); + + it("User visits Validation Page", function () { + validation.checkForHeading(); + }); + + it("Should Enter Lab Number and perform a search", function () { + cy.fixture("EnteredOrder").then((order) => { + validation.enterLabNumberAndSearch(order.labNo); + }); + }); + + it("Should Save the results", function () { + validation.saveResults('Test Note'); + }); +}); diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index 37ea03ef6d..d8cdb164e8 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -5,6 +5,7 @@ import ModifyOrderPage from "./ModifyOrderPage"; import WorkPlan from "./WorkPlan"; import NonConform from "./NonConformPage"; import Result from "./ResultsPage"; +import Validation from "./Validation"; class HomePage { constructor() {} @@ -132,6 +133,25 @@ class HomePage { cy.get("#menu_results_status").click(); return new Result(); } + + goToValidationByRoutine() { + this.openNavigationMenu(); + cy.get('#menu_resultvalidation').click(); + cy.get('#menu_resultvalidation_routine ').click(); + return new Validation(); + } + goToValidationByOrder() { + this.openNavigationMenu(); + cy.get("#menu_resultvalidation").click(); + cy.get('#menu_accession_validation ').click(); + return new Validation(); + } + goToValidationByRangeOrder() { + this.openNavigationMenu(); + cy.get("#menu_resultvalidation").click(); + cy.get('#menu_accession_validation_range ').click(); + return new Validation(); + } } export default HomePage; diff --git a/frontend/cypress/pages/Validation.js b/frontend/cypress/pages/Validation.js new file mode 100644 index 0000000000..5ffe488596 --- /dev/null +++ b/frontend/cypress/pages/Validation.js @@ -0,0 +1,28 @@ +class Validation { + checkForHeading() { + cy.get('section > h3').should("contain.text", "Validation"); + } + + selectTestUnit(unitType) { + cy.get('#unitType').select(unitType); + } + + validateTestUnit(unitType) { + cy.get('#cell-testName-0 > .sampleInfo').should("contain.text", unitType); + } + + enterLabNumberAndSearch(labNo) { + cy.get('#accessionNumber').type(labNo); + cy.get('.cds--sm\\:col-span-4.cds--lg\\:col-span-16 > #submit').click(); + cy.get('#cell-sampleInfo-0 > .sampleInfo').should("contain.text", labNo); + } + + saveResults(note) { + cy.get('#cell-save-0 > .cds--form-item > .cds--checkbox-label').click(); + cy.get('#resultList0\\.note').type(note); + cy.get(':nth-child(3) > #submit').click(); + } + } + + export default Validation; + \ No newline at end of file From ce488ba486f503abd3fe91b8f51afecda290ecaa Mon Sep 17 00:00:00 2001 From: Manish Jha Date: Mon, 12 Aug 2024 17:12:53 +0530 Subject: [PATCH 09/84] Initial changes --- frontend/cypress.config.js | 1 + frontend/cypress/e2e/abctest.js | 302 ++++++++++++++++++ frontend/cypress/e2e/report.cy.js | 119 +++++++ frontend/cypress/pages/HomePage.js | 13 + frontend/cypress/pages/ReportPage.js | 117 +++++++ .../components/reports/common/ReportByDate.js | 2 +- .../reports/common/ReportByLabNo.js | 4 +- 7 files changed, 556 insertions(+), 2 deletions(-) create mode 100644 frontend/cypress/e2e/abctest.js create mode 100644 frontend/cypress/e2e/report.cy.js create mode 100644 frontend/cypress/pages/ReportPage.js diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 0755f9764e..508a0919a4 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -15,6 +15,7 @@ module.exports = defineConfig({ "cypress/e2e/nonConform.cy.js", "cypress/e2e/modifyOrder.cy.js", "cypress/e2e/batchOrderEntry.cy.js", + "cypress/e2e/report.cy.js", ]; return config; }, diff --git a/frontend/cypress/e2e/abctest.js b/frontend/cypress/e2e/abctest.js new file mode 100644 index 0000000000..b4e9c31314 --- /dev/null +++ b/frontend/cypress/e2e/abctest.js @@ -0,0 +1,302 @@ +import LoginPage from "../pages/LoginPage"; + +let homePage = null; +let loginPage = null; +let report = null; + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +describe("Routine Reports", function () { + it("User Visits Routine Reports", function () { + homePage = loginPage.goToHomePage(); + report = homePage.goToRoutineReports(); + // workplan + // .getWorkPlanFilterTitle() + // .should("contain.text", "Workplan By Test"); + // workplan.getTestTypeOrPanelSelector().should("be.visible"); + }); + + it("User Visits Patint Status Report and check for Respective Forms", () => { + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + + + cy.get('section > h3').should('have.text', 'Patient Status Report'); + //clicks on report by patient + cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); + cy.get('#patientId').should('be.visible'); + cy.get('#local_search').should('be.visible'); + cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); + + + //clicks on Report By Lab No and validates field forms + cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); + cy.get('#from').should('be.visible'); + cy.get('#to').should('be.visible'); + cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); + + + //clicks on generate report by site and checks for respective fields + cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').click(); + cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').should('be.visible'); + cy.get('#downshift-1-toggle-button').should('be.visible'); + cy.get('.cds--date-picker-input__wrapper > #startDate').should('be.visible'); + + //checks for print button + cy.get(':nth-child(7) > :nth-child(2) > .cds--btn').should('be.visible'); + }); + + + it("Should Visit Statistics Reports ", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + + cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + + cy.get('section > h3').should('have.text', 'Statistics Report'); + for (let i = 2; i <= 11; i++) { + cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i}) input[type="checkbox"]`) + .check({ force: true }) // Force the check action + .should('be.checked'); + } + + + + + // Verify that the "All" checkbox is now checked + // cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1)').should('be.checked'); + // Verify that the "All" checkbox is now checked +cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') +.should('be.checked'); + + }); + + it('Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { + // First, check all individual checkboxes + for (let i = 2; i <= 11; i++) { + cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i})`).click(); + } + + // Ensure the "All" checkbox is checked + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') +.should('be.checked'); + // cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1)').check({ force: true }).should('be.checked'); + + // Now, uncheck one individual checkbox (e.g., the first one) + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(2)').click().should('not.be.checked'); + + // Verify that the "All" checkbox is now unchecked + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1)').should('not.be.checked'); + + + }); + + + //for checking checkboxes of priority wala + // ------------------------------------------------------------------------------------------------------------------------------------ + + it('Should check the "All" checkbox when all individual checkboxes in .inlineDiv are checked', () => { + // Click on each individual checkbox to check them (from 2 to 6) + for (let i = 2; i <= 6; i++) { + cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); + } + + // Verify that the "All" checkbox is now checked + cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]') + .should('be.checked'); + + }); + + it('Should uncheck the "All" checkbox if any individual checkbox in .inlineDiv is unchecked', () => { + // First, check all individual checkboxes (from 2 to 6) + for (let i = 2; i <= 6; i++) { + cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); + } + + // Ensure the "All" checkbox is checked + // cy.get('.inlineDiv > :nth-child(1) > .cds--checkbox-label ').should('be.checked'); + // Verify that the "All" checkbox is checked +cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]') +.should('not.be.checked'); + + + // Now, uncheck one individual checkbox (e.g., the second one) + cy.get('.inlineDiv > :nth-child(2) > .cds--checkbox-label').click(); + + // Verify that the "All" checkbox is now unchecked + cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); + + //checks all the time frames + cy.get(':nth-child(3) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) > .cds--checkbox-label').click(); + + }); + + + it("should check for print button", () => { + cy.get(':nth-child(6) > .cds--btn').should('be.visible'); + }); + + + // Summary of all test + it("Visits Summary of all tests", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + + cy.get('h1').should('have.text', 'Test Report Summary'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + + }); + it("Visits HIV Test Summary and validates", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(3) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + + }); + it("Visits Rejection Report and validates", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(3) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(3) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Rejection Report'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + + }); + + it("Visits Activity Report By Test Type", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(4) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(4) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Activity report By test'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('#type').select('Amylase(Serum)', { force: true }); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + + }); + it("Visits Activity Report By Panel Type", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(4) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(4) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Activity report By Panel'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('#type').select('NFS', { force: true }); + + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + + }); + it("Visits Activity Report By Unit", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(4) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(4) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(3) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Activity report By Test Section'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('#type').select('Biochemistry', { force: true }); + + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + }); + + it("Visits Reffered Out Test Report", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(5) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(5) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h3').should('have.text', 'External Refferals Report'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('.cds--date-picker-input__wrapper > #endDate').type('02/02/2023'); + cy.get('#locationcode').select('CEDRES', { force: true }); + + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + }); + + + it("Visits Non Conformity Report By Date", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(5) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(5) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Non ConformityReport by Date'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + + + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + }); + + + it("Visits Non Conformity Report By Unit and Reason", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(5) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(5) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Non Conformity Report by Unit and Reason'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + + + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + }); + + + it("Visits Export Routine CSV file", () => { + + cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports + + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(9) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(9) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('h1').should('have.text', 'Export Routine CSV file'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + + + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + + + }); +}); \ No newline at end of file diff --git a/frontend/cypress/e2e/report.cy.js b/frontend/cypress/e2e/report.cy.js new file mode 100644 index 0000000000..054aa13938 --- /dev/null +++ b/frontend/cypress/e2e/report.cy.js @@ -0,0 +1,119 @@ +import LoginPage from "../pages/LoginPage"; +import ReportPage from "../pages/ReportPage"; + +let homePage = null; +let loginPage = null; +let reportPage =null; + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +describe("Routine Reports", function () { + it("User Visits Routine Reports", function () { + homePage = loginPage.goToHomePage(); + // reportPage.visitRoutineReports(); + reportPage = homePage.goToRoutineReports(); + + // Additional checks can go here + }); + + it("User Visits Patient Status Report and check for Respective Forms", () => { + // reportPage.visitRoutineReports(); + reportPage.navigateToReport(1, 1); + cy.get('section > h3').should('have.text', 'Patient Status Report'); + reportPage.checkAccordionVisibility(2, ['#patientId', '#local_search']); + reportPage.checkAccordionVisibility(3, ['#from', '#to']); + reportPage.checkAccordionVisibility(6, ['#downshift-1-toggle-button', '.cds--date-picker-input__wrapper > #startDate']); + reportPage.checkPrintButton(':nth-child(7) > :nth-child(2) > .cds--btn'); + }); + + it("Should Visit Statistics Reports", () => { + reportPage.visitRoutineReports(); + reportPage.navigateToReport(2, 1); + cy.get('section > h3').should('have.text', 'Statistics Report'); + reportPage.checkCheckboxGroup(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2, 11); + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('be.checked'); + }); + + it('Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { + reportPage.visitRoutineReports(); + reportPage.navigateToReport(2, 1); + reportPage.uncheckIndividualCheckbox(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2); + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); + }); + + it('Should check the "All" checkbox when all individual checkboxes in .inlineDiv are checked', () => { + reportPage.checkAllCheckboxes('.inlineDiv', 2, 6); + }); + + it("should check for print button", () => { + reportPage.checkPrintButton(':nth-child(6) > .cds--btn'); + }); + + it("Visits Summary of all tests", () => { + reportPage.visitSummaryTest(2, 'Test Report Summary'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits HIV Test Summary and validates", () => { + reportPage.visitSummaryTest(3, 'HIV Test Summary'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Rejection Report and validates", () => { + reportPage.visitSummaryTest(3, 'Rejection Report'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Activity Report By Test Type", () => { + reportPage.visitSummaryTest(4, 'Activity report By test'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.selectDropdown('#type', 'Amylase(Serum)'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Activity Report By Panel Type", () => { + reportPage.visitSummaryTest(4, 'Activity report By Panel'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.selectDropdown('#type', 'NFS'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Activity Report By Unit", () => { + reportPage.visitSummaryTest(4, 'Activity report By Test Section'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.selectDropdown('#type', 'Biochemistry'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Referred Out Test Report", () => { + reportPage.visitSummaryTest(5, 'External Referrals Report'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #endDate', '02/02/2023'); + reportPage.selectDropdown('#locationcode', 'CEDRES'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Non Conformity Report By Date", () => { + reportPage.visitSummaryTest(5, 'Non Conformity Report by Date'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Non Conformity Report By Unit and Reason", () => { + reportPage.visitSummaryTest(5, 'Non Conformity Report by Unit and Reason'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Patient Reports", () => { + reportPage.visitSummaryTest(7, 'Patient Report'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); +}); diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index 4175ff4691..6b1d59a86d 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -5,6 +5,7 @@ import ModifyOrderPage from "./ModifyOrderPage"; import WorkPlan from "./WorkPlan"; import NonConform from "./NonConformPage"; import BatchOrderEntry from "./BatchOrderEntryPage"; +import ReportPage from "./ReportPage"; class HomePage { constructor() {} @@ -97,6 +98,18 @@ class HomePage { cy.get("#menu_non_conforming_corrective_actions").click(); return new NonConform(); } + goToRoutineReports() { + this.openNavigationMenu(); + cy.get('#menu_reports').click(); + cy.get('#menu_reports_routine').click(); + return new ReportPage(); + } + goToStudyReports() { + this.openNavigationMenu(); + cy.get('#menu_reports').click(); + cy.get('#menu_reports_study').click(); + return new ReportPage(); + } } export default HomePage; diff --git a/frontend/cypress/pages/ReportPage.js b/frontend/cypress/pages/ReportPage.js new file mode 100644 index 0000000000..39bc6a3758 --- /dev/null +++ b/frontend/cypress/pages/ReportPage.js @@ -0,0 +1,117 @@ +class ReportPage { + visitRoutineReports() { + cy.get(':nth-child(2) > .cds--link').click(); // visits routine reports + } + + visitPatientStatusReport() { + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + } + + validatePatientStatusReport() { + cy.get('section > h3').should('have.text', 'Patient Status Report'); + } + + validateReportByPatient() { + cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); + cy.get('#patientId').should('be.visible'); + cy.get('#local_search').should('be.visible'); + cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); + } + + validateReportByLabNo() { + cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); + cy.get('#from').should('be.visible'); + cy.get('#to').should('be.visible'); + cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); + } + + validateReportBySite() { + cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').click(); + cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').should('be.visible'); + cy.get('#downshift-1-toggle-button').should('be.visible'); + cy.get('.cds--date-picker-input__wrapper > #startDate').should('be.visible'); + } + + validatePrintButton() { + cy.get(':nth-child(7) > :nth-child(2) > .cds--btn').should('be.visible'); + } + + visitStatisticsReport() { + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + } + + validateStatisticsReport() { + cy.get('section > h3').should('have.text', 'Statistics Report'); + } + + checkAllStatisticsCheckboxes() { + for (let i = 2; i <= 11; i++) { + cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i}) input[type="checkbox"]`) + .check({ force: true }) + .should('be.checked'); + } + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') + .should('be.checked'); + } + + uncheckAllCheckboxes() { + for (let i = 2; i <= 11; i++) { + cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i})`).click(); + } + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') + .should('not.be.checked'); + } + + checkPriorityAllCheckboxes() { + for (let i = 2; i <= 6; i++) { + cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); + } + cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]').should('be.checked'); + } + + uncheckPriorityCheckboxes() { + for (let i = 2; i <= 6; i++) { + cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); + } + cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); + } + + visitSummaryOfAllTests() { + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + } + + validateSummaryOfAllTests() { + cy.get('h1').should('have.text', 'Test Report Summary'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + } + + visitHIVTestSummary() { + cy.get(':nth-child(2) > .cds--side-nav__menu > :nth-child(3) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + } + + visitRejectionReport() { + cy.get(':nth-child(3) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(3) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + } + + visitActivityReportByTestType() { + cy.get(':nth-child(4) > .cds--side-nav__submenu').click(); + cy.get(':nth-child(4) > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__link').click(); + } + + validateActivityReportByTestType() { + cy.get('h1').should('have.text', 'Activity report By test'); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); + cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); + cy.get('#type').select('Amylase(Serum)', { force: true }); + cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); + } + } + + export default ReportPage; + \ No newline at end of file diff --git a/frontend/src/components/reports/common/ReportByDate.js b/frontend/src/components/reports/common/ReportByDate.js index 6c653a5ade..6a1a2f044e 100644 --- a/frontend/src/components/reports/common/ReportByDate.js +++ b/frontend/src/components/reports/common/ReportByDate.js @@ -245,7 +245,7 @@ const ReportByDate = (props) => { )} - From 6d18d03e56a3d2f7028dfb8bf4e44df2678e6c0a Mon Sep 17 00:00:00 2001 From: Manish Jha Date: Thu, 15 Aug 2024 17:09:10 +0530 Subject: [PATCH 10/84] E2E coverage for Routine and Study Report --- frontend/cypress/e2e/abctest.js | 302 ---------------- frontend/cypress/e2e/bcctest.js | 123 +++++++ frontend/cypress/e2e/report.cy.js | 312 ++++++++++++---- frontend/cypress/pages/HomePage.js | 11 +- frontend/cypress/pages/ReportPage.js | 117 ------ frontend/cypress/pages/RoutineReportPage.js | 67 ++++ frontend/cypress/pages/StudyReportPage.js | 341 ++++++++++++++++++ .../components/reports/common/ReportByID.js | 2 +- 8 files changed, 788 insertions(+), 487 deletions(-) delete mode 100644 frontend/cypress/e2e/abctest.js create mode 100644 frontend/cypress/e2e/bcctest.js delete mode 100644 frontend/cypress/pages/ReportPage.js create mode 100644 frontend/cypress/pages/RoutineReportPage.js create mode 100644 frontend/cypress/pages/StudyReportPage.js diff --git a/frontend/cypress/e2e/abctest.js b/frontend/cypress/e2e/abctest.js deleted file mode 100644 index b4e9c31314..0000000000 --- a/frontend/cypress/e2e/abctest.js +++ /dev/null @@ -1,302 +0,0 @@ -import LoginPage from "../pages/LoginPage"; - -let homePage = null; -let loginPage = null; -let report = null; - -before("login", () => { - loginPage = new LoginPage(); - loginPage.visit(); -}); - -describe("Routine Reports", function () { - it("User Visits Routine Reports", function () { - homePage = loginPage.goToHomePage(); - report = homePage.goToRoutineReports(); - // workplan - // .getWorkPlanFilterTitle() - // .should("contain.text", "Workplan By Test"); - // workplan.getTestTypeOrPanelSelector().should("be.visible"); - }); - - it("User Visits Patint Status Report and check for Respective Forms", () => { - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - - - cy.get('section > h3').should('have.text', 'Patient Status Report'); - //clicks on report by patient - cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); - cy.get('#patientId').should('be.visible'); - cy.get('#local_search').should('be.visible'); - cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); - - - //clicks on Report By Lab No and validates field forms - cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); - cy.get('#from').should('be.visible'); - cy.get('#to').should('be.visible'); - cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); - - - //clicks on generate report by site and checks for respective fields - cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').click(); - cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').should('be.visible'); - cy.get('#downshift-1-toggle-button').should('be.visible'); - cy.get('.cds--date-picker-input__wrapper > #startDate').should('be.visible'); - - //checks for print button - cy.get(':nth-child(7) > :nth-child(2) > .cds--btn').should('be.visible'); - }); - - - it("Should Visit Statistics Reports ", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - - cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - - cy.get('section > h3').should('have.text', 'Statistics Report'); - for (let i = 2; i <= 11; i++) { - cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i}) input[type="checkbox"]`) - .check({ force: true }) // Force the check action - .should('be.checked'); - } - - - - - // Verify that the "All" checkbox is now checked - // cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1)').should('be.checked'); - // Verify that the "All" checkbox is now checked -cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') -.should('be.checked'); - - }); - - it('Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { - // First, check all individual checkboxes - for (let i = 2; i <= 11; i++) { - cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i})`).click(); - } - - // Ensure the "All" checkbox is checked - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') -.should('be.checked'); - // cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1)').check({ force: true }).should('be.checked'); - - // Now, uncheck one individual checkbox (e.g., the first one) - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(2)').click().should('not.be.checked'); - - // Verify that the "All" checkbox is now unchecked - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1)').should('not.be.checked'); - - - }); - - - //for checking checkboxes of priority wala - // ------------------------------------------------------------------------------------------------------------------------------------ - - it('Should check the "All" checkbox when all individual checkboxes in .inlineDiv are checked', () => { - // Click on each individual checkbox to check them (from 2 to 6) - for (let i = 2; i <= 6; i++) { - cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); - } - - // Verify that the "All" checkbox is now checked - cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]') - .should('be.checked'); - - }); - - it('Should uncheck the "All" checkbox if any individual checkbox in .inlineDiv is unchecked', () => { - // First, check all individual checkboxes (from 2 to 6) - for (let i = 2; i <= 6; i++) { - cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); - } - - // Ensure the "All" checkbox is checked - // cy.get('.inlineDiv > :nth-child(1) > .cds--checkbox-label ').should('be.checked'); - // Verify that the "All" checkbox is checked -cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]') -.should('not.be.checked'); - - - // Now, uncheck one individual checkbox (e.g., the second one) - cy.get('.inlineDiv > :nth-child(2) > .cds--checkbox-label').click(); - - // Verify that the "All" checkbox is now unchecked - cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); - - //checks all the time frames - cy.get(':nth-child(3) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) > .cds--checkbox-label').click(); - - }); - - - it("should check for print button", () => { - cy.get(':nth-child(6) > .cds--btn').should('be.visible'); - }); - - - // Summary of all test - it("Visits Summary of all tests", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - - cy.get('h1').should('have.text', 'Test Report Summary'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - - }); - it("Visits HIV Test Summary and validates", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(3) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - - }); - it("Visits Rejection Report and validates", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(3) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(3) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Rejection Report'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - - }); - - it("Visits Activity Report By Test Type", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(4) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(4) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Activity report By test'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('#type').select('Amylase(Serum)', { force: true }); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - - }); - it("Visits Activity Report By Panel Type", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(4) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(4) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Activity report By Panel'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('#type').select('NFS', { force: true }); - - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - - }); - it("Visits Activity Report By Unit", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(4) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(4) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(3) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Activity report By Test Section'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('#type').select('Biochemistry', { force: true }); - - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - }); - - it("Visits Reffered Out Test Report", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(5) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(5) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h3').should('have.text', 'External Refferals Report'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('.cds--date-picker-input__wrapper > #endDate').type('02/02/2023'); - cy.get('#locationcode').select('CEDRES', { force: true }); - - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - }); - - - it("Visits Non Conformity Report By Date", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(5) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(5) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Non ConformityReport by Date'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - - - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - }); - - - it("Visits Non Conformity Report By Unit and Reason", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(5) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(5) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Non Conformity Report by Unit and Reason'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - - - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - }); - - - it("Visits Export Routine CSV file", () => { - - cy.get(':nth-child(2) > .cds--link').click(); //visits routine reports - - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(9) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(9) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('h1').should('have.text', 'Export Routine CSV file'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - - - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - - - }); -}); \ No newline at end of file diff --git a/frontend/cypress/e2e/bcctest.js b/frontend/cypress/e2e/bcctest.js new file mode 100644 index 0000000000..e4b2abfadc --- /dev/null +++ b/frontend/cypress/e2e/bcctest.js @@ -0,0 +1,123 @@ +import LoginPage from "../pages/LoginPage"; +import ReportPage from "../pages/ReportPage"; + +let homePage = null; +let loginPage = null; +let reportPage =null; + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +describe("Routine Reports", function () { + it("User Visits Routine Reports", function () { + homePage = loginPage.goToHomePage(); + // reportPage.visitRoutineReports(); + reportPage = homePage.goToRoutineReports(); + + // Additional checks can go here + }); + + it("User Visits Patient Status Report and check for Respective Forms", () => { + // reportPage.visitRoutineReports(); + + + // reportPage.navigateToReport(1, 1); + cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click(); + cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); + cy.get('section > h3').should('have.text', 'Patient Status Report'); + reportPage.checkAccordionVisibility(2, ['#patientId', '#local_search']); + reportPage.checkAccordionVisibility(3, ['#from', '#to']); + reportPage.checkAccordionVisibility(6, ['#downshift-1-toggle-button', '.cds--date-picker-input__wrapper > #startDate']); + reportPage.checkPrintButton(':nth-child(7) > :nth-child(2) > .cds--btn'); + }); + + it("Should Visit Statistics Reports", () => { + reportPage.visitRoutineReports(); + reportPage.navigateToReport(2, 1); + cy.get('section > h3').should('have.text', 'Statistics Report'); + reportPage.checkCheckboxGroup(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2, 11); + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('be.checked'); + }); + + it('Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { + reportPage.visitRoutineReports(); + reportPage.navigateToReport(2, 1); + reportPage.uncheckIndividualCheckbox(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2); + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); + }); + + it('Should check the "All" checkbox when all individual checkboxes in .inlineDiv are checked', () => { + reportPage.checkAllCheckboxes('.inlineDiv', 2, 6); + }); + + it("should check for print button", () => { + reportPage.checkPrintButton(':nth-child(6) > .cds--btn'); + }); + + it("Visits Summary of all tests", () => { + reportPage.visitSummaryTest(2, 'Test Report Summary'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits HIV Test Summary and validates", () => { + reportPage.visitSummaryTest(3, 'HIV Test Summary'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Rejection Report and validates", () => { + reportPage.visitSummaryTest(3, 'Rejection Report'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Activity Report By Test Type", () => { + reportPage.visitSummaryTest(4, 'Activity report By test'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.selectDropdown('#type', 'Amylase(Serum)'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Activity Report By Panel Type", () => { + reportPage.visitSummaryTest(4, 'Activity report By Panel'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.selectDropdown('#type', 'NFS'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Activity Report By Unit", () => { + reportPage.visitSummaryTest(4, 'Activity report By Test Section'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.selectDropdown('#type', 'Biochemistry'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Referred Out Test Report", () => { + reportPage.visitSummaryTest(5, 'External Referrals Report'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #endDate', '02/02/2023'); + reportPage.selectDropdown('#locationcode', 'CEDRES'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Non Conformity Report By Date", () => { + reportPage.visitSummaryTest(5, 'Non Conformity Report by Date'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Non Conformity Report By Unit and Reason", () => { + reportPage.visitSummaryTest(5, 'Non Conformity Report by Unit and Reason'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); + + it("Visits Patient Reports", () => { + reportPage.visitSummaryTest(7, 'Patient Report'); + reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); + reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + }); +}); diff --git a/frontend/cypress/e2e/report.cy.js b/frontend/cypress/e2e/report.cy.js index 054aa13938..b3ed635769 100644 --- a/frontend/cypress/e2e/report.cy.js +++ b/frontend/cypress/e2e/report.cy.js @@ -1,9 +1,8 @@ import LoginPage from "../pages/LoginPage"; -import ReportPage from "../pages/ReportPage"; let homePage = null; let loginPage = null; -let reportPage =null; +let reportPage = null; before("login", () => { loginPage = new LoginPage(); @@ -13,107 +12,296 @@ before("login", () => { describe("Routine Reports", function () { it("User Visits Routine Reports", function () { homePage = loginPage.goToHomePage(); - // reportPage.visitRoutineReports(); reportPage = homePage.goToRoutineReports(); - - // Additional checks can go here }); + it("User Visits Patient Status Report and checks for Respective Forms", () => { + reportPage.navigateToSection(1, 1); + reportPage.validatePageHeader("Patient Status Report"); + + reportPage.toggleAccordionPatient(2); + reportPage.validateFieldVisibility("#patientId"); + reportPage.validateFieldVisibility("#local_search"); + reportPage.toggleAccordionPatient(2); - it("User Visits Patient Status Report and check for Respective Forms", () => { - // reportPage.visitRoutineReports(); - reportPage.navigateToReport(1, 1); - cy.get('section > h3').should('have.text', 'Patient Status Report'); - reportPage.checkAccordionVisibility(2, ['#patientId', '#local_search']); - reportPage.checkAccordionVisibility(3, ['#from', '#to']); - reportPage.checkAccordionVisibility(6, ['#downshift-1-toggle-button', '.cds--date-picker-input__wrapper > #startDate']); - reportPage.checkPrintButton(':nth-child(7) > :nth-child(2) > .cds--btn'); + reportPage.toggleAccordion(3); + reportPage.validateFieldVisibility("#from"); + reportPage.validateFieldVisibility("#to"); + reportPage.toggleAccordion(3); + + reportPage.toggleAccordion(6); + reportPage.validateFieldVisibility("#downshift-1-toggle-button"); + reportPage.validateFieldVisibility( + ".cds--date-picker-input__wrapper > #startDate", + ); + reportPage.validateButtonVisible( + ":nth-child(7) > :nth-child(2) > .cds--btn", + ); }); it("Should Visit Statistics Reports", () => { reportPage.visitRoutineReports(); - reportPage.navigateToReport(2, 1); - cy.get('section > h3').should('have.text', 'Statistics Report'); - reportPage.checkCheckboxGroup(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2, 11); - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('be.checked'); + reportPage.navigateToSection(2, 1); + reportPage.validatePageHeader("Statistics Report"); + + reportPage.checkAllCheckboxes( + 2, + 11, + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)", + ); + reportPage.validateFieldVisibility( + ':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]', + ); }); - it('Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { - reportPage.visitRoutineReports(); - reportPage.navigateToReport(2, 1); - reportPage.uncheckIndividualCheckbox(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2); - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); + it('Within Statistic Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { + reportPage.checkAllCheckboxes( + 2, + 11, + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)", + ); + reportPage.validateAllCheckBox("not.be.checked"); + reportPage.uncheckCheckbox( + 2, + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)", + ); + reportPage.validateAllCheckBox("not.be.checked"); + reportPage.validateFieldVisibility( + ':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]', + ); }); - it('Should check the "All" checkbox when all individual checkboxes in .inlineDiv are checked', () => { - reportPage.checkAllCheckboxes('.inlineDiv', 2, 6); + it('Should check/uncheck "All" checkbox for priority', () => { + reportPage.checkAllCheckboxes(2, 6, ".inlineDiv"); + reportPage.uncheckCheckbox(2, ".inlineDiv"); + reportPage.validateButtonVisible( + ":nth-child(3) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) > .cds--checkbox-label", + ); }); it("should check for print button", () => { - reportPage.checkPrintButton(':nth-child(6) > .cds--btn'); + reportPage.validateButtonVisible(":nth-child(6) > .cds--btn"); }); it("Visits Summary of all tests", () => { - reportPage.visitSummaryTest(2, 'Test Report Summary'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(2, 2); + reportPage.validatePageHeader("Test Report Summary"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); }); it("Visits HIV Test Summary and validates", () => { - reportPage.visitSummaryTest(3, 'HIV Test Summary'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(2, 3); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); }); it("Visits Rejection Report and validates", () => { - reportPage.visitSummaryTest(3, 'Rejection Report'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(3, 1); + reportPage.validatePageHeader("Rejection Report"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); }); it("Visits Activity Report By Test Type", () => { - reportPage.visitSummaryTest(4, 'Activity report By test'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.selectDropdown('#type', 'Amylase(Serum)'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(4, 1); + reportPage.validatePageHeader("Activity report By test"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.selectDropdown("#type", "Amylase(Serum)"); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); }); it("Visits Activity Report By Panel Type", () => { - reportPage.visitSummaryTest(4, 'Activity report By Panel'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.selectDropdown('#type', 'NFS'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(4, 2); + reportPage.validatePageHeader("Activity report By Panel"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.selectDropdown("#type", "NFS"); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); }); it("Visits Activity Report By Unit", () => { - reportPage.visitSummaryTest(4, 'Activity report By Test Section'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.selectDropdown('#type', 'Biochemistry'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(4, 3); + reportPage.validatePageHeader("Activity report By Test Section"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.selectDropdown("#type", "Biochemistry"); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); }); it("Visits Referred Out Test Report", () => { - reportPage.visitSummaryTest(5, 'External Referrals Report'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #endDate', '02/02/2023'); - reportPage.selectDropdown('#locationcode', 'CEDRES'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(5, 1); + reportPage.validatePageHeader("External Referrals Report"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #endDate", + "02/02/2023", + ); + reportPage.selectDropdown("#locationcode", "CEDRES"); + reportPage.validateButtonVisible(":nth-child(4) > .cds--btn"); }); it("Visits Non Conformity Report By Date", () => { - reportPage.visitSummaryTest(5, 'Non Conformity Report by Date'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + reportPage.visitRoutineReports(); + reportPage.navigateToSection(6, 1); + reportPage.validatePageHeader("Non ConformityReport by Date"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); + }); + + it("Visits Non Conformity Report By Unit", () => { + reportPage.visitRoutineReports(); + reportPage.navigateToSection(6, 2); + reportPage.validatePageHeader("Non Conformity Report by Unit and Reason"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); + }); + + it("Visits Export Routine CSV", () => { + reportPage.visitRoutineReports(); + reportPage.navigateToSection(9, 1); + reportPage.validatePageHeader("Export Routine CSV file"); + reportPage.validateButtonDisabled(".cds--form > :nth-child(3) > .cds--btn"); + reportPage.typeInDatePicker( + ".cds--date-picker-input__wrapper > #startDate", + "01/02/2023", + ); + reportPage.validateButtonVisible(".cds--form > :nth-child(3) > .cds--btn"); + }); +}); + +describe("Study Reports", function () { + it("User Visits Study Reports", function () { + homePage = loginPage.goToHomePage(); + reportPage = homePage.goToStudyReports(); + }); + + it("should visit ARV Initial Version 1 and verify the button state", () => { + reportPage.visitARVInitialVersion1(); + }); + + it("should visit ARV Initial Version 2 and verify the header and button state", () => { + reportPage.visitARVInitialVersion2(); + }); + + it("should visit ARV Follow-Up Version 1 and verify the header and button state", () => { + reportPage.visitARVFollowUpVersion1(); + }); + + it("should visit ARV Follow-Up Version 2 and verify the header and button state", () => { + reportPage.visitARVFollowUpVersion2(); + }); + + it("should visit ARV Follow-Up Version 3 and verify the header and button state", () => { + reportPage.visitARVFollowUpVersion3(); + }); + + it("should visit EID Version 1 and verify the accordion items and button state", () => { + reportPage.visitEIDVersion1(); + }); + + it("should visit EID Version 2 and verify the header and button state", () => { + reportPage.visitEIDVersion2(); + }); + + it("should visit VL Version and verify the accordion items and button state", () => { + reportPage.visitVLVersion(); + }); + + it("should visit Intermediate Version 1 and verify the header and button state", () => { + reportPage.visitIntermediateVersion1(); + }); + + it("should visit Intermediate Version 2 and verify the header and button state", () => { + reportPage.visitIntermediateVersion2(); + }); + + it("should visit Intermediate By Service and verify the input fields and button state", () => { + reportPage.visitIntermediateByService(); + }); + + it("should visit Special Request and verify the header and button state", () => { + reportPage.visitSpecialRequest(); + }); + + it("should visit Collected ARV Patient Report and verify the header and button state", () => { + reportPage.visitCollectedARVPatientReport(); + }); + + it("should visit Associated Patient Report and verify the header and button state", () => { + reportPage.visitAssociatedPatientReport(); + }); + + it("should visit Non-Conformity Report By Date and verify the header and button state", () => { + reportPage.visitNonConformityReportByDate(); + }); + + it("should visit Non-Conformity Report By Unit and Reason and verify the header and button state", () => { + reportPage.visitNonConformityReportByUnitAndReason(); + }); + + it("should visit Non-Conformity Report By Lab No and verify the header and button state", () => { + reportPage.visitNonConformityReportByLabNo(); + }); + + it("should visit Non-Conformity Report By Notification and verify the button state", () => { + reportPage.visitNonConformityReportByNotification(); + }); + + it("should visit Non-Conformity Report Follow-Up Required and verify the header and button state", () => { + reportPage.visitNonConformityReportFollowUpRequired(); }); - it("Visits Non Conformity Report By Unit and Reason", () => { - reportPage.visitSummaryTest(5, 'Non Conformity Report by Unit and Reason'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + it("should visit General Report In Export By Date and select options", () => { + reportPage.visitGeneralReportInExportByDate(); }); - it("Visits Patient Reports", () => { - reportPage.visitSummaryTest(7, 'Patient Report'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); + it("User Visits Audit Trail Report And Validates", function () { + reportPage.visitStudyReports(); + reportPage.visitAuditTrailReport(); + reportPage.verifyHeaderText("section > h3", "Audit Trail"); + cy.fixture("EnteredOrder").then((order) => { + reportPage. typeInField("labNo",order.labNo) + }); + reportPage.validateAudit(); }); }); diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index e65da7a6a9..54ce977960 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -5,7 +5,8 @@ import ModifyOrderPage from "./ModifyOrderPage"; import WorkPlan from "./WorkPlan"; import NonConform from "./NonConformPage"; import BatchOrderEntry from "./BatchOrderEntryPage"; -import ReportPage from "./ReportPage"; +import RoutineReportPage from "./RoutineReportPage"; +import StudyReportPage from "./StudyReportPage"; class HomePage { constructor() {} @@ -101,14 +102,14 @@ class HomePage { goToRoutineReports() { this.openNavigationMenu(); cy.get('#menu_reports').click(); - cy.get('#menu_reports_routine').click(); - return new ReportPage(); + cy.get('#menu_reports_routine_nav').click(); + return new RoutineReportPage(); } goToStudyReports() { this.openNavigationMenu(); cy.get('#menu_reports').click(); - cy.get('#menu_reports_study').click(); - return new ReportPage(); + cy.get('#menu_reports_study_nav').click(); + return new StudyReportPage(); } } diff --git a/frontend/cypress/pages/ReportPage.js b/frontend/cypress/pages/ReportPage.js deleted file mode 100644 index 39bc6a3758..0000000000 --- a/frontend/cypress/pages/ReportPage.js +++ /dev/null @@ -1,117 +0,0 @@ -class ReportPage { - visitRoutineReports() { - cy.get(':nth-child(2) > .cds--link').click(); // visits routine reports - } - - visitPatientStatusReport() { - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - } - - validatePatientStatusReport() { - cy.get('section > h3').should('have.text', 'Patient Status Report'); - } - - validateReportByPatient() { - cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); - cy.get('#patientId').should('be.visible'); - cy.get('#local_search').should('be.visible'); - cy.get(':nth-child(2) > .cds--accordion > .cds--accordion__item > .cds--accordion__heading').click(); - } - - validateReportByLabNo() { - cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); - cy.get('#from').should('be.visible'); - cy.get('#to').should('be.visible'); - cy.get(':nth-child(3) > .cds--accordion__item > .cds--accordion__heading').click(); - } - - validateReportBySite() { - cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').click(); - cy.get(':nth-child(6) > .cds--accordion__item > .cds--accordion__heading').should('be.visible'); - cy.get('#downshift-1-toggle-button').should('be.visible'); - cy.get('.cds--date-picker-input__wrapper > #startDate').should('be.visible'); - } - - validatePrintButton() { - cy.get(':nth-child(7) > :nth-child(2) > .cds--btn').should('be.visible'); - } - - visitStatisticsReport() { - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - } - - validateStatisticsReport() { - cy.get('section > h3').should('have.text', 'Statistics Report'); - } - - checkAllStatisticsCheckboxes() { - for (let i = 2; i <= 11; i++) { - cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i}) input[type="checkbox"]`) - .check({ force: true }) - .should('be.checked'); - } - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') - .should('be.checked'); - } - - uncheckAllCheckboxes() { - for (let i = 2; i <= 11; i++) { - cy.get(`:nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(${i})`).click(); - } - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]') - .should('not.be.checked'); - } - - checkPriorityAllCheckboxes() { - for (let i = 2; i <= 6; i++) { - cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); - } - cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]').should('be.checked'); - } - - uncheckPriorityCheckboxes() { - for (let i = 2; i <= 6; i++) { - cy.get(`.inlineDiv > :nth-child(${i}) > .cds--checkbox-label`).click(); - } - cy.get('.inlineDiv > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); - } - - visitSummaryOfAllTests() { - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(2) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(2) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(2) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - } - - validateSummaryOfAllTests() { - cy.get('h1').should('have.text', 'Test Report Summary'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - } - - visitHIVTestSummary() { - cy.get(':nth-child(2) > .cds--side-nav__menu > :nth-child(3) > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - } - - visitRejectionReport() { - cy.get(':nth-child(3) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(3) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - } - - visitActivityReportByTestType() { - cy.get(':nth-child(4) > .cds--side-nav__submenu').click(); - cy.get(':nth-child(4) > .cds--side-nav__menu > :nth-child(1) > .cds--side-nav__link').click(); - } - - validateActivityReportByTestType() { - cy.get('h1').should('have.text', 'Activity report By test'); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.disabled'); - cy.get('.cds--date-picker-input__wrapper > #startDate').type('01/02/2023'); - cy.get('#type').select('Amylase(Serum)', { force: true }); - cy.get('.cds--form > :nth-child(3) > .cds--btn').should('be.visible'); - } - } - - export default ReportPage; - \ No newline at end of file diff --git a/frontend/cypress/pages/RoutineReportPage.js b/frontend/cypress/pages/RoutineReportPage.js new file mode 100644 index 0000000000..438333f4b9 --- /dev/null +++ b/frontend/cypress/pages/RoutineReportPage.js @@ -0,0 +1,67 @@ +class RoutineReportPage { + + navigateToSection(sectionNumber, subsectionNumber) { + cy.get(`.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(${sectionNumber}) > .cds--side-nav__item > .cds--side-nav__submenu`).click(); + cy.get(`:nth-child(${sectionNumber}) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(${subsectionNumber}) > .cds--side-nav__menu-item > .cds--side-nav__link`).click(); + } + + validatePageHeader(expectedText) { + cy.get('section > h3, h1').should('have.text', expectedText); + } + + validateFieldVisibility(selector) { + cy.get(selector).should('be.visible'); + } + + validateButtonDisabled(selector) { + cy.get(selector).should('be.disabled'); + } + + validateButtonVisible(selector) { + cy.get(selector).should('be.visible'); + } + + visitRoutineReports() { + cy.get(':nth-child(2) > .cds--link').click(); + } + + toggleAccordion(accordionNumber) { + cy.get(`:nth-child(${accordionNumber})> .cds--accordion__item > .cds--accordion__heading`).click(); + } + + toggleAccordionPatient(accordionNumber) { + cy.get(`:nth-child(${accordionNumber}) >.cds--accordion > .cds--accordion__item > .cds--accordion__heading`).click(); + } + + toggleCheckbox(checkboxNumber, containerSelector) { + cy.get(`${containerSelector} > :nth-child(${checkboxNumber}) input[type="checkbox"]`).click({force: true}); + } + + checkAllCheckboxes(start, end, containerSelector) { + for (let i = start; i <= end; i++) { + this.toggleCheckbox(i, containerSelector); + + } + + } + + validateAllCheckBox(check){ + cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) > .cds--checkbox-label').should(check); + } + + uncheckCheckbox(checkboxNumber, containerSelector) { + this.toggleCheckbox(checkboxNumber, containerSelector); + } + + selectDropdown(selector, value) { + cy.get(selector).select(value, { force: true }); + } + + typeInDatePicker(selector, date) { + cy.get(selector).type(date); + } + +} + + +export default RoutineReportPage; \ No newline at end of file diff --git a/frontend/cypress/pages/StudyReportPage.js b/frontend/cypress/pages/StudyReportPage.js new file mode 100644 index 0000000000..67aa496c50 --- /dev/null +++ b/frontend/cypress/pages/StudyReportPage.js @@ -0,0 +1,341 @@ +class StudyReportPage { + visitHomePage() { + homePage = loginPage.goToHomePage(); + } + + visitStudyReports() { + report = homePage.goToStudyReports(); + } + + clickSideNavMenuItem(nthChild, submenuChild) { + cy.get( + `.cds--side-nav__items > :nth-child(${nthChild}) > .cds--side-nav__item > .cds--side-nav__submenu`, + ).click(); + cy.get( + `:nth-child(${nthChild}) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(${submenuChild}) > .cds--side-nav__menu-item > .cds--side-nav__link`, + ).click(); + } + + verifyButtonDisabled() { + cy.get("section > .cds--btn").should("be.disabled"); + } + + typeInField(fieldId, value) { + cy.get(`#${fieldId}`).type(value, { force: true }); + } + + verifyButtonVisible() { + cy.get("section > .cds--btn").should("be.visible"); + } + + // verifyHeaderText(expectedText) { + // cy.get('.cds--sm\\:col-span-4 > section > h3').should('have.text', expectedText); + // } + + verifyHeaderText(selector, expectedText) { + cy.get(selector).should("have.text", expectedText); + } + + typeInDate(fieldId, value) { + cy.get(`#${fieldId}`).type(value); + } + + clickAccordionItem(nthChild) { + cy.get( + `:nth-child(${nthChild}) >.cds--accordion__item > .cds--accordion__heading`, + ).click(); + } + + clickAccordionPatient(nthChild) { + cy.get( + `:nth-child(${nthChild}) >.cds--accordion > .cds--accordion__item > .cds--accordion__heading`, + ).click(); + } + + verifyElementVisible(selector) { + cy.get(selector).should("be.visible"); + } + + selectDropdown(optionId, value) { + cy.get(`#${optionId}`).select(value); + } + + visitStudyReports() { + cy.get(":nth-child(2) > .cds--link").click({ force: true }); + } + + visitARVInitialVersion1() { + this.clickSideNavMenuItem(1, 1); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitARVInitialVersion2() { + this.visitStudyReports(); + this.clickSideNavMenuItem(1, 2); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "ARV-initial", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitARVFollowUpVersion1() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(1, 3); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "ARV-Follow-up", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitARVFollowUpVersion2() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(1, 4); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "ARV-Follow-up", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitARVFollowUpVersion3() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(1, 5); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "ARV -->Initial-FollowUp-VL", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitAuditTrailReport() { + cy.get( + ":nth-child(11) > .cds--side-nav__item > .cds--side-nav__submenu", + ).click(); + cy.get( + ":nth-child(11) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link", + ).click(); + } + + validateAudit() { + cy.get("section > .cds--btn").click(); + cy.get(":nth-child(8) > :nth-child(2)").should( + "have.text", + "Optimus Prime", + ); + } + + visitEIDVersion1() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(2, 1); + this.verifyHeaderText( + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(1) > section > h3", + "Diagnostic for children with DBS-PCR", + ); + this.clickAccordionPatient(2); + this.verifyElementVisible("#patientId"); + this.verifyElementVisible("#local_search"); + this.clickAccordionPatient(2); + this.clickAccordionItem(3); + this.verifyElementVisible("#from"); + this.verifyElementVisible("#to"); + this.clickAccordionItem(3); + this.clickAccordionItem(6); + this.verifyElementVisible("#siteName"); + this.clickAccordionItem(6); + cy.get(":nth-child(7) > :nth-child(2) > .cds--btn").should("be.visible"); + } + + visitEIDVersion2() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(2, 2); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "Diagnostic for children with DBS-PCR", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitVLVersion() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(3, 1); + this.verifyHeaderText( + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(1) > section > h3", + "Viral Load", + ); + this.clickAccordionPatient(2); + this.verifyElementVisible("#patientId"); + this.verifyElementVisible("#local_search"); + this.clickAccordionPatient(2); + this.clickAccordionItem(3); + this.verifyElementVisible("#from"); + this.verifyElementVisible("#to"); + this.clickAccordionItem(3); + this.clickAccordionItem(6); + this.verifyElementVisible("#siteName"); + this.clickAccordionItem(6); + cy.get(":nth-child(7) > :nth-child(2) > .cds--btn").should("be.visible"); + } + + visitIntermediateVersion1() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(4, 1); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "Indeterminate", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitIntermediateVersion2() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(4, 2); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "Indeterminate", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitIntermediateByService() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(4, 3); + this.verifyHeaderText( + ".cds--lg\\:col-span-16 > section > h3", + "Indeterminate", + ); + this.typeInDate("startDate", "01/02/2023"); + this.typeInField("siteName", "CAME", { force: true }); + this.verifyElementVisible("#siteName"); + } + + visitSpecialRequest() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(5, 1); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "Special Request", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitCollectedARVPatientReport() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(6, 1); + this.verifyHeaderText( + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(1) > section > h3", + "Collected ARV Patient Report", + ); + this.verifyButtonDisabled(); + this.typeInField("nationalID", "UG-23SLHD7DBD"); + this.verifyButtonVisible(); + } + + visitAssociatedPatientReport() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(7, 1); + this.verifyHeaderText( + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(1) > section > h3", + "Associated Patient Report", + ); + this.verifyButtonDisabled(); + this.typeInField("nationalID", "UG-23SLHD7DBD"); + this.verifyButtonVisible(); + } + + visitNonConformityReportByDate() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(9, 1); + this.verifyHeaderText("h1", "Non-conformity Report By Date"); + this.verifyButtonDisabled(); + this.typeInDate("startDate", "01/02/2023"); + this.verifyButtonVisible(); + } + + visitNonConformityReportByUnitAndReason() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(9, 2); + this.verifyHeaderText("h1", "Non Conformity Report by Unit and Reason"); + this.verifyButtonDisabled(); + this.typeInDate("startDate", "01/02/2023"); + this.verifyButtonVisible(); + } + + visitNonConformityReportByLabNo() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(9, 3); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "ARV -->Initial-FollowUp-VL", + ); + this.verifyButtonDisabled(); + this.typeInField("from", "DEV0124000000000000"); + this.verifyButtonVisible(); + } + + visitNonConformityReportByNotification() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(9, 4); + this.verifyHeaderText( + ".cds--sm\\:col-span-4 > section > h3", + "Non-conformity notification", + ); + this.verifyButtonVisible(); + } + + visitNonConformityReportFollowUpRequired() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(9, 5); + this.verifyHeaderText("h1", "Follow-up Required"); + this.verifyButtonDisabled(); + this.typeInDate("startDate", "01/02/2023"); + this.verifyButtonVisible(); + } + + visitGeneralReportInExportByDate() { + this.visitStudyReports(); + + this.clickSideNavMenuItem(10, 1); + this.verifyHeaderText("h1", "Export a CSV File by Date"); + this.selectDropdown("studyType", "Testing"); + this.selectDropdown("dateType", "Order Date"); + } +} + +export default StudyReportPage; diff --git a/frontend/src/components/reports/common/ReportByID.js b/frontend/src/components/reports/common/ReportByID.js index dc46f15e94..43707af153 100644 --- a/frontend/src/components/reports/common/ReportByID.js +++ b/frontend/src/components/reports/common/ReportByID.js @@ -84,7 +84,7 @@ function ReportByID(props) {
-
From 7b2572c18db1327a2aafdfbc8cb49f34a2734c4b Mon Sep 17 00:00:00 2001 From: Manish Jha Date: Thu, 15 Aug 2024 17:11:53 +0530 Subject: [PATCH 11/84] fix formatting --- frontend/cypress/e2e/bcctest.js | 123 -------------------- frontend/cypress/e2e/report.cy.js | 2 +- frontend/cypress/pages/HomePage.js | 8 +- frontend/cypress/pages/RoutineReportPage.js | 43 ++++--- 4 files changed, 30 insertions(+), 146 deletions(-) delete mode 100644 frontend/cypress/e2e/bcctest.js diff --git a/frontend/cypress/e2e/bcctest.js b/frontend/cypress/e2e/bcctest.js deleted file mode 100644 index e4b2abfadc..0000000000 --- a/frontend/cypress/e2e/bcctest.js +++ /dev/null @@ -1,123 +0,0 @@ -import LoginPage from "../pages/LoginPage"; -import ReportPage from "../pages/ReportPage"; - -let homePage = null; -let loginPage = null; -let reportPage =null; - -before("login", () => { - loginPage = new LoginPage(); - loginPage.visit(); -}); - -describe("Routine Reports", function () { - it("User Visits Routine Reports", function () { - homePage = loginPage.goToHomePage(); - // reportPage.visitRoutineReports(); - reportPage = homePage.goToRoutineReports(); - - // Additional checks can go here - }); - - it("User Visits Patient Status Report and check for Respective Forms", () => { - // reportPage.visitRoutineReports(); - - - // reportPage.navigateToReport(1, 1); - cy.get('.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click(); - cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > div > .cds--side-nav__menu-item > .cds--side-nav__link').click(); - cy.get('section > h3').should('have.text', 'Patient Status Report'); - reportPage.checkAccordionVisibility(2, ['#patientId', '#local_search']); - reportPage.checkAccordionVisibility(3, ['#from', '#to']); - reportPage.checkAccordionVisibility(6, ['#downshift-1-toggle-button', '.cds--date-picker-input__wrapper > #startDate']); - reportPage.checkPrintButton(':nth-child(7) > :nth-child(2) > .cds--btn'); - }); - - it("Should Visit Statistics Reports", () => { - reportPage.visitRoutineReports(); - reportPage.navigateToReport(2, 1); - cy.get('section > h3').should('have.text', 'Statistics Report'); - reportPage.checkCheckboxGroup(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2, 11); - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('be.checked'); - }); - - it('Should uncheck the "All" checkbox if any individual checkbox is unchecked', () => { - reportPage.visitRoutineReports(); - reportPage.navigateToReport(2, 1); - reportPage.uncheckIndividualCheckbox(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2)', 2); - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) input[type="checkbox"]').should('not.be.checked'); - }); - - it('Should check the "All" checkbox when all individual checkboxes in .inlineDiv are checked', () => { - reportPage.checkAllCheckboxes('.inlineDiv', 2, 6); - }); - - it("should check for print button", () => { - reportPage.checkPrintButton(':nth-child(6) > .cds--btn'); - }); - - it("Visits Summary of all tests", () => { - reportPage.visitSummaryTest(2, 'Test Report Summary'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits HIV Test Summary and validates", () => { - reportPage.visitSummaryTest(3, 'HIV Test Summary'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Rejection Report and validates", () => { - reportPage.visitSummaryTest(3, 'Rejection Report'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Activity Report By Test Type", () => { - reportPage.visitSummaryTest(4, 'Activity report By test'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.selectDropdown('#type', 'Amylase(Serum)'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Activity Report By Panel Type", () => { - reportPage.visitSummaryTest(4, 'Activity report By Panel'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.selectDropdown('#type', 'NFS'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Activity Report By Unit", () => { - reportPage.visitSummaryTest(4, 'Activity report By Test Section'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.selectDropdown('#type', 'Biochemistry'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Referred Out Test Report", () => { - reportPage.visitSummaryTest(5, 'External Referrals Report'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #endDate', '02/02/2023'); - reportPage.selectDropdown('#locationcode', 'CEDRES'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Non Conformity Report By Date", () => { - reportPage.visitSummaryTest(5, 'Non Conformity Report by Date'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Non Conformity Report By Unit and Reason", () => { - reportPage.visitSummaryTest(5, 'Non Conformity Report by Unit and Reason'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); - - it("Visits Patient Reports", () => { - reportPage.visitSummaryTest(7, 'Patient Report'); - reportPage.setDateField('.cds--date-picker-input__wrapper > #startDate', '01/02/2023'); - reportPage.checkPrintButton('.cds--form > :nth-child(3) > .cds--btn'); - }); -}); diff --git a/frontend/cypress/e2e/report.cy.js b/frontend/cypress/e2e/report.cy.js index b3ed635769..eb45abb3b7 100644 --- a/frontend/cypress/e2e/report.cy.js +++ b/frontend/cypress/e2e/report.cy.js @@ -300,7 +300,7 @@ describe("Study Reports", function () { reportPage.visitAuditTrailReport(); reportPage.verifyHeaderText("section > h3", "Audit Trail"); cy.fixture("EnteredOrder").then((order) => { - reportPage. typeInField("labNo",order.labNo) + reportPage.typeInField("labNo", order.labNo); }); reportPage.validateAudit(); }); diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index 54ce977960..2b0137827a 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -101,14 +101,14 @@ class HomePage { } goToRoutineReports() { this.openNavigationMenu(); - cy.get('#menu_reports').click(); - cy.get('#menu_reports_routine_nav').click(); + cy.get("#menu_reports").click(); + cy.get("#menu_reports_routine_nav").click(); return new RoutineReportPage(); } goToStudyReports() { this.openNavigationMenu(); - cy.get('#menu_reports').click(); - cy.get('#menu_reports_study_nav').click(); + cy.get("#menu_reports").click(); + cy.get("#menu_reports_study_nav").click(); return new StudyReportPage(); } } diff --git a/frontend/cypress/pages/RoutineReportPage.js b/frontend/cypress/pages/RoutineReportPage.js index 438333f4b9..590843ac7d 100644 --- a/frontend/cypress/pages/RoutineReportPage.js +++ b/frontend/cypress/pages/RoutineReportPage.js @@ -1,52 +1,61 @@ class RoutineReportPage { - navigateToSection(sectionNumber, subsectionNumber) { - cy.get(`.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(${sectionNumber}) > .cds--side-nav__item > .cds--side-nav__submenu`).click(); - cy.get(`:nth-child(${sectionNumber}) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(${subsectionNumber}) > .cds--side-nav__menu-item > .cds--side-nav__link`).click(); + cy.get( + `.cds--white > :nth-child(1) > .cds--side-nav__navigation > .cds--side-nav__items > :nth-child(${sectionNumber}) > .cds--side-nav__item > .cds--side-nav__submenu`, + ).click(); + cy.get( + `:nth-child(${sectionNumber}) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(${subsectionNumber}) > .cds--side-nav__menu-item > .cds--side-nav__link`, + ).click(); } validatePageHeader(expectedText) { - cy.get('section > h3, h1').should('have.text', expectedText); + cy.get("section > h3, h1").should("have.text", expectedText); } validateFieldVisibility(selector) { - cy.get(selector).should('be.visible'); + cy.get(selector).should("be.visible"); } validateButtonDisabled(selector) { - cy.get(selector).should('be.disabled'); + cy.get(selector).should("be.disabled"); } validateButtonVisible(selector) { - cy.get(selector).should('be.visible'); + cy.get(selector).should("be.visible"); } visitRoutineReports() { - cy.get(':nth-child(2) > .cds--link').click(); + cy.get(":nth-child(2) > .cds--link").click(); } toggleAccordion(accordionNumber) { - cy.get(`:nth-child(${accordionNumber})> .cds--accordion__item > .cds--accordion__heading`).click(); + cy.get( + `:nth-child(${accordionNumber})> .cds--accordion__item > .cds--accordion__heading`, + ).click(); } toggleAccordionPatient(accordionNumber) { - cy.get(`:nth-child(${accordionNumber}) >.cds--accordion > .cds--accordion__item > .cds--accordion__heading`).click(); + cy.get( + `:nth-child(${accordionNumber}) >.cds--accordion > .cds--accordion__item > .cds--accordion__heading`, + ).click(); } toggleCheckbox(checkboxNumber, containerSelector) { - cy.get(`${containerSelector} > :nth-child(${checkboxNumber}) input[type="checkbox"]`).click({force: true}); + cy.get( + `${containerSelector} > :nth-child(${checkboxNumber}) input[type="checkbox"]`, + ).click({ force: true }); } checkAllCheckboxes(start, end, containerSelector) { for (let i = start; i <= end; i++) { this.toggleCheckbox(i, containerSelector); - } - } - validateAllCheckBox(check){ - cy.get(':nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) > .cds--checkbox-label').should(check); + validateAllCheckBox(check) { + cy.get( + ":nth-child(1) > .cds--sm\\:col-span-4 > :nth-child(2) > :nth-child(1) > .cds--checkbox-label", + ).should(check); } uncheckCheckbox(checkboxNumber, containerSelector) { @@ -60,8 +69,6 @@ class RoutineReportPage { typeInDatePicker(selector, date) { cy.get(selector).type(date); } - } - -export default RoutineReportPage; \ No newline at end of file +export default RoutineReportPage; From b9a5981932b357456504b224aea73446e19835e7 Mon Sep 17 00:00:00 2001 From: pascagihozo Date: Thu, 22 Aug 2024 14:11:04 +0400 Subject: [PATCH 12/84] select lab-translation --- frontend/src/languages/en.json | 1 + frontend/src/languages/fr.json | 1 + 2 files changed, 2 insertions(+) diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index a36765f8fc..2a1c89e0a8 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -194,6 +194,7 @@ "header.label.version": "Version:", "header.label.logout": "Logout", "header.label.selectlocale": "Select Locale", + "header.label.changeLab": "Select Lab", "banner.menu.home": "Home", "banner.menu.help": "Help", "banner.menu.reports": "Reports", diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index f15957610c..d0abc4093c 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -204,6 +204,7 @@ "header.label.version": "Version:", "header.label.logout": "Déconnexion", "header.label.selectlocale": "Sélectionner la Langue", + "header.label.selectLab": "Sélectionner la Lab", "header.label.ARV": "ARV-initial", "header.label.followup": "ARV-suivi", "header.label.intialFollowup": "ARV -->Suivi initial-VL", From 4f18a87c086060236d5470589a02422a5c4e35ca Mon Sep 17 00:00:00 2001 From: pascagihozo Date: Thu, 22 Aug 2024 17:27:59 +0400 Subject: [PATCH 13/84] pathology-conclusions-dropdown --- .../ImmunohistochemistryCaseView.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js index 68c0f8eb03..5241dd3311 100644 --- a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js @@ -19,6 +19,7 @@ import { InlineLoading, Toggle, TextArea, + FilterableMultiSelect, } from "@carbon/react"; import { Launch, Subtract } from "@carbon/react/icons"; import { @@ -57,6 +58,10 @@ function ImmunohistochemistryCaseView() { const { userSessionDetails } = useContext(UserSessionDetailsContext); const [immunohistochemistrySampleInfo, setImmunohistochemistrySampleInfo] = useState({ labNumber: "" }); + + const [pathologySampleInfo, setPathologySampleInfo] = useState({}); + const [conclusions, setConclusions] = useState([]); + const [statuses, setStatuses] = useState([]); const [reportTypes, setReportTypes] = useState([]); const [technicianUsers, setTechnicianUsers] = useState([]); @@ -174,6 +179,20 @@ function ImmunohistochemistryCaseView() { params[index]["toggled"] = e; setReportParams(params); }; + + useEffect(() => { + componentMounted.current = true; + + getFromOpenElisServer( + "/rest/displayList/PATHOLOGIST_CONCLUSIONS", + setConclusions, + ); + + return () => { + componentMounted.current = false; + }; + }, []); + const createReportParams = (reportType, index) => { switch (reportType) { case "BREAST_CANCER_HORMONE_RECEPTOR": @@ -650,6 +669,46 @@ function ImmunohistochemistryCaseView() { <> + + + + + } + items={conclusions} + itemToString={(item) => (item ? item.value : "")} + initialSelectedItems={pathologySampleInfo.conclusions} + onChange={(changes) => { + setPathologySampleInfo({ + ...pathologySampleInfo, + conclusions: changes.selectedItems, + }); + }} + selectionFeedback="top-after-reopen" + /> + + + {pathologySampleInfo.conclusions && + pathologySampleInfo.conclusions.map( + (conclusion, index) => ( + { + var info = { ...pathologySampleInfo }; + info["conclusions"].splice(index, 1); + setPathologySampleInfo(info); + }} + > + {conclusion.value} + + ), + )} + + + From a718db7e4804efcb980d9be88326805e465f57df Mon Sep 17 00:00:00 2001 From: pascagihozo Date: Thu, 22 Aug 2024 17:38:37 +0400 Subject: [PATCH 14/84] new landingpage to allow user to select lab at landingpage --- frontend/src/App.js | 28 +++- frontend/src/components/home/LandingPage.tsx | 164 +++++++++++++++++++ frontend/src/components/layout/Header.js | 2 +- 3 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 frontend/src/components/home/LandingPage.tsx diff --git a/frontend/src/App.js b/frontend/src/App.js index eff531cd88..ea9ce740ad 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,10 +1,16 @@ import React, { useState, useEffect } from "react"; -import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; -import { confirmAlert } from "react-confirm-alert"; +import { + BrowserRouter as Router, + Route, + Switch, + Redirect, +} from "react-router-dom"; import { IntlProvider } from "react-intl"; import Layout from "./components/layout/Layout"; import Home from "./components/Home"; import Login from "./components/Login"; +import LandingPage from "./components/home/LandingPage"; +import HomeDashBoard from "./components/home/Dashboard"; import { Admin } from "./components"; import ResultSearch from "./components/resultPage/ResultSearch"; import UserSessionDetailsContext from "./UserSessionDetailsContext"; @@ -88,6 +94,7 @@ export default function App() { ); } } catch (error) { + console.log(er); console.error(error); if (counter === 10) { const options = { @@ -209,10 +216,25 @@ export default function App() { } /> + } + /> + } + /> } + component={() => { + if (!userSessionDetails.unitSelected) { + return ; + } + return ; + }} role="" /> { + const intl = useIntl(); + const [departments, setDepartments] = useState([]); + const [filteredDepartments, setFilteredDepartments] = useState([]); + const [selectedDepartment, setSelectedDepartment] = useState(""); + const [selectedLabUnits, setSelectedLabUnits] = useState([]); + const [rememberChoice, setRememberChoice] = useState(false); + const [searchTerm, setSearchTerm] = useState(""); + + useEffect(() => { + getFromOpenElisServer("/rest/user-test-sections", (response) => { + setDepartments(response); + setFilteredDepartments(response); + }); + }, []); + + const handleSearch = (event) => { + const term = event.target.value.toLowerCase(); + setSearchTerm(term); + setFilteredDepartments( + departments.filter((dept) => + dept.value.toLowerCase().includes(term) + ) + ); + }; + + const handleDepartmentSelect = (departmentId) => { + setSelectedDepartment(departmentId); + setSelectedLabUnits([]); + }; + + + const handleContinue = () => { + if (rememberChoice) { + if (selectedDepartment) { + localStorage.setItem("selectedDepartment", selectedDepartment); + } else if (selectedLabUnits.length > 0) { + localStorage.setItem( + "selectedLabUnits", + JSON.stringify(selectedLabUnits) + ); + } + } + window.location.href = "/dashboard"; + }; + + return ( + + + +

Welcome!

+

Please select a unit to continue

+ + +
+ {filteredDepartments.map((dept) => ( +
handleDepartmentSelect(dept.id)} + > + {dept.value} +
+ ))} +
+ setRememberChoice(e.target.checked)} + /> + + +
+
+
+ ); +}; + +export default LandingPage; diff --git a/frontend/src/components/layout/Header.js b/frontend/src/components/layout/Header.js index f4e080bb11..0a0bdbc011 100644 --- a/frontend/src/components/layout/Header.js +++ b/frontend/src/components/layout/Header.js @@ -434,7 +434,7 @@ function OEHeader(props) { isCollapsible={true} /> )} - +
{configurationProperties?.BANNER_TEXT}
From 2661a81344e5140f2cda0f3155436e67df23fd2f Mon Sep 17 00:00:00 2001 From: "Aditya @ArchLinux" <132184385+adityadeshlahre@users.noreply.github.com> Date: Wed, 24 Jul 2024 03:09:04 +0530 Subject: [PATCH 15/84] fix(TestNotificationConfigMenu): restController init --- .../TestNotificationConfigMenu.js | 5 + ...tNotificationConfigMenuRestController.java | 127 ++++++++++++++++++ .../TestNotificationConfigRestController.java | 115 ++++++++++++++++ 3 files changed, 247 insertions(+) create mode 100644 frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js create mode 100644 src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java create mode 100644 src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java diff --git a/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js new file mode 100644 index 0000000000..8e0afd47be --- /dev/null +++ b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js @@ -0,0 +1,5 @@ +import { FormattedMessage, injectIntl, useIntl } from "react-intl"; + +function ProviderMenu() {} + +export default injectIntl(ProviderMenu); diff --git a/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java new file mode 100644 index 0000000000..c18b14c069 --- /dev/null +++ b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java @@ -0,0 +1,127 @@ +package org.openelisglobal.notification.controller.rest; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import org.openelisglobal.common.controller.BaseMenuController; +import org.openelisglobal.common.form.AdminOptionMenuForm; +import org.openelisglobal.common.log.LogEvent; +import org.openelisglobal.common.validator.BaseErrors; +import org.openelisglobal.notification.form.TestNotificationConfigMenuForm; +import org.openelisglobal.notification.service.TestNotificationConfigService; +import org.openelisglobal.notification.valueholder.TestNotificationConfig; +import org.openelisglobal.test.service.TestService; +import org.openelisglobal.test.valueholder.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.BindingResult; +import org.springframework.validation.Errors; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestNotificationConfigMenuRestController extends BaseMenuController { + + private static final String[] ALLOWED_FIELDS = new String[] { "menuList*.id", "menuList*.test.id", + "menuList*.providerSMS.active", "menuList*.providerEmail.active", "menuList*.patientEmail.active", + "menuList*.patientSMS.active", "menuList*.defaultPayloadTemplate.id" }; + + @InitBinder + public void initBinder(WebDataBinder binder) { + binder.setAllowedFields(ALLOWED_FIELDS); + } + + @Autowired + private TestService testService; + @Autowired + private TestNotificationConfigService testNotificationConfigService; + + @Override + protected int getPageSize() { + return -1; + } + + @GetMapping("/TestNotificationConfigMenu") + public TestNotificationConfigMenuForm displayNotificationConfig() + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestNotificationConfigMenuForm form = new TestNotificationConfigMenuForm(); + // request.setAttribute("menuDefinition", "TestNotificationMenuDefinition"); + String forward = performMenuAction(form, request); + // return findForward(forward, form); + return form; + } + + @PostMapping("/TestNotificationConfigMenu") + public TestNotificationConfigMenuForm updateNotificationConfig(HttpServletRequest request, + @RequestBody @Valid TestNotificationConfigMenuForm form, BindingResult result) + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + if (result.hasErrors()) { + saveErrors(result); + return displayNotificationConfig(); + } + try { + testNotificationConfigService.saveTestNotificationConfigsActiveStatuses(form.getMenuList(), + this.getSysUserId(request)); + } catch (RuntimeException e) { + LogEvent.logError("could not save result notification configs", e); + Errors errors = new BaseErrors(); + errors.reject("alert.error", "An error occured while saving"); + saveErrors(errors); + return displayNotificationConfig(); + } + + // redirectAttributes.addFlashAttribute(FWD_SUCCESS, true); + // return findForward(FWD_SUCCESS_INSERT, form); + return form; + } + + @Override + protected List createMenuList(AdminOptionMenuForm form, + HttpServletRequest request) { + List allOrderableTests = testService.getAllActiveOrderableTests(); + + List testNotificationConfigs = new ArrayList<>(); + for (Test test : allOrderableTests) { + TestNotificationConfig testNotificationConfig = testNotificationConfigService + .getTestNotificationConfigForTestId(test.getId()).orElse(new TestNotificationConfig()); + testNotificationConfig.setTest(test); + testNotificationConfigs.add(testNotificationConfig); + } + return testNotificationConfigs; + } + + @Override + protected String getDeactivateDisabled() { + return "false"; + } + + @Override + protected String findLocalForward(String forward) { + if (FWD_SUCCESS.equals(forward)) { + return "testNotificationMasterListsPageDefinition"; + } else if (FWD_FAIL.equals(forward)) { + return "redirect:/MasterListsPage"; + } else if (FWD_SUCCESS_INSERT.equals(forward)) { + return "redirect:/TestNotificationConfigMenu"; + } else if (FWD_FAIL_INSERT.equals(forward)) { + return "haitiMasterListsPageDefinition"; + } else { + return "PageNotFound"; + } + } + + @Override + protected String getPageTitleKey() { + return "testnotificationconfig.browse.title"; + } + + @Override + protected String getPageSubtitleKey() { + return "testnotificationconfig.browse.title"; + } +} diff --git a/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java new file mode 100644 index 0000000000..b3d78dc276 --- /dev/null +++ b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java @@ -0,0 +1,115 @@ +package org.openelisglobal.notification.controller.rest; + +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import org.apache.commons.validator.GenericValidator; +import org.openelisglobal.common.controller.BaseController; +import org.openelisglobal.notification.form.TestNotificationConfigForm; +import org.openelisglobal.notification.service.NotificationPayloadTemplateService; +import org.openelisglobal.notification.service.TestNotificationConfigService; +import org.openelisglobal.notification.valueholder.NotificationPayloadTemplate.NotificationPayloadType; +import org.openelisglobal.notification.valueholder.TestNotificationConfig; +import org.openelisglobal.test.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestNotificationConfigRestController extends BaseController { + + private static final String[] ALLOWED_FIELDS = new String[] { "config*", "editSystemDefaultPayloadTemplate", + "systemDefaultPayloadTemplate*" }; + + @Autowired + private TestNotificationConfigService testNotificationConfigService; + + @Autowired + private NotificationPayloadTemplateService payloadTemplateService; + @Autowired + private TestService testService; + + @InitBinder + public void initBinder(WebDataBinder binder) { + binder.setAllowedFields(ALLOWED_FIELDS); + } + + @GetMapping("/TestNotificationConfig") + public TestNotificationConfigForm displayNotificationConfig( + @RequestParam(name = "testId", required = false) String testId) { + TestNotificationConfigForm form = new TestNotificationConfigForm(); + + form.setFormName("TestNotificationConfigForm"); + form.setSystemDefaultPayloadTemplate( + payloadTemplateService.getSystemDefaultPayloadTemplateForType(NotificationPayloadType.TEST_RESULT)); + form.setConfig(testNotificationConfigService.getTestNotificationConfigForTestId(testId) + .orElse(new TestNotificationConfig())); + if (form.getConfig().getTest() == null || GenericValidator.isBlankOrNull(form.getConfig().getTest().getId())) { + form.getConfig().setTest(testService.get(testId)); + } + // return findForward(FWD_SUCCESS, form); + return form; + } + + @GetMapping(value = "/TestNotificationConfig/raw/list", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public List getNotificationConfigs( + @RequestParam(name = "testIds", required = false) List testIds) { + List configs = testNotificationConfigService + .getTestNotificationConfigsForTestId(testIds); + return configs; + } + + @PostMapping("/TestNotificationConfig") + public TestNotificationConfigForm updateNotificationConfig(HttpServletRequest request, + @RequestBody @Valid TestNotificationConfigForm form, BindingResult result) { + if (result.hasErrors()) { + saveErrors(result); + return displayNotificationConfig(form.getConfig().getTest().getId()); + } + String sysUserId = this.getSysUserId(request); + + testNotificationConfigService.saveStatusAndMessages(form.getConfig(), sysUserId); + if (form.getEditSystemDefaultPayloadTemplate()) { + payloadTemplateService.updatePayloadTemplateMessagesAndSubject(form.getSystemDefaultPayloadTemplate(), + sysUserId); + } + testNotificationConfigService.removeEmptyPayloadTemplates(form.getConfig(), sysUserId); + // redirectAttributes.addFlashAttribute(FWD_SUCCESS, true); + // return findForward(FWD_SUCCESS_INSERT, form); + return form; + } + + @Override + protected String findLocalForward(String forward) { + if (FWD_SUCCESS.equals(forward)) { + return "testNotificationConfigDefinition"; + } else if (FWD_FAIL.equals(forward)) { + return "redirect:/TestNotificationConfigMenu"; + } else if (FWD_SUCCESS_INSERT.equals(forward)) { + return "redirect:/TestNotificationConfigMenu"; + } else if (FWD_FAIL_INSERT.equals(forward)) { + return "testNotificationConfigDefinition"; + } else { + return "PageNotFound"; + } + } + + @Override + protected String getPageTitleKey() { + return "testnotificationconfig.browse.title"; + } + + @Override + protected String getPageSubtitleKey() { + return "testnotificationconfig.browse.title"; + } +} From 29d709a332406f7e2e7a3e4bfd0a9322f3b315f9 Mon Sep 17 00:00:00 2001 From: "Aditya @ArchLinux" <132184385+adityadeshlahre@users.noreply.github.com> Date: Wed, 24 Jul 2024 04:36:31 +0530 Subject: [PATCH 16/84] fix(TestNotificationConfigMenu): restController localhost CM error fix --- ...TestNotificationConfigMenuRestController.java | 16 +++++++++------- .../TestNotificationConfigRestController.java | 13 ++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java index c18b14c069..9a7fad865c 100644 --- a/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java +++ b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigMenuRestController.java @@ -22,9 +22,11 @@ import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController +@RequestMapping("/rest") public class TestNotificationConfigMenuRestController extends BaseMenuController { private static final String[] ALLOWED_FIELDS = new String[] { "menuList*.id", "menuList*.test.id", @@ -57,12 +59,11 @@ public TestNotificationConfigMenuForm displayNotificationConfig() } @PostMapping("/TestNotificationConfigMenu") - public TestNotificationConfigMenuForm updateNotificationConfig(HttpServletRequest request, - @RequestBody @Valid TestNotificationConfigMenuForm form, BindingResult result) - throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + public TestNotificationConfigMenuForm updateNotificationConfig(@RequestBody @Valid TestNotificationConfigMenuForm form, BindingResult result){ if (result.hasErrors()) { - saveErrors(result); - return displayNotificationConfig(); + // saveErrors(result); + // return displayNotificationConfig(); + throw new RuntimeException("Validation errors occurred"); } try { testNotificationConfigService.saveTestNotificationConfigsActiveStatuses(form.getMenuList(), @@ -71,8 +72,9 @@ public TestNotificationConfigMenuForm updateNotificationConfig(HttpServletReques LogEvent.logError("could not save result notification configs", e); Errors errors = new BaseErrors(); errors.reject("alert.error", "An error occured while saving"); - saveErrors(errors); - return displayNotificationConfig(); + // saveErrors(errors); + // return displayNotificationConfig(); + throw new RuntimeException("An error occurred while saving"); } // redirectAttributes.addFlashAttribute(FWD_SUCCESS, true); diff --git a/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java index b3d78dc276..f4097cb252 100644 --- a/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java +++ b/src/main/java/org/openelisglobal/notification/controller/rest/TestNotificationConfigRestController.java @@ -1,7 +1,6 @@ package org.openelisglobal.notification.controller.rest; import java.util.List; -import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import org.apache.commons.validator.GenericValidator; import org.openelisglobal.common.controller.BaseController; @@ -19,11 +18,12 @@ import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @RestController +@RequestMapping("/rest") public class TestNotificationConfigRestController extends BaseController { private static final String[] ALLOWED_FIELDS = new String[] { "config*", "editSystemDefaultPayloadTemplate", @@ -60,7 +60,6 @@ public TestNotificationConfigForm displayNotificationConfig( } @GetMapping(value = "/TestNotificationConfig/raw/list", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody public List getNotificationConfigs( @RequestParam(name = "testIds", required = false) List testIds) { List configs = testNotificationConfigService @@ -69,11 +68,11 @@ public List getNotificationConfigs( } @PostMapping("/TestNotificationConfig") - public TestNotificationConfigForm updateNotificationConfig(HttpServletRequest request, - @RequestBody @Valid TestNotificationConfigForm form, BindingResult result) { + public TestNotificationConfigForm updateNotificationConfig(@RequestBody @Valid TestNotificationConfigForm form, BindingResult result) { if (result.hasErrors()) { - saveErrors(result); - return displayNotificationConfig(form.getConfig().getTest().getId()); + // saveErrors(result); + // return displayNotificationConfig(form.getConfig().getTest().getId()); + throw new RuntimeException("Validation errors occurred"); } String sysUserId = this.getSysUserId(request); From d8e82bcfae8b96ecee6ce6ca2768225346764092 Mon Sep 17 00:00:00 2001 From: "Aditya @ArchLinux" <132184385+adityadeshlahre@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:21:39 +0530 Subject: [PATCH 17/84] fix(TestNotificationConfigMenu): ReactJs page init --- frontend/src/components/admin/Admin.js | 8 ++ .../GenricTestNotificationConfigEdit.js | 119 ++++++++++++++++++ .../TestNotificationConfigMenu.js | 79 +++++++++++- frontend/src/languages/en.json | 25 +++- frontend/src/languages/fr.json | 25 +++- 5 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js diff --git a/frontend/src/components/admin/Admin.js b/frontend/src/components/admin/Admin.js index 179efad4fc..b4e3302bf1 100644 --- a/frontend/src/components/admin/Admin.js +++ b/frontend/src/components/admin/Admin.js @@ -29,6 +29,7 @@ import { Bullhorn, User, BatchJob, + Popup, } from "@carbon/icons-react"; import PathRoute from "../utils/PathRoute"; import CalculatedValue from "./calculatedValue/CalculatedValueForm"; @@ -54,6 +55,7 @@ import UserManagement from "./userManagement/UserManagement"; import UserAddModify from "./userManagement/UserAddModify"; import ManageMethod from "./testManagement/ManageMethod.js"; import BatchTestReassignmentAndCancelation from "./BatchTestReassignmentAndCancellation/BatchTestReassignmentAndCancelation.js"; +import TestNotificationConfigMenu from "./testNotificationConfigMenu/TestNotificationConfigMenu.js"; function Admin() { const intl = useIntl(); @@ -188,6 +190,9 @@ function Admin() { defaultMessage={"Common Properties"} /> + + + @@ -325,6 +330,9 @@ function Admin() { id="sidenav.label.admin.formEntry.PrintedReportsconfig" /> + + + diff --git a/frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js b/frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js new file mode 100644 index 0000000000..a6cf077d11 --- /dev/null +++ b/frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js @@ -0,0 +1,119 @@ +import React, { useContext, useState, useEffect, useRef } from "react"; +import { + Heading, + Button, + Loading, + Grid, + Column, + Section, + DataTable, + Table, + TableHead, + TableRow, + TableBody, + TableHeader, + TableCell, + TableSelectRow, + TableSelectAll, + TableContainer, + Pagination, + Search, + Modal, + TextInput, + Dropdown, +} from "@carbon/react"; +import { + getFromOpenElisServer, + postToOpenElisServerFullResponse, +} from "../../utils/Utils.js"; +import { + ConfigurationContext, + NotificationContext, +} from "../../layout/Layout.js"; +import { + AlertDialog, + NotificationKinds, +} from "../../common/CustomNotification.js"; +import { FormattedMessage, injectIntl, useIntl } from "react-intl"; +import PageBreadCrumb from "../../common/PageBreadCrumb.js"; +import { ArrowLeft, ArrowRight } from "@carbon/icons-react"; +import ActionPaginationButtonType from "../../common/ActionPaginationButtonType.js"; + +let breadcrumbs = [ + { label: "home.label", link: "/" }, + { label: "breadcrums.admin.managment", link: "/MasterListsPage" }, + { + label: "testnotificationconfig.browse.title", + link: "/MasterListsPage#testNotificationConfigMenu", + }, +]; + +function GenricTestNotificationConfigEdit() { + const { notificationVisible, setNotificationVisible, addNotification } = + useContext(NotificationContext); + + const intl = useIntl(); + + const componentMounted = useRef(false); + + return ( + <> +
+ + + +
+
+ + + +
+
+
+
+
+ + +
+
+ + + +
+
+
+ +
+ +
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+ +
+ +
+ +
+ +
+
+
+
+
+ + ); +} + +export default injectIntl(GenricTestNotificationConfigEdit); diff --git a/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js index 8e0afd47be..2039aa6e0c 100644 --- a/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js +++ b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigMenu.js @@ -1,5 +1,80 @@ +import React, { useContext, useState, useEffect, useRef } from "react"; +import { + Heading, + Button, + Loading, + Grid, + Column, + Section, + DataTable, + Table, + TableHead, + TableRow, + TableBody, + TableHeader, + TableCell, + TableSelectRow, + TableSelectAll, + TableContainer, + Pagination, + Search, + Modal, + TextInput, + Dropdown, +} from "@carbon/react"; +import { + getFromOpenElisServer, + postToOpenElisServerFullResponse, +} from "../../utils/Utils.js"; +import { + ConfigurationContext, + NotificationContext, +} from "../../layout/Layout.js"; +import { + AlertDialog, + NotificationKinds, +} from "../../common/CustomNotification.js"; import { FormattedMessage, injectIntl, useIntl } from "react-intl"; +import PageBreadCrumb from "../../common/PageBreadCrumb.js"; +import { ArrowLeft, ArrowRight } from "@carbon/icons-react"; +import ActionPaginationButtonType from "../../common/ActionPaginationButtonType.js"; -function ProviderMenu() {} +let breadcrumbs = [ + { label: "home.label", link: "/" }, + { label: "breadcrums.admin.managment", link: "/MasterListsPage" }, + { + label: "testnotificationconfig.browse.title", + link: "/MasterListsPage#testNotificationConfigMenu", + }, +]; -export default injectIntl(ProviderMenu); +function TestNotificationConfigMenu() { + const { notificationVisible, setNotificationVisible, addNotification } = + useContext(NotificationContext); + + const intl = useIntl(); + + const componentMounted = useRef(false); + + return ( + <> +
+ + + +
+
+ + + +
+
+
+
+
+
+ + ); +} + +export default injectIntl(TestNotificationConfigMenu); diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index d595c89fee..b4f183b1e9 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -1239,5 +1239,28 @@ "notification.slideover.button.unsubscribe.success": "Unsubscribed successfully", "notification.slideover.button.unsubscribe.fail": "Unsubscribe failed", "notification.slideover.button.subscribe.success": "Subscribed successfully", - "notification.slideover.button.subscribe.fail": "Subscribe failed" + "notification.slideover.button.subscribe.fail": "Subscribe failed", + "testnotificationconfig.browse.title": "Test Notification Configuration", + "label.testName": "Test names", + "testnotification.instructionis.variables.body": "[testName] : Name of the test this is for", + "testnotification.instructionis.variables.body.0": "[testResult] : Result of the test", + "testnotification.instructionis.variables.body.1": "[patientFirstName] : Patient's first name ", + "testnotification.instructionis.variables.body.2": "[patientLastNameInitial] : Patient's last name's initial", + "testnotification.instructionis.variables.header": "List of variables:", + "testnotification.instructions.body": "When a notification is created, it will first check if a message template is defined for the recipient/message type.", + "testnotification.instructions.body.0": "If none exists, it will use the test default message.", + "testnotification.instructions.body.1": "If that does not exist, it will use the system default message.", + "testnotification.instructions.body.2": "Variables will be replaced by their corresponding values in the message body and the subject.", + "testnotification.instructions.body.3": "Variables should always include the square brackets and should have no whitespace.", + "testnotification.instructions.header": "Instructions:", + "testnotification.messagetemplate": "Message", + "testnotification.options": "Individiual Messages", + "testnotification.patient.email": "Patient Email", + "testnotification.patient.sms": "Patient SMS", + "testnotification.patiententry.header": "Result Reporting", + "testnotification.provider.email": "Provider Email", + "testnotification.provider.sms": "Provider SMS", + "testnotification.subjecttemplate": "Subject", + "testnotification.systemdefault.template": "System Default Message", + "testnotification.testdefault.template": "Default Message for Test" } diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index 6ae9c22038..d73a632edd 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -1143,5 +1143,28 @@ "notification.slideover.button.unsubscribe.success": "Désabonnement réussi", "notification.slideover.button.unsubscribe.fail": "Échec de l'annulation de l'abonnement", "notification.slideover.button.subscribe.success": "Abonnement réussi", - "notification.slideover.button.subscribe.fail": "Échec de l'abonnement" + "notification.slideover.button.subscribe.fail": "Échec de l'abonnement", + "testnotificationconfig.browse.title": "Configuration des notifications de test", + "label.testName": "Noms des tests", + "testnotification.instructionis.variables.body": "[testName] : Nom du test pour lequel cela est", + "testnotification.instructionis.variables.body.0": "[testResult] : Résultat du test", + "testnotification.instructionis.variables.body.1": "[patientFirstName] : Prénom du patient", + "testnotification.instructionis.variables.body.2": "[patientLastNameInitial] : Initiale du nom de famille du patient", + "testnotification.instructionis.variables.header": "Liste des variables :", + "testnotification.instructions.body": "Lorsqu'une notification est créée, elle vérifiera d'abord si un modèle de message est défini pour le destinataire/type de message.", + "testnotification.instructions.body.0": "S'il n'en existe pas, elle utilisera le message par défaut du test.", + "testnotification.instructions.body.1": "Si cela n'existe pas, elle utilisera le message par défaut du système.", + "testnotification.instructions.body.2": "Les variables seront remplacées par leurs valeurs correspondantes dans le corps du message et l'objet.", + "testnotification.instructions.body.3": "Les variables doivent toujours inclure les crochets et ne doivent pas contenir d'espaces.", + "testnotification.instructions.header": "Instructions :", + "testnotification.messagetemplate": "Message", + "testnotification.options": "Messages individuels", + "testnotification.patient.email": "E-mail du patient", + "testnotification.patient.sms": "SMS du patient", + "testnotification.patiententry.header": "Rapport de résultats", + "testnotification.provider.email": "E-mail du fournisseur", + "testnotification.provider.sms": "SMS du fournisseur", + "testnotification.subjecttemplate": "Objet", + "testnotification.systemdefault.template": "Message par défaut du système", + "testnotification.testdefault.template": "Message par défaut pour le test" } From 575f99cb6533143a88209e96231dd1685910cc71 Mon Sep 17 00:00:00 2001 From: "Aditya @ArchLinux" <132184385+adityadeshlahre@users.noreply.github.com> Date: Thu, 25 Jul 2024 02:58:42 +0530 Subject: [PATCH 18/84] fix(TestNotificationConfigMenu): testNotifConfIdEdit page init --- .../GenricTestNotificationConfigEdit.js | 119 ---- .../TestNotificationConfigEdit.js | 553 ++++++++++++++++++ frontend/src/languages/en.json | 3 +- frontend/src/languages/fr.json | 3 +- ...tNotificationConfigMenuRestController.java | 3 +- .../TestNotificationConfigRestController.java | 3 +- 6 files changed, 561 insertions(+), 123 deletions(-) delete mode 100644 frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js create mode 100644 frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js diff --git a/frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js b/frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js deleted file mode 100644 index a6cf077d11..0000000000 --- a/frontend/src/components/admin/testNotificationConfigMenu/GenricTestNotificationConfigEdit.js +++ /dev/null @@ -1,119 +0,0 @@ -import React, { useContext, useState, useEffect, useRef } from "react"; -import { - Heading, - Button, - Loading, - Grid, - Column, - Section, - DataTable, - Table, - TableHead, - TableRow, - TableBody, - TableHeader, - TableCell, - TableSelectRow, - TableSelectAll, - TableContainer, - Pagination, - Search, - Modal, - TextInput, - Dropdown, -} from "@carbon/react"; -import { - getFromOpenElisServer, - postToOpenElisServerFullResponse, -} from "../../utils/Utils.js"; -import { - ConfigurationContext, - NotificationContext, -} from "../../layout/Layout.js"; -import { - AlertDialog, - NotificationKinds, -} from "../../common/CustomNotification.js"; -import { FormattedMessage, injectIntl, useIntl } from "react-intl"; -import PageBreadCrumb from "../../common/PageBreadCrumb.js"; -import { ArrowLeft, ArrowRight } from "@carbon/icons-react"; -import ActionPaginationButtonType from "../../common/ActionPaginationButtonType.js"; - -let breadcrumbs = [ - { label: "home.label", link: "/" }, - { label: "breadcrums.admin.managment", link: "/MasterListsPage" }, - { - label: "testnotificationconfig.browse.title", - link: "/MasterListsPage#testNotificationConfigMenu", - }, -]; - -function GenricTestNotificationConfigEdit() { - const { notificationVisible, setNotificationVisible, addNotification } = - useContext(NotificationContext); - - const intl = useIntl(); - - const componentMounted = useRef(false); - - return ( - <> -
- - - -
-
- - - -
-
-
-
-
- - -
-
- - - -
-
-
- -
- -
- -
- -
- -
-
-
-
- -
-
-
-
- -
- -
- -
- -
-
-
-
-
- - ); -} - -export default injectIntl(GenricTestNotificationConfigEdit); diff --git a/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js new file mode 100644 index 0000000000..3a87feb9b6 --- /dev/null +++ b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js @@ -0,0 +1,553 @@ +import React, { useContext, useState, useEffect, useRef } from "react"; +import { + Heading, + Button, + Loading, + Grid, + Column, + Section, + DataTable, + Table, + TableHead, + TableRow, + TableBody, + TableHeader, + TableCell, + TableSelectRow, + TableSelectAll, + TableContainer, + Pagination, + Search, + Modal, + TextInput, + Dropdown, + TextArea, + Checkbox, +} from "@carbon/react"; +import { + getFromOpenElisServer, + postToOpenElisServerFullResponse, +} from "../../utils/Utils.js"; +import { + ConfigurationContext, + NotificationContext, +} from "../../layout/Layout.js"; +import { + AlertDialog, + NotificationKinds, +} from "../../common/CustomNotification.js"; +import { FormattedMessage, injectIntl, useIntl } from "react-intl"; +import PageBreadCrumb from "../../common/PageBreadCrumb.js"; +import { ArrowLeft, ArrowRight, Cost } from "@carbon/icons-react"; +import ActionPaginationButtonType from "../../common/ActionPaginationButtonType.js"; + +let breadcrumbs = [ + { label: "home.label", link: "/" }, + { label: "breadcrums.admin.managment", link: "/MasterListsPage" }, + { + label: "testnotificationconfig.browse.title", + link: "/MasterListsPage#testNotificationConfigMenu", + }, +]; + +function TestNotificationConfigEdit() { + const { notificationVisible, setNotificationVisible, addNotification } = + useContext(NotificationContext); + + const intl = useIntl(); + + const componentMounted = useRef(false); + const [indMsg, setIndMsg] = useState("0"); + + return ( + <> +
+ + + +
+
+ + + +
+
+
+
+
+ + +
+
+ + + +
+
+
+
+
+ + + { + // handleCheckboxChange(section.roleId); + // }} + /> + + + + + + + + + + + +
+
+
+ + +
+
+ + + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ + + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + +
+
+
+ + + +
+
+
+
+ + + +
+
+ + + + + + handleUserLoginNameChange(e)} + /> + + +
+ + + + + +
+ + +