125 lines
5.2 KiB
JavaScript
125 lines
5.2 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() => {
|
|
await 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.topbarSearch);
|
|
await page.write(selectors.itemsIndex.topbarSearch, '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);
|
|
let url = await page.expectURL('#!/item/create');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should return to the item index by clickig the cancel button', async() => {
|
|
await page.waitToClick(selectors.itemCreateView.cancelButton);
|
|
let url = await page.expectURL('#!/item/index');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should now access to the create item view by clicking the create floating button', async() => {
|
|
await page.waitForContentLoaded();
|
|
await page.waitToClick(selectors.itemsIndex.createItemButton);
|
|
let url = await page.expectURL('#!/item/create');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should create the Infinity Gauntlet item', async() => {
|
|
await page.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet');
|
|
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
|
|
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
|
|
await page.autocompleteSearch(selectors.itemCreateView.origin, '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.name, 'value');
|
|
|
|
expect(result).toEqual('Infinity Gauntlet');
|
|
|
|
|
|
result = await page
|
|
.waitToGetProperty(selectors.itemBasicData.type, 'value');
|
|
|
|
expect(result).toEqual('Crisantemo');
|
|
|
|
result = await page
|
|
.waitToGetProperty(selectors.itemBasicData.intrastat, 'value');
|
|
|
|
expect(result).toEqual('5080000 Coral y materiales similares');
|
|
|
|
result = await page
|
|
.waitToGetProperty(selectors.itemBasicData.origin, '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);
|
|
let url = await page.expectURL('#!/item/index');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it(`should search for the item Infinity Gauntlet`, async() => {
|
|
await page.clearInput(selectors.itemsIndex.topbarSearch);
|
|
await page.write(selectors.itemsIndex.topbarSearch, '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);
|
|
let url = await page.expectURL('tags');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should search for the item Infinity Gauntlet and find two', async() => {
|
|
await page.waitToClick(selectors.itemTags.goToItemIndexButton);
|
|
await page.clearInput(selectors.itemsIndex.topbarSearch);
|
|
await page.write(selectors.itemsIndex.topbarSearch, '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);
|
|
});
|
|
});
|
|
});
|