135 lines
5.5 KiB
JavaScript
135 lines
5.5 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Item Create/Clone path', () => {
|
|
const nightmare = createNightmare();
|
|
describe('create', () => {
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('buyer', 'item');
|
|
});
|
|
|
|
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => {
|
|
const result = await nightmare
|
|
.wait(selectors.itemsIndex.searchItemInput)
|
|
.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
|
|
.waitToGetProperty(selectors.itemBasicData.nameInput, 'value');
|
|
|
|
expect(result).toEqual('Infinity Gauntlet');
|
|
|
|
|
|
result = await nightmare
|
|
.waitToGetProperty(selectors.itemBasicData.typeSelect, 'value');
|
|
|
|
expect(result).toEqual('Crisantemo');
|
|
|
|
result = await nightmare
|
|
.waitToGetProperty(selectors.itemBasicData.intrastatSelect, 'value');
|
|
|
|
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
|
|
|
|
result = await nightmare
|
|
.waitToGetProperty(selectors.itemBasicData.originSelect, 'value');
|
|
|
|
expect(result).toEqual('Spain');
|
|
});
|
|
});
|
|
|
|
describe('clone', () => {
|
|
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.searchItemInput)
|
|
.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.searchItemInput)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
|
|
.countElement(selectors.itemsIndex.searchResult);
|
|
|
|
expect(result).toEqual(2);
|
|
});
|
|
});
|
|
});
|