135 lines
5.3 KiB
JavaScript
135 lines
5.3 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/helpers';
|
|
|
|
describe('Item', () => {
|
|
const nightmare = createNightmare();
|
|
describe('Create path', () => {
|
|
beforeAll(() => {
|
|
return nightmare
|
|
.waitForLogin('developer');
|
|
});
|
|
|
|
it('should access to the items index by clicking the items button', () => {
|
|
return nightmare
|
|
.click(selectors.moduleAccessView.itemsSectionButton)
|
|
.wait(selectors.itemsIndex.createItemButton)
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toEqual('#!/item/list');
|
|
});
|
|
});
|
|
|
|
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, () => {
|
|
return nightmare
|
|
.wait(selectors.itemsIndex.searchResult)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
|
|
.countSearchResults(selectors.itemsIndex.searchResult)
|
|
.then(result => {
|
|
expect(result).toEqual(0);
|
|
});
|
|
});
|
|
|
|
it('should access to the create item view by clicking the create floating button', () => {
|
|
return nightmare
|
|
.click(selectors.itemsIndex.createItemButton)
|
|
.wait(selectors.itemCreateView.createButton)
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toEqual('#!/item/create');
|
|
});
|
|
});
|
|
|
|
it('should create the Infinity Gauntlet item', () => {
|
|
return nightmare
|
|
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
|
|
.waitToClick(selectors.itemCreateView.typeSelect)
|
|
.waitToClick(selectors.itemCreateView.typeSelectOptionOne)
|
|
.waitToClick(selectors.itemCreateView.intrastatSelect)
|
|
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
|
|
.waitToClick(selectors.itemCreateView.originSelect)
|
|
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
|
|
.click(selectors.itemCreateView.createButton)
|
|
.waitForSnackbar()
|
|
.then(result => {
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
});
|
|
|
|
it('should confirm Infinity Gauntlet item was created', () => {
|
|
return nightmare
|
|
.wait(selectors.itemBasicData.nameInput)
|
|
.getInputValue(selectors.itemBasicData.nameInput)
|
|
.then(result => {
|
|
expect(result).toBe('Infinity Gauntlet');
|
|
return nightmare
|
|
.getInputValue(selectors.itemBasicData.typeSelect);
|
|
})
|
|
.then(result => {
|
|
expect(result).toBe('Crisantemo');
|
|
return nightmare
|
|
.getInputValue(selectors.itemBasicData.intrastatSelect);
|
|
})
|
|
.then(result => {
|
|
expect(result).toBe('Plantas vivas: Esqueje/injerto, Vid');
|
|
return nightmare
|
|
.getInputValue(selectors.itemBasicData.originSelect);
|
|
})
|
|
.then(result => {
|
|
expect(result).toBe('Spain');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Clone path', () => {
|
|
it('should return to the items index by clicking the return to items button', () => {
|
|
return nightmare
|
|
.click(selectors.itemBasicData.goToItemIndexButton)
|
|
.wait(selectors.itemsIndex.createItemButton)
|
|
.waitForURL('#!/item/list')
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toContain('#!/item/list');
|
|
});
|
|
});
|
|
|
|
it(`should search for the item Infinity Gauntlet`, () => {
|
|
return nightmare
|
|
.wait(selectors.itemsIndex.searchResult)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
|
|
.countSearchResults(selectors.itemsIndex.searchResult)
|
|
.then(result => {
|
|
expect(result).toEqual(1);
|
|
});
|
|
});
|
|
|
|
it(`should clone the Infinity Gauntlet`, () => {
|
|
return nightmare
|
|
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
|
|
.click(selectors.itemsIndex.searchResultCloneButton)
|
|
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
|
|
.waitForURL('tags')
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toContain('tags');
|
|
});
|
|
});
|
|
|
|
it('should search for the item Infinity Gauntlet and find two', () => {
|
|
return nightmare
|
|
.waitToClick(selectors.itemTags.goToItemIndexButton)
|
|
.wait(selectors.itemsIndex.searchResult)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
|
|
.countSearchResults(selectors.itemsIndex.searchResult)
|
|
.then(result => {
|
|
expect(result).toEqual(2);
|
|
});
|
|
});
|
|
});
|
|
});
|