From c4dcb5199b101d608915acaa3371b0590254df12 Mon Sep 17 00:00:00 2001 From: pasindur2 Date: Thu, 18 Aug 2022 19:57:02 +0530 Subject: [PATCH] Create medications e2e automated test workflow --- .github/workflows/refapp-3x-medications.yml | 37 +++++++++++++++++++ README.md | 1 + .../refapp-3.x/11-medications/medications.js | 32 ++++++++++++++++ packages/cypress/package.json | 3 +- .../11-medications/medications.feature | 10 +++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/refapp-3x-medications.yml create mode 100644 packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/11-medications/medications.js create mode 100644 packages/cypress/resources/features/refapp-3.x/11-medications/medications.feature diff --git a/.github/workflows/refapp-3x-medications.yml b/.github/workflows/refapp-3x-medications.yml new file mode 100644 index 0000000..c711435 --- /dev/null +++ b/.github/workflows/refapp-3x-medications.yml @@ -0,0 +1,37 @@ +name: RefApp 3.x Medications +on: + schedule: + - cron: "0 0 * * *" + push: + branches: [ main ] + pull_request: + branches: [ main ] + repository_dispatch: + types: [ qa ] + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout qaframework + uses: actions/checkout@main + with: + repository: ${{github.repository}} + - name: Run db and web containers + run: docker-compose -f docker/docker-compose-refqa-3x.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 10; done + - name: Using Node.js + uses: actions/setup-node@v1 + with: + node-version: '16.x' + - name: Installing dependencies + run: yarn install + - name: Run medications workflow tests + run: cd packages/cypress && yarn refapp3Medications + - name: Upload screen recordings of failed tests + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: Screen recordings of failed tests + path: packages/cypress/cypress/videos diff --git a/README.md b/README.md index 7d33d6c..57a71f5 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ ___ [![RefApp 3.x Appointments](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-appointments.yml/badge.svg)](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-appointments.yml) [![RefApp 3.x Care Programs](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-care-programs.yml/badge.svg)](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-care-programs.yml) [![RefApp 3.x Clinical Visit](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-clinical-visit.yml/badge.svg)](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-clinical-visit.yml) +[![RefApp 3.x Medications](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-medications.yml/badge.svg)](https://github.com/openmrs/openmrs-test-3refapp/actions/workflows/refapp-3x-medications.yml) ___ diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/11-medications/medications.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/11-medications/medications.js new file mode 100644 index 0000000..81d83ee --- /dev/null +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/11-medications/medications.js @@ -0,0 +1,32 @@ +import { Given, Before, When } from "cypress-cucumber-preprocessor/steps"; + +let identifier = null; +let patient = null; + +Before({ tags: "@patient-medications" }, () => { + cy.generateIdentifier().then((generatedIdentifier) => { + identifier = generatedIdentifier; + cy.createPatient(identifier).then((generatedPatient) => { + patient = generatedPatient; + }); + }); +}); + +Given("the user is logged in", () => { + cy.login(); +}); + +Given("the user arrives on a patient’s summary page", () => { + cy.visit(`patient/${patient.uuid}/chart`); +}); + +When("the user clicks on Orders tab", () => { + cy.contains("Orders").click({ force: true }); +}); + +Then("the empty Orders page should display", () => { + cy.contains("There are no active medications to display for this patient"); + cy.contains("There are no past medications to display for this patient"); +}); + +//TODO: Place drug orders diff --git a/packages/cypress/package.json b/packages/cypress/package.json index 6ebe8de..b685d32 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -19,7 +19,8 @@ "refapp3PatientConditions": "cypress run --spec resources/features/refapp-3.x/12-patient-conditions/patient-conditions.feature", "refapp3PatientAllergies": "cypress run --spec resources/features/refapp-3.x/13-patient-allergies/patient-allergies.feature", "refapp3Appointments": "cypress run --spec resources/features/refapp-3.x/14-appointments/appointments.feature", - "refapp3CarePrograms": "cypress run --spec resources/features/refapp-3.x/10-care-programs/care-programs.feature" + "refapp3CarePrograms": "cypress run --spec resources/features/refapp-3.x/10-care-programs/care-programs.feature", + "refapp3Medications": "cypress run --spec resources/features/refapp-3.x/11-medications/medications.feature" }, "devDependencies": { "@badeball/cypress-cucumber-preprocessor": "^12.2.0", diff --git a/packages/cypress/resources/features/refapp-3.x/11-medications/medications.feature b/packages/cypress/resources/features/refapp-3.x/11-medications/medications.feature new file mode 100644 index 0000000..6f5439f --- /dev/null +++ b/packages/cypress/resources/features/refapp-3.x/11-medications/medications.feature @@ -0,0 +1,10 @@ +Feature: Medications + + Background: + Given the user is logged in + And the user arrives on a patient’s summary page + + @patient-medications + Scenario: The user should be able view active and past medications + When the user clicks on Orders tab + Then the empty Orders page should display