Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): fix bh-date-editor tests #4970

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/js/components/bhDateEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ angular.module('bhima.components')
dateValue : '<', // one-way binding
onChange : '&',
minDate : '<?',
// required : '<?', // FIXME(@jniles) - finish this
maxDate : '<?',
allowFutureDate : '<?',
disabled : '<?',
Expand Down
11 changes: 6 additions & 5 deletions client/src/modules/offdays/modals/offday.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
</div>
</div>

<bh-date-editor
date-value="OffdayModalCtrl.offday.date"
on-change="OffdayModalCtrl.onDateChange(date)"
allow-future-date="true">
</bh-date-editor>
<bh-date-editor
id="offday-date-editor"
date-value="OffdayModalCtrl.offday.date"
on-change="OffdayModalCtrl.onDateChange(date)"
allow-future-date="true">
</bh-date-editor>

<div class="form-group" ng-class="{ 'has-error' : OffdayForm.$submitted && OffdayForm.percent_pay.$invalid }">
<label class="control-label" translate>FORM.LABELS.PERCENTAGE</label> (%)
Expand Down
18 changes: 12 additions & 6 deletions client/src/modules/offdays/modals/offday.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ OffdayModalController.$inject = [
'$state', 'OffdayService', 'NotifyService', 'appcache', 'moment', 'params',
];

