129 lines
5.6 KiB
JavaScript
129 lines
5.6 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Item Create/Clone path', () => {
|
|
let browser;
|
|
let page;
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('buyer', 'item');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
browser.close();
|
|
});
|
|
|
|
describe('create', () => {
|
|
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
|
|
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);
|
|
|
|
expect(result).toEqual(0);
|
|
});
|
|
|
|
it('should access to the create item view by clicking the create floating button', async() => {
|
|
await page.waitToClick(selectors.itemsIndex.createItemButton);
|
|
await page.wait(selectors.itemCreateView.createButton);
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/item/create');
|
|
});
|
|
|
|
it('should return to the item index by clickig the cancel button', async() => {
|
|
await page.waitToClick(selectors.itemCreateView.cancelButton);
|
|
await page.wait(selectors.itemsIndex.createItemButton);
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/item/index');
|
|
});
|
|
|
|
it('should now access to the create item view by clicking the create floating button', async() => {
|
|
await page.waitToClick(selectors.itemsIndex.createItemButton);
|
|
await page.wait(selectors.itemCreateView.createButton);
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/item/create');
|
|
});
|
|
|
|
it('should create the Infinity Gauntlet item', async() => {
|
|
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();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should confirm Infinity Gauntlet item was created', async() => {
|
|
let result = await page
|
|
.waitToGetProperty(`${selectors.itemBasicData.nameInput} input`, 'value');
|
|
|
|
expect(result).toEqual('Infinity Gauntlet');
|
|
|
|
|
|
result = await page
|
|
.waitToGetProperty(`${selectors.itemBasicData.typeAutocomplete} input`, 'value');
|
|
|
|
expect(result).toEqual('Crisantemo');
|
|
|
|
result = await page
|
|
.waitToGetProperty(`${selectors.itemBasicData.intrastatAutocomplete} input`, 'value');
|
|
|
|
expect(result).toEqual('5080000 Coral y materiales similares');
|
|
|
|
result = await page
|
|
.waitToGetProperty(`${selectors.itemBasicData.originAutocomplete} input`, 'value');
|
|
|
|
expect(result).toEqual('Holand');
|
|
});
|
|
});
|
|
|
|
describe('clone', () => {
|
|
it('should return to the items index by clicking the return to items button', async() => {
|
|
await page.waitToClick(selectors.itemBasicData.goToItemIndexButton);
|
|
await page.wait(selectors.itemsIndex.createItemButton);
|
|
await page.waitForURL('#!/item/index');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('#!/item/index');
|
|
});
|
|
|
|
it(`should search for the item Infinity Gauntlet`, async() => {
|
|
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);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should clone the Infinity Gauntlet`, async() => {
|
|
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();
|
|
|
|
expect(url.hash).toContain('tags');
|
|
});
|
|
|
|
it('should search for the item Infinity Gauntlet and find two', async() => {
|
|
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);
|
|
|
|
expect(result).toEqual(2);
|
|
});
|
|
});
|
|
});
|