Skip to content

Commit

Permalink
Merge pull request DIGI-UW#1425 from Bahati308/E2E
Browse files Browse the repository at this point in the history
Updated dashboard E2E
  • Loading branch information
mozzy11 authored Jan 30, 2025
2 parents d9dd2a9 + d66a6a0 commit 6a60fa5
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 113 deletions.
108 changes: 58 additions & 50 deletions frontend/cypress/e2e/dashboard.cy.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,93 @@
import LoginPage from "../pages/LoginPage";
import DashBoardPage from "../pages/DashBoard";

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

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

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

dashboard.checkForHeader("Pathology");
});
cy.fixture("Order").as("dashBData");
});

it("User adds a new Pathology order", function () {
homePage.goToOrderPage();
dashboard.addOrder("Histopathology");
describe("Dashboard for the Home Page", function () {
it("User clicks search bar", function () {
dashboard.homeSearchBar();
});
it("Check For Order", () => {
homePage.goToPathologyDashboard();
dashboard.checkForHeader("Pathology");

cy.fixture("DashBoard").then((order) => {
dashboard.validatePreStatus(order.labNo);
it("User types the patient to search and closes it", function () {
cy.fixture("Order").then((dashBData) => {
dashboard.searchBarInput(dashBData.searchName);
});
dashboard.homeSearchBar();
});

it("Change The Status of Order and save it", () => {
dashboard.changeStatus("Completed");
dashboard.enterDetails();
dashboard.saveOrder();
it("User interacts with the notifications icon", function () {
dashboard.notificationIcon();
dashboard.notificationIconClose();
});

it("Validate the Status of Order", () => {
cy.fixture("DashBoard").then((order) => {
// dashboard.validateOrderStatus(order.labNo, 4);
it("User interacts with the user icon", function () {
dashboard.userIcon();
cy.fixture("Order").then((dashBData) => {
dashboard.userSelectsEng(dashBData.engLang);
});
dashboard.userIcon();
});
});

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);

// });
describe("Pathology Dashboard", function () {
it("User Visits the Dashboard", function () {
dashboard = homePage.goToPathology();
});

it("User adds a new ImmunioChemistry order", function () {
homePage.goToOrderPage();
dashboard.addOrder("Immunohistochemistry");
it("User checks filters, selects cases and items per page", function () {
dashboard.checkFilters();
cy.fixture("Order").then((dashBData) => {
dashboard.selectCases(dashBData.myCases);
dashboard.enterLabNumber(dashBData.labNumb);
dashboard.pageItems(dashBData.itemsPerPage);
});
});
});

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

dashboard.checkForHeader("Immunohistochemistry");
describe("Immunohistochemistry Dashboard", function () {
it("User Visits the Dashboard", function () {
dashboard = homePage.goToImmunoChemistryDashboard();
});

cy.fixture("DashBoard").then((order) => {
dashboard.validatePreStatus(order.labNo);
it("User checks filters, selects cases and items per page", function () {
dashboard.checkFilters();
cy.fixture("Order").then((dashBData) => {
dashboard.selectCompletedCases(dashBData.myCases2);
dashboard.enterLabNumber(dashBData.labNumb);
dashboard.pageItems(dashBData.itemsPerPage);
});
});
});

it("Change The Status of Order and save it", () => {
dashboard.changeStatus("Completed");
dashboard.selectPathologist("ELIS,Open");
dashboard.saveOrder();
describe("Cytology Dashboard", function () {
it("User Visits the Dashboard", function () {
dashboard = homePage.goToCytology();
});

it("Validate the Status of Order", () => {
cy.fixture("DashBoard").then((order) => {
//TO DO : needs to be properly re-writen with proper selector
//dashboard.validateOrderStatus(order.labNo, 3);
it("User checks filters, selects cases and items per page", function () {
dashboard.checkFilters();
cy.fixture("Order").then((dashBData) => {
dashboard.selectScreeningCases(dashBData.myCases3);
dashboard.enterLabNumber(dashBData.labNumb);
dashboard.pageItems(dashBData.itemsPerPage);
});
});
});

describe("Back to home page", function () {
it("User navigates back to home page", function () {
dashboard = homePage.backToHomePage();
});
});
9 changes: 8 additions & 1 deletion frontend/cypress/fixtures/Order.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
"lastName": "Prime"
},
"labNo": "",
"invalidLabNo": "DEV0124000000000000"
"invalidLabNo": "DEV0124000000000000",
"labNumb": "REG-00000123",
"myCases": "Grossing",
"myCases2": "Completed",
"myCases3": "Screening",
"itemsPerPage": "30",
"searchName": "Smith",
"engLang": "English"
}
99 changes: 38 additions & 61 deletions frontend/cypress/pages/DashBoard.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,58 @@
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);
constructor() {}

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");
}
});
homeSearchBar() {
cy.get('[data-cy="header-global-action-search"]').click();
}
searchBarInput(inputName) {
cy.get("#searchItem").type(inputName);
}

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();
});
searchBarClose() {
cy.get('[data-cy="header-global-action-search"]').click();
}

checkForHeader(title) {
cy.get("section > h3").should("have.text", title);
notificationIcon() {
cy.get('[data-cy="header-global-action-notifications"]').click();
}

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");
notificationIconClose() {
cy.get("#close-slide-over").click();
}

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");
userIcon() {
cy.get('[data-cy="header-global-action-user"]').click();
}

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();
userSelectsEng(engLang) {
cy.get("#selector").select(engLang);
}

saveOrder() {
cy.get("#pathology_save2").click();
userClosesIcon() {
cy.get('[data-cy="header-global-action-user"]').click();
}

changeStatus(status) {
cy.get("#status").select(status);
checkFilters() {
cy.get("#filterMyCases").check({ force: true });
}

selectCases(myCases) {
cy.get("#statusFilter").select(myCases);
}

selectCompletedCases(myCases2) {
cy.get("#statusFilter").select(myCases2);
}

selectScreeningCases(myCases3) {
cy.get("#statusFilter").select(myCases3);
}
enterLabNumber(labNumb) {
cy.get("#search-input-41").should("be.visible").type(labNumb);
}

selectPathologist(pathologist) {
cy.get("#assignedPathologist").select(pathologist);
pageItems(itemsPerPage) {
cy.get("#cds-pagination-select-id-59").select(itemsPerPage);
}
}

Expand Down
13 changes: 12 additions & 1 deletion frontend/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class HomePage {
return new StudyReportPage();
}

goToPathologyDashboard() {
goToPathology() {
this.openNavigationMenu();
cy.get("#menu_pathology").click(); // Changed from menu_pathology_dropdown
return new DashBoardPage();
Expand All @@ -192,6 +192,12 @@ class HomePage {
return new DashBoardPage();
}

goToCytology() {
this.openNavigationMenu();
cy.get("#menu_cytology").click();
return new DashBoardPage();
}

goToAdminPage() {
this.openNavigationMenu();
cy.get("#menu_administration").click();
Expand Down Expand Up @@ -244,6 +250,11 @@ class HomePage {
selectDelayedTurnAround() {
cy.contains("a.cds--link", "Delayed Turn Around").click();
}
//This takes you from any page back to the home page
backToHomePage() {
this.openNavigationMenu();
cy.get("#menu_home").click();
}
}

export default HomePage;
3 changes: 3 additions & 0 deletions frontend/src/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ function OEHeader(props) {
<HeaderGlobalAction
aria-label="Search"
onClick={handleSearch}
data-cy="header-global-action-search"
>
{!searchBar ? (
<Search size={20} />
Expand All @@ -462,6 +463,7 @@ function OEHeader(props) {
<HeaderGlobalAction
aria-label="Notifications"
onClick={toggleSlideOver}
data-cy="header-global-action-notifications"
>
<div
style={{
Expand Down Expand Up @@ -502,6 +504,7 @@ function OEHeader(props) {
aria-label={panelSwitchLabel()}
onClick={clickPanelSwitch}
ref={userSwitchRef}
data-cy="header-global-action-user"
>
{panelSwitchIcon()}
</HeaderGlobalAction>
Expand Down

0 comments on commit 6a60fa5

Please sign in to comment.