Skip to content

Commit

Permalink
fix(cash): bug in debtor $state transitions
Browse files Browse the repository at this point in the history
This commit fixes another bug caught in $state transitions due to modals
being incorrectly $transitioned out of.  This makes sure the end to end
tests work correctly.
  • Loading branch information
Jonathan Niles authored and jniles committed Feb 19, 2017
1 parent 083875b commit e8417f8
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 103 deletions.
100 changes: 50 additions & 50 deletions client/src/partials/cash/cash.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,102 @@ angular.module('bhima.routes')
$stateProvider

.state('cashRegistry', {
url : '/payments',
controller: 'CashPaymentRegistryController as CPRCtrl',
templateUrl: 'partials/cash/payments/registry.html',
params : {
url : '/payments',
controller : 'CashPaymentRegistryController as CPRCtrl',
templateUrl : 'partials/cash/payments/registry.html',
params : {
filters : null,
display : null
}
display : null,
},
})

.state('cash', {
url : '/cash',
abstract: true,
controller: 'CashController as CashCtrl',
templateUrl: '/partials/cash/cash.html'
url : '/cash',
abstract : true,
controller : 'CashController as CashCtrl',
templateUrl : '/partials/cash/cash.html',
})

.state('cash.select', {
url : '/selection',
params : { id : { value: null } },
onEnter :['$uibModal', cashboxSelectionModal],
onExit : ['$uibModalStack', closeModal]
url : '/selection',
params : { id: { value: null } },
onEnter : ['$uibModal', cashboxSelectionModal],
onExit : ['$uibModalStack', closeModal],
})

.state('cash.window', {
url : '/:id?',
params : { id : { squash: true, value: null } },
controller: 'CashController as CashCtrl',
templateUrl: '/partials/cash/cash.html'
url : '/:id?',
params : { id: { squash: true, value: null } },
controller : 'CashController as CashCtrl',
templateUrl : '/partials/cash/cash.html',
})

.state('cash.transfer', {
url : '/:id/transfer',
params : { id : { squash: true, value: null } },
onEnter :['$state', '$uibModal', transferModal],
onExit : ['$uibModalStack', closeModal]
url : '/:id/transfer',
params : { id: { squash: true, value: null } },
onEnter : ['$state', '$uibModal', transferModal],
onExit : ['$uibModalStack', closeModal],
})

.state('cash.debtors', {
url : '/:id',
url : '/:id/debtors',
params : {
id : { squash: true, value: null },
debtor_uuid: { value: undefined },
invoices: { value : [] }
id : { squash: true, value: null },
debtor_uuid : { value: undefined },
invoices : { value: [] },
},
onEnter :['$state', '$uibModal', debtorInvoicesModal],
onExit : ['$uibModalStack', closeModal]
onEnter : ['$state', '$uibModal', debtorInvoicesModal],
onExit : ['$uibModalStack', closeModal],
})

.state('cash.scan', {
url : '/:id/scan',
params : { id : { squash: true, value: null } },
onEnter :['$state', '$uibModal', scanCashBarcodeModal],
onExit : ['$uibModalStack', closeModal]
url : '/:id/scan',
params : { id: { squash: true, value: null } },
onEnter : ['$state', '$uibModal', scanCashBarcodeModal],
onExit : ['$uibModalStack', closeModal],
});
}]);


function cashboxSelectionModal(Modal) {
Modal.open({
templateUrl: 'partials/cash/modals/selectCashbox.modal.html',
controller: 'SelectCashboxModalController as $ctrl',
backdrop: 'static',
keyboard: false
templateUrl : 'partials/cash/modals/selectCashbox.modal.html',
controller : 'SelectCashboxModalController as $ctrl',
backdrop : 'static',
keyboard : false,
});
}

