salix/e2e/paths/item-module/08_item_create_and_clone.sp...

132 lines
5.4 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2018-11-21 13:09:22 +00:00
describe('Item Create/Clone path', () => {
const nightmare = createNightmare();
2018-11-21 13:09:22 +00:00
describe('create', () => {
beforeAll(() => {
nightmare
.loginAndModule('buyer', 'item');
2018-11-21 13:09:22 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
2018-11-21 13:09:22 +00:00
const result = await nightmare
.wait(selectors.itemsIndex.searchItemInput)
2018-11-21 13:09:22 +00:00
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0);
});
2019-01-07 08:33:07 +00:00
it('should access to the create item view by clicking the create floating button', async() => {
2018-11-21 13:09:22 +00:00
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
2019-01-07 08:33:07 +00:00
it('should return to the item index by clickig the cancel button', async() => {
2018-11-21 13:09:22 +00:00
const url = await nightmare
.click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
2019-01-07 08:33:07 +00:00
it('should now access to the create item view by clicking the create floating button', async() => {
2018-11-21 13:09:22 +00:00
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
2019-01-07 08:33:07 +00:00
it('should create the Infinity Gauntlet item', async() => {
2018-11-21 13:09:22 +00:00
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo')
.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares')
.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand')
2018-11-21 13:09:22 +00:00
.click(selectors.itemCreateView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should confirm Infinity Gauntlet item was created', async() => {
2018-11-21 13:09:22 +00:00
let result = await nightmare
.waitToGetProperty(selectors.itemBasicData.nameInput, 'value');
2018-11-21 13:09:22 +00:00
expect(result).toEqual('Infinity Gauntlet');
result = await nightmare
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value');
2018-11-21 13:09:22 +00:00
expect(result).toEqual('Crisantemo');
result = await nightmare
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, 'value');
2018-11-21 13:09:22 +00:00
2019-01-07 08:33:07 +00:00
expect(result).toEqual('5080000 Coral y materiales similares');
2018-11-21 13:09:22 +00:00
result = await nightmare
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, 'value');
2018-11-21 13:09:22 +00:00
2019-01-07 08:33:07 +00:00
expect(result).toEqual('Holand');
2018-11-21 13:09:22 +00:00
});
});
2018-11-21 13:09:22 +00:00
describe('clone', () => {
2019-01-07 08:33:07 +00:00
it('should return to the items index by clicking the return to items button', async() => {
2018-11-21 13:09:22 +00:00
const url = await nightmare
.click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index')
.parsedUrl();
expect(url.hash).toContain('#!/item/index');
});
2019-01-07 08:33:07 +00:00
it(`should search for the item Infinity Gauntlet`, async() => {
2018-11-21 13:09:22 +00:00
const result = await nightmare
.wait(selectors.itemsIndex.searchItemInput)
2018-11-21 13:09:22 +00:00
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should clone the Infinity Gauntlet`, async() => {
2018-11-21 13:09:22 +00:00
const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchResultCloneButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags')
.parsedUrl();
expect(url.hash).toContain('tags');
});
2019-01-07 08:33:07 +00:00
it('should search for the item Infinity Gauntlet and find two', async() => {
2018-11-21 13:09:22 +00:00
const result = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton)
.wait(selectors.itemsIndex.searchItemInput)
2018-11-21 13:09:22 +00:00
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2);
});
});
});