From 0022ef0ae5ffe20b274656412a6b0c7aadb1d87e Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Wed, 10 Jul 2024 12:33:07 +0530 Subject: [PATCH 1/5] e2e coverage reportNCE --- frontend/cypress.config.js | 1 + frontend/cypress/e2e/nonConform.cy.js | 61 +++++++++++++++++++++++ frontend/cypress/fixtures/NonConform.json | 3 ++ frontend/cypress/pages/HomePage.js | 13 +++++ frontend/cypress/pages/NonConformPage.js | 40 +++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 frontend/cypress/e2e/nonConform.cy.js create mode 100644 frontend/cypress/fixtures/NonConform.json create mode 100644 frontend/cypress/pages/NonConformPage.js diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 475f7edd2e..ee50118896 100755 --- a/frontend/cypress.config.js +++ b/frontend/cypress.config.js @@ -12,6 +12,7 @@ module.exports = defineConfig({ "cypress/e2e/patientEntry.cy.js", "cypress/e2e/orderEntity.cy.js", "cypress/e2e/workplan.cy.js", + "cypress/e2e/nonConform.cy.js", "cypress/e2e/modifyOrder.cy.js", ]; return config; diff --git a/frontend/cypress/e2e/nonConform.cy.js b/frontend/cypress/e2e/nonConform.cy.js new file mode 100644 index 0000000000..99609f0cd3 --- /dev/null +++ b/frontend/cypress/e2e/nonConform.cy.js @@ -0,0 +1,61 @@ +import LoginPage from "../pages/LoginPage"; +import HomePage from "../pages/HomePage"; +import NonConform from "../pages/NonConformPage"; + +let homePage = null; +let loginPage = null; +let nonConform = null; + +before("login", () => { + loginPage = new LoginPage(); + loginPage.visit(); +}); + +describe("Report Non-Conforming Event", function () { + beforeEach("navigate to Report Non-Conforming Event Page", function () { + homePage = loginPage.goToHomePage(); + nonConform = homePage.goToReportNCE(); + }); + + it("User visits Report Non-Conforming Event Page", function () { + nonConform.getReportNonConformTitle().should("contain.text", "Report Non-Conforming Event (NCE)"); + }); + + it("Should Search by Last Name and Validate the results", function () { + cy.fixture("Patient").then((patient) => { + nonConform.selectSearchType('Last Name'); + nonConform.enterSearchField(patient.lastName); + nonConform.clickSearchButton(); + cy.fixture("Order").then((order) => { + nonConform.validateSearchResult(order.labNo); + }); + }); + }); + + it("Should Search by First Name and Validate the results", function () { + cy.fixture("Patient").then((patient) => { + nonConform.selectSearchType('First Name'); + nonConform.enterSearchField(patient.firstName); + nonConform.clickSearchButton(); + cy.fixture("Order").then((order) => { + nonConform.validateSearchResult(order.labNo); + }); + }); + }); + + it("Should Search by Lab Number and Submit the NCE Reporting Form", function () { + cy.fixture("Order").then((order) => { + nonConform.selectSearchType('Lab Number'); + nonConform.enterSearchField(order.labNo); + nonConform.clickSearchButton(); + nonConform.validateSearchResult(order.labNo); + nonConform.clickCheckbox(); + nonConform.clickGoToNceFormButton(); + }); + + cy.fixture("NonConform").then((nonConformData) => { + nonConform.enterStartDate(nonConformData.dateOfEvent); + nonConform.submitForm(); + }); + }); +}); diff --git a/frontend/cypress/fixtures/NonConform.json b/frontend/cypress/fixtures/NonConform.json new file mode 100644 index 0000000000..a6f5382c25 --- /dev/null +++ b/frontend/cypress/fixtures/NonConform.json @@ -0,0 +1,3 @@ +{ + "dateOfEvent":"10/07/2024" +} \ No newline at end of file diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index a33ae0ce92..21b64cec60 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -3,6 +3,7 @@ import PatientEntryPage from "./PatientEntryPage"; import OrderEntityPage from "./OrderEntityPage"; import ModifyOrderPage from "./ModifyOrderPage"; import WorkPlan from "./WorkPlan"; +import NonConform from "./NonConformPage"; class HomePage { constructor() {} @@ -96,6 +97,18 @@ class HomePage { ).click(); return new WorkPlan(); } + + goToReportNCE(){ + this.openNavigationMenu(); + 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 > :nth-child(1) > .cds--side-nav__link > .cds--side-nav__link-text > [style="display: flex; width: 100%;"] > .custom-sidenav-button', + ).click(); + return new NonConform(); + + } } export default HomePage; diff --git a/frontend/cypress/pages/NonConformPage.js b/frontend/cypress/pages/NonConformPage.js new file mode 100644 index 0000000000..024b2fe3f0 --- /dev/null +++ b/frontend/cypress/pages/NonConformPage.js @@ -0,0 +1,40 @@ +class NonConform { + getReportNonConformTitle() { + return cy.get("h2"); + } + + selectSearchType(type) { + cy.get('#type').select(type); + } + + enterSearchField(value) { + cy.get('#field\\.name').type(value); + } + + clickSearchButton() { + cy.get(':nth-child(4) > .cds--btn').click(); + } + + validateSearchResult(expectedValue) { + cy.get('tbody > tr > :nth-child(2)').invoke('text').should('eq', expectedValue); + } + + clickCheckbox() { + cy.get('.cds--checkbox-label').click(); + } + + clickGoToNceFormButton() { + cy.get(':nth-child(2) > :nth-child(2) > .cds--btn').click(); + } + + enterStartDate(date) { + cy.get('.cds--date-picker-input__wrapper > #startDate').type(date); + } + + submitForm() { + cy.get(':nth-child(16) > .cds--btn').click(); + } + } + + export default NonConform; + \ No newline at end of file From 7b2c82c80af647a2c90315bbcfeb6601d9f72f00 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Wed, 10 Jul 2024 12:39:45 +0530 Subject: [PATCH 2/5] minorfix --- frontend/cypress/e2e/nonConform.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/cypress/e2e/nonConform.cy.js b/frontend/cypress/e2e/nonConform.cy.js index 99609f0cd3..774373c598 100644 --- a/frontend/cypress/e2e/nonConform.cy.js +++ b/frontend/cypress/e2e/nonConform.cy.js @@ -26,7 +26,7 @@ describe("Report Non-Conforming Event", function () { nonConform.selectSearchType('Last Name'); nonConform.enterSearchField(patient.lastName); nonConform.clickSearchButton(); - cy.fixture("Order").then((order) => { + cy.fixture("EnteredOrder").then((order) => { nonConform.validateSearchResult(order.labNo); }); }); @@ -37,14 +37,14 @@ describe("Report Non-Conforming Event", function () { nonConform.selectSearchType('First Name'); nonConform.enterSearchField(patient.firstName); nonConform.clickSearchButton(); - cy.fixture("Order").then((order) => { + cy.fixture("EnteredOrder").then((order) => { nonConform.validateSearchResult(order.labNo); }); }); }); it("Should Search by Lab Number and Submit the NCE Reporting Form", function () { - cy.fixture("Order").then((order) => { + cy.fixture("EnteredOrder").then((order) => { nonConform.selectSearchType('Lab Number'); nonConform.enterSearchField(order.labNo); nonConform.clickSearchButton(); From de0a6dab7f4b0a13e9a1f5b1f90915211633f988 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Wed, 10 Jul 2024 13:52:33 +0530 Subject: [PATCH 3/5] minor fix --- .../controller/rest/ReportNonConformEventsRestController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java b/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java index 65a27bc4f4..e037ed3050 100644 --- a/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java +++ b/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java @@ -69,7 +69,7 @@ public ResponseEntity getNCESampleSearch(@RequestParam(required = false) Stri searchResults = sample != null ? List.of(sample) : List.of(); } else { List results = searchResultsService.getSearchResults(lastName, firstName, - STNumber, "", "", "", "", "", "", ""); + STNumber, STNumber,STNumber, "", "", "", "", ""); searchResults = results.stream() .flatMap(patientSearchResults -> sampleService .getSamplesForPatient(patientSearchResults.getPatientID()).stream()) From 122aa25a9d6289e4eaaa9f7589e718a4404c2825 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Wed, 10 Jul 2024 13:53:06 +0530 Subject: [PATCH 4/5] search by patientID --- frontend/cypress/e2e/nonConform.cy.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/cypress/e2e/nonConform.cy.js b/frontend/cypress/e2e/nonConform.cy.js index 774373c598..88310426a3 100644 --- a/frontend/cypress/e2e/nonConform.cy.js +++ b/frontend/cypress/e2e/nonConform.cy.js @@ -18,12 +18,14 @@ describe("Report Non-Conforming Event", function () { }); it("User visits Report Non-Conforming Event Page", function () { - nonConform.getReportNonConformTitle().should("contain.text", "Report Non-Conforming Event (NCE)"); + nonConform + .getReportNonConformTitle() + .should("contain.text", "Report Non-Conforming Event (NCE)"); }); it("Should Search by Last Name and Validate the results", function () { cy.fixture("Patient").then((patient) => { - nonConform.selectSearchType('Last Name'); + nonConform.selectSearchType("Last Name"); nonConform.enterSearchField(patient.lastName); nonConform.clickSearchButton(); cy.fixture("EnteredOrder").then((order) => { @@ -34,7 +36,7 @@ describe("Report Non-Conforming Event", function () { it("Should Search by First Name and Validate the results", function () { cy.fixture("Patient").then((patient) => { - nonConform.selectSearchType('First Name'); + nonConform.selectSearchType("First Name"); nonConform.enterSearchField(patient.firstName); nonConform.clickSearchButton(); cy.fixture("EnteredOrder").then((order) => { @@ -43,9 +45,20 @@ describe("Report Non-Conforming Event", function () { }); }); + it("Should Search by PatientID and Validate the results", function () { + cy.fixture("Patient").then((patient) => { + nonConform.selectSearchType("Patient Identification Code"); + nonConform.enterSearchField(patient.nationalId); + nonConform.clickSearchButton(); + cy.fixture("EnteredOrder").then((order) => { + nonConform.validateSearchResult(order.labNo); + }); + }); + }); + it("Should Search by Lab Number and Submit the NCE Reporting Form", function () { cy.fixture("EnteredOrder").then((order) => { - nonConform.selectSearchType('Lab Number'); + nonConform.selectSearchType("Lab Number"); nonConform.enterSearchField(order.labNo); nonConform.clickSearchButton(); nonConform.validateSearchResult(order.labNo); From a3d82876a71413254cd7d0ffe6ced3bcf6806e68 Mon Sep 17 00:00:00 2001 From: manishjha-04 Date: Wed, 10 Jul 2024 14:00:20 +0530 Subject: [PATCH 5/5] formatting fix --- .../controller/rest/ReportNonConformEventsRestController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java b/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java index e037ed3050..df35f55af1 100644 --- a/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java +++ b/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java @@ -69,7 +69,7 @@ public ResponseEntity getNCESampleSearch(@RequestParam(required = false) Stri searchResults = sample != null ? List.of(sample) : List.of(); } else { List results = searchResultsService.getSearchResults(lastName, firstName, - STNumber, STNumber,STNumber, "", "", "", "", ""); + STNumber, STNumber, STNumber, "", "", "", "", ""); searchResults = results.stream() .flatMap(patientSearchResults -> sampleService .getSamplesForPatient(patientSearchResults.getPatientID()).stream())