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

146 lines
5.9 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item Create path', () => {
const nightmare = createNightmare();
describe('Create path', () => {
beforeAll(() => {
return nightmare
.waitForLogin('buyer');
});
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)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0);
});
it('should access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should return to the item index by clickig the cancel button', async () => {
const url = await nightmare
.click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
it('should now access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should create the Infinity Gauntlet item', async () => {
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionThree)
.waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
.click(selectors.itemCreateView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm Infinity Gauntlet item was created', async () => {
let result = await nightmare
.wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput);
expect(result).toEqual('Infinity Gauntlet');
result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect);
expect(result).toEqual('Crisantemo');
result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect);
expect(result).toEqual('Spain');
});
});
describe('Clone path', () => {
it('should return to the items index by clicking the return to items button', async () => {
const url = await nightmare
.click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index')
.parsedUrl();
expect(url.hash).toContain('#!/item/index');
});
it(`should search for the item Infinity Gauntlet`, async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should clone the Infinity Gauntlet`, async () => {
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');
});
it('should search for the item Infinity Gauntlet and find two', async () => {
const result = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton)
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2);
});
});
});