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

124 lines
5.1 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2018-11-21 13:09:22 +00:00
describe('Item Create/Clone path', () => {
let browser;
2020-01-09 12:07:16 +00:00
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2020-01-09 12:07:16 +00:00
await page.loginAndModule('buyer', 'item');
});
2018-11-21 13:09:22 +00:00
2020-01-09 12:07:16 +00:00
afterAll(async() => {
await browser.close();
2020-01-09 12:07:16 +00:00
});
describe('create', () => {
2019-01-07 08:33:07 +00:00
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.itemsIndex.topbarSearch);
await page.write(selectors.itemsIndex.topbarSearch, 'Infinity Gauntlet');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.searchButton);
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0);
const result = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-21 13:09:22 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.createItemButton);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/item/create');
2018-11-21 13:09:22 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2018-11-21 13:09:22 +00:00
});
2019-01-07 08:33:07 +00:00
it('should return to the item index by clickig the cancel button', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemCreateView.cancelButton);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/item/index');
2018-11-21 13:09:22 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2018-11-21 13:09:22 +00:00
});
2019-01-07 08:33:07 +00:00
it('should now access to the create item view by clicking the create floating button', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.createItemButton);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/item/create');
2018-11-21 13:09:22 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2018-11-21 13:09:22 +00:00
});
2019-01-07 08:33:07 +00:00
it('should create the Infinity Gauntlet item', async() => {
2020-01-09 12:07:16 +00:00
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
2020-02-03 14:55:11 +00:00
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemCreateView.createButton);
const result = await page.waitForLastSnackbar();
2018-11-21 13:09:22 +00:00
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should confirm Infinity Gauntlet item was created', async() => {
2020-01-09 12:07:16 +00:00
let result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.itemBasicData.name, 'value');
2018-11-21 13:09:22 +00:00
expect(result).toEqual('Infinity Gauntlet');
2020-01-09 12:07:16 +00:00
result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.itemBasicData.type, 'value');
2018-11-21 13:09:22 +00:00
expect(result).toEqual('Crisantemo');
2020-01-09 12:07:16 +00:00
result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.itemBasicData.intrastat, '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
2020-01-09 12:07:16 +00:00
result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.itemBasicData.origin, '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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemBasicData.goToItemIndexButton);
await page.wait(selectors.itemsIndex.createItemButton);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/item/index');
2018-11-21 13:09:22 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2018-11-21 13:09:22 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should search for the item Infinity Gauntlet`, async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.itemsIndex.topbarSearch);
await page.write(selectors.itemsIndex.topbarSearch, 'Infinity Gauntlet');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.searchButton);
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
const result = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-21 13:09:22 +00:00
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should clone the Infinity Gauntlet`, async() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet');
await page.waitToClick(selectors.itemsIndex.searchResultCloneButton);
await page.waitToClick(selectors.itemsIndex.acceptClonationAlertButton);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('tags');
2018-11-21 13:09:22 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2018-11-21 13:09:22 +00:00
});
2019-01-07 08:33:07 +00:00
it('should search for the item Infinity Gauntlet and find two', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemTags.goToItemIndexButton);
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.itemsIndex.topbarSearch);
await page.write(selectors.itemsIndex.topbarSearch, 'Infinity Gauntlet');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.searchButton);
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
const result = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-21 13:09:22 +00:00
expect(result).toEqual(2);
});
});
});