Skip to content

Commit

Permalink
Merge pull request #1171 from manishjha-04/reportnce
Browse files Browse the repository at this point in the history
E2E Coverage for Report NCE
  • Loading branch information
mozzy11 authored Jul 10, 2024
2 parents 11d4faa + a3d8287 commit 089c748
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
74 changes: 74 additions & 0 deletions frontend/cypress/e2e/nonConform.cy.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
3 changes: 3 additions & 0 deletions frontend/cypress/fixtures/NonConform.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dateOfEvent":"10/07/2024"
}
13 changes: 13 additions & 0 deletions frontend/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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;
40 changes: 40 additions & 0 deletions frontend/cypress/pages/NonConformPage.js
Original file line number Diff line number Diff line change
@@ -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;

Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public ResponseEntity<?> getNCESampleSearch(@RequestParam(required = false) Stri
searchResults = sample != null ? List.of(sample) : List.of();
} else {
List<PatientSearchResults> results = searchResultsService.getSearchResults(lastName, firstName,
STNumber, "", "", "", "", "", "", "");
STNumber, STNumber, STNumber, "", "", "", "", "");
searchResults = results.stream()
.flatMap(patientSearchResults -> sampleService
.getSamplesForPatient(patientSearchResults.getPatientID()).stream())
Expand Down

0 comments on commit 089c748

Please sign in to comment.