From 1d076339b33d20ccd161b17522c419258f2c1729 Mon Sep 17 00:00:00 2001 From: Jayasanka Weerasinghe <33048395+jayasanka-sack@users.noreply.github.com> Date: Thu, 24 Nov 2022 17:02:36 +0530 Subject: [PATCH] O3-1655: Fix existing tests (#33) * Reduce retry count * Fix existing test cases * Remove unnessary files * Fix patient search * Reduce timeout * Fix patient registration * Fix appoinment test * Update appointment test * Remove irrelevent lines * Update the registration test * Include screenshots * Wait until the submit button is enabled * Update the clinical visit test * Update the clinical visit test * Remove commented code * Remove force clicks * Fix formatting issues * Fix formatting issues * Fix formatting issues * Update the patient search * Add extra step to visit the home page * Update the clinical visit test --- .github/workflows/refapp-3x-appointments.yml | 4 +- .github/workflows/refapp-3x-care-programs.yml | 4 +- .../workflows/refapp-3x-clinical-visit.yml | 4 +- .../workflows/refapp-3x-form-management.yml | 4 +- .github/workflows/refapp-3x-login.yml | 4 +- .github/workflows/refapp-3x-logout.yml | 4 +- .../workflows/refapp-3x-patient-allergies.yml | 4 +- .../refapp-3x-patient-conditions.yml | 4 +- .../refapp-3x-patient-registration.yml | 4 +- .../workflows/refapp-3x-patient-search.yml | 4 +- .github/workflows/refapp-3x-user-settings.yml | 4 +- .../refapp-3x-vitals-and-biometrics.yml | 4 +- .../integration/common/refapp-3.x/common.js | 22 ++++--- .../patient-registration.js | 34 +++------- .../03-user-settings/user-settings.js | 3 +- .../04-clinical-visit/clinical-visit.js | 66 ++++++++----------- .../vitals-and-biometrics.js | 9 +-- .../06-patient-search/patient-search.js | 14 +--- .../08-form-management/form-management.js | 9 +-- .../10-care-programs/care-programs.js | 9 +-- .../patient-conditions.js | 9 +-- .../13-patient-allergies/patient-allergies.js | 9 +-- .../14-appointments/appointments.js | 11 ++-- packages/cypress/cypress/support/commands.js | 13 ++-- packages/cypress/package.json | 2 +- .../patient-registration.feature | 1 + .../03-user-settings/user-settings.feature | 1 + .../04-clinical-visit/clinical-visit.feature | 37 ++++------- .../06-patient-search/patient-search.feature | 4 +- .../refapp-3.x/07-logout/logout.feature | 1 + 30 files changed, 131 insertions(+), 171 deletions(-) diff --git a/.github/workflows/refapp-3x-appointments.yml b/.github/workflows/refapp-3x-appointments.yml index 2a37df8..a1d6514 100644 --- a/.github/workflows/refapp-3x-appointments.yml +++ b/.github/workflows/refapp-3x-appointments.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-care-programs.yml b/.github/workflows/refapp-3x-care-programs.yml index a41f99b..053424d 100644 --- a/.github/workflows/refapp-3x-care-programs.yml +++ b/.github/workflows/refapp-3x-care-programs.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos/refapp-3.x + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-clinical-visit.yml b/.github/workflows/refapp-3x-clinical-visit.yml index 476e1de..5f3ae65 100644 --- a/.github/workflows/refapp-3x-clinical-visit.yml +++ b/.github/workflows/refapp-3x-clinical-visit.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-form-management.yml b/.github/workflows/refapp-3x-form-management.yml index 6f58bc0..be68e01 100644 --- a/.github/workflows/refapp-3x-form-management.yml +++ b/.github/workflows/refapp-3x-form-management.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-login.yml b/.github/workflows/refapp-3x-login.yml index afc8624..349f56d 100644 --- a/.github/workflows/refapp-3x-login.yml +++ b/.github/workflows/refapp-3x-login.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-logout.yml b/.github/workflows/refapp-3x-logout.yml index 86bddc4..b0ea146 100644 --- a/.github/workflows/refapp-3x-logout.yml +++ b/.github/workflows/refapp-3x-logout.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-patient-allergies.yml b/.github/workflows/refapp-3x-patient-allergies.yml index cfe628a..492a99b 100644 --- a/.github/workflows/refapp-3x-patient-allergies.yml +++ b/.github/workflows/refapp-3x-patient-allergies.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-patient-conditions.yml b/.github/workflows/refapp-3x-patient-conditions.yml index 4cbaaad..b8cc229 100644 --- a/.github/workflows/refapp-3x-patient-conditions.yml +++ b/.github/workflows/refapp-3x-patient-conditions.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-patient-registration.yml b/.github/workflows/refapp-3x-patient-registration.yml index c5ce55e..a279794 100644 --- a/.github/workflows/refapp-3x-patient-registration.yml +++ b/.github/workflows/refapp-3x-patient-registration.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-patient-search.yml b/.github/workflows/refapp-3x-patient-search.yml index a9a6ae0..c07621b 100644 --- a/.github/workflows/refapp-3x-patient-search.yml +++ b/.github/workflows/refapp-3x-patient-search.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-user-settings.yml b/.github/workflows/refapp-3x-user-settings.yml index b1f22e3..c75ad87 100644 --- a/.github/workflows/refapp-3x-user-settings.yml +++ b/.github/workflows/refapp-3x-user-settings.yml @@ -34,4 +34,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/.github/workflows/refapp-3x-vitals-and-biometrics.yml b/.github/workflows/refapp-3x-vitals-and-biometrics.yml index e6eb586..50b423a 100644 --- a/.github/workflows/refapp-3x-vitals-and-biometrics.yml +++ b/.github/workflows/refapp-3x-vitals-and-biometrics.yml @@ -32,4 +32,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: Screen recordings of failed tests - path: packages/cypress/cypress/videos + path: | + packages/cypress/cypress/videos + packages/cypress/cypress/screenshots diff --git a/packages/cypress/cypress/integration/common/refapp-3.x/common.js b/packages/cypress/cypress/integration/common/refapp-3.x/common.js index 40f8f3e..6f593a8 100644 --- a/packages/cypress/cypress/integration/common/refapp-3.x/common.js +++ b/packages/cypress/cypress/integration/common/refapp-3.x/common.js @@ -1,15 +1,17 @@ -import {Given, And} from '@badeball/cypress-cucumber-preprocessor'; +import {Given, Before} from '@badeball/cypress-cucumber-preprocessor'; + +Before(() => { + cy.log("Resetting the database") + cy.exec("bash scripts/resetDB.sh"); +}); Given('the user login to the Outpatient Clinic', () => { cy.on('uncaught:exception', (err, runnable) => { - return false; + return false; }); - cy.login(); - cy.visit('home'); - }) - -And('the user arrives on a patient’s chart page', () => { - cy.get('button[name=SearchPatientIcon]').click(); - cy.getByPlaceholder('Search for a patient by name or identifier number').type('John Doe') - cy.contains('John Doe').first().click({force: true}); + cy.login(); +}); + +Given('the user visit the home page', () => { + cy.visit('home'); }); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/02-patient-registration/patient-registration.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/02-patient-registration/patient-registration.js index cff12ca..88053f0 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/02-patient-registration/patient-registration.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/02-patient-registration/patient-registration.js @@ -11,11 +11,7 @@ When('the user enters {string} details for Andria Faiza', validity => { middleName: 'Kumbha', familyName: 'Faiza', gender: 'Female', - address1: '55372,test', - cityVillage: 'Nairobi', - stateProvince: 'Nairobi', - country: 'Kenya', - postalCode: '00100', + address1: 'chamkar leu', phone: '+211 34 567890' }, wrong: { @@ -24,10 +20,6 @@ When('the user enters {string} details for Andria Faiza', validity => { familyName: 'Mwangi', gender: 'Female', address1: null, - cityVillage: null, - stateProvince: null, - country: null, - postalCode: null, phone: null } }; @@ -36,6 +28,9 @@ When('the user enters {string} details for Andria Faiza', validity => { throw new Error(`Validity '${validity}' is not supported`); } const user = details[validity]; + + cy.contains('Register Patient').should('not.be.disabled') + if (user.givenName != null) { cy.getByLabel('First Name').type(user.givenName, {force: true}); } @@ -49,22 +44,11 @@ When('the user enters {string} details for Andria Faiza', validity => { cy.contains(user.gender).click({force: true}); } if (user.address != null) { - cy.getByLabel('Address Line 1').type(user.address, {force: true}); - } - if (user.country != null) { - cy.getByLabel('country').clear({force: true}).type(user.country, {force: true}); - } - if (user.stateProvince != null) { - cy.getByLabel('stateProvince').type(user.stateProvince, {force: true}); - } - if (user.cityVillage != null) { - cy.getByLabel('cityVillage').type(user.cityVillage, {force: true}); - } - if (user.postalCode != null) { - cy.getByLabel('postalCode').type(user.postalCode, {force: true}); + cy.getByLabel('Search address').type(user.address, {force: true}); + cy.contains('Cambodia > Kampong Cham > Chamkar Leu').click(); } if (user.phoneNumber != null) { - cy.getByLabel('Phone number(optional)').type(user.phone, {force: true}); + cy.getByLabel('Phone number (optional)').type(user.phone, {force: true}); } // Click on the first day on the calendar because the calendar doesn't support manual inputs cy.getByLabel('Date of Birth').click({force: true}); @@ -72,7 +56,7 @@ When('the user enters {string} details for Andria Faiza', validity => { }) When('the user clicks on the create patient button', () => { - cy.contains('Register Patient').click({force: true}) + cy.contains('Register Patient').click() }) Then('the patient registration should be {string}', status => { @@ -81,7 +65,7 @@ Then('the patient registration should be {string}', status => { cy.contains('New Patient Created'); break; case 'unsuccessful': - cy.get('input[aria-invalid="true"]').should('have.length.greaterThan', 0); + cy.contains('Incomplete form'); break; default: throw new Error(`Status '${status}' is not supported`); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/03-user-settings/user-settings.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/03-user-settings/user-settings.js index 957f85b..4a542fc 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/03-user-settings/user-settings.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/03-user-settings/user-settings.js @@ -2,7 +2,8 @@ import {After, And, Then, When} from '@badeball/cypress-cucumber-preprocessor'; When('the user change the locale to Spanish', () => { cy.get('button[name="Users"]').click({force: true}); - cy.getByLabel('Select locale').select('es', {force: true}); + cy.getByLabel('Select locale').select('es'); + cy.wait(2000); }); And("user clicks on patient search option", () => { diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/04-clinical-visit/clinical-visit.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/04-clinical-visit/clinical-visit.js index f7b1b2d..667b438 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/04-clinical-visit/clinical-visit.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/04-clinical-visit/clinical-visit.js @@ -1,11 +1,20 @@ -import {Before, After, And, Then, When} from '@badeball/cypress-cucumber-preprocessor'; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@clinical-visit'}, () => { +When('the user arrives on a patient’s chart page', () => { + cy.createPatient().then((generatedPatient) => { + patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); + }); +}); + +When('the user arrives on a patient chart page of a patient with an active visit', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; - cy.startFacilityVisit(patient.uuid); + cy.startFacilityVisit(patient.uuid).then(()=>{ + cy.visit(`patient/${patient.uuid}/chart`); + }); }); }); @@ -16,7 +25,7 @@ Then('the Patient header should display correct information', () => { }); Then('the user should be able to expand header to see more information', () => { - cy.contains('Show all details').click({force: true}); + cy.contains('Show all details').click(); cy.contains('Address'); }); @@ -36,53 +45,32 @@ Then('the Patient Summary should load properly', () => { cy.get('div[data-extension-slot-name="patient-chart-dashboard-slot"]').contains('Offline actions'); }); -When('the user clicks on {string} button', (actions) => { - cy.contains(actions).click({force: true}); +When('the user clicks on Actions button', () => { + cy.get('div[role="banner"]').contains("Actions").click(); }); -And('user selects {string}', (visitOption) => { - cy.contains(visitOption).click({force: true}); +When('user selects {string}', (visitOption) => { + cy.contains(visitOption).click(); }); -Then('the user starts a vist', () => { - cy.get('input[id="visitStartDateInput"]').type('01/09/2022', {force: true}); - cy.get('input[id="visitStartTime"]').type('05:12', {force: true}); +When('the user starts a visit', () => { + cy.get('input[id="visitStartDateInput"]').type('01/09/2022', ); + cy.get('input[id="visitStartTime"]').type('05:12', ); cy.get('#visitStartTimeSelect').select('PM'); cy.get('#location').select('Outpatient Clinic'); - cy.get('section [type="radio"]').check('Facility Visit') - cy.get('button[type="submit"').click({force: true}); + cy.contains('Facility Visit').click(); + cy.get('button[type="submit"').click(); }); Then('Visit should be saved and started', () => { - cy.contains('Visit started'); - cy.reload(); - cy.get('div[data-extension-slot-name="patient-header-slot"]').contains('Active Visit'); -}); - -Then('the user edits a vist', () => { - cy.get('input[id="visitStartDateInput"]').type('20/07/2022', {force: true}); - cy.get('input[id="visitStartTime"]').type('06:10', {force: true}); - cy.get('#visitStartTimeSelect').select('AM'); - cy.get('#location').select('Outpatient Clinic'); - cy.get('section [type="radio"]').check('Facility Visit') - cy.get('button[type="submit"').click({force: true}); + cy.get('div[data-extension-slot-name="patient-banner-tags-slot"]').contains('Active Visit'); }); -Then('the user clicks on Edit past Visit', () => { - cy.window().then((win) => { - cy.contains('Edit Past Visit').click({force: true}); - }) +When('the user confirm cancellation', () => { + cy.get('.omrs-modals-container').contains('Cancel Visit').click(); }); -And('the user selects Edit', () => { - cy.get("aside table tbody tr").first().focus() - cy.contains('...').click({force: true}); - cy.contains('Edit').click({force: true}); - cy.window().then((win) => { - cy.contains('Open anyway').click({force: true}); - }) +Then('the visit should have ended', () => { + cy.get('div[data-extension-slot-name="patient-banner-tags-slot"]').contains('Active Visit').should('not.exist'); }); -After({tags: '@clinical-visit'}, () => { - cy.deletePatient(patient.uuid); -}); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/05-vitals-and-biometrics/vitals-and-biometrics.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/05-vitals-and-biometrics/vitals-and-biometrics.js index 4ad8442..1565eb1 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/05-vitals-and-biometrics/vitals-and-biometrics.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/05-vitals-and-biometrics/vitals-and-biometrics.js @@ -1,10 +1,11 @@ -import { Before, Then, When, After } from '@badeball/cypress-cucumber-preprocessor'; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@vitals-and-biometrics' }, () => { +When('the user arrives on a patient’s chart page', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); }); }); @@ -41,7 +42,3 @@ Then("the vitals needs to be displayed on the Vitals table", () => { cy.contains("60"); cy.contains("23.4"); }); - -After({tags: '@vitals-and-biometrics'}, () => { - cy.deletePatient(patient.uuid); -}); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/06-patient-search/patient-search.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/06-patient-search/patient-search.js index d63e955..d05d935 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/06-patient-search/patient-search.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/06-patient-search/patient-search.js @@ -1,11 +1,7 @@ -import {Before, Then, When, After} from '@badeball/cypress-cucumber-preprocessor'; +import {Then, When} from '@badeball/cypress-cucumber-preprocessor'; -let patient = null; - -Before({tags: '@patient-search' }, () => { - cy.createPatient().then((generatedPatient) => { - patient = generatedPatient; - }); +When('John Doe is registered on the system', () => { + cy.createPatient(); }); When('the user search for {string}', patientName => { @@ -19,7 +15,3 @@ When('the user search for {string}', patientName => { Then('the result should be {string}', result => { cy.contains(result); }); - -After({tags: '@patient-search'}, () => { - cy.deletePatient(patient.uuid); -}); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/08-form-management/form-management.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/08-form-management/form-management.js index 7818e9c..56e37c5 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/08-form-management/form-management.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/08-form-management/form-management.js @@ -1,10 +1,11 @@ -import { Before, Then, When, After } from '@badeball/cypress-cucumber-preprocessor'; +import {Then, When} from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@form-management' }, () => { +When('the user arrives on a patient’s chart page', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); }); }); @@ -16,9 +17,5 @@ Then('the form table should displayed', () => { cy.contains("Test Form 1"); }); -After({tags: '@form-management'}, () => { - cy.deletePatient(patient.uuid); -}); - //TODO: Form management section is still under development. //TODO: Form management test should be expand after the developments are over diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/10-care-programs/care-programs.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/10-care-programs/care-programs.js index bd5833e..534776f 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/10-care-programs/care-programs.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/10-care-programs/care-programs.js @@ -1,10 +1,11 @@ -import { Before, Then, When, After } from '@badeball/cypress-cucumber-preprocessor'; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@care-programs' }, () => { +When('the user arrives on a patient’s chart page', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); }); }); @@ -34,7 +35,3 @@ When("the user enroll to a program", () => { Then("the patient should enrolled to the program", () => { cy.contains("Program enrollment saved"); }); - -After({tags: '@care-programs'}, () => { - cy.deletePatient(patient.uuid); -}); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/12-patient-conditions/patient-conditions.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/12-patient-conditions/patient-conditions.js index 460e259..7062097 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/12-patient-conditions/patient-conditions.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/12-patient-conditions/patient-conditions.js @@ -1,10 +1,11 @@ -import { Before, Then, When, After } from '@badeball/cypress-cucumber-preprocessor'; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@patient-conditions' }, () => { +When('the user arrives on a patient’s chart page', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); }); }); @@ -26,7 +27,3 @@ When("the user record a condition", () => { Then("the condition should record successfully", () => { cy.contains("Condition saved"); }); - -After({tags: '@patient-conditions'}, () => { - cy.deletePatient(patient.uuid); -}); diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/13-patient-allergies/patient-allergies.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/13-patient-allergies/patient-allergies.js index 84e2595..42e6fdd 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/13-patient-allergies/patient-allergies.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/13-patient-allergies/patient-allergies.js @@ -1,10 +1,11 @@ -import { Before, Then, When, After } from '@badeball/cypress-cucumber-preprocessor'; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@patient-allergies' }, () => { +When('the user arrives on a patient’s chart page', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); }); }); @@ -16,8 +17,4 @@ Then("the empty allergies section should be displayed", () => { cy.contains("There are no allergy intolerances to display for this patient"); }); -After({tags: '@patient-allergies'}, () => { - cy.deletePatient(patient.uuid); -}); - // TODO: Record allergies diff --git a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/14-appointments/appointments.js b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/14-appointments/appointments.js index 8beadfc..125b277 100644 --- a/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/14-appointments/appointments.js +++ b/packages/cypress/cypress/integration/cucumber/step_definitions/refapp-3.x/14-appointments/appointments.js @@ -1,10 +1,11 @@ -import { Before, Then, When, After } from '@badeball/cypress-cucumber-preprocessor'; +import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; let patient = null; -Before({tags: '@appointments' }, () => { +When('the user arrives on a patient’s chart page', () => { cy.createPatient().then((generatedPatient) => { patient = generatedPatient; + cy.visit(`patient/${patient.uuid}/chart`); }); }); @@ -13,7 +14,7 @@ When("a user clicks on Appointments tab", () => { }); Then("the empty upcoming appointment table should displayed", () => { - cy.contains("There are no upcoming appointments to display for this patient"); + cy.contains("There are no appointments scheduled for today to display for this patient"); }); When("the user clicks on past appointments section", () => { @@ -24,8 +25,4 @@ Then("the empty past appointment table should displayed", () => { cy.contains("There are no past appointments to display for this patient"); }); -After({tags: '@appointments'}, () => { - cy.deletePatient(patient.uuid); -}); - //ToDo: requests an appointment diff --git a/packages/cypress/cypress/support/commands.js b/packages/cypress/cypress/support/commands.js index b882375..2f165db 100644 --- a/packages/cypress/cypress/support/commands.js +++ b/packages/cypress/cypress/support/commands.js @@ -7,11 +7,6 @@ const ADMIN_PASSWORD = Cypress.env('ADMIN_PASSWORD'); const DEFAULT_LOCATION_UUID = Cypress.env('DEFAULT_LOCATION_UUID'); const TOKEN = window.btoa(`${ADMIN_USERNAME}:${ADMIN_PASSWORD}`); -beforeEach("Restore database",() => { - //Run the script - cy.exec("bash scripts/resetDB.sh"); -}) - Cypress.Commands.add('runAndAwait', (callable, method='GET', addArtificialWait=false) => { const requestId = `apiRequest-${uuid()}`; @@ -28,8 +23,8 @@ Cypress.Commands.add('runAndAwait', (callable, method='GET', addArtificialWait=f Cypress.Commands.add('initiateExceptionsLogger', () => { Cypress.on('uncaught:exception', (err, runnable) => { - console.log(err); - return false; + console.log(err); + return false; }); }); @@ -309,9 +304,9 @@ Cypress.Commands.add('createPatient', (identifier = null) => { names: [ { preferred: true, - givenName: 'John', + givenName: 'Harry', middleName: '', - familyName: 'Doe' + familyName: 'Potter' } ], diff --git a/packages/cypress/package.json b/packages/cypress/package.json index 312cd13..6ebe8de 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -34,7 +34,7 @@ }, "cypress-cucumber-preprocessor": { "stepDefinitions": [ - "cypress/integration/cucumber/step_definitions/**/**/*.js", + "cypress/integration/cucumber/step_definitions/refapp-3.x/[filepart]/*.js", "cypress/integration/common/**/*.js" ] }, diff --git a/packages/cypress/resources/features/refapp-3.x/02-patient-registration/patient-registration.feature b/packages/cypress/resources/features/refapp-3.x/02-patient-registration/patient-registration.feature index 56cb346..6e4a35d 100644 --- a/packages/cypress/resources/features/refapp-3.x/02-patient-registration/patient-registration.feature +++ b/packages/cypress/resources/features/refapp-3.x/02-patient-registration/patient-registration.feature @@ -2,6 +2,7 @@ Feature: Patient Registration Background: Given the user login to the Outpatient Clinic + And the user visit the home page Scenario Outline: Register a patient When the user clicks on the add patient icon diff --git a/packages/cypress/resources/features/refapp-3.x/03-user-settings/user-settings.feature b/packages/cypress/resources/features/refapp-3.x/03-user-settings/user-settings.feature index 3d1a162..c99a519 100644 --- a/packages/cypress/resources/features/refapp-3.x/03-user-settings/user-settings.feature +++ b/packages/cypress/resources/features/refapp-3.x/03-user-settings/user-settings.feature @@ -2,6 +2,7 @@ Feature: User Settings Background: Given the user login to the Outpatient Clinic + And the user visit the home page @user-settings @locale diff --git a/packages/cypress/resources/features/refapp-3.x/04-clinical-visit/clinical-visit.feature b/packages/cypress/resources/features/refapp-3.x/04-clinical-visit/clinical-visit.feature index 7267f83..f96f804 100644 --- a/packages/cypress/resources/features/refapp-3.x/04-clinical-visit/clinical-visit.feature +++ b/packages/cypress/resources/features/refapp-3.x/04-clinical-visit/clinical-visit.feature @@ -2,38 +2,25 @@ Feature: Clinical Visit Background: Given the user login to the Outpatient Clinic - And the user arrives on a patient’s chart page + @clinical-visit Scenario: The Patient Chart should load properly + When the user arrives on a patient’s chart page Then the Patient header should display correct information And the user should be able to expand header to see more information @clinical-visit - Scenario: User should be able to start a vist - When the user clicks on "Actions" button - And user selects "Start vist" - Then the user starts a vist - Then Visit should be saved and started - - @clinical-visit - Scenario: User should be able to Edit a vist - When the user clicks on "Actions" button - And user selects "Edit vist" - Then the user edits a vist + Scenario: User should be able to start a visit + When the user arrives on a patient’s chart page + And user selects "Start visit" + And the user starts a visit Then Visit should be saved and started @clinical-visit - Scenario: User should be able to emd a vist - When the user clicks on "Actions" button - And user selects "End vist" - Then the user ends a vist - Then Visit should have ended - - @clinical-visit - Scenario: User should be able to add a past vist - When the user clicks on "Actions" button - And user selects "Add past vist" - Then the user clicks on Edit past Visit - And the user selects Edit - Then Visit should be saved and started + Scenario: User should be able to end a visit + When the user arrives on a patient chart page of a patient with an active visit + And the user clicks on Actions button + And user selects "Cancel Visit" + And the user confirm cancellation + Then the visit should have ended diff --git a/packages/cypress/resources/features/refapp-3.x/06-patient-search/patient-search.feature b/packages/cypress/resources/features/refapp-3.x/06-patient-search/patient-search.feature index f189dfe..155d26a 100644 --- a/packages/cypress/resources/features/refapp-3.x/06-patient-search/patient-search.feature +++ b/packages/cypress/resources/features/refapp-3.x/06-patient-search/patient-search.feature @@ -2,6 +2,8 @@ Feature: Patient Search Background: Given the user login to the Outpatient Clinic + And John Doe is registered on the system + And the user visit the home page @patient-search Scenario Outline: Search for a patient @@ -9,5 +11,5 @@ Feature: Patient Search Then the result should be "" Examples: | patientName | result | - | John Doe | John Doe | + | Harry Potter | Harry Potter | | non existing | Sorry, no patient | diff --git a/packages/cypress/resources/features/refapp-3.x/07-logout/logout.feature b/packages/cypress/resources/features/refapp-3.x/07-logout/logout.feature index 4dc1f5a..aade9d1 100644 --- a/packages/cypress/resources/features/refapp-3.x/07-logout/logout.feature +++ b/packages/cypress/resources/features/refapp-3.x/07-logout/logout.feature @@ -2,6 +2,7 @@ Feature: User Logout Background: Given the user login to the Outpatient Clinic + And the user visit the home page Scenario: user logout successfully from the application When the user logout from the application