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

106 lines
4.2 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() => {
await page.doSearch('Infinity Gauntlet');
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-21 13:09:22 +00:00
expect(nResults).toEqual(0);
2018-11-21 13:09:22 +00:00
});
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.waitForState('item.create');
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);
await page.waitForState('item.index');
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);
await page.waitForState('item.create');
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);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-21 13:09:22 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
2018-11-21 13:09:22 +00:00
});
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
});
});
2020-03-18 12:54:05 +00:00
// Issue #2201
// When there is just one result you're redirected automatically to it, so
// it's not possible to use the clone option.
2020-03-17 13:01:25 +00:00
xdescribe('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.waitForState('item.index');
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() => {
await page.doSearch('Infinity Gauntlet');
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-21 13:09:22 +00:00
expect(nResults).toEqual(1);
2018-11-21 13:09:22 +00:00
});
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.waitForState('item.tags');
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() => {
await page.doSearch('Infinity Gauntlet');
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
expect(nResults).toEqual(2);
2018-11-21 13:09:22 +00:00
});
});
});