Skip to content

Commit

Permalink
updating e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
DedrickEnc committed Jul 31, 2017
1 parent ec81f5c commit 4a6caf4
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions client/src/modules/stock/entry/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ function StockEntryController(Depots, Inventory, Notify,

// ============================ lots management ===========================
function setLots(inventory) {
console.log('inventaire', inventory);
StockModal.openDefineLots({
inventory : inventory,
entry_type : vm.movement.entry_type,
Expand Down
5 changes: 3 additions & 2 deletions client/src/modules/stock/entry/modals/lots.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ StockDefineLotsModalController.$inject = [
];

function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, Session) {
console.log('Data', Data);
var vm = this;

// globals
Expand Down Expand Up @@ -86,14 +87,14 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data,

// add lot
function addLot() {
if (vm.remainingQuantity <= 0) {
if (vm.remainingQuantity <= 0 && vm.entryType !== 'integration') {
vm.maxLotReached = true;
return;
}
vm.gridOptions.data.push({
is_valid : false,
lot : vm.inventory.lot || '',
expiration_date : new Date(vm.inventory.expiration_date) || new Date(),
expiration_date : vm.inventory.expiration_date ? new Date(vm.inventory.expiration_date) : new Date(),
quantity : vm.remainingQuantity,
});

Expand Down
3 changes: 2 additions & 1 deletion test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ INSERT INTO `stock_movement` (`uuid`, `lot_uuid`, `document_uuid`, `depot_uuid`,
(HUID('6529ba0c-aef4-4527-b572-5ae77273de62'), HUID('6f80748b-1d94-4247-804e-d4be99e827d2'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 200, 0.8000, 0, 1),
(HUID('a4ff7358-f1f8-4301-86e4-e9e6fe99bd31'), HUID('5a0e06c2-6ca7-4633-8b17-92e2a59db44c'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 20, 0.5000, 0, 1),
(HUID('d8c83ad9-a3ea-4f9f-96f9-456a435f480d'), HUID('ef24cf1a-d5b9-4846-b70c-520e601c1ea6'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 50, 2.0000, 0, 1),
(HUID('f9aa33f1-65e2-4e37-89cb-843d27b2c586'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 100, 1.2000, 0, 1);
(HUID('f9aa33f1-65e2-4e37-89cb-843d27b2c586'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 100, 1.2000, 0, 1),
(HUID('e8502c3e-7483-11e7-a8de-507b9dd6de91'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('0cc6c435-7484-11e7-a8de-507b9dd6de91'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), HUID('d4bb1452-e4fa-4742-a281-814140246877'), 1, '2017-02-02', 75, 1.2000, 1, 1);

-- general ledger data
INSERT INTO `general_ledger` VALUES
Expand Down
9 changes: 4 additions & 5 deletions test/end-to-end/stock/stock.entry.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function StockEntryPage() {
* @param {string} rowNumber - movement line on the modal grid
*/
page.setTransfer = function setTransfer(rowNumber) {
components.stockEntryExitType.set('entry-exit-type-transfer-reception');
components.stockEntryExitType.set('entry-exit-type-transfer_reception');
GU.selectRow('TransferGrid', rowNumber);
FU.modal.submit();
};
Expand Down Expand Up @@ -114,10 +114,9 @@ function StockEntryPage() {

if (inventoryUnitCost) {
FU.input('$ctrl.inventory.unit_cost', inventoryUnitCost);

$('[data-add-lot]').click();
}
lotsArray.forEach((lot, index) => {

lotsArray.forEach((lot, index) => {
lotCell = GU.getCell(lotGridId, index, 1);
quantityCell = GU.getCell(lotGridId, index, 2);
expirationDateCell = GU.getCell(lotGridId, index, 3);
Expand All @@ -133,7 +132,7 @@ function StockEntryPage() {
// enter lot expiration date
if(!isTransferReception){
components.datePicker.set(lot.expiration_date, expirationDateCell);
}
}

if (index < lotsArray.length - 1) {
// Add another lot line
Expand Down
6 changes: 3 additions & 3 deletions test/end-to-end/stock/stock.entry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ function StockExiTests() {

page.setItem(0, 'INV0');

page.setLots(0, lots, 1500, 0.09);
page.setLots(0, lots, false, 1500, 0.09);

// submit
page.submit();
});
});

it('Should entry stock from a transfer reception', () => {
// select the movement
Expand All @@ -76,7 +76,7 @@ function StockExiTests() {
page.setDescription(DESCRIPTION.concat(' - Transfer reception'));

const lots = [
{ quantity: 75}
{ quantity: 75},
];

page.setLots(0, lots, true);
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/stock/stock.inventories.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function StockInventoriesRegistryTests() {
FU.buttons.search();
FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Secondaire');
FU.modal.submit();
GU.expectRowCount(gridId, 1 + depotGroupingRow);
GU.expectRowCount(gridId, 2 + depotGroupingRow);

FU.buttons.search();
FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal');
Expand Down Expand Up @@ -71,7 +71,7 @@ function StockInventoriesRegistryTests() {
FU.buttons.search();
FU.radio('$ctrl.bundle.status', 4);
FU.modal.submit();
GU.expectRowCount(gridId, 4 + (2 * depotGroupingRow));
GU.expectRowCount(gridId, 5 + (2 * depotGroupingRow));


// clear filters
Expand Down
4 changes: 2 additions & 2 deletions test/end-to-end/stock/stock.lots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function StockLotsRegistryTests() {
FU.buttons.search();
FU.uiSelect('$ctrl.bundle.inventory_uuid', 'First Test Inventory Item');
FU.modal.submit();
GU.expectRowCount(gridId, 9 + (2 * depotGroupingRow));
GU.expectRowCount(gridId, 8 + (2 * depotGroupingRow));

// clear filters
FU.buttons.clear();
Expand All @@ -48,7 +48,7 @@ function StockLotsRegistryTests() {
FU.buttons.search();
FU.input('$ctrl.bundle.label', 'VITAMINE-A');
FU.modal.submit();
GU.expectRowCount(gridId, 1 + depotGroupingRow);
GU.expectRowCount(gridId, 3 + depotGroupingRow);

// clear filters
FU.buttons.clear();
Expand Down
12 changes: 6 additions & 6 deletions test/end-to-end/stock/stock.movements.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function StockMovementsRegistryTests() {
FU.buttons.search();
FU.radio('$ctrl.bundle.is_exit', 1);
FU.modal.submit();
GU.expectRowCount(gridId, 7 + depotGroupingRow);
GU.expectRowCount(gridId, 8 + depotGroupingRow);

// clear filters
FU.buttons.clear();
Expand All @@ -43,7 +43,7 @@ function StockMovementsRegistryTests() {
FU.buttons.search();
FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal');
FU.modal.submit();
GU.expectRowCount(gridId, 16 + depotGroupingRow);
GU.expectRowCount(gridId, 17 + depotGroupingRow);

// clear filters
FU.buttons.clear();
Expand All @@ -54,7 +54,7 @@ function StockMovementsRegistryTests() {
FU.buttons.search();
FU.uiSelect('$ctrl.bundle.inventory_uuid', 'First Test Inventory Item');
FU.modal.submit();
GU.expectRowCount(gridId, 14 + (2 * depotGroupingRow));
GU.expectRowCount(gridId, 13 + (2 * depotGroupingRow));

// clear filters
FU.buttons.clear();
Expand All @@ -66,7 +66,7 @@ function StockMovementsRegistryTests() {
FU.buttons.search();
FU.input('$ctrl.bundle.label', 'VITAMINE-A');
FU.modal.submit();
GU.expectRowCount(gridId, 2 + depotGroupingRow);
GU.expectRowCount(gridId, 5 + depotGroupingRow);

// clear filters
FU.buttons.clear();
Expand All @@ -80,7 +80,7 @@ function StockMovementsRegistryTests() {
FU.buttons.search();
FU.uiSelect('$ctrl.bundle.flux_id', 'Commande d\'achat');
FU.modal.submit();
GU.expectRowCount(gridId, 8 + depotGroupingRow);
GU.expectRowCount(gridId, 9 + depotGroupingRow);

// to patient
FU.buttons.search();
Expand Down Expand Up @@ -121,7 +121,7 @@ function StockMovementsRegistryTests() {
FU.buttons.search();
components.dateInterval.range('02/02/2017', '02/02/2017');
FU.modal.submit();
GU.expectRowCount(gridId, 5 + depotGroupingRow);
GU.expectRowCount(gridId, 8 + depotGroupingRow);

FU.buttons.search();
components.dateInterval.range('01/01/2015', '30/01/2015');
Expand Down
8 changes: 4 additions & 4 deletions test/integration/stock.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('(/stock/) The Stock HTTP API', () => {
// ==============================================================================

const depot_principal_uuid = 'f9caeb16-1684-43c5-a6c4-47dbac1df296';
const depot_principal_mvt = 12; // 10 initial plus 2 distributions
const depot_principal_mvt = 13; // 11 initial plus 2 distributions
const lot_quinine_uuid = 'ae735e99-8faf-417b-aa63-9b404fca99ac';

// create new stock lots
Expand Down Expand Up @@ -162,16 +162,16 @@ describe('(/stock/) The Stock HTTP API', () => {
.catch(helpers.handler));

// list all movement relatives to 'Depot Principal'
it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (12: 8 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depot_principal_uuid}`)
it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (13: 9 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depot_principal_uuid}`)
.then((res) => {
helpers.api.listed(res, depot_principal_mvt);
})
.catch(helpers.handler));

// list all stock exit relatives to 'Depot Principal'
it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (2 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depot_principal_uuid}`)
it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (3 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depot_principal_uuid}`)
.then((res) => {
helpers.api.listed(res, 2);
helpers.api.listed(res, 3);
})
.catch(helpers.handler));

Expand Down

0 comments on commit 4a6caf4

Please sign in to comment.