backend unit test for barcode duplicity plus e2e path completed
This commit is contained in:
parent
f2d5d58513
commit
dcf5bf61da
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue