Skip to content

Commit

Permalink
fix(projects): patch brittle test
Browse files Browse the repository at this point in the history
This commit patches a brittle project test that depends on array
$indexes and makes it use the project.id instead.  This fixes some
errors that happen in the projects test suite.
  • Loading branch information
jniles committed Apr 1, 2016
1 parent 8569837 commit 2e23b17
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
36 changes: 18 additions & 18 deletions client/src/partials/projects/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
<td>{{ project.abbr }}</td>
<td>{{ project.enterprise_id }}</td>
<td>
<a class="btn btn-xs btn-default" ng-click="ProjectCtrl.update(project)" id="project-upd-{{ $index + 1}}"><span class="glyphicon glyphicon-pencil"></span></a>
<a class="btn btn-xs btn-default" ng-click="ProjectCtrl.update(project)" id="project-upd-{{ project.id }}"><span class="glyphicon glyphicon-pencil"></span></a>
</td>
<td>
<a class="btn btn-xs btn-default" ng-click="ProjectCtrl.del(project)" id="project-del-{{ $index + 1 }}" class="danger">
<a class="btn btn-xs btn-default" ng-click="ProjectCtrl.del(project)" id="project-del-{{ project.id }}" class="danger">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
Expand Down Expand Up @@ -93,15 +93,15 @@ <h4>{{ ProjectCtrl.HTTPError.data.code | translate }} </h4>
<input type="text" class="form-control" name="name" id="bhima-project-name" ng-model="ProjectCtrl.project.name" required>
<div class="help-block" ng-messages="CreateForm.name.$error" ng-show="CreateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : CreateForm.$submitted && CreateForm.abbr.$invalid }">
<label for="bhima-project-abbr" class="control-label">{{ "COLUMNS.ABBR" | translate }}</label>
<input type="text" class="form-control" name="abbr" required id="bhima-project-abbr" ng-model="ProjectCtrl.project.abbr">
<input type="text" class="form-control" name="abbr" required id="bhima-project-abbr" ng-model="ProjectCtrl.project.abbr">
<div class="help-block" ng-messages="CreateForm.abbr.$error" ng-show="CreateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : CreateForm.$submitted && CreateForm.enterprise_id.$invalid }">
Expand All @@ -111,7 +111,7 @@ <h4>{{ ProjectCtrl.HTTPError.data.code | translate }} </h4>
</select>
<div class="help-block" ng-messages="CreateForm.enterprise_id.$error" ng-show="CreateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<!-- zone de sante for snis -->
Expand All @@ -122,15 +122,15 @@ <h4>{{ ProjectCtrl.HTTPError.data.code | translate }} </h4>
</select>
<div class="help-block" ng-messages="CreateForm.zs_id.$error" ng-show="CreateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>
<!-- end zone de sante for snis -->

<div class="form-group" ng-class="{ 'has-error' : CreateForm.$submitted && CreateForm.locked.$invalid }">
<label class="control-label">
<input type="checkbox" name="locked" id="locked" ng-true-value="1" ng-false-value="0"
<input type="checkbox" name="locked" id="locked" ng-true-value="1" ng-false-value="0"
ng-model="ProjectCtrl.project.locked"> {{ "COLUMNS.LOCKED" | translate }}
</label>
</label>
</div>

<div class="form-group">
Expand All @@ -154,15 +154,15 @@ <h4>{{ ProjectCtrl.HTTPError.data.code | translate }} </h4>
<input type="text" class="form-control" name="name" id="bhima-project-name" ng-model="ProjectCtrl.project.name" required>
<div class="help-block" ng-messages="UpdateForm.name.$error" ng-show="UpdateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : UpdateForm.$submitted && UpdateForm.abbr.$invalid }">
<label for="bhima-project-abbr" class="control-label">{{ "COLUMNS.ABBR" | translate }}</label>
<input type="text" class="form-control" name="abbr" required id="bhima-project-abbr" ng-model="ProjectCtrl.project.abbr">
<input type="text" class="form-control" name="abbr" required id="bhima-project-abbr" ng-model="ProjectCtrl.project.abbr">
<div class="help-block" ng-messages="UpdateForm.abbr.$error" ng-show="UpdateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : UpdateForm.$submitted && UpdateForm.enterprise_id.$invalid }">
Expand All @@ -172,7 +172,7 @@ <h4>{{ ProjectCtrl.HTTPError.data.code | translate }} </h4>
</select>
<div class="help-block" ng-messages="UpdateForm.enterprise_id.$error" ng-show="UpdateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<!-- zone de sante for snis -->
Expand All @@ -183,15 +183,15 @@ <h4>{{ ProjectCtrl.HTTPError.data.code | translate }} </h4>
</select>
<div class="help-block" ng-messages="UpdateForm.zs_id.$error" ng-show="UpdateForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
</div>
</div>
</div>
<!-- end zone de sante for snis -->

