diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 475f7edd2..ee5011889 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 000000000..88310426a --- /dev/null +++ b/frontend/cypress/e2e/nonConform.cy.js @@ -0,0 +1,74 @@ +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("EnteredOrder").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("EnteredOrder").then((order) => { + nonConform.validateSearchResult(order.labNo); + }); + }); + }); + + 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.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 000000000..a6f5382c2 --- /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 a33ae0ce9..21b64cec6 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 000000000..024b2fe3f --- /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 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 65a27bc4f..df35f55af 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())