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

66 lines
2.5 KiB
JavaScript
Raw Normal View History

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