function transferModal($state, Modal) {
Modal.open({
controller: 'CashTransferModalController as TransferCtrl',
templateUrl: 'partials/cash/modals/transfer.modal.html',
backdrop: 'static',
keyboard: false
controller : 'CashTransferModalController as TransferCtrl',
templateUrl : 'partials/cash/modals/transfer.modal.html',
backdrop : 'static',
keyboard : false,
});
}

function scanCashBarcodeModal($state, Modal) {
Modal.open({
controller: 'CashBarcodeScannerModalController as BarcodeModalCtrl',
templateUrl: 'partials/cash/modals/scanBarcode.modal.html',
size : 'lg',
backdrop: 'static',
keyboard: true
controller : 'CashBarcodeScannerModalController as BarcodeModalCtrl',
templateUrl : 'partials/cash/modals/scanBarcode.modal.html',
size : 'lg',
backdrop : 'static',
keyboard : true,
}).result.finally(function () {
$state.go('^.window', { id : $state.params.id });
$state.go('^.window', { id: $state.params.id });
});
}

function debtorInvoicesModal($state, Modal) {
Modal.open({
templateUrl : 'partials/cash/modals/invoices.modal.html',
controller : 'CashInvoiceModalController as CashInvoiceModalCtrl',
backdrop: 'static',
animation : false,
keyboard: true
backdrop : 'static',
animation : false,
keyboard : true,
}).result.finally(function () {
$state.go('^.window', { id : $state.params.id });
$state.go('^.window', { id: $state.params.id });
});
}

Expand Down
43 changes: 20 additions & 23 deletions client/src/partials/cash/modals/invoices.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ angular.module('bhima.controllers')

CashInvoiceModalController.$inject = [
'DebtorService', 'SessionService', '$timeout', 'NotifyService', '$state',
'$rootScope'
'$rootScope', '$uibModalInstance',
];

