Skip to content

Commit

Permalink
new donation test-end
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremielodi committed Sep 29, 2020
1 parent 65f4898 commit 9a07f52
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 813 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<div class="toolbar">
<div class="toolbar-item">
<button type="button"
id="new_donation_btn"
ng-click="$ctrl.toggleAddDonation()"
class="btn btn-sm btn-default"
ng-class="{ 'btn-info' : $ctrl.showAddDonation }">
Expand Down
11 changes: 6 additions & 5 deletions server/controllers/admin/donation.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ function donationBalance(req, res, next) {
const donationUuid = db.bid(req.params.uuid);
const sql = `
SELECT BUID(x.uuid) as uuid, x.reference,
x.description, x.inventory_uuid,
x.quantity, x.unit_price, x.date,
x.donor_id, x.display_name,
x.distributed_quantity,
x.balance
x.description, x.inventory_uuid,
x.quantity, x.unit_price, x.date,
x.donor_id, x.display_name,
x.distributed_quantity,
x.balance
FROM (
SELECT dt.uuid as uuid, dt.reference,
Expand All @@ -117,6 +117,7 @@ function donationBalance(req, res, next) {
AND distributed.origin_uuid = dt.uuid
) AS x
WHERE x.uuid=? HAVING x.balance > 0 AND x.balance <= x.quantity
ORDER BY x.date ASC
`;

db.exec(sql, [FROM_DONATION_ID, donationUuid, donationUuid])
Expand Down
789 changes: 0 additions & 789 deletions server/models/migrations/next/migrate.sql

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions test/end-to-end/stock/stock.entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,26 @@ function StockEntryTests() {
await page.setDepot(DEPOT_PRINCIPAL);
});

