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

166 lines
6.5 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Item', () => {
const nightmare = createNightmare();
describe('Create path', () => {
beforeAll(() => {
return nightmare
2018-10-11 07:14:26 +00:00
.waitForLogin('buyer');
});
2018-10-22 15:12:41 +00:00
it('should access to the items index by clicking the items button', done => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, done => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(0);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should access to the create item view by clicking the create floating button', done => {
return nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/create');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should return to the item index by clickig the cancel button', done => {
return nightmare
.click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should now access to the create item view by clicking the create floating button', done => {
return nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/create');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should create the Infinity Gauntlet item', done => {
return 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()
.then(result => {
expect(result).toEqual('Data saved!');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should confirm Infinity Gauntlet item was created', done => {
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');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
});
describe('Clone path', () => {
2018-10-22 15:12:41 +00:00
it('should return to the items index by clicking the return to items button', done => {
return nightmare
.click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('#!/item/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should search for the item Infinity Gauntlet`, done => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should clone the Infinity Gauntlet`, done => {
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');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should search for the item Infinity Gauntlet and find two', done => {
return nightmare
2018-02-28 07:16:28 +00:00
.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)
.then(result => {
expect(result).toEqual(2);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
});
});