Skip to content

Commit

Permalink
Merge pull request I-TECH-UW#1210 from manishjha-04/result
Browse files Browse the repository at this point in the history
E2E Coverage for Results and Validation
  • Loading branch information
mozzy11 authored Sep 17, 2024
2 parents dc101d8 + 0c1c625 commit 0498149
Show file tree
Hide file tree
Showing 7 changed files with 544 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = defineConfig({
defaultCommandTimeout: 8000,
viewportWidth: 1200,
viewportHeight: 700,
watchForFileChanges: false,
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
Expand All @@ -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",
Expand Down
285 changes: 285 additions & 0 deletions frontend/cypress/e2e/result.cy.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
72 changes: 72 additions & 0 deletions frontend/cypress/e2e/validation.cy.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
13 changes: 13 additions & 0 deletions frontend/cypress/fixtures/result.json
Original file line number Diff line number Diff line change
@@ -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"
}
Loading

0 comments on commit 0498149

Please sign in to comment.