salix/e2e/paths/04-item-module/03_tax.spec.js

63 lines
2.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item edit tax path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon longbow 2m')
.accessToSection('item.card.tax');
});
it(`should add the item tax to all countries`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'General VAT')
.autocompleteSearch(selectors.itemTax.secondClassAutocomplete, 'General VAT')
.autocompleteSearch(selectors.itemTax.thirdClassAutocomplete, 'General VAT')
.waitToClick(selectors.itemTax.submitTaxButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the first item tax class was edited`, async() => {
const firstVatType = await nightmare
.reloadSection('item.card.tax')
.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
expect(firstVatType).toEqual('General VAT');
});
it(`should confirm the second item tax class was edited`, async() => {
const secondVatType = await nightmare
.waitToGetProperty(`${selectors.itemTax.secondClassAutocomplete} input`, 'value');
expect(secondVatType).toEqual('General VAT');
});
it(`should confirm the third item tax class was edited`, async() => {
const thirdVatType = await nightmare
.waitToGetProperty(`${selectors.itemTax.thirdClassAutocomplete} input`, 'value');
expect(thirdVatType).toEqual('General VAT');
});
it(`should edit the first class without saving the form`, async() => {
const firstVatType = await nightmare
.autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'Reduced VAT')
.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
expect(firstVatType).toEqual('Reduced VAT');
});
it(`should now click the undo changes button and see the changes works`, async() => {
const firstVatType = await nightmare
.waitToClick(selectors.itemTax.undoChangesButton)
.waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value');
expect(firstVatType).toEqual('General VAT');
});
});