<div class="form-group" ng-class="{ 'has-error' : UpdateForm.$submitted && UpdateForm.locked.$invalid }">
<label class="control-label">
<input type="checkbox" name="locked" id="locked" ng-true-value="1" ng-false-value="0"
<input type="checkbox" name="locked" id="locked" ng-true-value="1" ng-false-value="0"
ng-model="ProjectCtrl.project.locked"> {{ "COLUMNS.LOCKED" | translate }}
</label>
</label>
</div>
<div class="form-group">
<button class="btn btn-default" id="change_project" type="submit" data-method="submit">
Expand Down
1 change: 0 additions & 1 deletion client/test/e2e/billingServices/billingServices.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('Billing Services', function () {
FU.exists(by.css('[name="BillingServicesForm"]'), true);

// update the label
FU.clear('BillingServicesFormCtrl.model.label');
FU.input('BillingServicesFormCtrl.model.label', 'Value Reduced Tax');

// submit the forn
Expand Down
1 change: 0 additions & 1 deletion client/test/e2e/patient/invoice.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function PatientInvoicePage() {

// adds n rows to the grid
page.addRows = function addRows(n) {
FU.clear('PatientInvoiceCtrl.itemIncrement');
FU.input('PatientInvoiceCtrl.itemIncrement', n);
btns.add.click();
};
Expand Down
5 changes: 0 additions & 5 deletions client/test/e2e/patient/registration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,23 @@ describe('patient registration', function () {
var testMinYear = '1000';
var validYear = '2000';

FU.clear('PatientRegCtrl.yob');
FU.input('PatientRegCtrl.yob', testMaxYear);
FU.exists(by.css('[data-date-error]'), true);

FU.clear('PatientRegCtrl.yob');
FU.input('PatientRegCtrl.yob', validYear);
FU.exists(by.css('[data-date-error]'), false);

FU.clear('PatientRegCtrl.yob');
FU.input('PatientRegCtrl.yob', testMinYear);
FU.exists(by.css('[data-date-error]'), true);
});

it('correctly identifies duplicate hospital numbers (async)', function () {

// resend the (assumed) correctly registered patients hospital number
FU.clear('PatientRegCtrl.medical.hospital_no');
FU.input('PatientRegCtrl.medical.hospital_no', mockPatient.hospital_no);
FU.exists(by.id('unique-error-icon'), true);

// put in a unique hospital number
FU.clear('PatientRegCtrl.medical.hospital_no');
FU.input('PatientRegCtrl.medical.hospital_no', uniqueHospitalNumber);
FU.exists(by.id('unique-error-icon'), false);
});
Expand Down
11 changes: 5 additions & 6 deletions client/test/e2e/projects/projects.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* jshint expr:true */
/* global element, by, beforeEach, inject, browser */
/* global element, by, browser */

var chai = require('chai');
var expect = chai.expect;
Expand All @@ -20,15 +19,15 @@ describe('Projects Module', function () {

var defaultProject = 3;
var enterpriseRank = helpers.random(defaultProject);
var deleteSuccess = 4;
var deleteSuccess = 3;
var deleteError = 1;

// navigate to the project module before each test
beforeEach(function () {
browser.get(path);
});

it('successfully creates a new project', function () {
it('creates a new project', function () {

// swtich to the create form
FU.buttons.create();
Expand Down Expand Up @@ -56,7 +55,7 @@ describe('Projects Module', function () {
});


it('successfully edits an project', function () {
it('edits an project', function () {

element(by.id('project-upd-' + enterpriseRank )).click();

Expand Down Expand Up @@ -100,7 +99,7 @@ describe('Projects Module', function () {
FU.validation.ok('ProjectCtrl.project.locked');
});

it('successfully delete an project', function () {
it('delete an project', function () {
element(by.id('project-del-' + deleteSuccess )).click();

// click the alert asking for permission
Expand Down
5 changes: 0 additions & 5 deletions client/test/e2e/shared/FormUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ module.exports = {
return element(by.model(model)).clear().sendKeys(value);
},

// clear an input's value. Only works for <input> and <textarea>
clear : function input(model) {
return element(by.model(model)).clear();
},

// get a <select> element by its ng-model.
select: function select(model) {
return element(by.model(model)).all(by.tagName('option'));
Expand Down

0 comments on commit 2e23b17

Please sign in to comment.