salix/e2e/paths/item-module/07_create_item_barcode.spec.js

78 lines
3.0 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item', () => {
describe('Create barcodes path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
2018-10-11 07:14:26 +00:00
.waitForLogin('buyer');
});
2018-10-22 15:12:41 +00:00
it('should access to the items index by clicking the items button', done => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-20 12:48:25 +00:00
});
2018-10-22 15:12:41 +00:00
it('should search for the item Gem of Time', done => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-20 12:48:25 +00:00
});
2018-10-22 15:12:41 +00:00
it(`should click on the search result to access to the item barcodes`, done => {
return 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');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-20 12:48:25 +00:00
});
2018-10-22 15:12:41 +00:00
it(`should click create a new code and delete a former one`, done => {
return nightmare
.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton)
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
.wait(selectors.itemBarcodes.thirdCodeInput)
.type(selectors.itemBarcodes.thirdCodeInput, '5')
.waitToClick(selectors.itemBarcodes.submitBarcodesButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-20 14:22:24 +00:00
});
2018-10-22 15:12:41 +00:00
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBarcodes.barcodeButton)
.waitForTextInInput(selectors.itemBarcodes.thirdCodeInput, '5')
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
.then(result => {
expect(result).toEqual('5');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-20 14:22:24 +00:00
});
});
});