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

Ratest 302-Add an identifier for a patient #492

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/refapp-2x-add-new-identifier.yml
@@ -0,0 +1,50 @@
name: RefApp 2.x Add New Identifier
EdisonMeks marked this conversation as resolved.
Show resolved Hide resolved
on:
schedule:
- cron: '0 0 * * 1,3,5'
push:
branches: [master]
pull_request:
branches: [master]
repository_dispatch:
types: [qa]
workflow_dispatch:
jobs:
test-on-browsers:
runs-on: ubuntu-latest
defaults:
run:
working-directory: qaframework-bdd-tests
strategy:
matrix:
browser:
- firefox
- chrome
services:
${{ matrix.browser }}:
image: selenium/node-${{ matrix.browser }}:3.141.59-gold
env:
HUB_HOST: hub
HUB_PORT: 4444
steps:
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Checkout qaframework
uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
- name: Run db and web containers
run: |
docker-compose -f docker/docker-compose-refqa.yml up -d
- name: Wait for OpenMRS instance to start
run: |
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 1; done
- name: Run qaframework on ${{ matrix.browser }}
run: |
echo "cucumber.publish.enabled=true" > src/test/resources/cucumber.properties
mvn clean install -DskipTests=true
cp -f src/test/resources/org/openmrs/uitestframework/test-local-${{ matrix.browser }}.properties src/test/resources/org/openmrs/uitestframework/test.properties
npm run refapp2AddNewIdentifier
curl -sX POST -F messages=@target/cucumber.ndjson https://studio.cucumber.io/cucumber_project/results -H "project-access-token: ${{secrets.CUCUMBER_IO_TOKEN}}" -H "provider: github" -H "repo: ${{github.repository}}" -H "branch: master" -H "revision: ${{github.sha}}"
3 changes: 2 additions & 1 deletion qaframework-bdd-tests/package.json
Expand Up @@ -39,7 +39,8 @@
"advancedCoreInstall": "mvn test -Dcucumber.filter.tags='@selenium and @initialSetup and @advancedInstall'",
"postgresCoreInstall": "mvn test -Dcucumber.filter.tags='@selenium and @initialSetup and @postgresInstall'",
"testingCoreInstall": "mvn test -Dcucumber.filter.tags='@selenium and @initialSetup and @testingInstall'",
"coreUpgrade": "mvn test -Dcucumber.filter.tags='@selenium and @initialSetup and @upgrade'"
"coreUpgrade": "mvn test -Dcucumber.filter.tags='@selenium and @initialSetup and @upgrade'",
"refapp2AddNewIdentifier": "mvn test -Dcucumber.filter.tags='@selenium and @addNewIdentifier'"
},
"description": "![Build Status](https://ci.openmrs.org/plugins/servlet/wittified/build-status/CONTRIB-QA)",
"main": "index.js",
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class AdministrationPage extends Page {
private static final By REPORT_ADMINISTRATION_LINK = By.cssSelector("#content a[href*='/module/reporting/reports/manageReports.form']");
private static final By MANAGE_ENCOUNTERS_LINK = By.linkText("Manage Encounters");
private static final By MANAGE_LOCATIONS_LINK = By.linkText("Manage Locations");

private static final By MANAGE_PATIENTS_LINK = By.cssSelector("#content a[href='/openmrs/admin/patients/index.htm']");
public AdministrationPage(Page page) {
super(page);
}
Expand Down Expand Up @@ -86,4 +86,8 @@ public ManageLocationsOnAdminPage clickOnManageLocations() {
public String getPageUrl() {
return URL;
}
public PatientPage clickOnManagePatients() {
findElement(MANAGE_PATIENTS_LINK).click();
return new PatientPage(this);
}
}
@@ -0,0 +1,49 @@
package org.openmrs.contrib.qaframework.page;

import org.openmrs.contrib.qaframework.helper.Page;
import org.openqa.selenium.By;

public class PatientFormPage extends Page {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a patient registration form, a clinicianFacing patient form, what is it this form ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page has been deleted


private static final By ADD_NEW_IDENTIFIER = By.id("identifier");
private static final By PREFERRED_BUTTON = By.cssSelector("#preferred input[type=\"checkbox\"]");
private static final By IDENTIFIER_FIELD = By.name("identifiers[0].identifier");
private static final By IDENTIFIER_TYPE_FIELD = By.id("identifierTypeBox2");
private static final String IDENTIFIER_TYPE = "OpenMRS ID";
private static final By LOCATION_FIELD = By.id("locationBox2");
private static final String LOCATION = "Amani Hospital";
private static final By SAVE_PATIENT_BUTTON = By.id("saveButton");

public PatientFormPage(Page parent) {
super(parent);
}

@Override
public String getPageUrl() {
return "/admin/patients/patient.form";
}
public void addNewIdentifier() {
clickOn(ADD_NEW_IDENTIFIER);
}

public void selectPreferred() {
clickOn(PREFERRED_BUTTON);
}

public void setIdentifier(String identifier) {
findElement(IDENTIFIER_FIELD).clear();
findElement(IDENTIFIER_FIELD).sendKeys(identifier);
}

public void setIdentifierType() {
selectFrom(IDENTIFIER_TYPE_FIELD, IDENTIFIER_TYPE);
}

public void setLocation() {
selectFrom(LOCATION_FIELD, LOCATION);
}

public void savePatient() {
clickOn(SAVE_PATIENT_BUTTON);
}
}
@@ -0,0 +1,26 @@
package org.openmrs.contrib.qaframework.page;

import org.openmrs.contrib.qaframework.helper.Page;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;

public class PatientPage extends Page{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is patientManagementPage


private static final By SEARCH_ELEMENT = By.id("inputNode");
private static final By SEARCH_STATUS = By.id("pageInfo");

public PatientPage(Page parent) {
super(parent);
}

@Override
public String getPageUrl() {
return "/admin/patients/index.htm";
}

public void searchPatientIdentifierOrPatientName(String text) {
setText(SEARCH_ELEMENT, text);
findElement(SEARCH_ELEMENT).sendKeys(Keys.BACK_SPACE);
waitForTextToBePresentInElement(SEARCH_STATUS,text.substring(0, text.length() - 1));
}
}
Expand Up @@ -59,6 +59,7 @@ public class HOOK {
public static final String SERVICE = "@service";
public static final String PATIENT_VISIT = "@patientVisit";
public static final String LOCATION = "@location";
public static final String ADD_NEW_IDENTIFIER = "@addNewIdentifier";
public static final String SELENIUM_PERSON = SELENIUM + " and " + PERSON;
public static final String SELENIUM_LOGIN = SELENIUM + " and " + LOGIN;
public static final String SELENIUM_MODULES = SELENIUM + " and " + MODULES;
Expand Down Expand Up @@ -88,5 +89,6 @@ public class HOOK {
public static final String SELENIUM_PHONE_NUMBER_VALIDATION = SELENIUM + " and " + PHONE_NUMBER_VALIDATION;
public static final String SELENIUM_SERVICE = SELENIUM + " and " + SERVICE;
public static final String SELENIUM_LOCATION_MANAGEMENT = SELENIUM + " and " + LOCATION;
public static final String SELENIUM_ADD_NEW_IDENTIFIER = SELENIUM + " and " + ADD_NEW_IDENTIFIER;
}
}
@@ -0,0 +1,76 @@
package org.openmrs.contrib.qaframework.automation;

import static org.junit.Assert.assertTrue;

import org.openmrs.contrib.qaframework.RunTest;
import org.openmrs.contrib.qaframework.page.AdministrationPage;
import org.openmrs.contrib.qaframework.page.PatientFormPage;
import org.openmrs.contrib.qaframework.page.PatientPage;

import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
EdisonMeks marked this conversation as resolved.
Show resolved Hide resolved
public class AddNewIdentifierSteps extends Steps {
private AdministrationPage administrationPage;
private PatientPage patientPage;
private PatientFormPage patientFormPage;
private static final String IDENTIFIER = "100397A";


@Before(RunTest.HOOK.SELENIUM_ADD_NEW_IDENTIFIER)
public void setUp() {
initiateWithLogin();
}

@After(RunTest.HOOK.SELENIUM_ADD_NEW_IDENTIFIER)
public void tearDown() {
quit();
}

@Given("a user clicks on system administration link on the home page")
public void launchAdministrationPage() {
administrationPage = homePage.goToAdministration();
}

@Then("the administration page is loaded")
public void verifyAdministrationPageIsLoaded() {
assertTrue(textExists("Administration"));
}

@And("a user clicks on the manage Patients link on the administration page")
public void clickManagePatientsLink() {
patientPage = (PatientPage) administrationPage.clickOnManagePatients().waitForPage();
}

@Then("the system loads patient page")
public void loadManagePatientsPage() {
assertTrue(textExists("Patient"));
}

@When("a user searches for the patient")
public void searchPatientIdentifierOrPatientName() {
patientPage.searchPatientIdentifierOrPatientName(firstPatientIdentifier);
}

EdisonMeks marked this conversation as resolved.
Show resolved Hide resolved
@And("a user clicks on add new identifier")
public void ClickOnAddNewIdentifier() {
patientFormPage.addNewIdentifier();
}

@And("a user mentions preferred identifier, identifier type and location")
public void fillNewIdentifierForm() {
patientFormPage.selectPreferred();
patientFormPage.setIdentifier(IDENTIFIER);
patientFormPage.setIdentifierType();
patientFormPage.setLocation();
}

@Then("the system adds the new identifier")
public void clickOnSavePatient() {
patientFormPage.savePatient();
}

}
@@ -0,0 +1,15 @@
Feature: Add New Identifier

Background:
Given a user clicks on system administration link on the home page
Then the administration page is loaded
And a user clicks on the manage Patients link on the administration page
Then the system loads patient page

@selenium
@addNewIdentifier
Scenario: Adding New Identifier
When a user searches for the patient
And a user clicks on add new identifier
And a user mentions preferred identifier, identifier type and location
Then the system adds the new identifier
Expand Up @@ -3,5 +3,5 @@ login.username=admin
login.password=Admin123
login.location=Pharmacy
webdriver=chrome
headless=true
headless=false
EdisonMeks marked this conversation as resolved.
Show resolved Hide resolved
includes.csrftoken=true