salix/e2e/paths/item-module/02_edit_item_basic_data.spe...

99 lines
3.9 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item Edit basic data path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('buyer', 'item')
.accessToSearchResult('Gem of Mind')
.accessToSection('item.card.data');
});
it(`should edit the item basic data`, async () => {
const result = await nightmare
.wait(selectors.itemBasicData.nameInput)
.clearInput(selectors.itemBasicData.nameInput)
.type(selectors.itemBasicData.nameInput, 'Rose of Purity')
.waitToClick(selectors.itemBasicData.typeSelect)
.waitToClick(selectors.itemBasicData.typeSelectOptionThree)
.waitToClick(selectors.itemBasicData.intrastatSelect)
.waitToClick(selectors.itemBasicData.intrastatSelectOptionOne)
.clearInput(selectors.itemBasicData.relevancyInput)
.type(selectors.itemBasicData.relevancyInput, '1')
.waitToClick(selectors.itemBasicData.originSelect)
.waitToClick(selectors.itemBasicData.originSelectOptionTwo)
.waitToClick(selectors.itemBasicData.expenceSelect)
.waitToClick(selectors.itemBasicData.expenceSelectOptionThree)
.clearInput(selectors.itemBasicData.longNameInput)
.type(selectors.itemBasicData.longNameInput, 'RS Rose of Purity')
.waitToClick(selectors.itemBasicData.isActiveCheckbox)
.click(selectors.itemBasicData.submitBasicDataButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the item name was edited`, async () => {
const result = await nightmare
.click(selectors.itemNiches.nicheButton)
.wait(selectors.itemNiches.firstWarehouseDisabled)
.waitToClick(selectors.itemBasicData.basicDataButton)
.waitToGetProperty(selectors.itemBasicData.nameInput, 'value');
expect(result).toEqual('Rose of Purity');
});
it(`should confirm the item type was edited`, async () => {
const result = await nightmare
.waitToGetProperty(selectors.itemBasicData.typeSelect, 'value');
expect(result).toEqual('Crisantemo');
});
it(`should confirm the item intrastad was edited`, async () => {
const result = await nightmare
.waitToGetProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('5080000 Coral y materiales similares');
});
it(`should confirm the item relevancy was edited`, async () => {
const result = await nightmare
.waitToGetProperty(selectors.itemBasicData.relevancyInput, 'value');
expect(result).toEqual('1');
});
it(`should confirm the item origin was edited`, async () => {
const result = await nightmare
.waitToGetProperty(selectors.itemBasicData.originSelect, 'value');
expect(result).toEqual('Spain');
});
it(`should confirm the item expence was edited`, async () => {
const result = await nightmare
.waitToGetProperty(selectors.itemBasicData.expenceSelect, 'value');
expect(result).toEqual('Adquisición mercancia Extracomunitaria');
});
it(`should confirm the item long name was edited`, async () => {
const result = await nightmare
.waitToGetProperty(selectors.itemBasicData.longNameInput, 'value');
expect(result).toEqual('RS Rose of Purity');
});
it('should confirm isActive checkbox is unchecked', async () => {
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.itemBasicData.isActiveCheckbox);
expect(result).toBeFalsy();
});
});