Skip to content

Commit

Permalink
Merge pull request I-TECH-UW#946 from manishjha-04/cypressmodifypatient
Browse files Browse the repository at this point in the history
Test Coverage: Modify Order Page
  • Loading branch information
mozzy11 authored Apr 2, 2024
2 parents 38ef4e4 + a4c85d1 commit 091ad82
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 12 deletions.
5 changes: 4 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@

npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*

/cypress/videos/
cypress/screenshots/
7 changes: 7 additions & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
config.specPattern=[
'cypress/e2e/login.cy.js',
'cypress/e2e/patientEntry.cy.js',
'cypress/e2e/orderEntity.cy.js',
'cypress/e2e/modifyOrder.cy.js',
]
return config;
},
baseUrl: "https://localhost",
testIsolation: false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/common/TestProperties.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class TestProperties {
DEFAULT_USERNAME = "admin";
DEFAULT_PASSWORD = "adminADMIN!";
TEST_SERVER_URL = "https://openelis28.openelis-global.org/";
TEST_SERVER_URL = "https://localhost/";

constructor() {}

Expand Down
9 changes: 6 additions & 3 deletions frontend/cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ describe("Failing or Succeeding to Login", function () {
cy.fixture("Users").then((users) => {
users.forEach((user) => {
login.enterUsername(user.username);
login.getUsernameElement().should("contain.value", user.username);
login.getUsernameElement().as("usernameField");
cy.get("@usernameField").type(user.username);
cy.get("@usernameField").should("contain.value", user.username);

login.enterPassword(user.password);
login.getPasswordElement().should("contain.value", user.password);
login.getPasswordElement().as("passwordField");
cy.get("@passwordField").type(user.password);
cy.get("@passwordField").should("contain.value", user.password);
login.signIn();

if (user.correctPass === true) {
Expand Down
137 changes: 137 additions & 0 deletions frontend/cypress/e2e/modifyOrder.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import LoginPage from "../pages/LoginPage";
import PatientEntryPage from "../pages/PatientEntryPage";

let homePage = null;
let loginPage = null;
let modifyOrderPage = null;
let patientPage = new PatientEntryPage();

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

describe("Modify Order search by accession Number", function () {

it("User Visits Home Page and goes to Modify Order Page ", function () {
homePage = loginPage.goToHomePage();
modifyOrderPage = homePage.goToModifyOrderPage();
});

it("User searches with accession number", () => {
cy.fixture("Order").then((order) => {
modifyOrderPage.enterAccessionNo(order.labNo);
});
modifyOrderPage.clickSubmitButton();
});

it("should check for program selection button and go to next page ", function () {
modifyOrderPage.checkProgramButton();
modifyOrderPage.clickNextButton();
});

it("should be able to record", function () {
modifyOrderPage.assignValues();
});

it("User should click next to go add order page and submit the order", function () {
modifyOrderPage.clickNextButton();
cy.wait(1000);
modifyOrderPage.clickNextButton();
});

it("should be able to print barcode", function () {
cy.window().then((win) => {
cy.spy(win, "open").as("windowOpen");
});
modifyOrderPage.clickPrintBarcodeButton();
cy.get("@windowOpen").should(
"be.calledWithMatch",
"/api/OpenELIS-Global/LabelMakerServlet?labNo=",
);
});
});

describe("Modify Order search by patient ", function () {
it("User Visits Home Page and goes to Modify Order Page ", function () {
homePage = loginPage.goToHomePage();
modifyOrderPage = homePage.goToModifyOrderPage();
});

it("Should search Patient By First and LastName", 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);

modifyOrderPage.clickSearchPatientButton();
patientPage.validatePatientSearchTable(
patient.firstName,
patient.inValidName,
);
});
cy.wait(200).reload();
});

it("Should be able to search patients By gender", function () {
cy.wait(1000);
patientPage.getMaleGenderRadioButton().should("be.visible");
patientPage.getMaleGenderRadioButton().click();
cy.wait(200);
modifyOrderPage.clickSearchPatientButton();
cy.fixture("Patient").then((patient) => {
patientPage.validatePatientByGender("M");
});
cy.wait(200).reload();
});

it("should search patient By PatientId", function () {
cy.wait(1000);
cy.fixture("Patient").then((patient) => {
patientPage.searchPatientByPatientId(patient.nationalId);
modifyOrderPage.clickSearchPatientButton();
patientPage.validatePatientSearchTable(
patient.firstName,
patient.inValidName,
);
});
});

it("Should be able to search by respective patient ", function () {
cy.wait(1000);
modifyOrderPage.clickRespectivePatient();
});
it("should check for program selection button and go to next page ", function () {
cy.wait(1000);
modifyOrderPage.checkProgramButton();
modifyOrderPage.clickNextButton();
});

it("should be able to record", function () {
cy.wait(1000);
modifyOrderPage.assignValues();
});

it("User should click next to go add order page and submit the order", function () {
modifyOrderPage.clickNextButton();
cy.wait(1000);
modifyOrderPage.clickNextButton();
});

it("should be able to print barcode", function () {
cy.window().then((win) => {
cy.spy(win, "open").as("windowOpen");
});
modifyOrderPage.clickPrintBarcodeButton();
cy.get("@windowOpen").should(
"be.calledWithMatch",
"/api/OpenELIS-Global/LabelMakerServlet?labNo=",
);
});
});
11 changes: 10 additions & 1 deletion frontend/cypress/e2e/orderEntity.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ describe("Order Entity", function () {
orderEntityPage.clickNextButton();
});

it("Should click generate Lab Order Number", function () {
it("Should click generate Lab Order Number and store it in a fixture", function () {
orderEntityPage.generateLabOrderNumber();
cy.get("#labNo").then(($input) => {
const generatedOrderNumber = $input.val();
cy.fixture("Order").then((order) => {
order.labNo = generatedOrderNumber;
cy.writeFile("cypress/fixtures/Order.json", order);
});
});
cy.wait(1000);
});

Expand All @@ -78,3 +85,5 @@ describe("Order Entity", function () {
orderEntityPage.clickSubmitOrderButton();
});
});


2 changes: 1 addition & 1 deletion frontend/cypress/e2e/patientEntry.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Patient Search", function () {
it("Add|Modify Patient page should appear with search field", function () {
patientPage
.getPatientEntryPageTitle()
.should("contain.text", "Add/Modify Patient");
.should("contain.text", "Add Or Modify Patient");
});

it("User should be able to navigate to create Patient tab", function () {
Expand Down
7 changes: 4 additions & 3 deletions frontend/cypress/fixtures/Order.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"sampleType": "Serum"
}
],
"siteName": "example site",
"siteName": "279 - CAMES MAN",
"requester": {
"firstName": "Optimus",
"lastName": "Prime"
}
}
},
"labNo": ""
}
4 changes: 3 additions & 1 deletion frontend/cypress/fixtures/Patient.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"lastName": "Smith",
"subjectNumber": "001202782410",
"nationalId": "UG-23SLHD7DBD",
"DOB": "12/05/2001"
"DOB": "12/05/2001",
"gender":"Male"

}
8 changes: 8 additions & 0 deletions frontend/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import LoginPage from "./LoginPage";
import PatientEntryPage from "./PatientEntryPage";
import OrderEntityPage from "./OrderEntityPage";
import ModifyOrderPage from "./ModifyOrderPage";

