Skip to content

Commit

Permalink
fix(tests): add fiscal year
Browse files Browse the repository at this point in the history
The tests broke due to a missing fiscal year.  I've added the new year
and cleaned up the fiscal year test code to respect eslint.
  • Loading branch information
jniles committed Jan 8, 2018
1 parent 6aee79b commit 8494bec
Show file tree
Hide file tree
Showing 12 changed files with 489 additions and 142 deletions.
18 changes: 9 additions & 9 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"src"
],
"dependencies": {
"angular": "1.6.8",
"angular-animate": "1.6.8",
"angular-sanitize": "1.6.8",
"angular-messages": "1.6.8",
"angular": "1.6.6",
"angular-animate": "1.6.6",
"angular-sanitize": "1.6.6",
"angular-messages": "1.6.6",
"angular-bootstrap": "2.5.0",
"angular-ui-router": "1.0.0-rc.1",
"angular-ui-grid": "4.0.4",
Expand All @@ -32,19 +32,19 @@
"moment": "2.20.1",
"angular-dynamic-locale": "0.1.32",
"ngstorage": "0.3.11",
"Chart.js": "2.5.0",
"Chart.js": "2.7.1",
"angular-chart.js": "1.1.1",
"components-font-awesome": "4.7.0",
"angular-ui-select": "0.17.1",
"JsBarcode": "jsbarcode#3.8.0",
"angular-touch": "1.6.8",
"angular-growl-notifications": "2.5.0",
"angular-touch": "1.6.6",
"angular-growl-notifications": "2.6.0",
"webcam-directive": "3.1.1"
},
"devDependencies": {
"angular-mocks": "1.6.8"
"angular-mocks": "1.6.6"
},
"resolutions": {
"angular": "1.6.8"
"angular": "1.6.6"
}
}
54 changes: 27 additions & 27 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Karma configuration
// Generated on Wed Mar 30 2016 15:50:28 GMT+0100 (WAT)

