salix/e2e/paths/04-item-module/08_create_and_clone.spec.js

129 lines
5.3 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
2019-01-23 14:34:16 +00:00
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.searchButton)
2018-11-21 13:09:22 +00:00
.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
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.createItemButton)
2018-11-21 13:09:22 +00:00
.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
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemCreateView.cancelButton)
2018-11-21 13:09:22 +00:00
.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
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.createItemButton)
2018-11-21 13:09:22 +00:00
.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
2019-01-23 14:34:16 +00:00
.write(selectors.itemCreateView.temporalName, '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')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemCreateView.createButton)
2018-11-21 13:09:22 +00:00
.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
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemBasicData.goToItemIndexButton)
2018-11-21 13:09:22 +00:00
.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
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.searchButton)
2018-11-21 13:09:22 +00:00
.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')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.searchResultCloneButton)
2018-11-21 13:09:22 +00:00
.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)
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.searchButton)
2018-11-21 13:09:22 +00:00
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2);
});
});
});