Skip to content

Commit

Permalink
O3-1655: Fix existing tests (#33)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jayasanka-sack authored Nov 24, 2022
1 parent 8b5bb33 commit 1d07633
Show file tree
Hide file tree
Showing 30 changed files with 131 additions and 171 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-appointments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-care-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-clinical-visit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-form-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-login.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-logout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-patient-allergies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-patient-conditions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-patient-registration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-patient-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-user-settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .github/workflows/refapp-3x-vitals-and-biometrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 12 additions & 10 deletions packages/cypress/cypress/integration/common/refapp-3.x/common.js
Original file line number Diff line number Diff line change
@@ -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');
});
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
}
};
Expand All @@ -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});
}
Expand All @@ -49,30 +44,19 @@ 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});
cy.get('.dayContainer .flatpickr-day').first().click({force: true});
})

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 => {
Expand All @@ -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`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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`);
});
});
});

Expand All @@ -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');
});

Expand All @@ -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);
});
Original file line number Diff line number Diff line change
@@ -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`);
});
});

Expand Down Expand Up @@ -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);
});
Original file line number Diff line number Diff line change
@@ -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 => {
Expand All @@ -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);
});
Original file line number Diff line number Diff line change
@@ -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`);
});
});

Expand All @@ -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
Loading

0 comments on commit 1d07633

Please sign in to comment.