diff --git a/karma.conf.js b/karma.conf.js index a6bcf8605a..fb3e7b84a3 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -55,6 +55,12 @@ module.exports = (config) => { outputFile : process.env.KARMA_FILENAME || 'test.xml', suite : 'BHIMA-Tests', useBrowserName : false, + nameFormatter : (browser, result) => { + return result.description; + }, + classNameFormatter : (browser, result) => { + return result.suite[0]; + }, }, // web server port diff --git a/playwright.config.js b/playwright.config.js index e59eed451f..3d7460b651 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -18,7 +18,7 @@ module.exports = defineConfig({ // testIgnore : process.env.E2E_DIR ? '' : /\/stock\/|\/account\//, /* Maximum time one test can run for. */ - timeout : 40 * 1000, // Need longer value for CI + timeout : 50 * 1000, // Need longer value for CI expect : { /** diff --git a/sh/test-e2e-account.sh b/sh/test-e2e-account.sh index 57a761561d..f08e824f5a 100755 --- a/sh/test-e2e-account.sh +++ b/sh/test-e2e-account.sh @@ -45,6 +45,9 @@ echo "[test] Running end-to-end account tests using playwright." cd .. E2E_DIR=account npx playwright test 2>&1 | tee ./results/end-to-end-account-report +# Adjust formatting for Jenkins +sed -i 's/.spec.js//g' "./results/end-to-end-account-results.xml" + # FYI: Use --workers=1 to limit number of workers # Clean up any left-over zombie node processes (if not CI) diff --git a/sh/test-e2e.sh b/sh/test-e2e.sh index 060e0772e4..ea8a3a339f 100755 --- a/sh/test-e2e.sh +++ b/sh/test-e2e.sh @@ -48,6 +48,9 @@ cd .. npx playwright test $TESTS 2>&1 | tee "./results/end-to-end-report-$TEST_NUM" +# Adjust formatting for Jenkins +sed -i 's/.spec.js//g' "./results/end-to-end-$TEST_NUM-results.xml" + # FYI: Use PWTEST_SKIP_TEST_OUTPUT=1 to skip interactive web debug at the end # FYI: Use --workers=1 to limit number of workers diff --git a/test/client-unit/components/bhCardList.spec.js b/test/client-unit/components/bhCardList.spec.js index 9893757699..1087561edf 100644 --- a/test/client-unit/components/bhCardList.spec.js +++ b/test/client-unit/components/bhCardList.spec.js @@ -1,6 +1,7 @@ /* eslint no-unused-expressions:off */ /* global inject expect */ describe('test/client-unit/components/bhCardList', () => { + let $compile; let $rootScope; let $templateCache; diff --git a/test/client-unit/components/bhFindPatient/controller.spec.js b/test/client-unit/components/bhFindPatient/controller.spec.js index e52443913d..91169f4beb 100644 --- a/test/client-unit/components/bhFindPatient/controller.spec.js +++ b/test/client-unit/components/bhFindPatient/controller.spec.js @@ -1,7 +1,7 @@ /* eslint no-unused-expressions:"off" */ /* global inject, expect, chai */ -describe.skip('bhFindPatient Controller Tests', ControllerTests); +describe.skip('test/client-unit/components/bhFindPatient Controller Tests', ControllerTests); /** * @todo - finish the DOM tests to compliment this controller test suite. diff --git a/test/client-unit/components/bhFindPatient/dom.spec.js b/test/client-unit/components/bhFindPatient/dom.spec.js index c9192038df..7d35beabfb 100644 --- a/test/client-unit/components/bhFindPatient/dom.spec.js +++ b/test/client-unit/components/bhFindPatient/dom.spec.js @@ -1,6 +1,6 @@ /* global inject, expect, chai */ -describe.skip('bhFindPatient DOM bindings', DomTests); +describe.skip('test/client-unit/components/bhFindPatient DOM bindings', DomTests); /** * @todo(@jniles) - finish this test suite. At the moment, it is incomplete and diff --git a/test/client-unit/directives/bhBlur.spec.js b/test/client-unit/directives/bhBlur.spec.js index e001a8e891..8e69c9f8f4 100644 --- a/test/client-unit/directives/bhBlur.spec.js +++ b/test/client-unit/directives/bhBlur.spec.js @@ -1,7 +1,7 @@ /* eslint no-unused-expressions:off, no-continue: off */ /* global inject, expect, chai */ -describe('test/client-unit/directives/(directive) bhBlur', () => { +describe('test/client-unit/directives/bhBlur directive', () => { let $compile; let $scope; let element; diff --git a/test/client-unit/directives/bhInteger.spec.js b/test/client-unit/directives/bhInteger.spec.js index 8ad0e1a3e7..558f488ed4 100644 --- a/test/client-unit/directives/bhInteger.spec.js +++ b/test/client-unit/directives/bhInteger.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/directives/(directive) bhInteger', () => { +describe('test/client-unit/directives/bhInteger directive', () => { let $scope; let form; diff --git a/test/client-unit/directives/bhMaxInteger.spec.js b/test/client-unit/directives/bhMaxInteger.spec.js index 34aa963333..6151d5c496 100644 --- a/test/client-unit/directives/bhMaxInteger.spec.js +++ b/test/client-unit/directives/bhMaxInteger.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/directives/(directive) bhMaxInteger', () => { +describe('test/client-unit/directives/bhMaxInteger directive', () => { let $scope; let form; diff --git a/test/client-unit/directives/bhSubmit.spec.js b/test/client-unit/directives/bhSubmit.spec.js index b3afc74b5c..c666175878 100644 --- a/test/client-unit/directives/bhSubmit.spec.js +++ b/test/client-unit/directives/bhSubmit.spec.js @@ -1,5 +1,5 @@ /* global inject, expect, chai */ -describe('test/client-unit/directives/(directive) bhSubmit', () => { +describe('test/client-unit/directives/bhSubmit directive', () => { let $scope; let element; let deferred; @@ -15,7 +15,7 @@ describe('test/client-unit/directives/(directive) bhSubmit', () => { }; })); - describe('when the directive is added to a form', () => { + context('when the directive is added to a form', () => { beforeEach(inject(($compile) => { element = angular.element(`
@@ -27,49 +27,49 @@ describe('test/client-unit/directives/(directive) bhSubmit', () => { $scope.$digest(); })); - it('sets $loading to false on the FormControl', () => { + it('when the directive is added to a form - sets $loading to false on the FormControl', () => { expect($scope.form.$loading).to.equal(false); }); - describe('when the form is submitted', () => { + context('when the form is submitted', () => { beforeEach(() => { angular.element(element).trigger('submit'); }); - it('sets $loading to true on the FormControl', () => { + it('when the form is submitted - sets $loading to true on the FormControl', () => { expect($scope.form.$loading).to.equal(true); }); - it('calls the submit callback function', () => { + it('when the form is submitted - calls the submit callback function', () => { expect($scope.models.submit).to.have.been.called.with($scope.form); }); - describe('when the submit callback is resolved', () => { + context('when the submit callback is resolved', () => { beforeEach(() => { deferred.resolve(); $scope.$digest(); }); - it('sets $loading to false on the FormControl', () => { + it('when the submit callback is resolved - sets $loading to false on the FormControl', () => { expect($scope.form.$loading).to.equal(false); }); }); - describe('when the submit callback is rejected', () => { + context('when the submit callback is rejected', () => { beforeEach(() => { deferred.reject(new Error('callback rejected')); $scope.$digest(); }); - it('sets $loading to false on the FormControl', () => { + it('when the submit callback is rejected - sets $loading to false on the FormControl', () => { expect($scope.form.$loading).to.equal(false); }); }); }); }); - describe('when the directive is not added to a form', () => { - it('the compilation fails', inject(($compile) => { + context('when the directive is not added to a form', () => { + it('when the directive is not added to a form - the compilation fails', inject(($compile) => { element = angular.element(`
diff --git a/test/client-unit/directives/bhUnique.spec.js b/test/client-unit/directives/bhUnique.spec.js index 2b9c316d6a..1a117770b3 100644 --- a/test/client-unit/directives/bhUnique.spec.js +++ b/test/client-unit/directives/bhUnique.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/directives/(directive) bhUnique', () => { +describe('test/client-unit/directives/bhUnique directive', () => { let $scope; let form; diff --git a/test/client-unit/filters/bytes.spec.js b/test/client-unit/filters/bytes.spec.js index 40a03622c0..88723bfce3 100644 --- a/test/client-unit/filters/bytes.spec.js +++ b/test/client-unit/filters/bytes.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/filters/Bytes Filter', () => { +describe('test/client-unit/filters/bytes filter', () => { let bytes; @@ -48,4 +48,5 @@ describe('test/client-unit/filters/Bytes Filter', () => { expect(bytes(null, 100)).to.equal('-'); expect(bytes(undefined, 33)).to.equal('-'); }); + }); diff --git a/test/client-unit/filters/currency.spec.js b/test/client-unit/filters/currency.spec.js index 313cb03bc7..7a44ad37c6 100644 --- a/test/client-unit/filters/currency.spec.js +++ b/test/client-unit/filters/currency.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/filters/Currency Filter', () => { +describe('test/client-unit/filters/currency filter', () => { const FC = 1; const USD = 2; diff --git a/test/client-unit/filters/percentage.spec.js b/test/client-unit/filters/percentage.spec.js index 1e98959627..491600582a 100644 --- a/test/client-unit/filters/percentage.spec.js +++ b/test/client-unit/filters/percentage.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/filters/Percentage Filter', () => { +describe('test/client-unit/filters/percentage filter', () => { let percentage; diff --git a/test/client-unit/filters/telephone.spec.js b/test/client-unit/filters/telephone.spec.js index 7c1667da13..8b402bd5f6 100644 --- a/test/client-unit/filters/telephone.spec.js +++ b/test/client-unit/filters/telephone.spec.js @@ -1,5 +1,5 @@ /* global inject, expect */ -describe('test/client-unit/filters/Telephone Filter', () => { +describe('test/client-unit/filters/telephone filter', () => { let telephone; diff --git a/test/client-unit/services/BaseReportService.spec.js b/test/client-unit/services/BaseReportService.spec.js index a3b83f979e..e4ab1735fc 100644 --- a/test/client-unit/services/BaseReportService.spec.js +++ b/test/client-unit/services/BaseReportService.spec.js @@ -23,8 +23,8 @@ describe('test/client-unit/services/BaseReportService', () => { parseIcon = SavedReports.parseFileUrlToIcon; })); - describe('#parseUrlToExtension()', () => { - it('correctly parses simple paths', () => { + context('#parseUrlToExtension()', () => { + it('#parseUrlToExtension() correctly parses simple paths', () => { expect(parseExtension('image.jpg')).to.equal('jpg'); expect(parseExtension('image.svg')).to.equal('svg'); expect(parseExtension('doc.docx')).to.equal('docx'); @@ -34,19 +34,19 @@ describe('test/client-unit/services/BaseReportService', () => { }); - it('handles error cases', () => { + it('#parseUrlToExtension() handles error cases', () => { expect(parseExtension('')).to.equal(''); expect(parseExtension()).to.equal(''); }); - it('correctly parses complex paths', () => { + it('#parseUrlToExtension() correctly parses complex paths', () => { expect(parseExtension('a.file.with.decimals.pdf')).to.equal('pdf'); expect(parseExtension('/more/complex/file.with/decimals.gz')).to.equal('gz'); }); }); - describe('#parseUrlToIcon()', () => { - it('correctly parses paths to guess their icons', () => { + context('#parseUrlToIcon()', () => { + it('#parseUrlToIcon() correctly parses paths to guess their icons', () => { expect(parseIcon('icon.png')).to.equal('fa-file-image-o'); expect(parseIcon('icon.svg')).to.equal('fa-file-image-o'); diff --git a/test/client-unit/services/PatientInvoiceForm.spec.js b/test/client-unit/services/PatientInvoiceForm.spec.js index 1fe76d8f20..0ed5c22aef 100644 --- a/test/client-unit/services/PatientInvoiceForm.spec.js +++ b/test/client-unit/services/PatientInvoiceForm.spec.js @@ -73,7 +73,7 @@ describe('test/client-unit/services/PatientInvoiceForm', () => { httpBackend.verifyNoOutstandingRequest(); }); - describe('#constructor()', () => { + context('#constructor()', () => { let constructorForm; let setupSpy; let inventorySpy; @@ -84,21 +84,21 @@ describe('test/client-unit/services/PatientInvoiceForm', () => { inventorySpy = chai.spy.on(constructorForm.inventory, 'initialize'); }); - it('calls #setup() on initialization', () => { + it('#constructor() calls #setup() on initialization', () => { expect(setupSpy).to.have.been.called; }); - it('creates a new, empty store for the grid', () => { + it('#constructor() creates a new, empty store for the grid', () => { expect(constructorForm.store).to.exist; expect(constructorForm.store.identifier).to.equal('uuid'); expect(constructorForm.store.data).to.have.length(0); }); - it('initializes the inventory', () => { + it('#constructor() initializes the inventory', () => { expect(inventorySpy).to.have.been.called; }); - it('sets the form to be invalid by default', () => { + it('#constructor() sets the form to be invalid by default', () => { expect(constructorForm._invalid).to.equal(true); expect(constructorForm._valid).to.equal(false); }); diff --git a/test/client-unit/services/Pool.spec.js b/test/client-unit/services/Pool.spec.js index 1568eecee7..433559df94 100644 --- a/test/client-unit/services/Pool.spec.js +++ b/test/client-unit/services/Pool.spec.js @@ -1,7 +1,6 @@ /* global inject, expect */ describe('test/client-unit/services/Pool', () => { - let Pool; let data; @@ -18,7 +17,7 @@ describe('test/client-unit/services/Pool', () => { it('#constructor() runs with sane defaults', () => { let pool = new Pool(); - expect(pool).to.exist; + expect(pool).to.exist; // eslint-disable-line expect(pool.available.identifier).to.equal('id'); expect(pool.available.data).to.have.length(0); diff --git a/test/client-unit/services/PrototypeApiService.spec.js b/test/client-unit/services/PrototypeApiService.spec.js index 19c1fa52a5..3379eee3f7 100644 --- a/test/client-unit/services/PrototypeApiService.spec.js +++ b/test/client-unit/services/PrototypeApiService.spec.js @@ -1,7 +1,6 @@ /* global inject, expect */ describe('test/client-unit/services/PrototypeApiService', () => { - // shared common data let api; let httpBackend; diff --git a/test/client-unit/services/PurchaseOrderFormService.spec.js b/test/client-unit/services/PurchaseOrderFormService.spec.js index 87b646af6c..671e105158 100644 --- a/test/client-unit/services/PurchaseOrderFormService.spec.js +++ b/test/client-unit/services/PurchaseOrderFormService.spec.js @@ -74,7 +74,7 @@ describe('test/client-unit/services/PurchaseOrderForm', () => { setupSpy = chai.spy.on(form, 'setup'); }); - it('calls #setup() on initialization', () => { + it('calls #setup() on initialization in the constructor', () => { expect(setupSpy).to.have.been.called; }); diff --git a/test/client-unit/services/StockExitFormService.spec.js b/test/client-unit/services/StockExitFormService.spec.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/client-unit/services/UniqueValidatorService.spec.js b/test/client-unit/services/UniqueValidatorService.spec.js index 4277c37136..d577ecc80c 100644 --- a/test/client-unit/services/UniqueValidatorService.spec.js +++ b/test/client-unit/services/UniqueValidatorService.spec.js @@ -1,6 +1,6 @@ /* global inject, expect */ -describe('test/client-unit/services/(service) UniqueValidatorService', () => { +describe('test/client-unit/services/UniqueValidatorService', () => { // these will be injected in the beforeEach() calls diff --git a/test/client-unit/services/VoucherForm.spec.js b/test/client-unit/services/VoucherForm.spec.js index 1deabcdc51..64068dfda3 100644 --- a/test/client-unit/services/VoucherForm.spec.js +++ b/test/client-unit/services/VoucherForm.spec.js @@ -45,7 +45,7 @@ describe('test/client-unit/services/VoucherForm', () => { httpBackend.verifyNoOutstandingRequest(); }); - describe('#constructor()', () => { + context('#constructor()', () => { let constructorForm; let setupSpy; @@ -54,11 +54,11 @@ describe('test/client-unit/services/VoucherForm', () => { setupSpy = chai.spy.on(constructorForm, 'setup'); }); - it('calls #setup() on initialization', () => { + it('#constructor() calls #setup() on initialization', () => { expect(setupSpy).to.have.been.called; }); - it('creates a new store with two items in it', () => { + it('#constructor() creates a new store with two items in it', () => { expect(constructorForm.store).to.exist; expect(constructorForm.store.identifier).to.equal('uuid'); @@ -66,7 +66,7 @@ describe('test/client-unit/services/VoucherForm', () => { expect(constructorForm.store.data).to.have.length(2); }); - it('sets default data based on Session', () => { + it('#constructor() sets default data based on Session', () => { expect(constructorForm.details).to.exist; expect(constructorForm.details.project_id).to.be.equal(Session.project.id); expect(constructorForm.details.currency_id).to.be.equal(Session.enterprise.currency_id); @@ -88,7 +88,6 @@ describe('test/client-unit/services/VoucherForm', () => { expect(form.store.data).to.have.length(15); }); - it('#clear() removes all data from the internal store', () => { form.clear(); expect(form.store.data).to.have.length(0); diff --git a/test/end-to-end/cash/registry.spec.js b/test/end-to-end/cash/registry.spec.js deleted file mode 100644 index 6176ba5aab..0000000000 --- a/test/end-to-end/cash/registry.spec.js +++ /dev/null @@ -1,2 +0,0 @@ -// Moved these tests into cash.spec.js -// due to conflicts between the two tests when running in parallel diff --git a/test/end-to-end/stock/stock.spec.js b/test/end-to-end/stock/stock.spec.js index 37974080ec..5a2f1f37e8 100644 --- a/test/end-to-end/stock/stock.spec.js +++ b/test/end-to-end/stock/stock.spec.js @@ -22,7 +22,7 @@ const StockAggregateConsumptionTests = require('./stock.aggregate_consumption'); const StockImportTests = require('./stock.import'); test.describe('Stock E2E', () => { - test.describe('Stock Import', StockImportTests); + test.describe('test/end-to-end/stock/stock_import Stock Import', StockImportTests); test.describe('Stock Aggregate Consumption', StockAggregateConsumptionTests); // ??? test.describe('Stock Assign', StockAssignTests); test.describe('Stock Entry', StockEntryTests); diff --git a/test/integration-stock/depots.js b/test/integration-stock/depots.js index 575c1f0624..99a2892fa1 100644 --- a/test/integration-stock/depots.js +++ b/test/integration-stock/depots.js @@ -2,8 +2,8 @@ const helpers = require('./helpers'); -// The /depots API endpoint -describe('test/integration-stock (/depots) The depots API ', () => { +// The /depots API +describe('test/integration-stock/depots The depots API ', () => { const { principal } = helpers.data.depots; /** diff --git a/test/integration-stock/shipment.js b/test/integration-stock/shipment.js index 4e176cccce..244a964167 100644 --- a/test/integration-stock/shipment.js +++ b/test/integration-stock/shipment.js @@ -3,257 +3,263 @@ const moment = require('moment'); const helpers = require('./helpers'); -// the /shipments API endpoint -describe('test/integration-stock (/shipments) the shipments API', () => { - const SHIPMENT_AT_DEPOT = 2; - const SHIPMENT_READY = 3; +// the /shipments API +describe('test/integration-stock/shipments Shipments API', () => { - // lots from service-stock.sql - const LOT_QUININE_A = '0xC26BA248149D4FAB882C97A368072F2B'; - const LOT_QUININE_B = '0x971F7AC3FF604A649773CE9539871A07'; + describe('Shipments API', () => { - const newShipment = { - uuid : helpers.uuid(), - name : 'Test 1 shipment of medicines from principal to secondary', - project_id : helpers.data.PROJECT, - description : 'Note 1 for shipment of medicines', - origin_depot_uuid : helpers.data.depots.principal, - destination_depot_uuid : helpers.data.depots.secondaire, - anticipated_delivery_date : new Date(), - date_sent : null, - status_id : SHIPMENT_AT_DEPOT, - }; + const SHIPMENT_AT_DEPOT = 2; + const SHIPMENT_READY = 3; - const secondShipment = { - name : 'Test 1 shipment of medicines from principal to secondary', - project_id : helpers.data.PROJECT, - description : 'Note 1 for shipment of medicines', - origin_depot_uuid : helpers.data.depots.principal, - destination_depot_uuid : helpers.data.depots.secondaire, - anticipated_delivery_date : new Date(), - date_sent : null, - status_id : SHIPMENT_AT_DEPOT, - }; + // lots from service-stock.sql + const LOT_QUININE_A = '0xC26BA248149D4FAB882C97A368072F2B'; + const LOT_QUININE_B = '0x971F7AC3FF604A649773CE9539871A07'; - const incompleteShipment = { - name : 'Test Incomplete shipment of medicines from principal to secondary', - project_id : helpers.data.PROJECT, - description : 'Note for incomplete shipment of medicines', - origin_depot_uuid : helpers.data.depots.principal, - destination_depot_uuid : helpers.data.depots.secondaire, - anticipated_delivery_date : new Date(), - date_sent : null, - status_id : SHIPMENT_AT_DEPOT, - }; + const newShipment = { + uuid : helpers.uuid(), + name : 'Test 1 shipment of medicines from principal to secondary', + project_id : helpers.data.PROJECT, + description : 'Note 1 for shipment of medicines', + origin_depot_uuid : helpers.data.depots.principal, + destination_depot_uuid : helpers.data.depots.secondaire, + anticipated_delivery_date : new Date(), + date_sent : null, + status_id : SHIPMENT_AT_DEPOT, + }; - const lots = [ - { - lot_uuid : String(LOT_QUININE_A).replace(/0x/g, ''), - date_packed : new Date(), - unit_weight : 0.1, - quantity : 5, - }, - { - lot_uuid : LOT_QUININE_B.replace(/0x/g, ''), - date_packed : new Date(), - unit_weight : 0.15, - quantity : 15, - }, - ]; + const secondShipment = { + name : 'Test 1 shipment of medicines from principal to secondary', + project_id : helpers.data.PROJECT, + description : 'Note 1 for shipment of medicines', + origin_depot_uuid : helpers.data.depots.principal, + destination_depot_uuid : helpers.data.depots.secondaire, + anticipated_delivery_date : new Date(), + date_sent : null, + status_id : SHIPMENT_AT_DEPOT, + }; - const NUMBER_OF_SHIPMENTS = 2; + const incompleteShipment = { + name : 'Test Incomplete shipment of medicines from principal to secondary', + project_id : helpers.data.PROJECT, + description : 'Note for incomplete shipment of medicines', + origin_depot_uuid : helpers.data.depots.principal, + destination_depot_uuid : helpers.data.depots.secondaire, + anticipated_delivery_date : new Date(), + date_sent : null, + status_id : SHIPMENT_AT_DEPOT, + }; - it('POST /shipments create a new shipment', () => { - const shipment = { ...newShipment, lots }; - return agent.post('/shipments') - .send(shipment) - .then((res) => { - helpers.api.created(res); - shipment.uuid = res.body.uuid; - }) - .catch(helpers.handler); - }); + const lots = [ + { + lot_uuid : String(LOT_QUININE_A).replace(/0x/g, ''), + date_packed : new Date(), + unit_weight : 0.1, + quantity : 5, + }, + { + lot_uuid : LOT_QUININE_B.replace(/0x/g, ''), + date_packed : new Date(), + unit_weight : 0.15, + quantity : 15, + }, + ]; - it('POST /shipments create another shipment (without sending uuid)', () => { - const shipment = { ...secondShipment, lots }; - return agent.post('/shipments') - .send(shipment) - .then((res) => { - helpers.api.created(res); - shipment.uuid = res.body.uuid; - }) - .catch(helpers.handler); - }); + const NUMBER_OF_SHIPMENTS = 2; - it('POST /shipments should not create when missing data', () => { - const shipment = { ...incompleteShipment, lots }; - delete shipment.name; - return agent.post('/shipments') - .send(shipment) - .then((res) => { - helpers.api.errored(res, 400); - expect(res.body.code).to.be.equal('ERRORS.ER_BAD_NULL_ERROR'); - }) - .catch(helpers.handler); - }); + it('POST /shipments create a new shipment', () => { + const shipment = { ...newShipment, lots }; + return agent.post('/shipments') + .send(shipment) + .then((res) => { + helpers.api.created(res); + shipment.uuid = res.body.uuid; + }) + .catch(helpers.handler); + }); - it('GET /shipments returns list of shipments', () => { - return agent.get(`/shipments/`) - .then(res => { - helpers.api.listed(res, NUMBER_OF_SHIPMENTS); - }) - .catch(helpers.handler); - }); + it('POST /shipments create another shipment (without sending uuid)', () => { + const shipment = { ...secondShipment, lots }; + return agent.post('/shipments') + .send(shipment) + .then((res) => { + helpers.api.created(res); + shipment.uuid = res.body.uuid; + }) + .catch(helpers.handler); + }); - it('GET /shipments/allocated-assets get list of previously allocated assets', () => { - return agent.get(`/shipments/allocated-assets`) - .then(res => { - expect(res).to.have.status(200); - expect(res.body).to.an('array'); - expect(res.body.length).to.be.eq(lots.length * NUMBER_OF_SHIPMENTS); - const lotUuids = lots.map(l => l.lot_uuid); - res.body.forEach(item => { - expect(lotUuids.includes(item.lot_uuid)).to.be.eq(true); - expect(item.shipment_uuid).to.be.an('string'); - expect(item.lot_label).to.be.an('string'); - expect(item.inventory_code).to.be.an('string'); - expect(item.inventory_text).to.be.an('string'); - expect(item.reference).to.be.an('string'); - expect(item.quantity_sent).to.be.an('number'); - }); - }) - .catch(helpers.handler); - }); + it('POST /shipments should not create when missing data', () => { + const shipment = { ...incompleteShipment, lots }; + delete shipment.name; + return agent.post('/shipments') + .send(shipment) + .then((res) => { + helpers.api.errored(res, 400); + expect(res.body.code).to.be.equal('ERRORS.ER_BAD_NULL_ERROR'); + }) + .catch(helpers.handler); + }); - it('GET /shipments/:uuid get details of a shipment', () => { - const formatDate = date => moment(date).format('YYYY-MM-DD'); - return agent.get(`/shipments/${newShipment.uuid}`) - .then(res => { - expect(res).to.have.status(200); - expect(res.body.uuid).to.be.eq(newShipment.uuid); - expect(res.body.status_id).to.be.eq(newShipment.status_id); - expect(res.body.origin_depot_uuid).to.be.eq(helpers.uuidize(newShipment.origin_depot_uuid)); - expect(res.body.destination_depot_uuid).to.be.eq(helpers.uuidize(newShipment.destination_depot_uuid)); - expect(res.body.name).to.be.eq(newShipment.name); - expect(res.body.description).to.be.eq(newShipment.description); - const outDate = formatDate(res.body.anticipated_delivery_date); - const inDate = formatDate(newShipment.anticipated_delivery_date); - expect(outDate).to.be.eq(inDate); - }) - .catch(helpers.handler); - }); + it('GET /shipments returns list of shipments', () => { + return agent.get(`/shipments/`) + .then(res => { + helpers.api.listed(res, NUMBER_OF_SHIPMENTS); + }) + .catch(helpers.handler); + }); - it('GET /shipments/:uuid/full get details of a shipment with lots', () => { - return agent.get(`/shipments/${newShipment.uuid}/full`) - .then(res => { - expect(res).to.have.status(200); - expect(res.body.lots).to.an('array'); - res.body.lots.forEach((lot) => { - const [sent] = lots.filter(l => l.lot_uuid === lot.lot_uuid); - expect(lot.lot_uuid).to.be.eq(sent.lot_uuid); - expect(lot.quantity).to.be.eq(sent.quantity); - }); - }) - .catch(helpers.handler); - }); + it('GET /shipments/allocated-assets get list of previously allocated assets', () => { + return agent.get(`/shipments/allocated-assets`) + .then(res => { + expect(res).to.have.status(200); + expect(res.body).to.an('array'); + expect(res.body.length).to.be.eq(lots.length * NUMBER_OF_SHIPMENTS); + const lotUuids = lots.map(l => l.lot_uuid); + res.body.forEach(item => { + expect(lotUuids.includes(item.lot_uuid)).to.be.eq(true); + expect(item.shipment_uuid).to.be.an('string'); + expect(item.lot_label).to.be.an('string'); + expect(item.inventory_code).to.be.an('string'); + expect(item.inventory_text).to.be.an('string'); + expect(item.reference).to.be.an('string'); + expect(item.quantity_sent).to.be.an('number'); + }); + }) + .catch(helpers.handler); + }); - it('PUT /shipments/:uuid update a shipment (without updating lots)', () => { - const update = { - name : 'UPDATE Test 1 shipment of medicines from secondary to primary', - project_id : helpers.data.PROJECT, - description : 'UPDATE Note 1 for shipment of medicines', - origin_depot_uuid : helpers.data.depots.secondaire, - destination_depot_uuid : helpers.data.depots.principal, - anticipated_delivery_date : new Date(), - date_sent : null, - status_id : SHIPMENT_AT_DEPOT, - }; - return agent.put(`/shipments/${newShipment.uuid}`) - .send(update) - .then(res => { - expect(res).to.have.status(204); - return agent.get(`/shipments/${newShipment.uuid}/full`); - }) - .then(res => { - expect(res.body.name).to.be.eq(update.name); - expect(res.body.description).to.be.eq(update.description); - expect(res.body.origin_depot_uuid).to.be.eq(helpers.uuidize(update.origin_depot_uuid)); - expect(res.body.destination_depot_uuid).to.be.eq(helpers.uuidize(update.destination_depot_uuid)); - expect(res.body.status_id).to.be.eq(update.status_id); - expect(res.body.lots).to.an('array'); - res.body.lots.forEach((lot) => { - const [existingLot] = lots.filter(l => l.lot_uuid === lot.lot_uuid); - expect(lot.lot_uuid).to.be.eq(existingLot.lot_uuid); - expect(lot.quantity).to.be.eq(existingLot.quantity); - }); - }) - .catch(helpers.handler); - }); + it('GET /shipments/:uuid get details of a shipment', () => { + const formatDate = date => moment(date).format('YYYY-MM-DD'); + return agent.get(`/shipments/${newShipment.uuid}`) + .then(res => { + expect(res).to.have.status(200); + expect(res.body.uuid).to.be.eq(newShipment.uuid); + expect(res.body.status_id).to.be.eq(newShipment.status_id); + expect(res.body.origin_depot_uuid).to.be.eq(helpers.uuidize(newShipment.origin_depot_uuid)); + expect(res.body.destination_depot_uuid).to.be.eq(helpers.uuidize(newShipment.destination_depot_uuid)); + expect(res.body.name).to.be.eq(newShipment.name); + expect(res.body.description).to.be.eq(newShipment.description); + const outDate = formatDate(res.body.anticipated_delivery_date); + const inDate = formatDate(newShipment.anticipated_delivery_date); + expect(outDate).to.be.eq(inDate); + }) + .catch(helpers.handler); + }); - it('PUT /shipments/:uuid update a shipment with lots', () => { - const update = { - name : 'UPDATE Test 1 shipment of medicines from principal to secondaire', - description : 'UPDATE Note 1 for shipment of medicines', - origin_depot_uuid : helpers.data.depots.principal, - destination_depot_uuid : helpers.data.depots.secondaire, - lots : [ - { - lot_uuid : LOT_QUININE_B.replace(/0x/g, ''), - date_packed : new Date(), - unit_weight : 0.15, - quantity : 7, - }, - ], - }; - return agent.put(`/shipments/${newShipment.uuid}`) - .send(update) - .then(res => { - expect(res).to.have.status(204); - return agent.get(`/shipments/${newShipment.uuid}/full`); - }) - .then(res => { - expect(res.body.name).to.be.eq(update.name); - expect(res.body.description).to.be.eq(update.description); - expect(res.body.origin_depot_uuid).to.be.eq(helpers.uuidize(update.origin_depot_uuid)); - expect(res.body.destination_depot_uuid).to.be.eq(helpers.uuidize(update.destination_depot_uuid)); - expect(res.body.lots).to.an('array'); - expect(res.body.lots.length).to.be.eq(update.lots.length); - res.body.lots.forEach((lot) => { - const [newLot] = update.lots.filter(l => l.lot_uuid === lot.lot_uuid); - expect(lot.lot_uuid).to.be.eq(newLot.lot_uuid); - expect(lot.quantity).to.be.eq(newLot.quantity); - }); - }) - .catch(helpers.handler); - }); + it('GET /shipments/:uuid/full get details of a shipment with lots', () => { + return agent.get(`/shipments/${newShipment.uuid}/full`) + .then(res => { + expect(res).to.have.status(200); + expect(res.body.lots).to.an('array'); + res.body.lots.forEach((lot) => { + const [sent] = lots.filter(l => l.lot_uuid === lot.lot_uuid); + expect(lot.lot_uuid).to.be.eq(sent.lot_uuid); + expect(lot.quantity).to.be.eq(sent.quantity); + }); + }) + .catch(helpers.handler); + }); - it('PUT /shipments/:uuid/ready-for-shipment set shipment status to ready for shipping', () => { - return agent.put(`/shipments/${newShipment.uuid}/ready-for-shipment`) - .then(res => { - expect(res).to.have.status(201); - return agent.get(`/shipments/${newShipment.uuid}`); - }) - .then(res => { - expect(res.body.status_id).to.be.eq(SHIPMENT_READY); - }) - .catch(helpers.handler); - }); + it('PUT /shipments/:uuid update a shipment (without updating lots)', () => { + const update = { + name : 'UPDATE Test 1 shipment of medicines from secondary to primary', + project_id : helpers.data.PROJECT, + description : 'UPDATE Note 1 for shipment of medicines', + origin_depot_uuid : helpers.data.depots.secondaire, + destination_depot_uuid : helpers.data.depots.principal, + anticipated_delivery_date : new Date(), + date_sent : null, + status_id : SHIPMENT_AT_DEPOT, + }; + return agent.put(`/shipments/${newShipment.uuid}`) + .send(update) + .then(res => { + expect(res).to.have.status(204); + return agent.get(`/shipments/${newShipment.uuid}/full`); + }) + .then(res => { + expect(res.body.name).to.be.eq(update.name); + expect(res.body.description).to.be.eq(update.description); + expect(res.body.origin_depot_uuid).to.be.eq(helpers.uuidize(update.origin_depot_uuid)); + expect(res.body.destination_depot_uuid).to.be.eq(helpers.uuidize(update.destination_depot_uuid)); + expect(res.body.status_id).to.be.eq(update.status_id); + expect(res.body.lots).to.an('array'); + res.body.lots.forEach((lot) => { + const [existingLot] = lots.filter(l => l.lot_uuid === lot.lot_uuid); + expect(lot.lot_uuid).to.be.eq(existingLot.lot_uuid); + expect(lot.quantity).to.be.eq(existingLot.quantity); + }); + }) + .catch(helpers.handler); + }); - it('PUT /shipments/:uuid do not update a ready-to-go shipment', () => { - const updates = {}; - return agent.put(`/shipments/${newShipment.uuid}`) - .send(updates) - .then(res => { - expect(res).to.have.status(500); - }) - .catch(helpers.handler); - }); + it('PUT /shipments/:uuid update a shipment with lots', () => { + const update = { + name : 'UPDATE Test 1 shipment of medicines from principal to secondaire', + description : 'UPDATE Note 1 for shipment of medicines', + origin_depot_uuid : helpers.data.depots.principal, + destination_depot_uuid : helpers.data.depots.secondaire, + lots : [ + { + lot_uuid : LOT_QUININE_B.replace(/0x/g, ''), + date_packed : new Date(), + unit_weight : 0.15, + quantity : 7, + }, + ], + }; + return agent.put(`/shipments/${newShipment.uuid}`) + .send(update) + .then(res => { + expect(res).to.have.status(204); + return agent.get(`/shipments/${newShipment.uuid}/full`); + }) + .then(res => { + expect(res.body.name).to.be.eq(update.name); + expect(res.body.description).to.be.eq(update.description); + expect(res.body.origin_depot_uuid).to.be.eq(helpers.uuidize(update.origin_depot_uuid)); + expect(res.body.destination_depot_uuid).to.be.eq(helpers.uuidize(update.destination_depot_uuid)); + expect(res.body.lots).to.an('array'); + expect(res.body.lots.length).to.be.eq(update.lots.length); + res.body.lots.forEach((lot) => { + const [newLot] = update.lots.filter(l => l.lot_uuid === lot.lot_uuid); + expect(lot.lot_uuid).to.be.eq(newLot.lot_uuid); + expect(lot.quantity).to.be.eq(newLot.quantity); + }); + }) + .catch(helpers.handler); + }); + + it('PUT /shipments/:uuid/ready-for-shipment set shipment status to ready for shipping', () => { + return agent.put(`/shipments/${newShipment.uuid}/ready-for-shipment`) + .then(res => { + expect(res).to.have.status(201); + return agent.get(`/shipments/${newShipment.uuid}`); + }) + .then(res => { + expect(res.body.status_id).to.be.eq(SHIPMENT_READY); + }) + .catch(helpers.handler); + }); + + it('PUT /shipments/:uuid do not update a ready-to-go shipment', () => { + const updates = {}; + return agent.put(`/shipments/${newShipment.uuid}`) + .send(updates) + .then(res => { + expect(res).to.have.status(500); + }) + .catch(helpers.handler); + }); + + it('DELETE /shipments/:uuid should delete an existing shipment', () => { + return agent.delete(`/shipments/${newShipment.uuid}`) + .then((res) => { + helpers.api.deleted(res); + }) + .catch(helpers.handler); + }); - it('DELETE /shipments/:uuid should delete an existing shipment', () => { - return agent.delete(`/shipments/${newShipment.uuid}`) - .then((res) => { - helpers.api.deleted(res); - }) - .catch(helpers.handler); }); + }); diff --git a/test/integration-stock/shipmentContainer.js b/test/integration-stock/shipmentContainer.js index 9fd0a97936..f94edba8e8 100644 --- a/test/integration-stock/shipmentContainer.js +++ b/test/integration-stock/shipmentContainer.js @@ -3,8 +3,8 @@ const helpers = require('./helpers'); -// the /shipments API endpoint -describe('test/integration-stock (/shipment_containers) the shipments containers API', () => { +// the /shipments API +describe('test/integration-stock/shipmentContainers The Shipments Containers API', () => { const SHIPMENT_AT_DEPOT = 2; const shipment1 = { diff --git a/test/integration/accountCategories.js b/test/integration/accountCategories.js index 22b168a76f..497f986c5b 100644 --- a/test/integration/accountCategories.js +++ b/test/integration/accountCategories.js @@ -3,7 +3,8 @@ const helpers = require('./helpers'); -describe('test/integration (/accounts/categories) Account Categories', () => { +describe('test/integration/accountsCategories Account Categories API', () => { + const newAccountCategory = { category : 'Test Account Category 1', }; @@ -71,4 +72,5 @@ describe('test/integration (/accounts/categories) Account Categories', () => { }) .catch(helpers.handler); }); + }); diff --git a/test/integration/accountConfig.js b/test/integration/accountConfig.js index fbe46807d6..89317d8f83 100644 --- a/test/integration/accountConfig.js +++ b/test/integration/accountConfig.js @@ -3,11 +3,11 @@ const helpers = require('./helpers'); /* - * The /payroll/account_configuration API endpoint + * The /payroll/account_configuration API * - * This test suite implements full CRUD on the /payroll/account_configuration HTTP API endpoint. + * This test suite implements full CRUD on the /payroll/account_configuration API. */ -describe('test/integration (/payroll/account_configuration) The /payroll/account_configuration API endpoint', () => { +describe('test/integration/accountConfig Account configuration API', () => { // Account Payroll Configuration we will add during this test suite. const accountConfig = { diff --git a/test/integration/accountFYBalances.js b/test/integration/accountFYBalances.js index 8aac3d3eb4..3fe566536b 100644 --- a/test/integration/accountFYBalances.js +++ b/test/integration/accountFYBalances.js @@ -1,6 +1,6 @@ /* global expect, agent */ -describe('Test getting all accounts balances for an FY http API', () => { +describe('test/integration/accountFYBalances Accounts FY balances API', () => { const fiscalYearId = 4; // 2018 diff --git a/test/integration/accountReferenceType.js b/test/integration/accountReferenceType.js index e08b232810..eef2481e4a 100644 --- a/test/integration/accountReferenceType.js +++ b/test/integration/accountReferenceType.js @@ -1,7 +1,8 @@ /* global expect, agent */ const helpers = require('./helpers'); -describe('test/integration (/account_reference_type) Account Reference Type', () => { +describe('test/integration/accountReferenceType Account Reference Type API', () => { + const numAccountReferenceType = 5; const newAccountReferenceType = { @@ -63,4 +64,5 @@ describe('test/integration (/account_reference_type) Account Reference Type', () }) .catch(helpers.handler); }); + }); diff --git a/test/integration/accountReferences.js b/test/integration/accountReferences.js index c6299772ac..ac4cb9900c 100644 --- a/test/integration/accountReferences.js +++ b/test/integration/accountReferences.js @@ -1,7 +1,8 @@ /* global expect, agent */ const helpers = require('./helpers'); -describe('test/integration (/accounts/references) Accounts References', () => { +describe('test/integration/accountReferences Accounts References API', () => { + const numAccountReference = 14; const newAccountReference = { @@ -118,4 +119,5 @@ describe('test/integration (/accounts/references) Accounts References', () => { }) .catch(helpers.handler); }); + }); diff --git a/test/integration/accountTypes.js b/test/integration/accountTypes.js index 7d84571ca1..1427f232dc 100644 --- a/test/integration/accountTypes.js +++ b/test/integration/accountTypes.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/accounts/types) Account Types', () => { +describe('test/integration/accountTypes Account Types', () => { const newAccountType = { type : 'Test Account Type 1', account_category_id : 1, diff --git a/test/integration/accounts.js b/test/integration/accounts.js index 457ecba75b..ba87171c6a 100644 --- a/test/integration/accounts.js +++ b/test/integration/accounts.js @@ -8,7 +8,7 @@ function clone(array) { return array.slice(); } -describe('test/integration (/accounts) Accounts', () => { +describe('test/integration/accounts Accounts', () => { const newAccount = { type_id : 1, enterprise_id : 1, diff --git a/test/integration/allocationCostCenters.js b/test/integration/allocationCostCenters.js index ad800ebf30..0ce75aa719 100644 --- a/test/integration/allocationCostCenters.js +++ b/test/integration/allocationCostCenters.js @@ -3,11 +3,11 @@ const helpers = require('./helpers'); /* - * The Distribution Fees Centers API endpoint + * The Distribution Fees Centers API * - * This test suite implements full CRUD on the all cost center allocations HTTP API endpoint. + * This test suite implements full CRUD on the all cost center allocations API. */ -describe('test/integration (/cost_center_allocation) The /cost_center API endpoint', () => { +describe('test/integration/allocationCostCenters Cost Centers REST API', () => { const allocationKey1 = { data : { auxiliary_cost_center_id : 6, diff --git a/test/integration/barcodes.js b/test/integration/barcodes.js index ee376b3d93..3eb7aad0c8 100644 --- a/test/integration/barcodes.js +++ b/test/integration/barcodes.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/barcode) Barcode Reverse Lookup', () => { +describe('test/integration/barcodes Barcode Reverse Lookup', () => { const validPatientBarcode = 'PA81af634f'; const invalidPatientBarcode = 'PAnotvalid'; const validLotBarcode = 'LT064ab1d9'; diff --git a/test/integration/budget/budget.js b/test/integration/budget/budget.js index 2c9ca99f11..fff265011f 100644 --- a/test/integration/budget/budget.js +++ b/test/integration/budget/budget.js @@ -2,7 +2,7 @@ const helpers = require('../helpers'); -describe('test/integration (/budget) basic budget operations http API', () => { +describe('test/integration/budget/budget Basic Budget Operations API', () => { const accountTotal = 100000; const accountNum = 70611012; // Hospitalisation (income) diff --git a/test/integration/budget/import.js b/test/integration/budget/import.js index cfe51538c9..7bc6a187bc 100644 --- a/test/integration/budget/import.js +++ b/test/integration/budget/import.js @@ -3,7 +3,7 @@ const fs = require('fs'); const helpers = require('../helpers'); -describe('test/integration (/budget/import) The budget import http API', () => { +describe('test/integration/budget/import The budget import API', () => { const file = './test/fixtures/budget-to-import.csv'; const filename = 'budget-to-import.csv'; diff --git a/test/integration/cash.js b/test/integration/cash.js index 6bcdee8f57..168fcc6946 100644 --- a/test/integration/cash.js +++ b/test/integration/cash.js @@ -6,7 +6,7 @@ const CashInvoicePayments = require('./cash.invoices'); const CashCautionPayments = require('./cash.cautions'); const CashSearch = require('./cash.search'); -describe('test/integration (/cash) Cash Payments', () => { +describe('test/integration/cash Cash Payments', () => { const NUM_CASH_PAYMENTS = 2; const TO_DELETE_UUID = '25b69e1d-c9bc-46f2-98a5-5dd948de3636'; diff --git a/test/integration/cashboxes.js b/test/integration/cashboxes.js index 8f70e16154..12647b0e6e 100644 --- a/test/integration/cashboxes.js +++ b/test/integration/cashboxes.js @@ -3,8 +3,8 @@ const helpers = require('./helpers'); -/* The /cashboxes API endpoint */ -describe('test/integration (/cashboxes) The Cashboxes API endpoint', () => { +/* The /cashboxes API */ +describe('test/integration/cashboxes The Cashboxes API', () => { const numCashboxes = 2; const numAuxCashboxes = 1; const NUMBER_OF_CASHBOX_CURRENCIES = 2; diff --git a/test/integration/choiceListManagement.js b/test/integration/choiceListManagement.js index 33ae80bb29..f298f8e287 100644 --- a/test/integration/choiceListManagement.js +++ b/test/integration/choiceListManagement.js @@ -1,7 +1,7 @@ /* global expect, agent */ const helpers = require('./helpers'); -describe('test/integration (/choices_list_management) Choice List Management', () => { +describe('test/integration/choiceListManagement Choice List Management', () => { const numListElement = 28; const newElementList = { diff --git a/test/integration/configurationAnalysisTools.js b/test/integration/configurationAnalysisTools.js index 4fd657ecc3..1e02b3e5cf 100644 --- a/test/integration/configurationAnalysisTools.js +++ b/test/integration/configurationAnalysisTools.js @@ -1,7 +1,7 @@ /* global expect, agent */ const helpers = require('./helpers'); -describe('test/integration (/configuration_analysis_tools) Configuration Analysis Tools', () => { +describe('test/integration/configurationAnalysisTools Configuration Analysis Tools', () => { const numConfiguration = 5; const newConfiguration = { diff --git a/test/integration/cost-centers/index.js b/test/integration/cost-centers/index.js index 4913a74b1c..829c2450e7 100644 --- a/test/integration/cost-centers/index.js +++ b/test/integration/cost-centers/index.js @@ -1,11 +1,11 @@ const helpers = require('../helpers'); /* - * The /cost_center API endpoint + * The /cost_center API * - * This test suite implements full CRUD on the /cost_center HTTP API endpoint. + * This test suite implements full CRUD on the /cost_center API. */ -describe('test/integration (/cost_center) The /cost_center API endpoint', () => { +describe('test/integration/cost-centers/index The /cost_center API', () => { // Cost Center we will add during this test suite. const { services } = helpers.data; diff --git a/test/integration/costCenterAllocationBasis.js b/test/integration/costCenterAllocationBasis.js index 41a8516af1..422d9d11bd 100644 --- a/test/integration/costCenterAllocationBasis.js +++ b/test/integration/costCenterAllocationBasis.js @@ -4,11 +4,11 @@ const { it } = require('mocha'); const helpers = require('./helpers'); /* - * The /fee_center API endpoint + * The /fee_center API * - * This test suite implements full CRUD on the /cost_center_allocation_basis HTTP API endpoint. + * This test suite implements full CRUD on the /cost_center_allocation_basis API. */ /* eslint-disable-next-line max-len */ -describe('test/integration (/cost_center_allocation_basis) The cost center step-down allocation basis API endpoint', () => { +describe('test/integration/costCenterAllocationBasis The cost center step-down allocation basis API', () => { const basis = { name : 'Laundry Processed', diff --git a/test/integration/costCenterAllocationQuantity.js b/test/integration/costCenterAllocationQuantity.js index 3b3654aadc..0358c2965a 100644 --- a/test/integration/costCenterAllocationQuantity.js +++ b/test/integration/costCenterAllocationQuantity.js @@ -4,11 +4,11 @@ const { it } = require('mocha'); const helpers = require('./helpers'); /* - * The /cost_center API endpoint + * The /cost_center API * - * This test suite implements full CRUD on the /cost_center_allocation_basis_quantity HTTP API endpoint. + * This test suite implements full CRUD on the /cost_center_allocation_basis_quantity API. */ /* eslint-disable-next-line max-len */ -describe('test/integration (cost_center_allocation_basis_quantity) Cost center step-down allocation basis quantity API endpoint', () => { +describe('test/integration/costCenterAllocationQuantity Cost center step-down allocation basis quantity API', () => { const quantity1 = { basis_id : 2, diff --git a/test/integration/creditorGroups.js b/test/integration/creditorGroups.js index c07b93f8f2..cc012e59cd 100644 --- a/test/integration/creditorGroups.js +++ b/test/integration/creditorGroups.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /creditors/groups API endpoint + * The /creditors/groups API * - * This test suite implements full CRUD on the /creditors/groups HTTP API endpoint. + * This test suite implements full CRUD on the /creditors/groups API. */ -describe('test/integration (/creditors/groups) Creditor Groups', () => { +describe('test/integration/creditorGroups Creditor Groups', () => { // creditor group we will add during this test suite. const creditorGroup = { enterprise_id : 1, diff --git a/test/integration/cronEmailReport/cronEmailReport.js b/test/integration/cronEmailReport/cronEmailReport.js index 908af1ce21..962ff0ce2b 100644 --- a/test/integration/cronEmailReport/cronEmailReport.js +++ b/test/integration/cronEmailReport/cronEmailReport.js @@ -1,8 +1,8 @@ /* global agent */ const helpers = require('../helpers'); -// The /cron_email_reports API endpoint -describe('test/integration (/cron_email_reports) The cron_email_reports API ', () => { +// The /cron_email_reports API +describe('test/integration/cronEmailReport The /cron_email_reports API ', () => { // new cron_email_report object const record = { cron : diff --git a/test/integration/currencies.js b/test/integration/currencies.js index 32027e560f..39c87ca885 100644 --- a/test/integration/currencies.js +++ b/test/integration/currencies.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/currencies) currencies API routes', () => { +describe('test/integration/currencies currencies API routes', () => { const currencyIdFc = 1; const currencyIdEur = 3; const keys = [ diff --git a/test/integration/dataCollectorManagement.js b/test/integration/dataCollectorManagement.js index 7b4adbec9f..d3e1779d54 100644 --- a/test/integration/dataCollectorManagement.js +++ b/test/integration/dataCollectorManagement.js @@ -1,7 +1,7 @@ /* global expect, agent */ const helpers = require('./helpers'); -describe('test/integration (/data_collector_management) Data Collector Management', () => { +describe('test/integration/dataCollectorManagement Data Collector Management', () => { const numDataCollector = 3; const newDataCollector = { diff --git a/test/integration/debtorGroups.js b/test/integration/debtorGroups.js index 31a495cb10..608a617c70 100644 --- a/test/integration/debtorGroups.js +++ b/test/integration/debtorGroups.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/debtor_groups) The debtor groups API', () => { +describe('test/integration/debtorGroups The debtor groups API', () => { const numDebtorGroups = 7; const debtorGroup = { @@ -301,22 +301,20 @@ describe('test/integration (/debtor_groups) The debtor groups API', () => { * @todo: Need to be implemented at the server side in * /server/controllers/debtors/groups/index.js #function invoices */ - describe('/debtor_groups/:uuid/invoices', () => { - it('GET /debtor_groups/:uuid/invoices returns all invoices for a debtor group', () => { - return agent.get(`/debtor_groups/${debtorGroup.uuid}/invoices`) - .then(res => { - expect(res).to.have.status(200); - }) - .catch(helpers.handler); - }); - - it('GET /debtor_groups/:uuid/invoices returns only balanced invoices for a debtor group', () => { - return agent.get(`/debtor_groups/${debtorGroup.uuid}/invoices`).query({ balanced : 1 }) - .then(res => { - helpers.api.listed(res, 0); - }) - .catch(helpers.handler); - }); + it('GET /debtor_groups/:uuid/invoices returns all invoices for a debtor group', () => { + return agent.get(`/debtor_groups/${debtorGroup.uuid}/invoices`) + .then(res => { + expect(res).to.have.status(200); + }) + .catch(helpers.handler); + }); + + it('GET /debtor_groups/:uuid/invoices returns only balanced invoices for a debtor group', () => { + return agent.get(`/debtor_groups/${debtorGroup.uuid}/invoices`).query({ balanced : 1 }) + .then(res => { + helpers.api.listed(res, 0); + }) + .catch(helpers.handler); }); /** diff --git a/test/integration/debtors.js b/test/integration/debtors.js index 3f7e300153..477d7af904 100644 --- a/test/integration/debtors.js +++ b/test/integration/debtors.js @@ -2,7 +2,7 @@ const helpers = require('./helpers'); -describe('test/integration (/debtors) The /debtors API', () => { +describe('test/integration/debtors The /debtors API', () => { const debtorKeys = ['uuid', 'group_uuid', 'text']; const debtorUuid = '3BE232F9A4B94AF6984C5D3F87D5C107'; const emptyDebtorUuid = 'A11E6B7FFBBB432EAC2A5312A66DCCF4'; diff --git a/test/integration/depots.js b/test/integration/depots.js index 828c915236..f985b5fafa 100644 --- a/test/integration/depots.js +++ b/test/integration/depots.js @@ -2,8 +2,9 @@ const helpers = require('./helpers'); -// The /depots API endpoint -describe('test/integration (/depots) The depots API ', () => { +// The /depots API +describe('test/integration/depots Depots API', () => { + const principalDepotUuid = 'F9CAEB16168443C5A6C447DBAC1DF296'; const secondaryDepotUuid = 'D4BB1452E4FA4742A281814140246877'; // new depot object diff --git a/test/integration/discounts.js b/test/integration/discounts.js index 80d094cb8a..f5e2a69e77 100644 --- a/test/integration/discounts.js +++ b/test/integration/discounts.js @@ -4,9 +4,9 @@ const helpers = require('./helpers'); /* - * The /discounts API endpoint + * The /discounts API */ -describe('test/integration (/discounts) Discounts Interface', () => { +describe('test/integration/discounts Discounts Interface', () => { // FIXME(@jniles) - make a discount account. const ACCOUNT_ID = 220; // 66110011 - Remunération Personnel diff --git a/test/integration/employee.js b/test/integration/employee.js index 27cfc3efa9..2f22699428 100644 --- a/test/integration/employee.js +++ b/test/integration/employee.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /employees API endpoint + * The /employees API * - * This test suite implements full CRUD on the /employees HTTP API endpoint. + * This test suite implements full CRUD on the /employees API. */ -describe('test/integration (/employees) the employees API endpoint', () => { +describe('test/integration/employees the employees API', () => { const testService = 'AFF85BDCD7C64047AFE71724F8CD369E'; // custom dates diff --git a/test/integration/employeeConfig.js b/test/integration/employeeConfig.js index 1009481364..261a67d225 100644 --- a/test/integration/employeeConfig.js +++ b/test/integration/employeeConfig.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /payroll/employee_configuration API endpoint + * The /payroll/employee_configuration API * - * This test suite implements full CRUD on the /payroll/employee_configuration HTTP API endpoint. + * This test suite implements full CRUD on the /payroll/employee_configuration API. */ -describe('test/integration (/payroll/account_configuration) The /payroll/employee_configuration API endpoint', () => { +describe('test/integration/payroll/accountConfiguration The Employee Payroll Configuration API', () => { // Employee Payroll Configuration we will add during this test suite. const employeeConfig = { diff --git a/test/integration/enterprises.js b/test/integration/enterprises.js index 013f8fc010..5ce9864e1c 100644 --- a/test/integration/enterprises.js +++ b/test/integration/enterprises.js @@ -6,10 +6,10 @@ const helpers = require('./helpers'); const fixtures = path.resolve(__dirname, '../fixtures'); /* - * The /enterprises API endpoint - * This test suite implements full CRUD on the /enterprises HTTP API endpoint. + * The /enterprises API + * This test suite implements full CRUD on the /enterprises API. */ -describe('test/integration (/enterprises) Enterprises API', () => { +describe('test/integration/enterprises Enterprises API', () => { const defaultEnterpriseId = 1; const enterprise = { diff --git a/test/integration/entities/entities.js b/test/integration/entities/entities.js index 3bd2b167f8..eb4a1698b8 100644 --- a/test/integration/entities/entities.js +++ b/test/integration/entities/entities.js @@ -1,7 +1,7 @@ /* global expect, agent */ const helpers = require('../helpers'); -describe('test/integration (/entities) Entities', () => { +describe('test/integration/entities Entities API', () => { const types = { PERSON : 1, SERVICE : 2, diff --git a/test/integration/entities/types.js b/test/integration/entities/types.js index 423f57f70b..8c96490213 100644 --- a/test/integration/entities/types.js +++ b/test/integration/entities/types.js @@ -1,7 +1,7 @@ /* global expect, agent */ const helpers = require('../helpers'); -describe('test/integration (/entities/types) Entities', () => { +describe('test/integration/entities/types Entity Types API', () => { const type = { label : 'Super Human' }; const responseKeys = [ diff --git a/test/integration/exchange.js b/test/integration/exchange.js index 7e4a1542ef..5dd62687e2 100644 --- a/test/integration/exchange.js +++ b/test/integration/exchange.js @@ -4,9 +4,9 @@ const helpers = require('./helpers'); /* - * The /exchange API endpoint + * The /exchange API */ -describe('test/integration (/exchange) The /exchange API endpoint', () => { +describe('test/integration/exchange The Exchange API', () => { // constants const FcRATE = { diff --git a/test/integration/fillForm.js b/test/integration/fillForm.js index 9d4bf63618..0c9816ae93 100644 --- a/test/integration/fillForm.js +++ b/test/integration/fillForm.js @@ -2,7 +2,7 @@ const qs = require('qs'); const helpers = require('./helpers'); -describe('test/integration (/fill_form) Fill Form', () => { +describe('test/integration/fillForm Fill Form', () => { const numDataSurvey = 7; const surveyElement1 = { diff --git a/test/integration/fiscalYear.extra.js b/test/integration/fiscalYear.extra.js index 1be1cec663..b4ea17c3f5 100644 --- a/test/integration/fiscalYear.extra.js +++ b/test/integration/fiscalYear.extra.js @@ -3,7 +3,7 @@ const moment = require('moment'); const helpers = require('./helpers'); -describe('test/integration (/fiscal) Fiscal Year extra operations', () => { +describe('test/integration/fiscalYear Fiscal Year extra operations', () => { const url = '/fiscal'; const date = new Date('2017-08-24 12:00:00'); diff --git a/test/integration/fiscalYear.js b/test/integration/fiscalYear.js index 735304678c..ca339eef57 100644 --- a/test/integration/fiscalYear.js +++ b/test/integration/fiscalYear.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/fiscal) Fiscal Year', () => { +describe('test/integration/fiscalYear Fiscal Year', () => { const newFiscalYear = { label : 'A New Fiscal Year 2024', start_date : new Date('2024-01-01 01:00'), diff --git a/test/integration/functions.js b/test/integration/functions.js index 59bcb5ffbf..12315e611e 100644 --- a/test/integration/functions.js +++ b/test/integration/functions.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /functions API endpoint + * The /functions API * - * This test suite implements full CRUD on the /functions HTTP API endpoint. + * This test suite implements full CRUD on the /functions API. */ -describe('test/integration (/functions) The /functions API endpoint', () => { +describe('test/integration/functions The /functions API', () => { // Function we will add during this test suite. const fonction = { diff --git a/test/integration/grades.js b/test/integration/grades.js index ea56e49048..06bc84e1aa 100644 --- a/test/integration/grades.js +++ b/test/integration/grades.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /grades API endpoint + * The /grades API * - * This test suite implements full CRUD on the /grades HTTP API endpoint. + * This test suite implements full CRUD on the /grades API. */ -describe('test/integration (/grades) API endpoint', () => { +describe('test/integration/grades The grades API', () => { // grade we will add during this test suite. const grade = { diff --git a/test/integration/groups.js b/test/integration/groups.js index 9dec783712..6488843bf4 100644 --- a/test/integration/groups.js +++ b/test/integration/groups.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/groups) Group subscriptions API', () => { +describe('test/integration/groups Group subscriptions API', () => { const invalidKey = 'notakey'; const validKey = 'debtor_group_invoicing_fee'; diff --git a/test/integration/holidays.js b/test/integration/holidays.js index 55e6e0779b..919a2bf64b 100644 --- a/test/integration/holidays.js +++ b/test/integration/holidays.js @@ -3,11 +3,11 @@ const helpers = require('./helpers'); /* - * The /holidays API endpoint + * The /holidays API * - * This test suite implements full CRUD on the /holidays HTTP API endpoint. + * This test suite implements full CRUD on the /holidays API. */ -describe('test/integration (/holidays) The /holidays API endpoint', () => { +describe('test/integration/holidays The /holidays API', () => { // Holiday we will add during this test suite. diff --git a/test/integration/indicator.js b/test/integration/indicator.js index 803c77848c..a7a9e4d372 100644 --- a/test/integration/indicator.js +++ b/test/integration/indicator.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /roles API endpoint + * The /roles API * - * This test suite implements full CRUD on the /indicators_file HTTP API endpoint. + * This test suite implements full CRUD on the /indicators_file API. */ -describe('test/integration (/indicators_file) The indicators API endpoint', () => { +describe('test/integration/indicators The indicators file API', () => { const { services } = helpers.data; const HOSPITALIZATION_TYPE = 1; diff --git a/test/integration/inventory/group.js b/test/integration/inventory/group.js index 0c5b0f2c68..70cf58578f 100644 --- a/test/integration/inventory/group.js +++ b/test/integration/inventory/group.js @@ -3,7 +3,7 @@ const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/inventory/groups) The inventory groups HTTP API', () => { +describe('test/integration/inventory/groups The inventory groups API', () => { const NUM_GROUPS = 34; it(`GET /inventory/groups finds ${NUM_GROUPS} inventory groups`, () => { diff --git a/test/integration/inventory/import.js b/test/integration/inventory/import.js index ffbada2c57..b279c68aaa 100644 --- a/test/integration/inventory/import.js +++ b/test/integration/inventory/import.js @@ -3,7 +3,7 @@ const fs = require('fs'); const helpers = require('../helpers'); -describe('test/integration (/inventory/import) The inventory import http API', () => { +describe('test/integration/inventory/import The inventory import API', () => { const templateCsvContent = 'inventory_group_name, inventory_code, inventory_text, inventory_type, inventory_unit, ' + 'inventory_unit_price, inventory_consumable, inventory_is_asset, depreciation_rate, inventory_brand, ' + 'inventory_model'; diff --git a/test/integration/inventory/lot_schedule.js b/test/integration/inventory/lot_schedule.js index 27b1fbf34f..0963c1323f 100644 --- a/test/integration/inventory/lot_schedule.js +++ b/test/integration/inventory/lot_schedule.js @@ -9,7 +9,7 @@ function compareDate(date1, date2, msg) { expect(date1.getDate(), `${msg} (day does not match)`).to.equal(date2.getDate()); } -describe('test/integration Inventory lots schedule HTML REST API', () => { +describe('test/integration/inventory/lot_schedule Inventory lots schedule HTML REST API', () => { it('GET /inventory/:uuid/schedule: test usage schedule for QUININE (DORA_QUIN1S-_0)', () => { const uuid = helpers.data.QUININE; diff --git a/test/integration/inventory/metadata.js b/test/integration/inventory/metadata.js index 4d1c7308d8..78d9879e40 100644 --- a/test/integration/inventory/metadata.js +++ b/test/integration/inventory/metadata.js @@ -2,9 +2,9 @@ const helpers = require('../helpers'); const shared = require('./shared'); -const xlsx = require('../../../server/lib/renderers/xlsx.js'); +const xlsx = require('../../../server/lib/renderers/xlsx'); -describe('test/integration (/inventory/metadata) The inventory metadata http API', () => { +describe('test/integration/inventory/metadata The inventory metadata API', () => { let inventoryList; // inventory list items diff --git a/test/integration/inventory/type.js b/test/integration/inventory/type.js index e19863d31d..546cdf92f2 100644 --- a/test/integration/inventory/type.js +++ b/test/integration/inventory/type.js @@ -3,7 +3,7 @@ const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/inventory/types) The inventory types http API', () => { +describe('test/integration/inventory/types The inventory types API', () => { const NUM_TYPES = 3; it(`GET /inventory/types finds ${NUM_TYPES} inventory types`, () => { diff --git a/test/integration/inventory/unit.js b/test/integration/inventory/unit.js index 2cc75455c0..b27c70160a 100644 --- a/test/integration/inventory/unit.js +++ b/test/integration/inventory/unit.js @@ -3,7 +3,7 @@ const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/inventory/units) The inventory units HTTP API', () => { +describe('test/integration/inventory/units The inventory units API', () => { const NUM_UNITS = 42; // Only 41, but a new one is created in import test diff --git a/test/integration/invoicingFees.js b/test/integration/invoicingFees.js index 035e812e8a..4e5b72f799 100644 --- a/test/integration/invoicingFees.js +++ b/test/integration/invoicingFees.js @@ -4,9 +4,9 @@ const helpers = require('./helpers'); /* - * The /invoicing_fees API endpoint + * The /invoicing_fees API */ -describe('test/integration (/invoicing_fees) Invoicing Fee API', () => { +describe('test/integration/invoicingFees Invoicing Fee API', () => { const invoicingFeeA = { account_id : 260, // 75881010 - Autres revenus label : 'Test Invoicing Fee A', diff --git a/test/integration/journal.js b/test/integration/journal.js index 68b271e62b..79bb218375 100644 --- a/test/integration/journal.js +++ b/test/integration/journal.js @@ -3,9 +3,9 @@ const helpers = require('./helpers'); /* - * The /journal API endpoint + * The /journal API */ -describe('test/integration (/journal) API endpoint', () => { +describe('test/integration/journal Journal Basic API', () => { const RECORD_UUID = 'A5A5F950-A4C9-47F0-9A9A-2BFC3123E534'; const MISSING_RECORD_UUID = 'A5A5F950-A4C9-47F0-9A9A-2BFC3123E635'; @@ -36,12 +36,10 @@ describe('test/integration (/journal) API endpoint', () => { .catch(helpers.handler); }); - describe('(/journal) Search', SearchTests); - - describe('(/journal) Corrections', CorrectionTests); }); -function SearchTests() { +describe('test/integration/journal Journal Search API', () => { + const description = 'Sample voucher data one'; const accountId = 187; const amount = 100; @@ -114,9 +112,11 @@ function SearchTests() { }) .catch(helpers.handler); }); -} -function CorrectionTests() { +}); + +describe('test/integration/journal Journal Corrections API', () => { + const REVERSE_UUID = 'A5A5F950A4C947F09A9A2BFC3123E534'; const CORRECT_UUID = '19B4D28CCBB311E8BF7E7F323238856C'; @@ -201,4 +201,5 @@ function CorrectionTests() { }) .catch(helpers.handler); }); -} + +}); diff --git a/test/integration/locations.js b/test/integration/locations.js index 35b1959c2c..f15d90c0e9 100644 --- a/test/integration/locations.js +++ b/test/integration/locations.js @@ -5,9 +5,9 @@ const _ = require('lodash'); const helpers = require('./helpers'); /* - * The /locations API endpoint + * The /locations API */ -describe('test/integration (/locations) Locations Interface', () => { +describe('test/integration/locations Locations Interface', () => { /* * number of test villages, sectors, provinces, and countries in the test * dataset. diff --git a/test/integration/login.js b/test/integration/login.js index e411e93777..ce04fbebf5 100644 --- a/test/integration/login.js +++ b/test/integration/login.js @@ -2,7 +2,7 @@ const helpers = require('./helpers'); -describe('test/integration (/auth/login) The login API', () => { +describe('test/integration/login The login authorization API', () => { const port = process.env.PORT || 8080; const url = `http://localhost:${port}`; diff --git a/test/integration/mergeLots.js b/test/integration/mergeLots.js index 76acf9d3b4..787d420f81 100644 --- a/test/integration/mergeLots.js +++ b/test/integration/mergeLots.js @@ -99,7 +99,7 @@ function addStockMovementSQL(params) { + ` '${createdAt}', ${isExit}, ${userId}, 9, '${createdAt}', '${periodId}');`; } -describe('Test merging lots', () => { +describe('test/integration/mergeLots Test merging lots', () => { before('Note original counts of lots, tags, etc', () => { return preTestInfo.reduce((chain, item) => { diff --git a/test/integration/offdays.js b/test/integration/offdays.js index e4bb1e1cff..7841113964 100644 --- a/test/integration/offdays.js +++ b/test/integration/offdays.js @@ -3,11 +3,11 @@ const helpers = require('./helpers'); /* - * The /offdays API endpoint + * The /offdays API * - * This test suite implements full CRUD on the /offdays HTTP API endpoint. + * This test suite implements full CRUD on the /offdays API. */ -describe('test/integration (/offdays) The /offdays API endpoint', () => { +describe('test/integration/offdays The /offdays API', () => { // Offday we will add during this test suite. diff --git a/test/integration/patientDocuments.js b/test/integration/patientDocuments.js index 3976b135c4..1dd4b9aa5c 100644 --- a/test/integration/patientDocuments.js +++ b/test/integration/patientDocuments.js @@ -7,8 +7,7 @@ const helpers = require('./helpers'); const fixtures = path.resolve(__dirname, '../fixtures'); -describe('test/integration (patients/:uuid/documents) Patient Documents', () => { - +describe('test/integration/patients/documents Patient Documents (/patients/:uuid/documents) API', () => { const patientUuid = '81af634f-321a-40de-bc6f-ceb1167a9f65'; let docId = null; diff --git a/test/integration/patientGroups.js b/test/integration/patientGroups.js index 98d65559e0..46b40679ff 100644 --- a/test/integration/patientGroups.js +++ b/test/integration/patientGroups.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/patients/groups) Patient Group API', () => { +describe('test/integration/patientsGroups Patient Group API', () => { const newPatientGroup = { enterprise_id : 1, diff --git a/test/integration/patientInvoice.js b/test/integration/patientInvoice.js index 1998752ab9..3c6bdaa37d 100644 --- a/test/integration/patientInvoice.js +++ b/test/integration/patientInvoice.js @@ -12,8 +12,8 @@ const genuuid = () => uuid.v4().toUpperCase().replace(/-/g, ''); * should be fixed and verified with tests */ -/* The /invoices API endpoint */ -describe('test/integration (/invoices) Patient Invoices', () => { +/* The /invoices API */ +describe('test/integration/patientInvoice Patient Invoices API', () => { const numInvoices = 5; const numCreatedInvoices = 3; const numDeletedInvoices = 1; @@ -21,7 +21,7 @@ describe('test/integration (/invoices) Patient Invoices', () => { const fetchableInvoiceUuid = '957e4e79-a6bb-4b4d-a8f7-c42152b2c2f6'; // run the 'InvoicingFeeScenario' test suite - describe('(POST /invoices)', InvoicingFeeScenario); + context('Creating Patient Invoices API', InvoicingFeeScenario); it('GET /invoices returns a list of patient invoices', () => { return agent.get('/invoices') @@ -63,7 +63,7 @@ describe('test/integration (/invoices) Patient Invoices', () => { .catch(helpers.handler); }); - describe('(/invoices) Search interface for the invoices table', () => { + context('Search interface for the patient invoices table', () => { // no parameters provided it('GET /invoices/ should return all invoices if no query string provided', () => { diff --git a/test/integration/patientInvoiceCreditNote.js b/test/integration/patientInvoiceCreditNote.js index b81831aa83..4b10d1be32 100644 --- a/test/integration/patientInvoiceCreditNote.js +++ b/test/integration/patientInvoiceCreditNote.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/Journal) Credit Notes to reverse invoice transactions', () => { +describe('test/integration/patientInvoiceCreditNotes Credit Notes to reverse invoice transactions', () => { const fetchableInvoiceUuid = '957e4e79-a6bb-4b4d-a8f7-c42152b2c2f6'; diff --git a/test/integration/patientMatches.js b/test/integration/patientMatches.js index 98102ca08e..9178b434ae 100644 --- a/test/integration/patientMatches.js +++ b/test/integration/patientMatches.js @@ -44,7 +44,7 @@ const mockPatients = [ [uuid(), 'Lynn Black', 'F', '1981-06-01', 'TRUE', uuid()], ]; -describe('test/integration (/patients) Find matching patients', () => { +describe('test/integration/patientMatches Find matching patients', () => { // prior to tests, create default patients. before('add mock patients', () => { diff --git a/test/integration/patientPictures.js b/test/integration/patientPictures.js index dda9bd7ea0..a38f59901b 100644 --- a/test/integration/patientPictures.js +++ b/test/integration/patientPictures.js @@ -6,7 +6,7 @@ const helpers = require('./helpers'); const fixtures = path.resolve(__dirname, '../fixtures'); -describe('test/integration (patients/:uuid/pictures) Patient Pictures', () => { +describe('test/integration/patientPictures Patient Pictures (patients/:uuid/pictures) API', () => { const patientUuid = '274c51ae-efcc-4238-98c6-f402bfb39866'; it('POST /patients/:uuid/pictures should set the patient\'s picture', () => { diff --git a/test/integration/patientVisits.js b/test/integration/patientVisits.js index 973198b0f8..72aea629e3 100644 --- a/test/integration/patientVisits.js +++ b/test/integration/patientVisits.js @@ -2,7 +2,7 @@ const helpers = require('./helpers'); -describe('test/integration (/patients/:uuid/visits) Patient Visits', () => { +describe('test/integration/patientVisits Patient Visits (/patients/:uuid/visits) API', () => { const { services } = helpers.data; const patientUuid = '81af634f-321a-40de-bc6f-ceb1167a9f65'; diff --git a/test/integration/patients.js b/test/integration/patients.js index 56202680ab..3228d50b9b 100644 --- a/test/integration/patients.js +++ b/test/integration/patients.js @@ -78,8 +78,8 @@ const mockDoublonRequest = { medical : mockPatientDoublon, }; -describe('test/integration (/patients) Patients', () => { - // HTTP API Test for /patients/ routes +describe('test/integration/patients Patients API', () => { + // API Test for /patients/ routes describe('Patient Search', () => { it('GET /patients with missing necessary parameters should succeed', () => { @@ -291,17 +291,17 @@ describe('test/integration (/patients) Patients', () => { }); // merge patients - describe('merge patients', MergePatients); + describe('Merge Patients', MergePatients); // hospital number uniqueness tests - describe('/hospital_number/:id/exists', HospitalNumber); + describe('Hospital Number uniqueness', HospitalNumber); // patient group tests - describe('patient groups (/patient/:uuid/groups)', PatientGroups); + describe('Patient Groups', PatientGroups); - describe('patient billing service', billingServices); + describe('Patient Billing Service', billingServices); - describe('patient subsidies', subsidies); + describe('Patient Subsidies', subsidies); }); // patients merge diff --git a/test/integration/payroll.js b/test/integration/payroll.js index da28deddfc..6369bbf3d0 100644 --- a/test/integration/payroll.js +++ b/test/integration/payroll.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /multiplePayroll API endpoint + * The /multiplePayroll API * * This test suite implements Payroll Process Managere. */ -describe('test/integration (/multiplePayroll ) the Payroll API endpoint', () => { +describe('test/integration/payroll the Multiple Payroll API', () => { const params = { periodPaie : 1, diff --git a/test/integration/payrollConfig.js b/test/integration/payrollConfig.js index 2008c71a89..9bdffaa2a0 100644 --- a/test/integration/payrollConfig.js +++ b/test/integration/payrollConfig.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /payroll API endpoint + * The /payroll API * - * This test suite implements full CRUD on the /payroll HTTP API endpoint. + * This test suite implements full CRUD on the /payroll API. */ -describe('test/integration (/payroll) The /payroll API endpoint', () => { +describe('test/integration/payrollConfig The payroll Config API', () => { // Payroll Configuration we will add during this test suite. const payrollConfig = { diff --git a/test/integration/priceList.js b/test/integration/priceList.js index 51a69835d2..ee8dd43539 100644 --- a/test/integration/priceList.js +++ b/test/integration/priceList.js @@ -4,9 +4,9 @@ const helpers = require('./helpers'); /* - * The /prices API endpoint + * The /prices API */ -describe('test/integration (/prices ) Price List', () => { +describe('test/integration/priceList Price List', () => { // constants const emptyPriceList = { uuid : 'DA4BE62A4310408897A457C14CAB49C8', diff --git a/test/integration/projects.js b/test/integration/projects.js index 6a28e317ce..4ef4fdf1a7 100644 --- a/test/integration/projects.js +++ b/test/integration/projects.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /projects API endpoint + * The /projects API * - * This test suite implements full CRUD on the /projects HTTP API endpoint. + * This test suite implements full CRUD on the /projects API. */ -describe('test/integration (/projects) The projects API endpoint', () => { +describe('test/integration/projects The projects API', () => { // project we will add during this test suite. const project = { diff --git a/test/integration/purchase.js b/test/integration/purchase.js index fe15907b9c..1ca30ee5a0 100644 --- a/test/integration/purchase.js +++ b/test/integration/purchase.js @@ -2,15 +2,14 @@ /* eslint-disable no-unused-expressions */ const moment = require('moment'); const helpers = require('./helpers'); -const SearchTests = require('./purchase.search'); const puid = helpers.uuid(); /* - * The /purchases API endpoint - * This test suite implements full CRUD on the /purchases HTTP API endpoint. + * The /purchases API + * This test suite implements full CRUD on the /purchases API. */ -describe('test/integration (/purchases) Purchases', () => { +describe('test/integration/purchases Purchases API', () => { const datePurchaseFormat1 = moment().subtract(1725, 'days').toDate(); const datePurchaseFormat2 = moment().subtract(1665, 'days').toDate(); const datePurchaseFormat3 = moment().subtract(1543, 'days').toDate(); @@ -331,9 +330,42 @@ describe('test/integration (/purchases) Purchases', () => { expect(hasCorrectQuantities).to.equal(true); }); - describe('/purchases/search', SearchTests); + context('Purchases Search API', () => { + const NUM_PURCHASE_ORDERS = 7; - describe('deletion tests', () => { + // this is a quick querying function to reduce LOC + const SendHTTPQuery = (parameters, numResults) => { + return agent.get('/purchases/search') + .query(parameters) + .then((res) => { + helpers.api.listed(res, numResults); + }) + .catch(helpers.handler); + }; + + it('GET /purchases/search returns all purchase orders', () => { + return SendHTTPQuery({}, NUM_PURCHASE_ORDERS); + }); + + // TODO - implement limit query + it('GET /purchases/search?limit=1 returns a single purchase order', () => { + const options = { limit : 1 }; + return SendHTTPQuery(options, 1); + }); + + it('GET /purchases/search?dateFrom={date} returns a single purchase order from today', () => { + const date = new Date('2016-02-19'); + const options = { dateFrom : date }; + return SendHTTPQuery(options, NUM_PURCHASE_ORDERS); + }); + + it('GET /purchases/search?reference=PO.TPA.1 returns a single purchase order', () => { + const options = { reference : 'PO.TPA.1' }; + return SendHTTPQuery(options, 1); + }); + }); + + context('Purchases Deletion API', () => { it('DELETE /purchases/:uuid removes a purchase order', () => { return agent.delete(`/purchases/${puid}`) diff --git a/test/integration/purchase.search.js b/test/integration/purchase.search.js deleted file mode 100644 index 0f4ce97b90..0000000000 --- a/test/integration/purchase.search.js +++ /dev/null @@ -1,46 +0,0 @@ -/* global agent */ - -/** - * @overview PurchaseOrderSearch - * - * @description - * This file contains search tests for the purchase orders API. - */ -const helpers = require('./helpers'); - -module.exports = PurchaseOrderSearch; - -function PurchaseOrderSearch() { - const NUM_PURCHASE_ORDERS = 7; - - // this is a quick querying function to reduce LOC - const SendHTTPQuery = (parameters, numResults) => { - return agent.get('/purchases/search') - .query(parameters) - .then((res) => { - helpers.api.listed(res, numResults); - }) - .catch(helpers.handler); - }; - - it('GET /purchases/search returns all purchase orders', () => { - return SendHTTPQuery({}, NUM_PURCHASE_ORDERS); - }); - - // TODO - implement limit query - it('GET /purchases/search?limit=1 returns a single purchase order', () => { - const options = { limit : 1 }; - return SendHTTPQuery(options, 1); - }); - - it('GET /purchases/search?dateFrom={date} returns a single purchase order from today', () => { - const date = new Date('2016-02-19'); - const options = { dateFrom : date }; - return SendHTTPQuery(options, NUM_PURCHASE_ORDERS); - }); - - it('GET /purchases/search?reference=PO.TPA.1 returns a single purchase order', () => { - const options = { reference : 'PO.TPA.1' }; - return SendHTTPQuery(options, 1); - }); -} diff --git a/test/integration/remoteAccess.js b/test/integration/remoteAccess.js index d69b5c1475..241203cef9 100644 --- a/test/integration/remoteAccess.js +++ b/test/integration/remoteAccess.js @@ -2,7 +2,7 @@ const helpers = require('./helpers'); -describe('test/integration /remote access APIs', () => { +describe('test/integration/remoteAccess access APIs', () => { const port = process.env.PORT || 8080; const url = `http://localhost:${port}`; diff --git a/test/integration/reports/finance/account.chart.js b/test/integration/reports/finance/account.chart.js index 99c6f3ea69..f77f2edc4d 100644 --- a/test/integration/reports/finance/account.chart.js +++ b/test/integration/reports/finance/account.chart.js @@ -1,4 +1,5 @@ const RenderingTests = require('../rendering'); + const target = '/reports/finance/accounts/chart'; -describe(`(${target}) Chart of Accounts`, RenderingTests(target)); +describe(`test/integration${target} Chart of Accounts Report`, RenderingTests(target)); diff --git a/test/integration/reports/finance/account_report.js b/test/integration/reports/finance/account_report.js index 8ace486ade..18578ae070 100644 --- a/test/integration/reports/finance/account_report.js +++ b/test/integration/reports/finance/account_report.js @@ -1,10 +1,12 @@ /* global expect, agent */ +/* eslint-disable no-unused-expressions */ const helpers = require('../../helpers'); const target = '/reports/finance/account_report'; -describe(`(${target}) Report Account`, () => { +describe(`test/integration${target} Report Account`, () => { + const parameters = { account_id : 171, // 41111000 - SNEL dateFrom : '2016-01-01', @@ -40,4 +42,5 @@ describe(`(${target}) Report Account`, () => { }) .catch(helpers.handler); }); + }); diff --git a/test/integration/reports/finance/aged_creditors.js b/test/integration/reports/finance/aged_creditors.js index 854c6c7bac..a6262672b1 100644 --- a/test/integration/reports/finance/aged_creditors.js +++ b/test/integration/reports/finance/aged_creditors.js @@ -8,4 +8,4 @@ const options = { enterprise_id : 1, }; -describe(`test/integration (${target}) Aged Creditors`, RenderingTests(target, null, options)); +describe(`test/integration${target}) Aged Creditors Report`, RenderingTests(target, null, options)); diff --git a/test/integration/reports/finance/aged_debtors.js b/test/integration/reports/finance/aged_debtors.js index b8b9f65ba5..b44231c0d1 100644 --- a/test/integration/reports/finance/aged_debtors.js +++ b/test/integration/reports/finance/aged_debtors.js @@ -8,4 +8,4 @@ const options = { enterprise_id : 1, }; -describe(`test/integration (${target}) Aged Debtors`, RenderingTests(target, null, options)); +describe(`test/integration${target} Aged Debtors Report`, RenderingTests(target, null, options)); diff --git a/test/integration/reports/finance/cash.receipt.js b/test/integration/reports/finance/cash.receipt.js index 30b947f249..1fc3137c3a 100644 --- a/test/integration/reports/finance/cash.receipt.js +++ b/test/integration/reports/finance/cash.receipt.js @@ -1,62 +1,68 @@ -/* global expect, chai, agent */ +/* global expect, agent */ +/* eslint-disable no-unused-vars, no-multi-spaces, no-unused-expressions */ const helpers = require('../../helpers'); -describe('/reports/finance/cash Receipts Interface', function () { - - // known data for requests and assertions - const validPayment = '2e1332b7-3e63-411e-827d-42ad585ff517'; - const jsonRenderTarget = '?renderer=json'; - const htmlRenderTarget = '?renderer=html'; - const pdfRenderTarget = '?renderer=pdf'; - const invalidRenderTarget = '?renderer=unkownRender'; - - it('GET /reports/finance/cash/:uuid should return not found for invalid uuid', function () { - return agent.get('/reports/finance/cash/unknown') - .then(function (result) { - helpers.api.errored(result, 404); - }) - .catch(helpers.handler); - }); +describe('test/integration/reports/finance/cash_receipts', () => { - it('GET /reports/finance/cash/:uuid should return bad request for invalid renderer', function () { - return agent.get('/reports/finance/cash/'.concat(validPayment, invalidRenderTarget)) - .then(function (result) { - helpers.api.errored(result, 400); - }) - .catch(helpers.handler); - }); + describe('Cash Receipts Interface API', () => { - it('GET /reports/finance/cash/:uuid should return JSON data for `json` rendering target', function () { - return agent.get('/reports/finance/cash/'.concat(validPayment, jsonRenderTarget)) - .then(expectReportJSONSuccess) - .catch(helpers.handler); - }); + // known data for requests and assertions + const validPayment = '2e1332b7-3e63-411e-827d-42ad585ff517'; + const jsonRenderTarget = '?renderer=json'; + const htmlRenderTarget = '?renderer=html'; + const pdfRenderTarget = '?renderer=pdf'; + const invalidRenderTarget = '?renderer=unkownRender'; - it('GET /reports/finance/cash/:uuid should return HTML data for `html` rendering target', function () { - return agent.get('/reports/finance/cash/'.concat(validPayment, htmlRenderTarget)) - .then(function (result) { - expect(result.headers['content-type']).to.equal('text/html; charset=utf-8'); - expect(result.text).to.not.be.empty; - }) - .catch(helpers.handler); - }); + it('GET /reports/finance/cash/:uuid should return not found for invalid uuid', () => { + return agent.get('/reports/finance/cash/unknown') + .then((result) => { + helpers.api.errored(result, 404); + }) + .catch(helpers.handler); + }); + + it('GET /reports/finance/cash/:uuid should return bad request for invalid renderer', () => { + return agent.get('/reports/finance/cash/'.concat(validPayment, invalidRenderTarget)) + .then((result) => { + helpers.api.errored(result, 400); + }) + .catch(helpers.handler); + }); + + it('GET /reports/finance/cash/:uuid should return JSON data for `json` rendering target', () => { + return agent.get('/reports/finance/cash/'.concat(validPayment, jsonRenderTarget)) + .then(expectReportJSONSuccess) + .catch(helpers.handler); + }); + + it('GET /reports/finance/cash/:uuid should return HTML data for `html` rendering target', () => { + return agent.get('/reports/finance/cash/'.concat(validPayment, htmlRenderTarget)) + .then((result) => { + expect(result.headers['content-type']).to.equal('text/html; charset=utf-8'); + expect(result.text).to.not.be.empty; + }) + .catch(helpers.handler); + }); + + it('GET /reports/finance/cash/:uuid should return PDF data for `pdf` rendering target', () => { + return agent.get('/reports/finance/cash/'.concat(validPayment, pdfRenderTarget)) + .then((result) => { + expect(result.headers['content-type']).to.equal('application/pdf'); + expect(result.type).to.equal('application/pdf'); + }) + .catch(helpers.handler); + }); + + function expectReportJSONSuccess(result) { + const keys = ['payment', 'enterprise', 'patient']; + expect(result).to.have.status(200); + expect(result.headers['content-type']).to.equal('application/json; charset=utf-8'); + expect(result).to.be.json; + expect(result.body).to.contain.all.keys(keys); + return result; + } - it('GET /reports/finance/cash/:uuid should return PDF data for `pdf` rendering target', function () { - return agent.get('/reports/finance/cash/'.concat(validPayment, pdfRenderTarget)) - .then(function (result) { - expect(result.headers['content-type']).to.equal('application/pdf'); - expect(result.type).to.equal('application/pdf'); - }) - .catch(helpers.handler); }); - function expectReportJSONSuccess(result) { - const keys = ['payment', 'enterprise', 'patient']; - expect(result).to.have.status(200); - expect(result.headers['content-type']).to.equal('application/json; charset=utf-8'); - expect(result).to.be.json; - expect(result.body).to.contain.all.keys(keys); - return result; - } }); diff --git a/test/integration/reports/finance/cash_report.js b/test/integration/reports/finance/cash_report.js index 110ab99631..cab486e636 100644 --- a/test/integration/reports/finance/cash_report.js +++ b/test/integration/reports/finance/cash_report.js @@ -5,7 +5,7 @@ const RenderingTests = require('../rendering'); const target = '/reports/finance/cash_report'; const helpers = require('../../helpers'); -describe(`(${target}) cash Reports`, () => { +describe(`test/integration${target} Cash Report`, () => { const keys = [ 'account', 'cashbox', 'footer', 'dateFrom', 'dateTo', 'hasUnpostedRecords', 'header', 'metadata', 'transactions', @@ -19,7 +19,7 @@ describe(`(${target}) cash Reports`, () => { format : 2, }; - describe(`test/integration ${target} Rendering`, RenderingTests(target, null, parameters)); + describe('Cash Report', RenderingTests(target, null, parameters)); it(`GET ${target} returns the correct JSON keys`, () => { parameters.renderer = 'json'; @@ -27,7 +27,7 @@ describe(`(${target}) cash Reports`, () => { .query(parameters) .then(res => { expect(res).to.have.status(200); - expect(res).to.be.json; + expect(res).to.be.json; // eslint-disable-line expect(res.body).to.contain.all.keys(keys); }) .catch(helpers.handler); diff --git a/test/integration/reports/finance/cashflow.js b/test/integration/reports/finance/cashflow.js index b008f7ac8b..87cf25fb3d 100644 --- a/test/integration/reports/finance/cashflow.js +++ b/test/integration/reports/finance/cashflow.js @@ -21,4 +21,4 @@ const keys = [ 'totalPeriodColumn', ]; -describe(`test/integration (${target}) Rendering`, RenderingTests(target, keys, parameters)); +describe(`test/integration${target} Cash Flow Report`, RenderingTests(target, keys, parameters)); diff --git a/test/integration/reports/finance/cashflowByService.js b/test/integration/reports/finance/cashflowByService.js index 8c1bd97ac9..09bc287154 100644 --- a/test/integration/reports/finance/cashflowByService.js +++ b/test/integration/reports/finance/cashflowByService.js @@ -2,4 +2,4 @@ const RenderingTests = require('../rendering'); const target = '/reports/finance/cashflow/services'; const params = { cashboxId : 1, dateFrom : new Date('2010-01-01'), dateTo : new Date() }; -describe(`test/integration (${target}) Rendering`, RenderingTests(target, null, params)); +describe(`test/integration${target} Cash Flow Report`, RenderingTests(target, null, params)); diff --git a/test/integration/reports/finance/employee_standing.js b/test/integration/reports/finance/employee_standing.js index 0c3a2b155f..e64f436378 100644 --- a/test/integration/reports/finance/employee_standing.js +++ b/test/integration/reports/finance/employee_standing.js @@ -2,4 +2,4 @@ const RenderingTests = require('../rendering'); const target = '/reports/finance/employee_standing'; const params = { employee_uuid : '75e09694-65f2-45a1-a8a2-8b025003d793' }; -describe(`test/integration (${target}) Rendering`, RenderingTests(target, null, params)); +describe(`test/integration${target} Employee Standing Report`, RenderingTests(target, null, params)); diff --git a/test/integration/reports/finance/income_expense.js b/test/integration/reports/finance/income_expense.js index c1c8256076..16a674157a 100644 --- a/test/integration/reports/finance/income_expense.js +++ b/test/integration/reports/finance/income_expense.js @@ -4,7 +4,7 @@ const helpers = require('../../helpers'); const target = '/reports/finance/income_expense'; -describe.skip(`(${target}) Income Expense Reports`, () => { +describe.skip(`test/integration${target} Income Expense Report`, () => { const keys = [ 'incomes', 'expenses', 'dateFrom', 'dateTo', 'isEmpty', 'isLost', 'overallBalance', 'type_id', ]; @@ -16,7 +16,7 @@ describe.skip(`(${target}) Income Expense Reports`, () => { type : 1, }; - describe(`test/integration ${target} Rendering`, RenderingTests(target, null, parameters)); + describe(`Render Report`, RenderingTests(target, null, parameters)); it(`GET ${target} returns the correct JSON keys`, () => { parameters.renderer = 'json'; @@ -24,7 +24,7 @@ describe.skip(`(${target}) Income Expense Reports`, () => { .query(parameters) .then(res => { expect(res).to.have.status(200); - expect(res).to.be.json; + expect(res).to.be.json; // eslint-disable-line expect(res.body).to.contain.all.keys(keys); }) .catch(helpers.handler); diff --git a/test/integration/reports/finance/invoices.js b/test/integration/reports/finance/invoices.js index 8541a8a118..793b5b337c 100644 --- a/test/integration/reports/finance/invoices.js +++ b/test/integration/reports/finance/invoices.js @@ -1,4 +1,4 @@ const RenderingTests = require('../rendering'); const target = '/reports/finance/invoices'; -describe(`(${target}) Invoice Report`, RenderingTests(target)); +describe(`test/integration${target} Invoice Report`, RenderingTests(target)); diff --git a/test/integration/reports/finance/invoices.receipt.js b/test/integration/reports/finance/invoices.receipt.js index 28f1e5c0f5..5acaaed358 100644 --- a/test/integration/reports/finance/invoices.receipt.js +++ b/test/integration/reports/finance/invoices.receipt.js @@ -1,11 +1,11 @@ -/* global expect, chai, agent */ +/* global expect, agent */ const helpers = require('../../helpers'); const RenderingTests = require('../rendering'); const target = '/reports/finance/invoices/'; -describe(`(${target}) Invoice Receipt`, () => { +describe(`test/integration${target} Invoice Receipt`, () => { const validInvoice = '957e4e79-a6bb-4b4d-a8f7-c42152b2c2f6'; @@ -27,7 +27,7 @@ describe(`(${target}) Invoice Receipt`, () => { .query({ renderer : 'json' }) .then((result) => { expect(result).to.have.status(200); - expect(result).to.be.json; + expect(result).to.be.json; // eslint-disable-line expect(result.body.items).to.have.length(invoiceItemLength); }) .catch(helpers.handler); diff --git a/test/integration/reports/finance/open_debtors.js b/test/integration/reports/finance/open_debtors.js index ed489115b0..ccbc56446c 100644 --- a/test/integration/reports/finance/open_debtors.js +++ b/test/integration/reports/finance/open_debtors.js @@ -5,4 +5,4 @@ const options = { currencyId : 1, }; -describe(`test/integration (${target}) Rendering`, RenderingTests(target, null, options)); +describe(`test/integration${target} Open Debtors Report`, RenderingTests(target, null, options)); diff --git a/test/integration/reports/finance/vouchers.js b/test/integration/reports/finance/vouchers.js index 02386aed8d..0667a68a44 100644 --- a/test/integration/reports/finance/vouchers.js +++ b/test/integration/reports/finance/vouchers.js @@ -1,4 +1,4 @@ const RenderingTests = require('../rendering'); const target = '/reports/finance/vouchers'; -describe(`(${target}) Voucher Report`, RenderingTests(target)); +describe(`test/integration${target} Voucher Report`, RenderingTests(target)); diff --git a/test/integration/reports/finance/vouchers.receipt.js b/test/integration/reports/finance/vouchers.receipt.js index 6deb702a2a..4dc7f18430 100644 --- a/test/integration/reports/finance/vouchers.receipt.js +++ b/test/integration/reports/finance/vouchers.receipt.js @@ -1,11 +1,12 @@ -/* global expect, chai, agent */ +/* global expect, agent */ +/* eslint-disable no-unused-expressions */ const helpers = require('../../helpers'); const RenderingTests = require('../rendering'); const target = '/reports/finance/vouchers/'; -describe(`(${target}) Voucher Receipt`, function () { +describe(`test/integration${target} Voucher Receipt`, () => { const validVoucher = 'a5a5f950-a4c9-47f0-9a9a-2bfc3123e534'; @@ -14,21 +15,21 @@ describe(`(${target}) Voucher Receipt`, function () { suite(); // known data for requests and assertions - const invalidVoucher = 'unknown'; + const invalidVoucher = 'unknown'; - it(`GET ${target}:uuid should return JSON data for a valid voucher uuid`, function () { + it(`GET ${target}:uuid should return JSON data for a valid voucher uuid`, () => { return agent.get(target.concat(validVoucher)) .query({ renderer : 'json' }) - .then(function (result) { + .then((result) => { expect(result).to.have.status(200); expect(result).to.be.json; }) .catch(helpers.handler); }); - it(`GET ${target}:uuid should return not found for invalid uuid`, function () { + it(`GET ${target}:uuid should return not found for invalid uuid`, () => { return agent.get(target.concat(invalidVoucher)) - .then(function (result) { + .then((result) => { helpers.api.errored(result, 404); }) .catch(helpers.handler); diff --git a/test/integration/reports/inventory/items.js b/test/integration/reports/inventory/items.js index 79c4fd6c07..f69117bee8 100644 --- a/test/integration/reports/inventory/items.js +++ b/test/integration/reports/inventory/items.js @@ -1,4 +1,4 @@ const RenderingTests = require('../rendering'); const target = '/reports/inventory/items'; -describe(`(${target}) Inventory Report`, RenderingTests(target)); +describe(`test/integration${target} Inventory Report`, RenderingTests(target)); diff --git a/test/integration/reports/inventory/purchases.receipt.js b/test/integration/reports/inventory/purchases.receipt.js index a623e93f78..99cf0b893b 100644 --- a/test/integration/reports/inventory/purchases.receipt.js +++ b/test/integration/reports/inventory/purchases.receipt.js @@ -1,4 +1,4 @@ const RenderingTests = require('../rendering'); const target = '/reports/inventory/purchases/'; const purchaseUuid = 'e07ceadc-82cf-4ae2-958a-6f6a78c87588'; -describe(`(${target}) Purchase Order Receipt`, RenderingTests(target + purchaseUuid)); +describe(`test/integration${target} Purchase Order Receipt`, RenderingTests(target + purchaseUuid)); diff --git a/test/integration/reports/medical/card.js b/test/integration/reports/medical/card.js index 8c2fbaa7b3..07e47f8aff 100644 --- a/test/integration/reports/medical/card.js +++ b/test/integration/reports/medical/card.js @@ -2,4 +2,4 @@ const RenderingTests = require('../rendering'); const patientUuid = '274c51ae-efcc-4238-98c6-f402bfb39866'; const target = '/reports/medical/patients/'; -describe(`(${target}:uuid) Patient Card`, RenderingTests(target + patientUuid)); +describe(`test/integration/${target}:uuid Patient Card`, RenderingTests(target + patientUuid)); diff --git a/test/integration/reports/medical/registrations.js b/test/integration/reports/medical/registrations.js index 0d7ce1c1f1..e89c648a55 100644 --- a/test/integration/reports/medical/registrations.js +++ b/test/integration/reports/medical/registrations.js @@ -1,4 +1,5 @@ const RenderingTests = require('../rendering'); + const target = '/reports/medical/patients'; -describe(`(${target}) Patient Registrations`, RenderingTests(target)); +describe(`test/integration${target} Patients Registration Report`, RenderingTests(target)); diff --git a/test/integration/role.js b/test/integration/role.js index fbf7f7984d..5cc7e8e135 100644 --- a/test/integration/role.js +++ b/test/integration/role.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /roles API endpoint + * The /roles API * - * This test suite implements full CRUD on the /roles HTTP API endpoint. + * This test suite implements full CRUD on the /roles API. */ -describe('test/integration (/roles) The roles API endpoint', () => { +describe('test/integration/roles The roles API', () => { // role we will add during this test suite. const newRole = { diff --git a/test/integration/rubrics.js b/test/integration/rubrics.js index bc4678cbb4..9102f644f8 100644 --- a/test/integration/rubrics.js +++ b/test/integration/rubrics.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /payroll/rubrics API endpoint + * The /payroll/rubrics API * - * This test suite implements full CRUD on the /payroll/rubrics HTTP API endpoint. + * This test suite implements full CRUD on the /payroll/rubrics API. */ -describe('test/integration (/payroll/rubrics) The /payroll/rubrics API endpoint', () => { +describe('test/integration/rubrics The /payroll/rubrics API', () => { // Rubric we will add during this test suite. const rubric = { diff --git a/test/integration/services.js b/test/integration/services.js index 7aaae88181..26f6b3d4cc 100644 --- a/test/integration/services.js +++ b/test/integration/services.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); -describe('test/integration (/services) The Service API', () => { +describe('test/integration/services The Services API', () => { const newService = { enterprise_id : 1, name : 'tested Service', diff --git a/test/integration/shipment/shipmentContainerTypes.js b/test/integration/shipment/shipmentContainerTypes.js index a948373df4..af13c76ba7 100644 --- a/test/integration/shipment/shipmentContainerTypes.js +++ b/test/integration/shipment/shipmentContainerTypes.js @@ -3,8 +3,8 @@ const helpers = require('../helpers'); -// the /shipment_container_types API endpoint -describe('test/integration (/shipment_container_types) the shipments API', () => { +// the /shipment_container_types API +describe('test/integration/shipmentContainerTypes The Shipment Container API', () => { it('/shipment_container_types', () => { return agent.get('/shipment_container_types') diff --git a/test/integration/staffingIndices.js b/test/integration/staffingIndices.js index 0913985d00..439cbc3867 100644 --- a/test/integration/staffingIndices.js +++ b/test/integration/staffingIndices.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /staffing_indices API endpoint + * The /staffing_indices API * - * This test suite implements full CRUD on the /staffing_indices HTTP API endpoint. + * This test suite implements full CRUD on the /staffing_indices API. */ -describe('test/integration (/staffing_indices) The staffing indices API endpoint', () => { +describe('test/integration/staffingIndices The staffing indices API', () => { const newIndice = { uuid : 'd2f7ef71-6f3e-44bd-8056-378c5ca26e20', grade_uuid : '9EE06E4A7B5948E6812CC0F8A00CF7D3', diff --git a/test/integration/stock/asset_scans.js b/test/integration/stock/asset_scans.js index a8d52bf88b..7fb7327ad3 100644 --- a/test/integration/stock/asset_scans.js +++ b/test/integration/stock/asset_scans.js @@ -10,7 +10,7 @@ const newAssetScan1 = { notes : 'Test scan 1', }; -describe('test/integration (/asset/scan) The Stock Asset Scan HTTP API', () => { +describe('test/integration/asset_scans The Stock Asset Scan API', () => { const variables = {}; const keys = [ 'asset_label', 'asset_uuid', 'assigned_to_name', 'condition_id', diff --git a/test/integration/stock/assign.js b/test/integration/stock/assign.js index 0c54b2aec0..3c89bb8e11 100644 --- a/test/integration/stock/assign.js +++ b/test/integration/stock/assign.js @@ -3,7 +3,7 @@ const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/stock/assign) The Stock Assign HTTP API', () => { +describe('test/integration/stock/assign The Stock Assign API', () => { const variables = {}; const keys = [ 'uuid', 'lot_uuid', 'depot_uuid', 'entity_uuid', diff --git a/test/integration/stock/import.js b/test/integration/stock/import.js index d3fecabd2d..66eddd37f7 100644 --- a/test/integration/stock/import.js +++ b/test/integration/stock/import.js @@ -4,7 +4,7 @@ const fs = require('fs'); const helpers = require('../helpers'); const shared = require('./shared'); -describe.skip('(/stock/import) The stock import http API', () => { +describe.skip('test/integration/stock/import The stock import API', () => { const templateCsvHeader = 'inventory_group_name,inventory_code,inventory_text,inventory_type,inventory_unit,inventory_unit_price,inventory_cmm,stock_lot_label,stock_lot_quantity,stock_lot_expiration'; const templateCsvContent = '"Comprimé", "00001", "Quinine sulfate 500mg", "article", "comprimé", "0.02", "300", "QNN2020", "24000", "2020-12-31"'; diff --git a/test/integration/stock/lots.js b/test/integration/stock/lots.js index e88a0491be..ee3ad82ce0 100644 --- a/test/integration/stock/lots.js +++ b/test/integration/stock/lots.js @@ -4,7 +4,7 @@ const moment = require('moment'); const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/lots/) The lots HTTP API', () => { +describe('test/integration/stock/lots The stock lots API', () => { it('GET /lots/:uuid returns details of a lot', () => { return agent.get(`/lots/${shared.lotQuinineUuid}`) .then((res) => { diff --git a/test/integration/stock/required_inventory_scans.js b/test/integration/stock/required_inventory_scans.js index e2400d4bde..a28db82e16 100644 --- a/test/integration/stock/required_inventory_scans.js +++ b/test/integration/stock/required_inventory_scans.js @@ -14,7 +14,7 @@ const newRequiredInventoryScan1 = { reference_number : null, }; -describe('test/integration (/inventory/required/scan) The Stock Asset Inventory Scans HTTP API', () => { +describe('test/integration/stock/required_inventory_scans The Stock Asset Inventory Scans API', () => { const variables = {}; const keys = ['uuid', 'title', 'description', 'start_date', 'end_date', 'is_asset', 'reference_number', 'created_at', 'updated_at', diff --git a/test/integration/stock/requisition.js b/test/integration/stock/requisition.js index 53579f6763..1dcaa49310 100644 --- a/test/integration/stock/requisition.js +++ b/test/integration/stock/requisition.js @@ -3,7 +3,7 @@ const moment = require('moment'); const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/stock/requisition) The Stock Assign HTTP API', () => { +describe('test/integration/stock/requisition The Stock Requisition API', () => { const variables = {}; const keys = [ 'uuid', 'requestor_uuid', 'requestor_type_id', 'description', 'date', diff --git a/test/integration/stock/satisfication.js b/test/integration/stock/satisfication.js index 610fe92377..2461247db4 100644 --- a/test/integration/stock/satisfication.js +++ b/test/integration/stock/satisfication.js @@ -2,7 +2,7 @@ const helpers = require('../helpers'); -describe('Test the stock statification rate REST API', () => { +describe('test/integration/stock Test the stock satisfaction rate REST API', () => { it('GET /stock/satisfication_rate', () => { const options = { diff --git a/test/integration/stock/stock.js b/test/integration/stock/stock.js index d6a26ebac7..b1efb65a41 100644 --- a/test/integration/stock/stock.js +++ b/test/integration/stock/stock.js @@ -3,7 +3,7 @@ const moment = require('moment'); const helpers = require('../helpers'); const shared = require('./shared'); -describe('test/integration (/stock/) The Stock HTTP API', () => { +describe('test/integration/stock/stock The Stock API', () => { // create new stock lots it('POST /stock/lots create a new stock lots entry', async () => { diff --git a/test/integration/stock/stockSettings.js b/test/integration/stock/stockSettings.js index 636bd22390..2a8c22a667 100644 --- a/test/integration/stock/stockSettings.js +++ b/test/integration/stock/stockSettings.js @@ -2,10 +2,10 @@ const helpers = require('../helpers'); /* - * The /stock/setting API endpoint - * This test suite implements the Read-Update functions on the /stock_setting HTTP API endpoint. + * The /stock/setting API + * This test suite implements the Read-Update functions on the /stock_setting API. */ -describe('test/integration (/stock/setting) Stock Settings API', () => { +describe('test/integration/stock/stockSetting Stock Settings API', () => { const defaultEnterpriseId = 1; const defaultValuemonthAverageConsumption = 6; diff --git a/test/integration/subsidy.js b/test/integration/subsidy.js index 73317d8427..7193bb9712 100644 --- a/test/integration/subsidy.js +++ b/test/integration/subsidy.js @@ -5,7 +5,7 @@ const helpers = require('./helpers'); // FIXME(@jniles) - make a subventions/subsidy account -describe('test/integration (/subsidies) Subsidies', () => { +describe('test/integration/subsidy Subsidies API', () => { const newSubsidy = { account_id : 211, // 60310012 - Achat Médicaments en crème label : 'tested subsidy', diff --git a/test/integration/suppliers.js b/test/integration/suppliers.js index 4377451f5c..6c340945bf 100644 --- a/test/integration/suppliers.js +++ b/test/integration/suppliers.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /supplier API endpoint + * The /supplier API * - * This test suite implements full CRUD on the /supplier HTTP API endpoint. + * This test suite implements full CRUD on the /supplier API. */ -describe('test/integration (/suppliers) The supplier API endpoint', () => { +describe('test/integration/suppliers The supplier API', () => { // supplier we will add during this test suite. const supplier = { diff --git a/test/integration/surveyForm.js b/test/integration/surveyForm.js index 01bec42686..5a06418aa5 100644 --- a/test/integration/surveyForm.js +++ b/test/integration/surveyForm.js @@ -1,7 +1,7 @@ /* global expect, agent */ const helpers = require('./helpers'); -describe('test/integration (/survey_form) Survey Form', () => { +describe('test/integration/surveyForm Survey Form API', () => { const numListElement = 17; const formElement = { diff --git a/test/integration/system.js b/test/integration/system.js index 57792fcce5..064318094a 100644 --- a/test/integration/system.js +++ b/test/integration/system.js @@ -2,7 +2,7 @@ const helpers = require('./helpers'); -describe('test/integration (/system) System Information', () => { +describe('test/integration/system System Information API', () => { it('GET /system/information downloads the system architecture', () => { return agent.get('/system/information') .then((res) => { diff --git a/test/integration/tags.js b/test/integration/tags.js index 64d95515e4..6a894b23a2 100644 --- a/test/integration/tags.js +++ b/test/integration/tags.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /tags API endpoint + * The /tags API * - * This test suite implements full CRUD on the /projects HTTP API endpoint. + * This test suite implements full CRUD on the /projects API. */ -describe('test/integration (/tags) The tags API endpoint', () => { +describe('test/integration/tags The tags API', () => { // project we will add during this test suite. const uuid = '5b7dd0d692734955a703126fbd504b61'; const uuid2 = '7b7dd0d692734955a703126fbd504b61'; diff --git a/test/integration/taxIpr.js b/test/integration/taxIpr.js index 6ec5742201..fd7bba7055 100644 --- a/test/integration/taxIpr.js +++ b/test/integration/taxIpr.js @@ -3,11 +3,11 @@ const helpers = require('./helpers'); /* - * The /ipr_tax API endpoint + * The /ipr_tax API * - * This test suite implements full CRUD on the /ipr_tax HTTP API endpoint. + * This test suite implements full CRUD on the /ipr_tax API. */ -describe('test/integration (/ipr_tax) The /ipr_tax API endpoint', () => { +describe('test/integration/taxIpr The /ipr_tax API', () => { // IPR TAX we will add during this test suite. const iprTax = { diff --git a/test/integration/titles.js b/test/integration/titles.js index 0b8ec1535f..1c6f7a60db 100644 --- a/test/integration/titles.js +++ b/test/integration/titles.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /titles API endpoint + * The /titles API * - * This test suite implements full CRUD on the /titles HTTP API endpoint. + * This test suite implements full CRUD on the /titles API. */ -describe('test/integration (/titles) The job titles API endpoint', () => { +describe('test/integration/titles The job titles API', () => { // Job titles we will add during this test suite. const jobTitle = { diff --git a/test/integration/transactionType.js b/test/integration/transactionType.js index 06585ad57e..beba84b4c6 100644 --- a/test/integration/transactionType.js +++ b/test/integration/transactionType.js @@ -2,7 +2,7 @@ const helpers = require('./helpers'); -describe('test/integration (/transaction_type) Transaction Type API', () => { +describe('test/integration/transactionType Transaction Type API', () => { // default number of transaction type (TT) const TT_DEFAULT = 25; diff --git a/test/integration/trialBalance.js b/test/integration/trialBalance.js index 0bb442b241..0053eb7f96 100644 --- a/test/integration/trialBalance.js +++ b/test/integration/trialBalance.js @@ -3,9 +3,9 @@ const helpers = require('./helpers'); /* - * The /trial_balance API endpoint + * The /trial_balance API */ -describe('test/integration (/journal/trialbalance) API endpoint', () => { +describe('test/integration/trialbalance The /journal/trialbalance API', () => { const GOOD_TXNS = ['a5a5f950-a4c9-47f0-9a9a-2bfc3123e534']; // TPA1 const EMPTY_TXNS = []; const ERROR_TXNS = ['3688e9ce-85ea-4b5c-9144-688177edcb63']; // TRANS5 diff --git a/test/integration/users.js b/test/integration/users.js index 9102064314..0c90cadb1f 100644 --- a/test/integration/users.js +++ b/test/integration/users.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /users API endpoint + * The /users API * - * This test suite implements full CRUD on the /users HTTP API endpoint. + * This test suite implements full CRUD on the /users API. */ -describe('test/integration (/users) Users and Permissions', () => { +describe('test/integration/users Users and Permissions', () => { const newUser = { username : 'newUser', password : 'newUser', diff --git a/test/integration/vouchers.js b/test/integration/vouchers.js index 2cdd6cb591..6521cb899e 100644 --- a/test/integration/vouchers.js +++ b/test/integration/vouchers.js @@ -7,11 +7,11 @@ const helpers = require('./helpers'); const genuuid = () => uuid.v4().toUpperCase().replace(/-/g, ''); /* - * The /vouchers API endpoint + * The /vouchers API * * This test suit is about the vouchers table */ -describe('test/integration (/vouchers) The vouchers HTTP endpoint', () => { +describe('test/integration/vouchers The vouchers HTTP endpoint', () => { const date = new Date(); const vUuid = 'B140C1446CA847B099BA94732CF6EFDE'; diff --git a/test/integration/ward/bed.js b/test/integration/ward/bed.js index 9740ba28a2..f1c92d3571 100644 --- a/test/integration/ward/bed.js +++ b/test/integration/ward/bed.js @@ -4,11 +4,11 @@ const helpers = require('../helpers'); const shared = require('./shared'); /* - * The /beds API endpoint + * The /beds API * - * This test suite implements full CRUD on the /beds HTTP API endpoint. + * This test suite implements full CRUD on the /beds API. */ -describe('test/integration (/beds) The bed API endpoint', () => { +describe('test/integration/war/beds The Ward Bed API', () => { // beds we will add during this test suite. const { bed1, bed2 } = shared; let id1; diff --git a/test/integration/ward/room.js b/test/integration/ward/room.js index 8e35ca3fb6..3282600844 100644 --- a/test/integration/ward/room.js +++ b/test/integration/ward/room.js @@ -4,11 +4,11 @@ const helpers = require('../helpers'); const shared = require('./shared'); /* - * The /rooms API endpoint + * The /rooms API * - * This test suite implements full CRUD on the /rooms HTTP API endpoint. + * This test suite implements full CRUD on the /rooms API. */ -describe('test/integration (/rooms) The room API endpoint', () => { +describe('test/integration/ward/rooms The Ward Room API', () => { const EXISTING_ROOMS_IN_DB = 2; // rooms we will add during this test suite. const room1 = { diff --git a/test/integration/ward/ward.js b/test/integration/ward/ward.js index 8466e67a23..f971605509 100644 --- a/test/integration/ward/ward.js +++ b/test/integration/ward/ward.js @@ -2,11 +2,11 @@ const helpers = require('../helpers'); /* - * The /wards API endpoint + * The /wards API * - * This test suite implements full CRUD on the /wards HTTP API endpoint. + * This test suite implements full CRUD on the /wards API. */ -describe('test/integration (/wards) The ward API endpoint', () => { +describe('test/integration/ward/wards The ward API', () => { const EXISTING_WARDS_IN_DB = 2; // wards we will add during this test suite. const uuid = '5b7dd0d6-9273-4955-a703-126fbd504b61'; diff --git a/test/integration/weekEndConfig.js b/test/integration/weekEndConfig.js index 81098bbcb0..e424fc4435 100644 --- a/test/integration/weekEndConfig.js +++ b/test/integration/weekEndConfig.js @@ -4,11 +4,11 @@ const helpers = require('./helpers'); /* - * The /payroll/weekend_configuration API endpoint + * The /payroll/weekend_configuration API * - * This test suite implements full CRUD on the /payroll/weekend_configuration HTTP API endpoint. + * This test suite implements full CRUD on the /payroll/weekend_configuration API. */ -describe('test/integration (/payroll/weekend_configuration) The /payroll/weekend_configuration API endpoint', () => { +describe('test/integration/weekEndConfig The /payroll/weekend_configuration API', () => { const weekEndConfig = { label : 'Configuration Week end 2013', daysChecked : [0, 5, 6], diff --git a/test/server-unit/bhMoment.spec.js b/test/server-unit/bhMoment.spec.js index 587ea6dcca..026ff462fc 100644 --- a/test/server-unit/bhMoment.spec.js +++ b/test/server-unit/bhMoment.spec.js @@ -19,7 +19,7 @@ function evaluate(startDate, endDate, dateBhMoment) { expect(formated).to.deep.equal(expected); } -describe('test/server-unit bhMoment', () => { +describe('test/sever-unit/bhMoment', () => { it('#day() should return the start and stop dates of the given date', () => { const startDate = '2019-08-24'; diff --git a/test/server-unit/cron/addDynamicDatesOptions.spec.js b/test/server-unit/cron/addDynamicDatesOptions.spec.js index 3714396b30..54a2066110 100644 --- a/test/server-unit/cron/addDynamicDatesOptions.spec.js +++ b/test/server-unit/cron/addDynamicDatesOptions.spec.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const rewire = require('@ima-worldhealth/rewire'); -describe('test/server-unit/cron/cronEmailReport', () => { +describe('test/sever-unit/cron/addDynamicDatesOptions', () => { let addDynamicDatesOptions; const DAILY = 1; @@ -9,75 +9,73 @@ describe('test/server-unit/cron/cronEmailReport', () => { const MONTHLY = 3; const YEARLY = 4; - describe('#addDynamicDatesOptions', () => { - before(() => { - const cronEmailReport = rewire('../../../server/controllers/admin/cronEmailReport'); - addDynamicDatesOptions = cronEmailReport.__get__('addDynamicDatesOptions'); - }); + before(() => { + const cronEmailReport = rewire('../../../server/controllers/admin/cronEmailReport'); + addDynamicDatesOptions = cronEmailReport.__get__('addDynamicDatesOptions'); + }); - it('#addDynamicDatesOptions() does nothing if cronId is unrecognized', () => { - const options = { id : 1, label : 'Some ole options' }; - const processed = addDynamicDatesOptions(123, options); - expect(processed).to.deep.equal(options); - }); + it('#addDynamicDatesOptions() does nothing if cronId is unrecognized', () => { + const options = { id : 1, label : 'Some ole options' }; + const processed = addDynamicDatesOptions(123, options); + expect(processed).to.deep.equal(options); + }); - it('#addDynamicDatesOptions() sets the DAILY schedule to the current day', () => { - const options = { id : 1, label : 'A schedule' }; - const processed = addDynamicDatesOptions(DAILY, options); - expect(processed.dateFrom).to.be.a('object'); - expect(processed.dateTo).to.be.a('object'); + it('#addDynamicDatesOptions() sets the DAILY schedule to the current day', () => { + const options = { id : 1, label : 'A schedule' }; + const processed = addDynamicDatesOptions(DAILY, options); + expect(processed.dateFrom).to.be.a('object'); + expect(processed.dateTo).to.be.a('object'); - const today = new Date().toDateString(); + const today = new Date().toDateString(); - expect(processed.dateFrom.toDate().toDateString()).to.equal(today); - expect(processed.dateTo.toDate().toDateString()).to.equal(today); - }); + expect(processed.dateFrom.toDate().toDateString()).to.equal(today); + expect(processed.dateTo.toDate().toDateString()).to.equal(today); + }); - it('#addDynamicDatesOptions() sets the WEEKLY schedule to the current week', () => { - const options = { id : 1, label : 'A schedule' }; + it('#addDynamicDatesOptions() sets the WEEKLY schedule to the current week', () => { + const options = { id : 1, label : 'A schedule' }; - const { dateFrom, dateTo } = addDynamicDatesOptions(WEEKLY, options); - expect(dateFrom).to.be.a('object'); - expect(dateTo).to.be.a('object'); + const { dateFrom, dateTo } = addDynamicDatesOptions(WEEKLY, options); + expect(dateFrom).to.be.a('object'); + expect(dateTo).to.be.a('object'); - const today = new Date(); + // const today = new Date(); - expect(dateFrom.toDate().getDay()).to.equal(0); - expect(dateTo.toDate().getDay()).to.equal(6); - }); + expect(dateFrom.toDate().getDay()).to.equal(0); + expect(dateTo.toDate().getDay()).to.equal(6); + }); - it('#addDynamicDatesOptions() sets the MONTHLY schedule to the current month', () => { - const options = { id : 1, label : 'A schedule' }; + it('#addDynamicDatesOptions() sets the MONTHLY schedule to the current month', () => { + const options = { id : 1, label : 'A schedule' }; - const { dateFrom, dateTo } = addDynamicDatesOptions(MONTHLY, options); - expect(dateFrom).to.be.a('object'); - expect(dateTo).to.be.a('object'); + const { dateFrom, dateTo } = addDynamicDatesOptions(MONTHLY, options); + expect(dateFrom).to.be.a('object'); + expect(dateTo).to.be.a('object'); - const today = new Date(); - expect(dateFrom.toDate().getMonth()).to.equal(today.getMonth()); - expect(dateTo.toDate().getMonth()).to.equal(today.getMonth()); + const today = new Date(); + expect(dateFrom.toDate().getMonth()).to.equal(today.getMonth()); + expect(dateTo.toDate().getMonth()).to.equal(today.getMonth()); - expect(dateFrom.toDate().getDate()).to.equal(1); - expect(dateTo.toDate().getDate()).to.be.at.least(28); - }); + expect(dateFrom.toDate().getDate()).to.equal(1); + expect(dateTo.toDate().getDate()).to.be.at.least(28); + }); - it('#addDynamicDatesOptions() sets the YEARLY schedule to the current year', () => { - const options = { id : 1, label : 'A schedule' }; + it('#addDynamicDatesOptions() sets the YEARLY schedule to the current year', () => { + const options = { id : 1, label : 'A schedule' }; - const { dateFrom, dateTo } = addDynamicDatesOptions(YEARLY, options); - expect(dateFrom).to.be.a('object'); - expect(dateTo).to.be.a('object'); + const { dateFrom, dateTo } = addDynamicDatesOptions(YEARLY, options); + expect(dateFrom).to.be.a('object'); + expect(dateTo).to.be.a('object'); - const today = new Date(); - expect(dateFrom.toDate().getFullYear()).to.equal(today.getFullYear()); - expect(dateTo.toDate().getFullYear()).to.equal(today.getFullYear()); + const today = new Date(); + expect(dateFrom.toDate().getFullYear()).to.equal(today.getFullYear()); + expect(dateTo.toDate().getFullYear()).to.equal(today.getFullYear()); - expect(dateFrom.toDate().getMonth()).to.equal(0); - expect(dateTo.toDate().getMonth()).to.equal(11); + expect(dateFrom.toDate().getMonth()).to.equal(0); + expect(dateTo.toDate().getMonth()).to.equal(11); - expect(dateFrom.toDate().getDate()).to.equal(1); - expect(dateTo.toDate().getDate()).to.equal(31); + expect(dateFrom.toDate().getDate()).to.equal(1); + expect(dateTo.toDate().getDate()).to.equal(31); - }); }); }); diff --git a/test/server-unit/cron/timers.spec.js b/test/server-unit/cron/timers.spec.js index 1d807951e8..a25ce250e9 100644 --- a/test/server-unit/cron/timers.spec.js +++ b/test/server-unit/cron/timers.spec.js @@ -4,87 +4,88 @@ const chai = require('chai'); const sinon = require('sinon'); const rewire = require('@ima-worldhealth/rewire'); -describe('test/server-unit/cron/cronEmailReport', () => { - describe('cron timers', () => { - let CURRENT_JOBS; - let addJob; - let removeJob; - // this crontab fires once a minute - const CRONTAB = '* * * * *'; +describe('test/sever-unit/cron/timers', () => { - let clock; + let CURRENT_JOBS; + let addJob; + let removeJob; - before(() => { - const cronEmailReport = rewire('../../../server/controllers/admin/cronEmailReport'); - addJob = cronEmailReport.__get__('addJob'); - removeJob = cronEmailReport.__get__('removeJob'); - CURRENT_JOBS = cronEmailReport.__get__('CURRENT_JOBS'); + // this crontab fires once a minute + const CRONTAB = '* * * * *'; - // use fake timers to emulate time passing - clock = sinon.useFakeTimers(); - }); + let clock; - after(() => { - clock.restore(); - }); + before(() => { + const cronEmailReport = rewire('../../../server/controllers/admin/cronEmailReport'); + addJob = cronEmailReport.__get__('addJob'); + removeJob = cronEmailReport.__get__('removeJob'); + CURRENT_JOBS = cronEmailReport.__get__('CURRENT_JOBS'); - it('#addJob() creates a cron job', () => { - const cb = chai.spy(() => {}); - const job = addJob(CRONTAB, cb, {}); + // use fake timers to emulate time passing + clock = sinon.useFakeTimers(); + }); + + after(() => { + clock.restore(); + }); + + it('#addJob() creates a cron job', () => { + const cb = chai.spy(() => {}); + const job = addJob(CRONTAB, cb, {}); - expect(job).to.be.an('object'); - expect(job).to.have.any.keys('running'); - expect(job.running).to.equal(true); - }); + expect(job).to.be.an('object'); + expect(job).to.have.any.keys('running'); + expect(job.running).to.equal(true); + }); - it('#addJob() will start the created cron job', () => { - const cb = chai.spy(() => {}); - const job = addJob(CRONTAB, cb, {}); + it('#addJob() will start the created cron job', () => { + const cb = chai.spy(() => {}); + const job = addJob(CRONTAB, cb, {}); - // tick ahead a minute and a second - clock.tick(61 * 1000); + // tick ahead a minute and a second + clock.tick(61 * 1000); - expect(cb).to.have.been.called.exactly(1); - expect(job.running).to.equal(true); - }); + expect(cb).to.have.been.called.exactly(1); + expect(job.running).to.equal(true); + }); - it('#removeJob() removes a cron job by its identifier', () => { - // mock a cron job - const stop = chai.spy(() => {}); - const id = 3; - const job = { id, job : { stop } }; - CURRENT_JOBS.set(id, job); + it('#removeJob() removes a cron job by its identifier', () => { + // mock a cron job + const stop = chai.spy(() => {}); + const id = 3; + const job = { id, job : { stop } }; + CURRENT_JOBS.set(id, job); - expect(CURRENT_JOBS.size).to.equal(1); + expect(CURRENT_JOBS.size).to.equal(1); - removeJob(id); + removeJob(id); - expect(stop).to.have.been.called(); - expect(CURRENT_JOBS.size).to.equal(0); - }); + expect(stop).to.have.been.called(); + expect(CURRENT_JOBS.size).to.equal(0); + }); - it('#removeJob() stops a running cron job added by #addJob()', () => { - const cb = chai.spy(() => {}); - const job = addJob(CRONTAB, cb, {}); - const id = 7; - CURRENT_JOBS.set(id, { id, job }); + it('#removeJob() stops a running cron job added by #addJob()', () => { + const cb = chai.spy(() => {}); + const job = addJob(CRONTAB, cb, {}); + const id = 7; + CURRENT_JOBS.set(id, { id, job }); - expect(CURRENT_JOBS.size).to.equal(1); + expect(CURRENT_JOBS.size).to.equal(1); - // tick ahead a minute and a second - clock.tick(61 * 1000); + // tick ahead a minute and a second + clock.tick(61 * 1000); - expect(cb).to.have.been.called.exactly(1); - expect(job.running).to.equal(true); + expect(cb).to.have.been.called.exactly(1); + expect(job.running).to.equal(true); - removeJob(id); + removeJob(id); - // tick ahead a minute and a second - clock.tick(61 * 1000); + // tick ahead a minute and a second + clock.tick(61 * 1000); - // the schedule should not have been called again - expect(cb).to.have.been.called.exactly(1); - expect(job.running).to.equal(false); - }); + // the schedule should not have been called again + expect(cb).to.have.been.called.exactly(1); + expect(job.running).to.equal(false); }); + }); diff --git a/test/server-unit/csv.spec.js b/test/server-unit/csv.spec.js index cbf2ce8b07..4628091fcb 100644 --- a/test/server-unit/csv.spec.js +++ b/test/server-unit/csv.spec.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const csv = require('../../server/lib/renderers/csv'); -describe('test/server-unit renderers/csv.js', () => { +describe('test/sever-unit/csv', () => { const data = [ { id : 1, name : 'jniles', score : 12 }, diff --git a/test/server-unit/dates.spec.js b/test/server-unit/dates.spec.js index 3e6e8d2626..b42a404fff 100644 --- a/test/server-unit/dates.spec.js +++ b/test/server-unit/dates.spec.js @@ -1,7 +1,7 @@ const { expect } = require('chai'); const dates = require('../../server/lib/template/helpers/dates'); -describe('test/server-unit dates', () => { +describe('test/sever-unit/dates', () => { it('#date() should format a date is "DD/MM/YYYY" format.', () => { const date = new Date('2015-03-25 12:00:00'); diff --git a/test/server-unit/db.spec.js b/test/server-unit/db.spec.js index f6e3801ad6..8c58cdde82 100644 --- a/test/server-unit/db.spec.js +++ b/test/server-unit/db.spec.js @@ -1,7 +1,7 @@ /* eslint global-require:off */ const { expect } = require('chai'); -describe('test/server-unit/lib/db/index.js', () => { +describe('test/sever-unit/db', () => { let db; before(() => { diff --git a/test/server-unit/filter.spec.js b/test/server-unit/filter.spec.js index c478724650..6f5109b4c8 100644 --- a/test/server-unit/filter.spec.js +++ b/test/server-unit/filter.spec.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const Filter = require('../../server/lib/filter'); -describe('test/server-unit/filter.js', () => { +describe('test/sever-unit/filter', () => { const object1 = { id : 1, name : 'Unit Test', diff --git a/test/server-unit/handlebars.spec.js b/test/server-unit/handlebars.spec.js index 66c87b53a2..80c3111f66 100644 --- a/test/server-unit/handlebars.spec.js +++ b/test/server-unit/handlebars.spec.js @@ -22,7 +22,7 @@ const equalItem = 'developer'; const gtItem = 17; const ltItem = 7; -describe('test/server-unit/handlebars renderer', () => { +describe('test/sever-unit/handlebars', () => { it('#handlebars.render() renders correctly template with corresponding data', async () => { let result; diff --git a/test/server-unit/mysql_functions.spec.js b/test/server-unit/mysql_functions.spec.js index 3dc70a58ab..c8577a7e36 100644 --- a/test/server-unit/mysql_functions.spec.js +++ b/test/server-unit/mysql_functions.spec.js @@ -1,7 +1,7 @@ /* eslint global-require:off */ const { expect } = require('chai'); -describe('test/server-unit/lib/db/function.sql.js', () => { +describe('test/sever-unit/mysql_functions', () => { let db; before(() => { diff --git a/test/server-unit/numberToText.spec.js b/test/server-unit/numberToText.spec.js index 6ab41a43dd..4e1c763d38 100644 --- a/test/server-unit/numberToText.spec.js +++ b/test/server-unit/numberToText.spec.js @@ -6,7 +6,7 @@ const util = require('../../server/lib/util'); const { loadDictionary } = util; -describe('test/server-unit/NumberToText convert number to text', () => { +describe('test/sever-unit/numberToText', () => { // use local dictionary before(() => { diff --git a/test/server-unit/payroll/assignCostCenter.spec.js b/test/server-unit/payroll/assignCostCenter.spec.js index 7c3bbc169b..3f3d22fcb8 100644 --- a/test/server-unit/payroll/assignCostCenter.spec.js +++ b/test/server-unit/payroll/assignCostCenter.spec.js @@ -3,7 +3,7 @@ const chai = require('chai'); const { expect } = chai; const CostCenter = require('../../../server/controllers/finance/cost_center'); -describe('test/server-unit/payroll/payroll/multiplePayroll/datelogic.js', () => { +describe('test/sever-unit/payroll/assignCostCenters', () => { const accountsCostCenter = [ { account_id : 215, diff --git a/test/server-unit/payroll/datelogic.spec.js b/test/server-unit/payroll/datelogic.spec.js index b741af6f1e..f2055454a2 100644 --- a/test/server-unit/payroll/datelogic.spec.js +++ b/test/server-unit/payroll/datelogic.spec.js @@ -4,7 +4,7 @@ chai.use(require('chai-datetime')); const { expect } = chai; const logic = require('../../../server/controllers/payroll/multiplePayroll/datelogic'); -describe('test/server-unit/payroll/payroll/multiplePayroll/datelogic.js', () => { +describe('test/sever-unit/payroll/datelogic', () => { it('#isDateOnWeekend() returns true if date in array passed in', () => { const date = new Date(2019, 1, 2); // this is a Sunday (index 6) diff --git a/test/server-unit/pdf.spec.js b/test/server-unit/pdf.spec.js index 756911c4a0..7ee6cda206 100644 --- a/test/server-unit/pdf.spec.js +++ b/test/server-unit/pdf.spec.js @@ -32,10 +32,11 @@ const data = { const fixturesPath = path.resolve('test/fixtures'); -describe('test/server-unit/PDF renderer', () => { +describe('test/sever-unit/pdf', function () { // eslint-disable-line + this.timeout(5000); it('#pdf.render() renders a valid PDF file', async () => { - // ??? this.timeout(5000); + const htmlString = await fs.readFile(template, 'utf8'); const result = await pdf.render(data, htmlString, {}); const hasValidVersion = hasValidPdfVersion(result.toString()); @@ -44,7 +45,6 @@ describe('test/server-unit/PDF renderer', () => { }); it('#pdf.render() templates in a barcode to the pdf file', async () => { - // this.timeout(5000); const tmpl = await fs.readFile(path.join(fixturesPath, templateWithBarcode), 'utf8'); // since we removed the actual html templating, this is a poor man's templating diff --git a/test/server-unit/purchases/purchases.spec.js b/test/server-unit/purchases/purchases.spec.js index 02b83a5b2b..c327ffb2c6 100644 --- a/test/server-unit/purchases/purchases.spec.js +++ b/test/server-unit/purchases/purchases.spec.js @@ -2,7 +2,7 @@ const { expect } = require('chai'); const uuid = require('uuid').v4; -describe('test/server-unit/purchases/Purchase Orders', () => { +describe('test/sever-unit/purchases/purchases', () => { let db; before(() => { diff --git a/test/server-unit/stepdown.spec.js b/test/server-unit/stepdown.spec.js index 80a3f1dc11..a4d60f7629 100644 --- a/test/server-unit/stepdown.spec.js +++ b/test/server-unit/stepdown.spec.js @@ -3,9 +3,10 @@ const { expect } = require('chai'); const dataset = require('./stepdown.data'); -describe('test/server-unit/lib/db/stepdown.js', () => { +describe('test/sever-unit/stepdown', () => { let Stepdown; + before(() => { Stepdown = require('../../server/lib/stepdown'); }); diff --git a/test/server-unit/translate.spec.js b/test/server-unit/translate.spec.js index b8f4405d34..fc5b8c36d0 100644 --- a/test/server-unit/translate.spec.js +++ b/test/server-unit/translate.spec.js @@ -12,7 +12,7 @@ const dictionaries = { const translate = rewire('../../server/lib/helpers/translate'); translate.__set__('dictionaries', dictionaries); -describe('test/server-unit/lib/helpers/translate.js', () => { +describe('test/sever-unit/translate', () => { it('#translate() should return a compiler function', () => { const compiler = translate('fr'); diff --git a/test/server-unit/util.spec.js b/test/server-unit/util.spec.js index 6f685da654..e851a6b9ba 100644 --- a/test/server-unit/util.spec.js +++ b/test/server-unit/util.spec.js @@ -4,7 +4,8 @@ const path = require('path'); const util = require('../../server/lib/util'); -describe('test/server-unit/util.js', () => { +describe('test/sever-unit/util', () => { + it('#take() should take values from one key of each object in an array of objects', () => { const objects = [{ id : 1 }, { id : 2 }, { id : 3 }]; const expected = [1, 2, 3]; diff --git a/test/server-unit/xlsx.spec.js b/test/server-unit/xlsx.spec.js index d1c645b835..739aed0753 100644 --- a/test/server-unit/xlsx.spec.js +++ b/test/server-unit/xlsx.spec.js @@ -8,7 +8,8 @@ const xlsx = rewire('../../server/lib/renderers/xlsx'); // mock the translation as a no-op function xlsx.__set__('i18n', () => (() => {})); -describe('test/server-unit/xlsx.js', () => { +describe('test/sever-unit/xlsx', () => { + it('Should return a xlsx buffer', (done) => { const data = { rows : [{ Firstname : 'Alice', Lastname : 'Bob' }],