Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E Coverage For Pathology And ImmunioChemistry Dashboard #1241

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = defineConfig({
"cypress/e2e/nonConform.cy.js",
"cypress/e2e/modifyOrder.cy.js",
"cypress/e2e/batchOrderEntry.cy.js",
"cypress/e2e/dashboard.cy.js",
];
return config;
},
Expand Down
84 changes: 84 additions & 0 deletions frontend/cypress/e2e/dashboard.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import LoginPage from "../pages/LoginPage";

let homePage = null;
let loginPage = null;
let dashboard = null;

before("login", () => {
loginPage = new LoginPage();
loginPage.visit();
});

describe("Pathology Dashboard", function () {
it("User Visits Pathology Dashboard", function () {
homePage = loginPage.goToHomePage();
dashboard = homePage.goToPathologyDashboard();

dashboard.checkForHeader("Pathology");
});

it("User adds a new Pathology order", function () {
homePage.goToOrderPage();
dashboard.addOrder("Histopathology");
});
it("Check For Order", () => {
homePage.goToPathologyDashboard();
dashboard.checkForHeader("Pathology");

cy.fixture("DashBoard").then((order) => {
dashboard.validatePreStatus(order.labNo);
});
});

it("Change The Status of Order and save it", () => {
dashboard.changeStatus("Completed");
dashboard.enterDetails();
dashboard.saveOrder();
});

it("Validate the Status of Order", () => {
cy.fixture("DashBoard").then((order) => {
dashboard.validateOrderStatus(order.labNo, 4);
});
});
});

describe("ImmunoChemistry Dashboard", function () {
it("User Visits ImmunoChemistry Dashboard", function () {
homePage = loginPage.goToHomePage();
dashboard = homePage.goToImmunoChemistryDashboard();
dashboard.checkForHeader("Immunohistochemistry");

// cy.fixture("DashBoard").then((order) => {
// dashboard.validatePreStatus(order.labNo);

// });
});

it("User adds a new ImmunioChemistry order", function () {
homePage.goToOrderPage();
dashboard.addOrder("Immunohistochemistry");
});

it("Check For Order", () => {
homePage.goToImmunoChemistryDashboard();

dashboard.checkForHeader("Immunohistochemistry");

cy.fixture("DashBoard").then((order) => {
dashboard.validatePreStatus(order.labNo);
});
});

it("Change The Status of Order and save it", () => {
dashboard.changeStatus("Completed");
dashboard.selectPathologist("ELIS,Open");
dashboard.saveOrder();
});

it("Validate the Status of Order", () => {
cy.fixture("DashBoard").then((order) => {
dashboard.validateOrderStatus(order.labNo, 3);
});
});
});
82 changes: 82 additions & 0 deletions frontend/cypress/pages/DashBoard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
class DashBoardPage {
addOrder(Program) {
cy.fixture("Order").then((order) => {
cy.get(
":nth-child(2) > .cds--radio-button__label > .cds--radio-button__appearance",
).click();
cy.get("#local_search").click();
cy.get(
"tbody > :nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance",
).click();
cy.get(".forwardButton").click();
cy.get("#additionalQuestionsSelect").select(Program);
cy.get(".forwardButton").click();
cy.get("#sampleId_0").select("Serum");
cy.get(
".testPanels > .cds--col > :nth-child(5) > .cds--checkbox-label",
).click();
cy.get(".forwardButton").click();
cy.get(
":nth-child(2) > :nth-child(1) > :nth-child(2) > .cds--link",
).click();
cy.wait(1000);

cy.get("#labNo")
.invoke("val")
.then((labNoValue) => {
if (labNoValue) {
const data = { labNo: labNoValue };
cy.writeFile("cypress/fixtures/DashBoard.json", data);
} else {
cy.log("labNoValue is empty or undefined");
}
});

cy.get("#siteName").type(order.siteName);
cy.get("#requesterFirstName").type(order.requester.firstName);
cy.get("#requesterLastName").type(order.requester.firstName);
cy.get(".forwardButton").should("be.visible").click();
});
}

checkForHeader(title) {
cy.get("section > h3").should("have.text", title);
}

enterDetails() {
cy.get(
":nth-child(14) > .gridBoundary > :nth-child(1) > .cds--form-item > .cds--text-area__wrapper > .cds--text-area",
).type("Test");
cy.get(
":nth-child(2) > .cds--form-item > .cds--text-area__wrapper > .cds--text-area",
).type("Test");
}

validateOrderStatus(orderNumber, childIndex) {
cy.get(":nth-child(2) > .cds--link").click();
cy.get(":nth-child(1) > .tile-value").should("have.text", "0");
cy.get(`:nth-child(${childIndex}) > .tile-value`).should("have.text", "1");
cy.get("#statusFilter").select("Completed");
cy.get("tbody > tr > :nth-child(4)").should("have.text", "John");
}

validatePreStatus(order) {
cy.get(":nth-child(1) > .tile-value").should("have.text", "1");
cy.get("tbody > tr > :nth-child(4)").should("have.text", "John");
cy.get("tbody > tr > :nth-child(6)").click();
}

saveOrder() {
cy.get("#pathology_save2").click();
}

changeStatus(status) {
cy.get("#status").select(status);
}

selectPathologist(pathologist) {
cy.get("#assignedPathologist").select(pathologist);
}
}

export default DashBoardPage;
15 changes: 15 additions & 0 deletions frontend/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ModifyOrderPage from "./ModifyOrderPage";
import WorkPlan from "./WorkPlan";
import NonConform from "./NonConformPage";
import BatchOrderEntry from "./BatchOrderEntryPage";
import DashBoardPage from "./DashBoard";

class HomePage {
constructor() {}
Expand Down Expand Up @@ -97,6 +98,20 @@ class HomePage {
cy.get("#menu_non_conforming_corrective_actions_nav").click();
return new NonConform();
}

goToPathologyDashboard() {
this.openNavigationMenu();
cy.get("#menu_pathology_dropdown").click();
cy.get("#menu_pathologydashboard_nav").click();
return new DashBoardPage();
}

goToImmunoChemistryDashboard() {
this.openNavigationMenu();
cy.get("#menu_immunochem_dropdown").click();
cy.get("#menu_immunochemdashboard_nav").click();
return new DashBoardPage();
}
}

export default HomePage;
Loading