Skip to content

Commit

Permalink
Added PatientEntry features
Browse files Browse the repository at this point in the history
  • Loading branch information
abertnamanya committed Jul 20, 2023
1 parent 1c579ea commit e97e1a8
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 14 deletions.
3 changes: 2 additions & 1 deletion react-ui/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = defineConfig({
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: "https://localhost"
baseUrl: "https://localhost",
testIsolation: false,
},
});
18 changes: 18 additions & 0 deletions react-ui/cypress/common/TestProperties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class TestProperties {

DEFAULT_USERNAME = "admin";
DEFAULT_PASSWORD = "adminADMIN!";

constructor() {
}

getUsername() {
return this.DEFAULT_USERNAME
}

getPassword() {
return this.DEFAULT_PASSWORD
}
}

export default TestProperties;
31 changes: 22 additions & 9 deletions react-ui/cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
import HomePage from "../pages/HomePage";
import LoginPage from "../pages/LoginPage";

const login = new LoginPage();

describe('Failing or Succeeding to Login', function () {

before(() => {
before("User visits login page", () => {
login.visit();
// login.acceptSelfAssignedCert();
});

it('User should enter username', function () {
login.enterUsername("admin");
login.getUsernameElement().should('contain.value', 'admin')
});
after('Close Browser', () => {

})

it('Should validate user authentication', function () {
cy.fixture('Users').then((users) => {
users.forEach((user) => {
login.enterUsername(user.username);
login.getUsernameElement().should('contain.value', user.username)

login.enterPassword(user.password);
login.getPasswordElement().should('contain.value', user.password);
login.signIn();

it('User should enter password', function () {
login.enterPassword("adminADMIN!");
login.getPasswordElement().should('contain.value', 'adminADMIN!');
if (user.correctPass === true) {
cy.get('header#mainHeader > button[title=\'Open menu\']').should('exist')
.and('span:nth-of-type(3) > .cds--btn.cds--btn--icon-only.cds--btn--primary.cds--header__action > svg > path:nth-of-type(1)', 'exist');
} else {
cy.get('div[role=\'status\']').should('be.visible');
}
});
});
});


Expand Down
24 changes: 24 additions & 0 deletions react-ui/cypress/e2e/patientEntry.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import LoginPage from "../pages/LoginPage";

let homePage = null;
let loginPage = null;
let patientPatient = null;

before('login', () => {
loginPage = new LoginPage();
loginPage.visit();
});
describe('Patient Search', function () {

it('User Visits Home Page and goes to Add Add|Modify Patient Page', () => {
homePage = loginPage.goToHomePage();
patientPatient = homePage.goToPatientEntry();
});

it('Add|Modify Patient page should appear with search field', function () {
patientPatient.getPatientEntryPageTitle().should('contain.text', 'Add/Modify Patient');

});


});
17 changes: 17 additions & 0 deletions react-ui/cypress/fixtures/Users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"username": "wrongUser",
"password": "adminADMIN!",
"correctPass": "false"
},
{
"username": "itech",
"password": "wrongPass",
"correctPass": "false"
},
{
"username": "admin",
"password": "adminADMIN!",
"correctPass": "true"
}
]
12 changes: 12 additions & 0 deletions react-ui/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import LoginPage from "./LoginPage";
import PatientEntryPage from "./PatientEntryPage";

class HomePage {
constructor() {
Expand All @@ -11,6 +12,17 @@ class HomePage {
goToSign() {
return new LoginPage();
}

openNavigationMenu() {
cy.get('header#mainHeader > button[title=\'Open menu\']').click();
}

goToPatientEntry() {
this.openNavigationMenu();
cy.get('li:nth-of-type(2) > .cds--side-nav__submenu > .cds--side-nav__icon.cds--side-nav__icon--small.cds--side-nav__submenu-chevron').click()
cy.get('li:nth-of-type(2) > .cds--side-nav__menu > li:nth-of-type(1) > .cds--side-nav__link > .cds--side-nav__link-text').click();
return new PatientEntryPage();
}
}

export default HomePage;
17 changes: 13 additions & 4 deletions react-ui/cypress/pages/LoginPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import HomePage from "./HomePage";
import TestProperties from "../common/TestProperties";

class LoginPage {
testProperties = null;

constructor() {
this.testProperties = new TestProperties();
}

visit() {
Expand Down Expand Up @@ -28,10 +34,6 @@ class LoginPage {
return this;
}

checkInvalidPassword() {

}

signIn() {
const button = cy.get(`[type='submit']`);
button.click();
Expand All @@ -44,6 +46,13 @@ class LoginPage {
link.click();

}

goToHomePage() {
this.enterUsername(this.testProperties.getUsername())
this.enterPassword(this.testProperties.getPassword())
this.signIn();
return new HomePage();
}
}

export default LoginPage;
17 changes: 17 additions & 0 deletions react-ui/cypress/pages/PatientEntryPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class PatientEntryPage {

constructor() {
}

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


getPatientEntryPageTitle() {
return cy.get('section > h3');
}

}

export default PatientEntryPage;

0 comments on commit e97e1a8

Please sign in to comment.