backend unit test for barcode duplicity plus e2e path completed
This commit is contained in:
parent
f2d5d58513
commit
dcf5bf61da
|
@ -1,31 +1,31 @@
|
|||
<form name="form" ng-submit="$ctrl.submit()">
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-one margin-medium-top>
|
||||
<vn-title>Item Barcodes</vn-title>
|
||||
<mg-ajax path="/item/api/ItemBarcodes" options="mgIndex as barcodes"></mg-ajax>
|
||||
<vn-horizontal ng-repeat="barcode in $ctrl.barcodes track by $index">
|
||||
<vn-textfield vn-three label="code" model="barcode.code" vn-acl="buyer, replenisher"></vn-textfield>
|
||||
<vn-one pad-medium-top>
|
||||
<vn-icon
|
||||
vn-acl="buyer, replenisher"
|
||||
pointer
|
||||
medium-grey
|
||||
icon="remove_circle_outline"
|
||||
ng-click="$ctrl.removeBarcode($index)">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
vn-acl="buyer, replenisher"
|
||||
pointer
|
||||
margin-medium-left
|
||||
orange
|
||||
icon="add_circle"
|
||||
ng-if = "barcode.showAddIcon"
|
||||
ng-click="$ctrl.addBarcode()"
|
||||
></vn-icon>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one margin-medium-top>
|
||||
<vn-title>Item Barcodes</vn-title>
|
||||
<mg-ajax path="/item/api/ItemBarcodes" options="mgIndex as barcodes"></mg-ajax>
|
||||
<vn-horizontal ng-repeat="barcode in $ctrl.barcodes track by $index">
|
||||
<vn-textfield vn-three label="code" model="barcode.code" vn-acl="buyer, replenisher"></vn-textfield>
|
||||
<vn-one pad-medium-top>
|
||||
<vn-icon
|
||||
vn-acl="buyer, replenisher"
|
||||
pointer
|
||||
medium-grey
|
||||
icon="remove_circle_outline"
|
||||
ng-click="$ctrl.removeBarcode($index)">
|
||||
</vn-icon>
|
||||
<vn-icon
|
||||
vn-acl="buyer, replenisher"
|
||||
pointer
|
||||
margin-medium-left
|
||||
orange
|
||||
icon="add_circle"
|
||||
ng-if = "barcode.showAddIcon"
|
||||
ng-click="$ctrl.addBarcode()"
|
||||
></vn-icon>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
|
|
|
@ -145,8 +145,16 @@ export default {
|
|||
searchItemInput: `${components.vnTextfield}`,
|
||||
searchButton: `${components.vnSearchBar} > vn-icon-button > button`
|
||||
},
|
||||
itemBasicData: {
|
||||
basicDataButton: `${components.vnMenuItem}[ui-sref="item.card.data"]`
|
||||
},
|
||||
itemBarcodes: {
|
||||
barcodeButton: `${components.vnMenuItem}[ui-sref="item.card.itemBarcode"]`
|
||||
barcodeButton: `${components.vnMenuItem}[ui-sref="item.card.itemBarcode"]`,
|
||||
addBarcodeButton: `${components.vnIcon}[icon="add_circle"]`,
|
||||
thirdCodeInput: `vn-horizontal:nth-child(5) > ${components.vnTextfield}`,
|
||||
fourthCodeInput: `vn-horizontal:nth-child(6) > ${components.vnTextfield}`,
|
||||
submitBarcodesButton: `${components.vnSubmit}`,
|
||||
firstCodeRemoveButton: `vn-horizontal:nth-child(3) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]`
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -55,17 +55,47 @@ describe('create item barcodes path', () => {
|
|||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
// it(`should click on the search result to access to the item barcodes`, done => {
|
||||
// nightmare
|
||||
// .waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
|
||||
// .waitToClick(selectors.itemsIndex.searchResult)
|
||||
// .waitToClick(selectors.itemBarcodes.barcodeButton)
|
||||
// .waitForURL('barcode')
|
||||
// .url()
|
||||
// .then(url => {
|
||||
// expect(url).toContain('barcode');
|
||||
// done();
|
||||
// })
|
||||
// .catch(catchErrors(done));
|
||||
// });
|
||||
it(`should click on the search result to access to the item barcodes`, done => {
|
||||
nightmare
|
||||
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
|
||||
.waitToClick(selectors.itemsIndex.searchResult)
|
||||
.waitToClick(selectors.itemBarcodes.barcodeButton)
|
||||
.waitForURL('barcode')
|
||||
.url()
|
||||
.then(url => {
|
||||
expect(url).toContain('barcode');
|
||||
done();
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it(`should click create a new code and delete a former one`, done => {
|
||||
nightmare
|
||||
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
|
||||
.type(selectors.itemBarcodes.fourthCodeInput, '5')
|
||||
.click(selectors.itemBarcodes.firstCodeRemoveButton)
|
||||
.click(selectors.itemBarcodes.submitBarcodesButton)
|
||||
.wait(selectors.globalItems.snackbarIsActive)
|
||||
.getInnerText(selectors.globalItems.snackbarIsActive)
|
||||
.then(result => {
|
||||
expect(result).toContain('Data saved!');
|
||||
done();
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => {
|
||||
nightmare
|
||||
.waitForSnackbarReset()
|
||||
.click(selectors.itemBasicData.basicDataButton)
|
||||
.wait(selectors.itemBasicData.nameInput)
|
||||
.click(selectors.itemBarcodes.barcodeButton)
|
||||
.wait(200)
|
||||
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
|
||||
.then(result => {
|
||||
expect(result).toEqual('5');
|
||||
done();
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
const crudItemBarcodes = require('../crudItemBarcodes');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
let mysql = require('mysql2');
|
||||
|
||||
describe('Item crudItemBarcodes()', () => {
|
||||
let connection;
|
||||
beforeAll(() => {
|
||||
connection = mysql.createConnection({
|
||||
multipleStatements: true,
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'salix'
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the destroyAll methodif there are ids in delete Array', done => {
|
||||
let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemBarcodes', 'destroyAll', 'create', 'upsert']);
|
||||
|
||||
|
@ -48,4 +60,13 @@ describe('Item crudItemBarcodes()', () => {
|
|||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it('should return an error when attempting to save a duplicated barcode', done => {
|
||||
let callback = (err, res) => {
|
||||
expect(err.toString()).toBe("Error: Duplicate entry '4' for key 'PRIMARY'");
|
||||
done();
|
||||
};
|
||||
|
||||
connection.query('INSERT INTO `vn`.`itemBarcode` VALUES (4, 2 ,4 );', callback);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
{
|
||||
"name": "ItemBarcode",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemBarcode",
|
||||
"database": "vn"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"code": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
"name": "ItemBarcode",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemBarcode",
|
||||
"database": "vn"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"relations": {
|
||||
"item": {
|
||||
"type": "belongsTo",
|
||||
"model": "Item",
|
||||
"foreignKey": "itemFk"
|
||||
}
|
||||
"code": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"item": {
|
||||
"type": "belongsTo",
|
||||
"model": "Item",
|
||||
"foreignKey": "itemFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue