diff --git a/frontend/cypress.config.js b/frontend/cypress.config.js index 565db9634a..f5b9f83351 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 @@ -13,6 +14,8 @@ module.exports = defineConfig({ "cypress/e2e/orderEntity.cy.js", "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", "cypress/e2e/report.cy.js", "cypress/e2e/batchOrderEntry.cy.js", diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js new file mode 100644 index 0000000000..9a4f4f3b9b --- /dev/null +++ b/frontend/cypress/e2e/result.cy.js @@ -0,0 +1,285 @@ +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 () { + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); + }); + + it("Should Search by Unit", function () { + cy.fixture("workplan").then((order) => { + result.selectUnitType(order.unitType); + }); + }); + + it("should accept the sample, refer the sample, and save the result", function () { + 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(); + }); + }); +}); + +describe("Result By Patient", function () { + before("navigate to Result By Patient", function () { + result = homePage.goToResultsByPatient(); + }); + + it("User visits Results Page", function () { + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); + }); + + 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.reload(); + }); + + it("should search patient By PatientId and validate", function () { + cy.wait(500); + cy.fixture("Patient").then((patient) => { + patientPage.searchPatientByPatientId(patient.nationalId); + patientPage.clickSearchPatientButton(); + patientPage.validatePatientSearchTable( + patient.firstName, + patient.inValidName, + ); + }); + cy.reload(); + }); + + it("should search patient By Lab Number and validate", function () { + cy.wait(500); + 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.acceptResult(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.stainTestMethod); + result.submitResults(); + }); + }); +}); + +describe("Result By Order", function () { + before("navigate to Result By Order", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByOrder(); + }); + + it("User visits Results Page", function () { + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); + }); + + it("Should Search by Accession Number", 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 () { + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.stainTestMethod); + result.submitResults(); + }); + }); +}); + +describe("Result By Referred Out Tests", function () { + before("navigate to Result By Referred Out Tests", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsForRefferedOut(); + }); + + it("User visits Reffered out Page", function () { + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.referralPageTitle); + }); + }); + + 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, + patient.inValidName, + ); + }); + }); + + it("should click respective patient and search for referred out tests", function () { + result.selectPatient(); + result.search(); + }); + + it("should validate the results", function () { + cy.wait(1000); + cy.fixture("Patient").then((patient) => { + result.validatePatientResult(patient); + }); + cy.reload(); + }); + + it("should search Referrals By Test Unit and validate", function () { + 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 }); + }); + //update in UI elements + // cy.fixture("result").then((res) => { + // cy.get("tbody > tr > :nth-child(8)").should( + // "contain.text", + // res.westernBlotHiv, + // ); + // }); + cy.reload(); + }); + + it("should search Referrals By LabNumber and validate", function () { + 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(); + //update in UI elements + // cy.fixture("EnteredOrder").then((patient) => { + // cy.get("tbody > tr > :nth-child(3)").should( + // "contain.text", + // patient.labNo, + // ); + // }); + }); +//commented due to UI changes + // 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 Range Of Order", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByRangeOrder(); + }); + + it("User visits Results Page", function () { + cy.fixture("result").then((res) => { + result.getResultTitle().should("contain.text", res.pageTitle); + }); + }); + + it("Should Enter Lab 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.wait(1000); + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.eiaTestMethod); + result.submitResults(); + }); + }); +}); + +describe("Result By Test And Status", function () { + before("navigate to Result By Test And Status", function () { + homePage = loginPage.goToHomePage(); + result = homePage.goToResultsByTestAndStatus(); + }); + + it("User visits Results Page", function () { + 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); + }); + 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, + ); + }); + cy.fixture("result").then((res) => { + result.acceptSample(); + result.expandSampleDetails(); + result.selectTestMethod(0, res.eiaTestMethod); + result.submitResults(); + }); + }); +}); 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/fixtures/result.json b/frontend/cypress/fixtures/result.json new file mode 100644 index 0000000000..dc0bcbec8e --- /dev/null +++ b/frontend/cypress/fixtures/result.json @@ -0,0 +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" +} diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index e41d863cb6..8b5e46a5a5 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -4,6 +4,8 @@ import OrderEntityPage from "./OrderEntityPage"; import ModifyOrderPage from "./ModifyOrderPage"; import WorkPlan from "./WorkPlan"; import NonConform from "./NonConformPage"; +import Result from "./ResultsPage"; +import Validation from "./Validation"; import BatchOrderEntry from "./BatchOrderEntryPage"; import RoutineReportPage from "./RoutineReportPage"; @@ -103,6 +105,68 @@ class HomePage { 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(); + } + + 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(); + } + goToRoutineReports() { this.openNavigationMenu(); cy.get("#menu_reports").click(); @@ -115,6 +179,7 @@ class HomePage { cy.get("#menu_reports_study_nav").click(); return new StudyReportPage(); } + goToPathologyDashboard() { this.openNavigationMenu(); cy.get("#menu_pathology_dropdown").click(); diff --git a/frontend/cypress/pages/ResultsPage.js b/frontend/cypress/pages/ResultsPage.js new file mode 100644 index 0000000000..cacab599ad --- /dev/null +++ b/frontend/cypress/pages/ResultsPage.js @@ -0,0 +1,78 @@ +class Result { + getResultTitle() { + return cy.get("section > h3"); + } + + selectUnitType(unitType) { + cy.get("#unitType").select(unitType); + } + + 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(); + } + + 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(); + } + + validatePatientResult(patient) { + cy.get('tbody > :nth-child(1) > :nth-child(2)').should("contain.text", patient.lastName); + cy.get('tbody > :nth-child(1) > :nth-child(3)').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; 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