salix/e2e/paths/04-item-module/02_basic_data.spec.js

106 lines
4.0 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item Edit basic data path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Melee weapon combat fist 15cm');
await page.accessToSection('item.card.basicData');
});
afterAll(async() => {
await browser.close();
});
it(`should check the descritor edit button is visible for buyer`, async() => {
await page.waitForSelector(selectors.itemDescriptor.editButton, {visible: true});
});
it(`should edit the item basic data`, async() => {
await page.clearInput(selectors.itemBasicData.name);
await page.write(selectors.itemBasicData.name, 'Rose of Purity');
await page.autocompleteSearch(selectors.itemBasicData.type, 'Anthurium');
await page.autocompleteSearch(selectors.itemBasicData.intrastat, 'Coral y materiales similares');
await page.clearInput(selectors.itemBasicData.relevancy);
await page.write(selectors.itemBasicData.relevancy, '1');
await page.autocompleteSearch(selectors.itemBasicData.origin, 'Spain');
await page.autocompleteSearch(selectors.itemBasicData.expense, 'Alquiler VNH');
await page.clearInput(selectors.itemBasicData.longName);
await page.write(selectors.itemBasicData.longName, 'RS Rose of Purity');
await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
await page.waitToClick(selectors.itemBasicData.priceInKgCheckbox);
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
}, 20000);
it(`should confirm the item name was edited`, async() => {
await page.reloadSection('item.card.basicData');
await page.waitForContentLoaded();
const result = await page.waitToGetProperty(selectors.itemBasicData.name, 'value');
expect(result).toEqual('Rose of Purity');
});
it(`should confirm the item type was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBasicData.type, 'value');
expect(result).toEqual('Anthurium');
});
it(`should confirm the item intrastad was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBasicData.intrastat, 'value');
expect(result).toEqual('5080000 Coral y materiales similares');
});
it(`should confirm the item relevancy was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBasicData.relevancy, 'value');
expect(result).toEqual('1');
});
it(`should confirm the item origin was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBasicData.origin, 'value');
expect(result).toEqual('Spain');
});
it(`should confirm the item expence was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBasicData.expense, 'value');
expect(result).toEqual('Alquiler VNH');
});
it(`should confirm the item long name was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBasicData.longName, 'value');
expect(result).toEqual('RS Rose of Purity');
});
it('should confirm isActive checkbox is unchecked', async() => {
const result = await page
.checkboxState(selectors.itemBasicData.isActiveCheckbox);
expect(result).toBe('unchecked');
});
it('should confirm the priceInKg checkbox is checked', async() => {
const result = await page
.checkboxState(selectors.itemBasicData.priceInKgCheckbox);
expect(result).toBe('checked');
});
});