/**
* @function OffdayModalController
*
* @description
* This modal sets the offdays for the payroll module.
*/
function OffdayModalController($state, Offdays, Notify, AppCache, moment, params) {
const vm = this;
vm.offday = {};
Expand All @@ -13,11 +19,9 @@ function OffdayModalController($state, Offdays, Notify, AppCache, moment, params

if (params.isCreateState || params.id) {
cache.stateParams = params;
vm.stateParams = cache.stateParams;
} else {
vm.stateParams = cache.stateParams;
}

vm.stateParams = cache.stateParams;
vm.isCreateState = vm.stateParams.isCreateState;

// update the date
Expand All @@ -41,11 +45,13 @@ function OffdayModalController($state, Offdays, Notify, AppCache, moment, params
function submit(offdayForm) {
if (offdayForm.$invalid) { return 0; }

vm.offday.date = moment(vm.offday.date).format('YYYY-MM-DD');
const data = { ...vm.offday };

data.date = moment(data.date).format('YYYY-MM-DD');

const promise = (vm.isCreateState)
? Offdays.create(vm.offday)
: Offdays.update(vm.offday.id, vm.offday);
? Offdays.create(data)
: Offdays.update(vm.offday.id, data);

return promise
.then(() => {
Expand Down
6 changes: 4 additions & 2 deletions test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ SET NAMES 'utf8';
INSERT INTO `enterprise` VALUES
(1, 'Test Enterprise', 'TE', '243 81 504 0540', 'enterprise@test.org', NULL, HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'), NULL, 2, 103, NULL, NULL);

INSERT INTO `enterprise_setting` (enterprise_id, enable_price_lock, enable_password_validation, enable_delete_records, enable_auto_email_report, enable_auto_stock_accounting, enable_auto_purchase_order_confirmation) VALUES
(1, 0, 1, 1, 1, 0, 0);
INSERT INTO `enterprise_setting`
(enterprise_id, enable_price_lock, enable_password_validation, enable_delete_records, enable_auto_email_report, enable_auto_stock_accounting, enable_auto_purchase_order_confirmation, month_average_consumption)
VALUES (1, 0, 1, 1, 1, 0, 0, 12);

-- Project
INSERT INTO `project` VALUES
Expand Down Expand Up @@ -3050,6 +3051,7 @@ VALUES
(22, 'taux_de_paie', 'TauxPaie', 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 10, 1, 'is_pay_rate', NULL, 0),
(23, 'Salire_brute', 'Salaire brute', 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 11, 1, 'is_gross_salary', NULL, 0),
(24, 'Nombre_deJours', 'Nbr_jrs', 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 12, 1, 'is_number_of_days', NULL, 0);

-- Configuration of Rubrinc
INSERT INTO `config_rubric` (`id`, `label`)
VALUES (1, 'Configuration des rubriques'),
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/offdays/offdays.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class OffdayPage {
await FU.buttons.create();
await FU.input('OffdayModalCtrl.offday.label', offday.label);

components.dateEditor.set(new Date(offday.date), null, '[uib-modal] .title');
await components.dateEditor.set(offday.date, 'offday-date-editor', '.modal li.title');

await FU.input('OffdayModalCtrl.offday.percent_pay', offday.percent_pay);

Expand Down Expand Up @@ -50,7 +50,7 @@ class OffdayPage {

await FU.input('OffdayModalCtrl.offday.label', updateOffday.label);

components.dateEditor.set(new Date(updateOffday.date), null, '[uib-modal] .title');
await components.dateEditor.set(updateOffday.date, 'offday-date-editor', '.modal li.title');

await FU.input('OffdayModalCtrl.offday.percent_pay', updateOffday.percent_pay);

Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/offdays/offdays.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ describe('Offdays Management', () => {

const offday = {
label : 'Fete de Parent',
date : '2017-08-01',
date : new Date('2017-08-01'),
percent_pay : 100,
};

const updateOffday = {
label : 'Vingt',
date : '2017-11-24',
date : new Date('2017-11-24'),
percent_pay : 100,
};

Expand Down
6 changes: 3 additions & 3 deletions test/end-to-end/stock/stock.inventories.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ function StockInventoriesRegistryTests() {
it('find 3 inventory by state (security reached)', async () => {
await FU.radio('$ctrl.searchQueries.status', 2);
await FU.modal.submit();
await GU.expectRowCount(gridId, 3);
await GU.expectRowCount(gridId, 2);

await filters.resetFilters();
});

it('find 0 inventories by state plus one line for grouping (minimum reached)', async () => {
it('find 1 inventories by state plus one line for grouping (minimum reached)', async () => {
await FU.radio('$ctrl.searchQueries.status', 3);
await FU.modal.submit();

await GU.expectRowCount(gridId, 0);
await GU.expectRowCount(gridId, 2);
await filters.resetFilters();
});

Expand Down
2 changes: 1 addition & 1 deletion test/integration/enterprises.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fixtures = path.resolve(__dirname, '../fixtures');
*/
describe('(/enterprises) Enterprises API', () => {
const defaultEnterpriseId = 1;
const defaultValuemonthAverageConsumption = 6;
const defaultValuemonthAverageConsumption = 12;

const enterprise = {
name : 'enterprises',
Expand Down
14 changes: 7 additions & 7 deletions test/integration/stock/stock.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ describe('(/stock/) The Stock HTTP API', () => {

// (report) render all stock exit
it(
`GET /reports/stock/lots?renderer=json
returns exits for all depots`,
`GET /reports/stock/lots?renderer=json returns exits for all depots`,
async () => {
const res = await agent.get(`/reports/stock/lots?renderer=json`);
expect(res.body.rows.length).to.equal(23);
Expand Down Expand Up @@ -171,11 +170,12 @@ describe('(/stock/) The Stock HTTP API', () => {
helpers.api.listed(res, 4);

expect(res.body[1].quantity).to.equal(140);
expect(res.body[1].avg_consumption).to.equal(15);
expect(res.body[1].S_SEC).to.equal(15);
expect(res.body[1].S_MIN).to.equal(30);
expect(res.body[1].S_MAX).to.equal(30);
expect(res.body[1].S_MONTH).to.equal(9);
expect(res.body[1].avg_consumption).to.equal(8);

expect(res.body[1].S_SEC).to.equal(8);
expect(res.body[1].S_MIN).to.equal(16);
expect(res.body[1].S_MAX).to.equal(16);
expect(res.body[1].S_MONTH).to.equal(17);

expect(res.body[2].quantity).to.equal(180300);
expect(res.body[2].avg_consumption).to.equal(49916.67);
Expand Down