class HomePage {
constructor() {}
Expand Down Expand Up @@ -38,6 +39,13 @@ class HomePage {
).click();
return new PatientEntryPage();
}

goToModifyOrderPage() {
this.openNavigationMenu();
cy.getElement(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__submenu').click();
cy.get(':nth-child(1) > .cds--side-nav__item > .cds--side-nav__menu > :nth-child(7) > .cds--side-nav__link > .cds--side-nav__link-text > [style="display: flex; width: 100%;"] > .custom-sidenav-button').click();
return new ModifyOrderPage();
}
}

export default HomePage;
44 changes: 44 additions & 0 deletions frontend/cypress/pages/ModifyOrderPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class ModifyOrderPage {

constructor() {
}

visit() {
cy.visit('/FindOrder');
}

enterAccessionNo(accessionNo) {
cy.enterText('.cds--text-input.cds--text-input--md.cds--text__input', accessionNo);
}

clickSubmitButton() {
return cy.getElement('div[class=\'cds--lg:col-span-2 cds--css-grid-column\'] button[type=\'submit\']').should('be.visible').click();

}

clickNextButton(){
return cy.get('.forwardButton').should('be.visible').click();
}


checkProgramButton(){
return cy.get('#additionalQuestionsSelect').should("be.disabled");
}

assignValues() {
cy.get(':nth-child(1) > :nth-child(4) > .cds--form-item > .cds--checkbox-label').click();
}

clickPrintBarcodeButton(){
return cy.get('.orderEntrySuccessMsg > :nth-child(3) > .cds--btn').click();
}
clickSearchPatientButton(){
return cy.get('.searchActionButtons > .cds--btn--primary').click();
}

clickRespectivePatient(){
return cy.get(':nth-child(1) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance').click();
}
}

export default ModifyOrderPage;
2 changes: 1 addition & 1 deletion frontend/cypress/pages/OrderEntityPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OrderEntityPage {
).check({ force: true });
}
generateLabOrderNumber() {
cy.getElement(":nth-child(3) > .cds--link").click();
cy.getElement(":nth-child(2) > .cds--link").click();
}

enterSiteName(siteName) {
Expand Down

0 comments on commit 091ad82

Please sign in to comment.