module.exports = function (config) {
module.exports = (config) => {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
basePath : '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai-spies', 'chai-dom', 'chai'],
// available frameworks : https://npmjs.org/browse/keyword/karma-adapter
frameworks : ['mocha', 'chai-spies', 'chai-dom', 'chai'],

// list of files / patterns to load in the browser
files: [
files : [
'bin/client/js/vendor.min.js',
'client/vendor/angular-mocks/angular-mocks.js',
'bin/client/js/bhima.min.js',
Expand All @@ -23,53 +23,53 @@ module.exports = function (config) {

// Karma serves all files out of the route /base/*. We must make a proxy to
// intercept these requests and rewrite them to the right place.
// see: http://karma-runner.github.io/1.0/config/files.html
proxies: {
'/i18n/' : '/base/bin/client/i18n/',
// see : http://karma-runner.github.io/2.0/config/files.html
proxies : {
'/i18n/' : '/base/bin/client/i18n/',
},

// list of files to exclude
exclude: [],
exclude : [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.html' : ['ng-html2js'],
// available preprocessors : https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors : {
'**/*.html' : ['ng-html2js'],
},

ngHtml2JsPreprocessor : {
stripPrefix : 'bin/client/',
moduleName : 'templates',
ngHtml2JsPreprocessor : {
stripPrefix : 'bin/client/',
moduleName : 'templates',
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// possible values : 'dots', 'progress'
// available reporters : https://npmjs.org/browse/keyword/karma-reporter
reporters : ['progress'],

// web server port
port: 9876,
port : 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,
colors : true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// possible values : config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel : config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
autoWatch : true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// available browser launchers : https://npmjs.org/browse/keyword/karma-launcher
browsers : ['Chrome'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
singleRun : false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: 1,
concurrency : 1,
});
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dependencies": {
"accounting-js": "^1.1.1",
"body-parser": "^1.15.0",
"bower-npm-resolver": "^0.7.0",
"bower-npm-resolver": "^0.8.2",
"chai-spies": "^0.7.1",
"chai-spies-next": "^0.9.3",
"compression": "^1.7.0",
Expand Down Expand Up @@ -103,7 +103,7 @@
"gulp-less": "^3.3.2",
"gulp-rev": "^8.1.0",
"gulp-rev-replace": "^0.4.3",
"gulp-template": "^4.0.0",
"gulp-template": "^5.0.0",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.7",
"karma": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sh/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sleep $TIMEOUT
echo "[test] running tests using mocha"

# run the tests
../node_modules/.bin/mocha --recursive ../test/integration/
../node_modules/.bin/mocha --recursive --bail ../test/integration/

echo "[test] cleaning up node process $NODE_PID."

Expand Down
3 changes: 3 additions & 0 deletions test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ CALL CreateFiscalYear(1, @fiscalYear2015, @superUser, 'Test Fiscal Year 2016', 1
SET @fiscalYear2017 = 0;
CALL CreateFiscalYear(1, @fiscalYear2016, @superUser, 'Test Fiscal Year 2017', 12, DATE('2017-01-01'), DATE('2017-12-31'), 'Note for 2017', @fiscalYear2017);

SET @fiscalYear2018 = 0;
CALL CreateFiscalYear(1, @fiscalYear2017, @superUser, 'Fiscal Year 2018', 12, DATE('2018-01-01'), DATE('2018-12-31'), 'Notes for 2018', @fiscalYear2018);

-- give test permission to all projects
INSERT INTO `project_permission` VALUES (1, 1, 1),(2, 1, 2),(3, 2, 1),(4, 4, 1);

Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/fiscalYears/fiscalYears.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Fiscal Year', () => {
const fiscalYear = {
label : 'A Special Fiscal Year',
note : 'Note for the new fiscal Year',
previous : 'Test Fiscal Year 2016',
previous : 'Test Fiscal Year 2017',
};

it('blocks invalid form submission with relevant error classes', () => {
Expand All @@ -42,7 +42,7 @@ describe('Fiscal Year', () => {
FU.input('FiscalManageCtrl.fiscal.label', fiscalYear.label);

// select the proper date
components.dateInterval.range('01/01/2018', '31/12/2018');
components.dateInterval.range('01/01/2019', '31/12/2019');
FU.select('FiscalManageCtrl.fiscal.previous_fiscal_year_id', fiscalYear.previous);
FU.input('FiscalManageCtrl.fiscal.note', fiscalYear.note);
FU.buttons.submit();
Expand Down
16 changes: 6 additions & 10 deletions test/end-to-end/patient/record.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
const path = require('path');
const chai = require('chai');

const expect = chai.expect;
const { expect } = chai;

const moment = require('moment');

const components = require('../shared/components');
const helpers = require('../shared/helpers');
Expand All @@ -18,21 +20,15 @@ describe('Patient Record', () => {
const root = '#!/patients/';
const id = '274c51ae-efcc-4238-98c6-f402bfb39866';

// calcul Age dynamically
const currentDate = new Date();
const currentYear = currentDate.getFullYear();

// Calculate age and transform ageTestPatient2 to String
const ageTestPatient2 = `${(currentYear - 1990)}`;

const patient = {
name : 'Test 2 Patient',
id : 'PA.TPA.2',
hospital_no : '110',
age : ageTestPatient2,
dob : '1990-06-01',
gender : 'M',
};

const age = (dob) => `${moment().diff(dob, 'years')}`;
const url = root.concat(id);

before(() => helpers.navigate(url));
Expand All @@ -41,7 +37,7 @@ describe('Patient Record', () => {
FU.hasText(by.id('name'), patient.name);
FU.hasText(by.id('patientID'), patient.id);
FU.hasText(by.id('hospitalNo'), patient.hospital_no);
FU.hasText(by.id('age'), patient.age);
FU.hasText(by.id('age'), age(patient.dob));
FU.hasText(by.id('gender'), patient.gender);
});

Expand Down
31 changes: 15 additions & 16 deletions test/end-to-end/purchases/registry.search.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
/* global element, by */

const chai = require('chai');
const expect = chai.expect;
const { expect } = require('chai');

const Filters = require('../shared/components/bhFilters');
const SearchModal = require('../shared/search.page');
Expand All @@ -13,16 +12,16 @@ function PurchaseOrderSearch() {
let filters;

const parameters = {
reference: 'PO.TPA.2',
name1: 'Patient',
author: 'Super User',
status: ['Confirmé'],
reference : 'PO.TPA.2',
name1 : 'Patient',
author : 'Super User',
status : ['Confirmé'],
supplier : 'SNEL',
};

const grid = element(by.id('purchase-registry'));
const rows = grid.element(by.css('.ui-grid-render-container-body'))
.all(by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index'));
.all(by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index'));

beforeEach(() => {
SearchModal.open();
Expand Down Expand Up @@ -50,12 +49,12 @@ function PurchaseOrderSearch() {
});

// demonstrates that filtering works
it(`should find one Purchase Order with Reference "${parameters.reference}" for the current year`, () => {
it(`should find one Purchase Order with Reference "${parameters.reference}" for all time`, () => {
const NUM_MATCHING = 1;
modal.setReference(parameters.reference);

modal.switchToDefaultFilterTab();
modal.setPeriod('year');
modal.setPeriod('allTime');
FU.modal.submit();

expectNumberOfGridRows(NUM_MATCHING);
Expand All @@ -64,9 +63,9 @@ function PurchaseOrderSearch() {
it(`should find four Purchases Orders authored By "${parameters.author}" for all time`, () => {
const NUM_MATCHING = 4;
modal.setUser(parameters.author);

modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
modal.setPeriod('allTime');
FU.modal.submit();

expectNumberOfGridRows(NUM_MATCHING);
Expand All @@ -75,20 +74,20 @@ function PurchaseOrderSearch() {
it(`should list all purchase orders ordered to "${parameters.supplier}" for all time`, () => {
const NUM_MATCHING = 4;
modal.setSupplier(parameters.supplier);

modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
modal.setPeriod('allTime');
FU.modal.submit();

expectNumberOfGridRows(NUM_MATCHING);
});


it(`Choose the status confirmed and should find two Purchases Orders status By "${parameters.status}" for all time`, function () {
it(`choose the status confirmed and should find two purchases orders status by "${parameters.status}" for all time`, function () {
const NUM_MATCHING = 1;
components.purchaseStatusSelect.set(parameters.status);
modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
modal.setPeriod('allTime');
FU.modal.submit();

expectNumberOfGridRows(NUM_MATCHING);
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/stock/stock.lots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function StockLotsRegistryTests() {
const depotGroupingRow = 1;
const LOT_FOR_ALLTIME = 16;
const LOT_FOR_TODAY = 10;
const LOT_FOR_LAST_YEAR = 16;
const LOT_FOR_LAST_YEAR = 10;


it(`finds ${LOT_FOR_TODAY} lot for today`, () => {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const helpers = require('./helpers');

// cheeky method to duplicate an array
function clone(array) {
return array.filter(() => true);
return array.slice();
}

describe('(/accounts) Accounts', () => {
Expand Down Expand Up @@ -186,5 +186,4 @@ describe('(/accounts) Accounts', () => {
})
.catch(helpers.handler);
});

});
Loading

0 comments on commit 8494bec

Please sign in to comment.