it('Should enter stock from a donation', async () => {
it('Should enter stock from a new donation', async () => {

await page.newDonation({
donor : 'Jeremie LODI',
description : 'Test - new donation from modal',
inventory : {
name : 'Vitamines',
quantity : 120,
unit_price : 250.5,
},
lots : [
{ label : 'LD-ONE', quantity : 100, expiration_date : expireInThreeYears },
{ label : 'LD-TWO', quantity : 20, expiration_date : expireInTwoYears },
],
});
});

// select the purchase order
it('Should enter stock from a donation', async () => {
await this.timeout(80000);
// select the donation order
await page.setDonation(0);

await page.setDate(new Date());
Expand Down
43 changes: 42 additions & 1 deletion test/end-to-end/stock/stock.entry.page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global by, protractor */
/* global by, element, protractor */
/* eslint no-await-in-loop:off */

const FU = require('../shared/FormUtils');
Expand Down Expand Up @@ -37,6 +37,26 @@ function StockEntryPage() {
await FU.modal.submit();
};

page.newDonation = async (params) => {

const { inventory, lots, description } = params;
await components.stockEntryExitType.set('donation');
await element(by.id('new_donation_btn')).click();
await components.dateEditor.set(new Date());
await element(by.model('$ctrl.donation.description')).clear().sendKeys(description);
await FU.select('$ctrl.donation.donor_id', params.donor);
// fill inventory grid

await components.addItem.set(1);
await page.addItem(0, inventory.name, inventory.quantity, inventory.unit_price);

await FU.buttons.submit();

await page.setLots(0, lots, false);
// submit
await page.submit();
};

/**
* @method setTransfer
* @param {string} rowNumber - movement line on the modal grid
Expand Down Expand Up @@ -77,6 +97,27 @@ function StockEntryPage() {
await components.addItem.set(n);
};

// add item
page.addItem = async function setInventory(rowNumber, code, quantity, price) {
const modalGridId = 'new-donation-grid';
// inventory code column
const itemCell = await GU.getCell(modalGridId, rowNumber, 1);

// inventory quantity column
const quantityCell = await GU.getCell(modalGridId, rowNumber, 3);
const unitPriceCell = await GU.getCell(modalGridId, rowNumber, 4);

// enter data into the typeahead input.
await FU.input('row.entity.inventory_uuid', code, itemCell);

const externalAnchor = element(by.css('body > ul.dropdown-menu.ng-isolate-scope:not(.ng-hide)'));
const option = externalAnchor.all(by.cssContainingText('[role="option"]', code)).first();
await option.click();

// set the quantity
await FU.input('row.entity.quantity', quantity, quantityCell);
await FU.input('row.entity.unit_price', price, unitPriceCell);
};
/**
* @method setItem
*/
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/stock/stock.inventories.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function StockInventoriesRegistryTests() {
await filters.resetFilters();
});

it('find 3 inventories who requires a purchase order', async () => {
it('find 2 inventories who requires a purchase order', async () => {
await element(by.model('$ctrl.searchQueries.require_po')).click();
await FU.modal.submit();
await GU.expectRowCount(gridId, 3);
await GU.expectRowCount(gridId, 2);
await filters.resetFilters();
});
}
Expand Down
10 changes: 5 additions & 5 deletions test/end-to-end/stock/stock.lots.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function StockLotsRegistryTests() {
// techinically this is 26 in total, but the grid doesn't render that
// many on small screens
const LOT_FOR_ALLTIME = 22;
const LOT_FOR_TODAY = 14;
const LOT_FOR_LAST_YEAR = 21;
const LOT_FOR_TODAY = 19;
const LOT_FOR_LAST_YEAR = 26;

const inventoryGroup = 'Injectable';

Expand Down Expand Up @@ -57,7 +57,7 @@ function StockLotsRegistryTests() {
it('find lots in depot principal', async () => {
await modal.setDepot('Depot Principal');
await modal.submit();
await GU.expectRowCount(gridId, 17 + depotGroupingRow);
await GU.expectRowCount(gridId, 22 + depotGroupingRow);
});

it('find lots by inventory', async () => {
Expand All @@ -81,13 +81,13 @@ function StockLotsRegistryTests() {
it('find lots by expiration date', async () => {
await modal.setdateInterval('01/01/2017', '31/12/2017', 'expiration-date');
await modal.submit();
await GU.expectRowCount(gridId, 1 + depotGroupingRow);
await GU.expectRowCount(gridId, 2);
});

it('find inventories by group', async () => {
await components.inventoryGroupSelect.set(inventoryGroup);
await FU.modal.submit();
await GU.expectRowCount(gridId, 9);
await GU.expectRowCount(gridId, 14);
await filters.resetFilters();
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/stock/stock.movements.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function StockMovementsRegistryTests() {
await modal.switchToDefaultFilterTab();
await modal.setPeriod('allTime');
await modal.submit();
await GU.expectRowCount(gridId, 21 + (2 * depotGroupingRow));
await GU.expectRowCount(gridId, 23 + (2 * depotGroupingRow));
});

it('find entry movements ', async () => {
// for Entry
await modal.setEntryExit(0);
await modal.switchToDefaultFilterTab();
await modal.submit();
await GU.expectRowCount(gridId, 8 + (2 * depotGroupingRow));
await GU.expectRowCount(gridId, 10 + (2 * depotGroupingRow));
});

it('filters by entry/exit', async () => {
Expand Down
1 change: 0 additions & 1 deletion test/end-to-end/stock/stock.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const StockRequisitionTests = require('./stock.requisition');
const StockInventoryAdjustement = require('./stock.z1.inventory-adjustment');

describe('Stock end-to-end test', () => {

describe('Stock Adjustment Test', StockAdjustmentTests);
describe('Stock Assign Module', StockAssignTests);
describe('Stock Entry Test', StockEntryTests);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ function StockInventoriesRegistryTests() {
it('find 3 inventory in Depot Principal plus one line for the Grouping', async () => {
await modal.setDepot('Depot Principal');
await modal.submit();
await GU.expectRowCount(gridId, 2 + GROUPING_ROW);
await GU.expectRowCount(gridId, 3 + GROUPING_ROW);
await filters.resetFilters();
});

it('find only inventories setted during the adjustment process', async () => {
const quinine = {
label : 'Quinine Bichlorhydrate, sirop, 100mg base/5ml, 100ml, flacon, Unité',
label : 'Acide Acetylsalicylique, 500mg, Tab, 1000, Vrac',
quantity : '17',
};
const vitamine = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function StockLotsRegistryTests() {
});

const gridId = 'stock-lots-grid';
const LOT_FOR_ALLTIME = 2;
const LOT_FOR_ALLTIME = 7;
const GROUPING_ROW = 1;

it(`finds ${LOT_FOR_ALLTIME} lots for all time`, async () => {
Expand All @@ -36,14 +36,14 @@ function StockLotsRegistryTests() {

it('find only lots set during the adjustment process', async () => {
const quinine = {
label : 'Quinine Bichlorhydrate, sirop, 100mg base/5ml, 100ml, flacon, Unité',
lot : 'QUININE-B',
label : 'Acide Acetylsalicylique, 500mg, Tab, 1000, Vrac',
lot : '759170203',
quantity : '17',
};

const vitamine = {
label : 'Vitamines B1+B6+B12, 100+50+0.5mg/2ml, Amp, Unité',
lot : 'VITAMINE-B',
lot : 'LY-THREE',
quantity : '23',
};

Expand Down

0 comments on commit 9a07f52

Please sign in to comment.