Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Jul 17, 2017
1 parent f2aa2d1 commit 72eeb50
Showing 1 changed file with 29 additions and 38 deletions.
67 changes: 29 additions & 38 deletions test/end-to-end/inventory/list.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* global element, by, browser */
'use strict';

const uuid = require('node-uuid');
const chai = require('chai');
const expect = chai.expect;

const chai = require('chai');
const GU = require('../shared/GridUtils');
const FU = require('../shared/FormUtils');
const helpers = require('../shared/helpers');
Expand All @@ -17,34 +13,34 @@ describe('Inventory List', () => {
// navigate to the page
before(() => helpers.navigate('#/inventory'));

let currentDate = new Date();
let uniqueIdentifier = currentDate.getTime().toString();
const currentDate = new Date();
const uniqueIdentifier = currentDate.getTime().toString();

// inventory list items
let metadata = {
const metadata = {
code : uniqueIdentifier,
text : '[E2E] Inventory Article',
price : 7.57,
group : 'Test inventory group',
type : 'Article',
unit : 'Act',
unit_weight : 1,
unit_volume : 1
unit_volume : 1,
};

let metadataUpdate = {
const metadataUpdate = {
code : uniqueIdentifier.concat('_updated'),
text : '[E2E] Inventory Article updated',
price : 7.77,
group : 'Test inventory group',
type : 'Service',
unit : 'Pill',
unit_weight : 7,
unit_volume : 7
unit_volume : 7,
};

let metadataSearch = {
label : 'First'
const metadataSearch = {
label : 'First',
};

it('successfully creates a new inventory item (metadata)', () => {
Expand All @@ -62,15 +58,33 @@ describe('Inventory List', () => {
components.notification.hasSuccess();
});

it('successfully updates an existing inventory item (metadata)', () => {
const row = $(`[data-row-item="${metadata.code}"]`);
row.$('[data-method="action"]').click();
element(by.css(`[data-edit-metadata="${metadata.code}"]`)).click();

FU.input('$ctrl.item.label', metadataUpdate.text);
FU.input('$ctrl.item.code', metadataUpdate.code);
element(by.model('$ctrl.item.consumable')).click();
FU.input('$ctrl.item.price', metadataUpdate.price);
FU.select('$ctrl.item.group_uuid', metadataUpdate.group);
FU.select('$ctrl.item.type_id', metadataUpdate.type);
FU.select('$ctrl.item.unit_id', metadataUpdate.unit);
FU.input('$ctrl.item.unit_weight', metadataUpdate.unit_weight);
FU.input('$ctrl.item.unit_volume', metadataUpdate.unit_volume);

FU.modal.submit();
components.notification.hasSuccess();
});

// demonstrates that filtering works
it(`should find one Inventory with Label "${metadataSearch.label}"`, () => {
element(by.id('research')).click();
//FU.buttons.research();

FU.input('ModalCtrl.params.text', metadataSearch.label);
FU.modal.submit();

GU.expectRowCount('inventoryListGrid', 1);
FU.buttons.clear();
});

it('dont creates a new inventory item (metadata) for invalid data', () => {
Expand All @@ -89,29 +103,6 @@ describe('Inventory List', () => {
FU.validation.error('$ctrl.item.group_uuid');
FU.validation.error('$ctrl.item.type_id');
FU.validation.error('$ctrl.item.unit_id');

//components.notification.hasDanger();

FU.buttons.cancel();
});

it('successfully updates an existing inventory item (metadata)', () => {
let row = $(`[data-row-item="${metadata.code}"]`);
row.$('[data-method="action"]').click();
element(by.css(`[data-edit-metadata="${metadata.code}"]`)).click();

FU.input('$ctrl.item.label', metadataUpdate.text);
FU.input('$ctrl.item.code', metadataUpdate.code);
element(by.model('$ctrl.item.consumable')).click();
FU.input('$ctrl.item.price', metadataUpdate.price);
FU.select('$ctrl.item.group_uuid', metadataUpdate.group);
FU.select('$ctrl.item.type_id', metadataUpdate.type);
FU.select('$ctrl.item.unit_id', metadataUpdate.unit);
FU.input('$ctrl.item.unit_weight', metadataUpdate.unit_weight);
FU.input('$ctrl.item.unit_volume', metadataUpdate.unit_volume);

FU.modal.submit();
components.notification.hasSuccess();
});

});

0 comments on commit 72eeb50

Please sign in to comment.