/**
* @module cash/modals/CashInvoiceModalController
*
* @description
* This controller is responsible for retrieving a list of debtor invoices
* from the server, and allowing selection of any number of invoices.
* This controller is responsible for retrieving a list of debtor invoices from the server,
* and allowing selection of any number of invoices.
*/
function CashInvoiceModalController(Debtors, Session, $timeout, Notify, $state, $rootScope) {
function CashInvoiceModalController(Debtors, Session, $timeout, Notify, $state, $rootScope, Instance) {
var vm = this;

var debtorId = $state.params.debtor_uuid;
Expand All @@ -26,21 +26,21 @@ function CashInvoiceModalController(Debtors, Session, $timeout, Notify, $state,

// bind methods
vm.submit = submit;
vm.cancel = dismiss;
vm.cancel = Instance.dismiss;

vm.gridOptions = {
appScopeProvider : vm,
multiSelect: true,
fastWatch: true,
flatEntityAccess: true,
onRegisterApi : onRegisterApi,
enableColumnMenus: false,
columnDefs : [
{ name : 'reference' },
{ name : 'balance', cellFilter: 'currency:' + Session.enterprise.currencyId},
{ name : 'date', cellFilter: 'date' }
appScopeProvider : vm,
multiSelect : true,
fastWatch : true,
flatEntityAccess : true,
onRegisterApi : onRegisterApi,
enableColumnMenus : false,
columnDefs : [
{ name: 'reference' },
{ name: 'balance', cellFilter: 'currency:' + Session.enterprise.currencyId},
{ name: 'date', cellFilter: 'date' },
],
minRowsToShow : 10
minRowsToShow : 10,
};

function selectionChangeCallback() {
Expand Down Expand Up @@ -107,21 +107,18 @@ function CashInvoiceModalController(Debtors, Session, $timeout, Notify, $state,

// resolve the modal with the selected invoices to add to the cash payment bills
function submit() {
var invoices;

// we start in a neutral state
vm.loading = false;
vm.hasError = false;

// retrieve the outstanding patient invoices from the ui grid
var invoices = vm.getSelectedRows();
invoices = vm.getSelectedRows();

$rootScope.$broadcast('cash:configure', { invoices : invoices });
$rootScope.$broadcast('cash:configure', { invoices: invoices });

$state.go('^.window', $state.params);
}

function dismiss() {
$state.go('^.window', $state.params);
return Instance.close();
}

// start up the module
Expand Down
57 changes: 27 additions & 30 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* global by,browser, element */
'use strict';

const q = require('q');

// we want to make sure we run tests locally, but TravisCI
Expand All @@ -11,35 +9,35 @@ const q = require('q');

const config = {

specs: ['test/end-to-end/**/*.spec.js'],
specs : ['test/end-to-end/**/*.spec.js'],

framework : 'mocha',
baseUrl : 'http://localhost:8080/',
baseUrl : 'http://localhost:8080/',

mochaOpts : {
reporter: 'mochawesome-screenshots',
reporterOptions: {
reportDir: `${__dirname}/test/artifacts/`,
reportName: 'mochawesome-end-to-end',
reportTitle: 'Bhima End to End Tests',
takePassedScreenshot: false,
clearOldScreenshots: true,
jsonReport: false
reporter : 'mochawesome-screenshots',
reporterOptions : {
reportDir : `${__dirname}/test/artifacts/`,
reportName : 'mochawesome-end-to-end',
reportTitle : 'Bhima End to End Tests',
takePassedScreenshot : false,
clearOldScreenshots : true,
jsonReport : false,
},
timeout : 30000
timeout : 30000,
},

// default browsers to run
multiCapabilities: [{
//'browserName': 'firefox',
multiCapabilities : [{
// 'browserName': 'firefox',
// }, {
'browserName': 'chrome'
'browserName': 'chrome',
}],

// this will log the user in to begin with
onPrepare : function () {
return q.fcall(function () {
browser.get('http://localhost:8080/#/login');
browser.get('http://localhost:8080/#!/login');

element(by.model('LoginCtrl.credentials.username')).sendKeys('superuser');
element(by.model('LoginCtrl.credentials.password')).sendKeys('superuser');
Expand All @@ -48,12 +46,11 @@ const config = {
// NOTE - you may need to play with the delay time to get this to work properly
// Give this plenty of time to run
}).delay(3100);
}
},
};

// configuration for running on SauceLabs via Travis
if (process.env.TRAVIS_BUILD_NUMBER) {

// SauceLabs credentials
config.sauceUser = process.env.SAUCE_USERNAME;
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
Expand All @@ -64,22 +61,22 @@ if (process.env.TRAVIS_BUILD_NUMBER) {
// 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
// 'build': process.env.TRAVIS_BUILD_NUMBER,
// }, {
browserName: 'chrome',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
build: process.env.TRAVIS_BUILD_NUMBER,
browserName : 'chrome',
'tunnel-identifier' : process.env.TRAVIS_JOB_NUMBER,
build : process.env.TRAVIS_BUILD_NUMBER,
}];

// make Travis take screenshots!
config.mochaOpts = {
reporter: 'mochawesome-screenshots',
reporterOptions: {
reportDir: `${__dirname}/test/artifacts/`,
reportName: 'protractor-' + new Date().toDateString().replace(/\s/g,'-') + '-' + process.env.TRAVIS_BUILD_NUMBER,
reportTitle: 'Bhima End to End Tests',
takePassedScreenshot: false,
clearOldScreenshots: true
reporter : 'mochawesome-screenshots',
reporterOptions : {
reportDir : `${__dirname}/test/artifacts/`,
reportName : `protractor-${new Date().toDateString().replace(/\s/g,'-')}-${process.env.TRAVIS_BUILD_NUMBER}`,
reportTitle : 'Bhima End to End Tests',
takePassedScreenshot : false,
clearOldScreenshots : true,
},
timeout : 30000
timeout : 30000,
};
}

Expand Down

0 comments on commit e8417f8

Please sign in to comment.