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

Added Lab Number Management E2E #1407

Merged
merged 17 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
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
Next Next commit
Added Pathology e2e
Bahati308 committed Jan 8, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f663444fce57dd736dcc80dc37cd9439b25a91a6
66 changes: 66 additions & 0 deletions frontend/cypress/e2e/pathology.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import LoginPage from "../pages/LoginPage";
import HomePage from "../pages/HomePage";
import PathologyDashboardPage from "../pages/PathologyDashboardPage";

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

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

beforeEach(() => {
// Navigate to the pathology dashboard page before each test
//dashboard = homePage.goToPathologyDashboard();
dashboard = new PathologyDashboardPage();
dashboard.visit();
});

describe("Pathology Dashboard", function () {
it("User Visits Pathology Dashboard", function () {
dashboard.checkForHeader("Pathology");
});

it("User adds a new Pathology order", function () {
homePage.goToOrderPage();
// Add steps to fill out and submit the order form
dashboard.fillOrderForm({
patientId: "12345",
sampleId: "67890",
testType: "Blood Test",
notes: "Urgent",
});
dashboard.submitOrderForm();
dashboard
.getSuccessMessage()
.should("be.visible")
.and("contain.text", "Order added successfully");
});

it("User can search for cases", function () {
dashboard.searchForCase("case123");
dashboard.getSearchResults().should("contain.text", "case123");
});

it("User can paginate results", function () {
dashboard.clickNextPage();
dashboard.getPreviousPageButton().should("be.visible");
});

it("Displays error message for failed data fetch", function () {
cy.intercept("GET", "/api/pathology/dashboard", {
statusCode: 500,
body: { error: "Internal Server Error" },
}).as("fetchDashboardData");

cy.reload();
cy.wait("@fetchDashboardData");
dashboard
.getErrorMessage()
.should("be.visible")
.and("contain.text", "Internal Server Error");
});
});
7 changes: 7 additions & 0 deletions frontend/cypress/fixtures/Pathology.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"patientId": "12345",
"sampleId": "67890",
"testType": "Blood Test",
"notes": "Urgent",
"searchQuery": "case123"
}
47 changes: 47 additions & 0 deletions frontend/cypress/pages/PathologyDashboardPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class PathologyDashboardPage {
visit() {
cy.visit("/pathology-dashboard");
}

checkForHeader(headerText) {
cy.get("h1").should("contain.text", headerText);
}

searchForCase(caseId) {
cy.get('input[placeholder="Search"]').type(caseId);
cy.get('button[type="submit"]').click();
}

getSearchResults() {
return cy.get(".search-results");
}

clickNextPage() {
cy.get(".pagination-next").click();
}

getPreviousPageButton() {
return cy.get(".pagination-previous");
}

getErrorMessage() {
return cy.get(".error-message");
}

fillOrderForm({ patientId, sampleId, testType, notes }) {
cy.get('input[name="patientId"]').type(patientId);
cy.get('input[name="sampleId"]').type(sampleId);
cy.get('select[name="testType"]').select(testType);
cy.get('textarea[name="notes"]').type(notes);
}

submitOrderForm() {
cy.get('button[type="submit"]').click();
}

getSuccessMessage() {
return cy.get(".success-message");
}
}

export default PathologyDashboardPage;