Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Added acceptance testing for visits
Browse files Browse the repository at this point in the history
Fixes #554
  • Loading branch information
jkleinsc committed Jul 15, 2016
1 parent 37b5662 commit d0e1cb6
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/procedures/charge/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
updateButtonAction=updateButtonAction
updateButtonText=updateButtonText }}
{{#em-form model=model submitButton=false }}
{{pricing-typeahead property="itemName" label=(t 'inventory.labels.item') content=pricingList selection=selectedItem class="required"}}
{{pricing-typeahead property="itemName" label=(t 'inventory.labels.item') content=pricingList selection=selectedItem class="required charge-item-name"}}
<div class="row">
{{em-input label=(t 'labels.quantity') property="quantity" class="col-xs-3 required"}}
{{date-picker property="dateCharged" label="Date Charged" class="col-xs-4 required"}}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/item-charges.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</h3>
</div>
<div class="panel-body detail-section-content">
<table class="table">
<table class="table charge-items">
<tr class="table-header">
<th>{{t 'labels.date'}}</th>
<th>{{t 'inventory.labels.item'}}</th>
Expand All @@ -22,7 +22,7 @@
{{#unless charge.medicationCharge}}
<tr>
<td>{{date-format charge.dateCharged}}</td>
<td>{{charge.pricingItem.name}}</td>
<td class="charge-item-name">{{charge.pricingItem.name}}</td>
<td>{{charge.quantity}}</td>
<td>
{{#if canAddCharge}}
Expand Down
2 changes: 1 addition & 1 deletion app/visits/add-diagnosis/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
updateButtonAction=updateButtonAction
updateButtonText=updateButtonText }}
{{#em-form model=model submitButton=false }}
{{select-or-typeahead property="diagnosis" label="Diagnosis" list=diagnosisList hint=false}}
{{select-or-typeahead property="diagnosis" label="Diagnosis" list=diagnosisList hint=false class="diagnosis-text"}}
{{/em-form}}
{{/modal-dialog}}
2 changes: 1 addition & 1 deletion app/visits/delete/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p class="form-control-static">{{date-format model.endDate}}</p>
</div>
<div class="form-group">
<label class="control-label">{{t 'labels.examiner'}}</label>
<label class="control-label">{{t 'visits.labels.examiner'}}</label>
<p class="form-control-static">{{model.examiner}}</p>
</div>
<div class="form-group">
Expand Down
10 changes: 5 additions & 5 deletions app/visits/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="row">
<div class="form-group col-sm-3">
<label>{{t 'labels.patient'}}</label>
<p class="form-control-static">{{model.patient.displayName}}</p>
<p class="form-control-static patient-name">{{model.patient.displayName}}</p>
</div>
{{#if isAdmissionVisit}}
{{date-picker property="startDate" label=(t "patients.labels.admission_date") showTime=true class="col-sm-3 required"}}
Expand Down Expand Up @@ -78,10 +78,10 @@
{{#each model.additionalDiagnoses as |diagnosis|}}
<tr>
<td>{{date-format diagnosis.date}}</td>
<td>{{diagnosis.description}}</td>
<td class="additional-diagnoses-text">{{diagnosis.description}}</td>
<td>
{{#if canDeleteDiagnosis}}
<button class="btn btn-default warning" {{action "deleteDiagnosis" diagnosis}}>
<button class="btn btn-default warning delete-additional-diagnosis" {{action "deleteDiagnosis" diagnosis}}>
<span class="octicon octicon-x"></span> {{t 'buttons.delete' }}
</button>
{{/if}}
Expand Down Expand Up @@ -167,7 +167,7 @@
{{/if}}
{{#if canDeleteProcedure}}
<button class="btn btn-default warning" {{action "showDeleteProcedure" procedure}}>
<span class="octicon octicon-x"></span> {{t 'visits.edit.delete' }}
<span class="octicon octicon-x"></span> {{t 'buttons.delete' }}
</button>
{{/if}}
</td>
Expand All @@ -181,7 +181,7 @@
<div class="panel-heading">
<h3 class="panel-title">
<a data-toggle="collapse" data-parent="#patient-accordion" href="#patient-medication">
{{t 'labels.actions' }}
{{t 'visits.labels.medication' }}
{{#if canAddMedication}}
<button class="btn btn-primary align-right" {{action "newMedication" bubbles=false }}><span class="octicon octicon-plus"></span> {{t 'visits.buttons.new_medication' }}</button>
{{/if}}
Expand Down
14 changes: 7 additions & 7 deletions app/visits/vitals/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
{{date-picker property="dateRecorded" label=(t "vitals.labels.date_recorded") class="col-sm-6" format="l h:mm A" showTime=true }}
</div>
<div class="row">
{{em-input class="col-sm-3 required" property="temperature" label=temperatureLabel }}
{{em-input class="col-sm-3 required temperature-text" property="temperature" label=temperatureLabel }}
</div>
<div class="row">
{{em-input class="col-sm-3" property="weight" label=(t "vitals.labels.weight")}}
{{em-input class="col-sm-3" property="height" label=(t "vitals.labels.height")}}
{{em-input class="col-sm-3 weight-text" property="weight" label=(t "vitals.labels.weight")}}
{{em-input class="col-sm-3 height-text" property="height" label=(t "vitals.labels.height")}}
</div>
<div class="row">
{{em-input class="col-sm-3 required" property="sbp" label=(t "vitals.labels.sbp")}}
{{em-input class="col-sm-3 required" property="dbp" label=(t "vitals.labels.dbp")}}
{{em-input class="col-sm-3 required sbp-text" property="sbp" label=(t "vitals.labels.sbp")}}
{{em-input class="col-sm-3 required dbp-text" property="dbp" label=(t "vitals.labels.dbp")}}
</div>
<div class="row">
{{em-input class="col-sm-3 required" property="heartRate" label=(t "vitals.labels.heart_rate")}}
{{em-input class="col-sm-3 required" property="respiratoryRate" label=(t "vitals.labels.respiratory_rate")}}
{{em-input class="col-sm-3 required heart-rate-text" property="heartRate" label=(t "vitals.labels.heart_rate")}}
{{em-input class="col-sm-3 required respiratory-rate-text" property="respiratoryRate" label=(t "vitals.labels.respiratory_rate")}}
</div>
{{/em-form}}
{{/modal-dialog}}
185 changes: 185 additions & 0 deletions tests/acceptance/visit-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'hospitalrun/tests/helpers/start-app';

module('Acceptance | visits', {
beforeEach: function() {
this.application = startApp();
},

afterEach: function() {
Ember.run(this.application, 'destroy');
}
});

test('Add visit', function(assert) {
runWithPouchDump('patient', function() {
authenticateUser();
visit('/patients');
andThen(function() {
assert.equal(currentURL(), '/patients', 'Patient url is correct');
click('button:contains(Edit)');
});
andThen(function() {
assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient record displays');
click('[data-test-selector=visits-tab]');
waitToAppear('#visits button:contains(Edit)'); // Make sure visits have been retrieved.
});
andThen(function() {
click('#visits button:contains(New Visit)');
waitToAppear('#visit-info');
});
andThen(function() {
assert.equal(find('.patient-name').text(), 'Joe Bagadonuts', 'Joe Bagadonuts displays as patient for visit');
updateVisit(assert, 'Add');
});
});
});

test('Edit visit', function(assert) {
runWithPouchDump('patient', function() {
authenticateUser();
visit('/patients');
andThen(function() {
assert.equal(currentURL(), '/patients', 'Patient url is correct');
click('button:contains(Edit)');
});
andThen(function() {
assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient record displays');
click('[data-test-selector=visits-tab]');
waitToAppear('#visits button:contains(Edit)');
});
andThen(function() {
click('#visits button:contains(Edit)');
});
andThen(function() {
assert.equal(currentURL(), '/visits/edit/03C7BF8B-04E0-DD9E-9469-96A5604F5340', 'Visit url is correct');
click('button:contains(Add Diagnosis)');
waitToAppear('.modal-dialog');
});
andThen(function() {
assert.equal(find('.modal-title').text(), 'Add Diagnosis', 'Add Diagnosis dialog displays');
fillIn('.diagnosis-text input', 'Broken Arm');
click('.modal-footer button:contains(Add)');
});
andThen(function() {
assert.equal(find('.additional-diagnoses-text').text(), 'Broken Arm', 'New additional diagnosis appears');
click('button:contains(New Medication)');
});
andThen(function() {
assert.equal(currentURL(), '/medication/edit/new', 'New medication url is correct');
assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New medication prepopulates with patient');
click('button:contains(Cancel)');
});
andThen(function() {
click('button:contains(New Lab)');
});
andThen(function() {
assert.equal(currentURL(), '/labs/edit/new', 'New lab url is correct');
assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New lab prepopulates with patient');
click('button:contains(Cancel)');
});
andThen(function() {
click('button:contains(New Imaging)');
});
andThen(function() {
assert.equal(currentURL(), '/imaging/edit/new', 'New imaging url is correct');
assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'New imaging prepopulates with patient');
click('button:contains(Cancel)');
});
andThen(function() {
click('button:contains(New Vitals)');
waitToAppear('.modal-dialog');
});
andThen(function() {
fillIn('.temperature-text input', '34.56');
fillIn('.weight-text input', '34.56');
fillIn('.height-text input', '34.56');
fillIn('.sbp-text input', '34.56');
fillIn('.dbp-text input', '34.56');
fillIn('.heart-rate-text input', '34.56');
fillIn('.respiratory-rate-text input', '34.56');
click('.modal-footer button:contains(Add)');
waitToAppear('#visit-vitals tr:last td:contains(34.56)');
});
andThen(function() {
assert.equal(find('#visit-vitals tr:last td:contains(34.56)').length, 7, 'New vitals appears');
click('button:contains(Add Item)');
waitToAppear('.modal-dialog');
});
andThen(function() {
fillIn('.charge-item-name .tt-input', 'Gauze pad');
triggerEvent('.charge-item-name .tt-input', 'input');
triggerEvent('.charge-item-name .tt-input', 'blur');
click('.modal-footer button:contains(Add)');
waitToAppear('td.charge-item-name');
});
andThen(function() {
assert.equal(find('td.charge-item-name').text(), 'Gauze pad', 'New charge item appears');
});
updateVisit(assert, 'Update');
andThen(function() {
click('.delete-additional-diagnosis');
});
andThen(function() {
click('#visit-vitals tr:last button:contains(Delete)');
waitToAppear('.modal-dialog');
});
andThen(function() {
assert.equal(find('.modal-title').text(), 'Delete Vitals', 'Delete Vitals dialog displays');
click('.modal-footer button:contains(Delete)');
});
andThen(function() {
click('.charge-items tr:last button:contains(Delete)');
waitToAppear('.modal-dialog');
});
andThen(function() {
assert.equal(find('.modal-title').text(), 'Delete Charge Item', 'Delete Charge Item dialog displays');
click('.modal-footer button:contains(Ok)');
});
andThen(function() {
assert.equal(find('.additional-diagnoses-text').length, 0, 'New additional diagnosis is deleted');
assert.equal(find('#visit-vitals tr:last td:contains(34.56)').length, 0, 'Vital is deleted');
assert.equal(find('td.charge-item-name').length, 0, 'Charge item is deleted');
});
});
});

test('Delete visit', function(assert) {
runWithPouchDump('patient', function() {
authenticateUser();
visit('/patients');
andThen(function() {
assert.equal(currentURL(), '/patients', 'Patient url is correct');
click('button:contains(Edit)');
});
andThen(function() {
assert.equal(find('.patient-name .ps-info-data').text(), 'Joe Bagadonuts', 'Joe Bagadonuts patient record displays');
click('[data-test-selector=visits-tab]');
waitToAppear('#visits button:contains(Delete)'); // Make sure visits have been retrieved.
});
andThen(function() {
assert.equal(find('#visits tr').length, 2, 'One visit is displayed to delete');
click('#visits button:contains(Delete)');
waitToAppear('.modal-dialog');
});
andThen(function() {
assert.equal(find('.modal-title').text(), 'Delete Visit', 'Delete Visit confirmation displays');
click('.modal-footer button:contains(Delete)');
});
andThen(function() {
assert.equal(find('#visits tr').length, 1, 'Visit is deleted');
});
});
});

function updateVisit(assert, buttonText) {
andThen(function() {
click(`.panel-footer button:contains(${buttonText})`);
waitToAppear('.modal-dialog');
});
andThen(function() {
assert.equal(find('.modal-title').text(), 'Visit Saved', 'Visit Saved dialog displays');
click('button:contains(Ok)');
});
}
9 changes: 9 additions & 0 deletions tests/fixtures/patient.txt

Large diffs are not rendered by default.

0 comments on commit d0e1cb6

Please sign in to comment.