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

130 lines
5.6 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-01-09 12:07:16 +00:00
await page.clearInput(selectors.itemsIndex.searchItemInput);
await page.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet');
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);
await page.wait(selectors.itemCreateView.createButton);
const url = await page.parsedUrl();
2018-11-21 13:09:22 +00:00
expect(url.hash).toEqual('#!/item/create');
});
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);
await page.wait(selectors.itemsIndex.createItemButton);
const url = await page.parsedUrl();
2018-11-21 13:09:22 +00:00
expect(url.hash).toEqual('#!/item/index');
});
2019-01-07 08:33:07 +00:00
it('should now access to the create item view by clicking the create floating button', async() => {
await page.waitForContentLoaded();
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.createItemButton);
await page.wait(selectors.itemCreateView.createButton);
const url = await page.parsedUrl();
2018-11-21 13:09:22 +00:00
expect(url.hash).toEqual('#!/item/create');
});
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');
await page.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo');
await page.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares');
await page.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand');
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
.waitToGetProperty(`${selectors.itemBasicData.nameInput} input`, '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
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value');
2018-11-21 13:09:22 +00:00
expect(result).toEqual('Crisantemo');
2020-01-09 12:07:16 +00:00
result = await page
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, '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
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, '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);
await page.waitForURL('#!/item/index');
const url = await page.parsedUrl();
2018-11-21 13:09:22 +00:00
expect(url.hash).toContain('#!/item/index');
});
2019-01-07 08:33:07 +00:00
it(`should search for the item Infinity Gauntlet`, async() => {
2020-01-09 12:07:16 +00:00
await page.clearInput(selectors.itemsIndex.searchItemInput);
await page.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet');
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);
await page.waitForURL('tags');
const url = await page.parsedUrl();
2018-11-21 13:09:22 +00:00
expect(url.hash).toContain('tags');
});
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);
await page.clearInput(selectors.itemsIndex.searchItemInput);
await page.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet');
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);
});
});
});