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

Commit

Permalink
Merging PR #198 - Imaging acceptance tests
Browse files Browse the repository at this point in the history
Resolves #192; Closes #198
  • Loading branch information
jkleinsc committed Oct 28, 2015
1 parent 1ff3b5d commit 20b325f
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
6 changes: 4 additions & 2 deletions app/imaging/edit/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#edit-panel editPanelProps=editPanelProps}}
{{#em-form model=this submitButton=false }}
{{#if selectPatient}}
{{patient-typeahead property="patientTypeAhead" label="Patient" content=patientList selection=selectedPatient class="required"}}
{{patient-typeahead property="patientTypeAhead" label="Patient" content=patientList selection=selectedPatient class="required patient-input"}}
{{else}}
{{patient-summary patient=patient returnTo='imaging.edit' returnToContext=id disablePatientLink=isNew }}
{{/if}}
Expand All @@ -22,6 +22,7 @@
className="required"
prompt=" "
model=model
class="imaging-type-input"
}}
{{else}}
<div class="row">
Expand All @@ -39,8 +40,9 @@
{{select-or-typeahead property="radiologist"
label="Radiologist" list=radiologistList
prompt=" "
class="radiologist-input"
}}
{{em-input property="result" label="Result"}}
{{em-input property="result" label="Result" class="result-input"}}
{{/if}}
{{em-text property="notes" label="Notes" rows=3 }}
{{/em-form}}
Expand Down
2 changes: 1 addition & 1 deletion app/mixins/patient-submodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default Ember.Mixin.create(PatientVisits, {
this.store.find('patient', selectedPatient.id).then(function(item) {
this.set('model.patient', item);
Ember.run.once(this, function() {
this.get('model').validate();
this.get('model').validate().catch(Ember.K);
});
}.bind(this));
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/patient-summary.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="panel panel-success" {{action 'linkToPatient'}}>
<div class="panel-body">
<div class="row">
<div class="form-group col-sm-3" data-test-selector="patient-summary-id">
<div class="row test-patient-summary">
<div class="form-group col-sm-3">
<label class="control-label">Id</label> {{patient.displayPatientId}}
</div>
<div class="form-group col-sm-4">
Expand Down
107 changes: 107 additions & 0 deletions tests/acceptance/imaging-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'hospitalrun/tests/helpers/start-app';

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

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

test('visiting /imaging', function(assert) {
loadPouchDump('default');
authenticateUser();
visit('/imaging');

andThen(() => {
assert.equal(currentURL(), '/imaging');
assert.equal(find('li a:contains(Requests)').length, 1, 'Requests link is visible');
assert.equal(find('li a:contains(Completed)').length, 1, 'Completed link is visible');
let newImagingButton = find('button:contains(new imaging)');
assert.equal(newImagingButton.length, 1, 'New Imaging button is visible');
findWithAssert('p:contains(No items found. )');
findWithAssert('a:contains(Create a new record?)');
});
click('button:contains(new imaging)');
andThen(() => {
assert.equal(currentURL(), '/imaging/edit/new');
});
destroyDatabases();
});

test('create a new imaging request', (assert) => {
loadPouchDump('imaging');
authenticateUser();
visit('/imaging/edit/new');

andThen(() => {
assert.equal(currentURL(), '/imaging/edit/new');
});
fillIn('.patient-input .tt-input', 'Lennex Zinyando - P00017');
triggerEvent('.patient-input .tt-input', 'input');
triggerEvent('.patient-input .tt-input', 'blur');
fillIn('.imaging-type-input .tt-input', 'Chest Scan');
fillIn('.radiologist-input .tt-input', 'Dr Test');
fillIn('.result-input input', 'Check is clear');
fillIn('textarea', 'Patient is healthy');
click('button:contains(Add)');
waitToAppear('.modal-dialog');
andThen(() => {
assert.equal(find('.modal-title').text(), 'Imaging Request Saved', 'Imaging Request was saved successfully');
});
click('button:contains(Ok)');
andThen(() => {
findWithAssert('button:contains(Update)');
findWithAssert('button:contains(Return)');
findWithAssert('button:contains(Complete)');
assert.equal(find('.test-patient-summary').length, 1, 'Patient summary is displayed');
});
destroyDatabases();
});

test('completed requests are displayed', (assert) => {
loadPouchDump('imaging');
authenticateUser();
visit('/imaging/completed');

andThen(() => {
assert.equal(currentURL(), '/imaging/completed');
assert.equal(find('.table').length, 1, 'Requests table is visible');
});
destroyDatabases();
});

test('mark an imaging request as completed', (assert) => {
loadPouchDump('imaging');
authenticateUser();
visit('/imaging');

andThen(() => {
assert.equal(currentURL(), '/imaging');
assert.equal(find('.table').length, 1, 'Requests table is visible');
assert.equal(find('tr').length, 3, 'Two imaging requests not completed');
});
click('button:contains(Edit)');
andThen(() => {
assert.equal(currentURL(), '/imaging/edit/1AC1DD3D-E7E7-15B4-A698-8A8AE62749EB');
findWithAssert('button:contains(Update)');
findWithAssert('button:contains(Return)');
findWithAssert('button:contains(Complete)');
});
click('button:contains(Complete)');
waitToAppear('.modal-dialog');
andThen(() => {
assert.equal(find('.modal-title').text(), 'Imaging Request Completed', 'Imaging Request was saved successfully');
});
click('button:contains(Ok)');
click('button:contains(Return)');
andThen(() => {
assert.equal(currentURL(), '/imaging');
assert.equal(find('tr').length, 2, 'One request is left to complete');
});
destroyDatabases();
});
9 changes: 9 additions & 0 deletions tests/fixtures/imaging.txt

Large diffs are not rendered by default.

0 comments on commit 20b325f

Please sign in to comment.