salix/e2e/paths/item-module/03_edit_item_tax.spec.js

91 lines
3.5 KiB
JavaScript
Raw Normal View History

2018-02-26 12:24:47 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Item', () => {
describe('Edit tax path', () => {
const nightmare = createNightmare();
2018-02-26 12:24:47 +00:00
beforeAll(() => {
return nightmare
2018-10-11 07:14:26 +00:00
.waitForLogin('buyer');
2018-02-26 12:24:47 +00:00
});
2018-10-22 15:12:41 +00:00
it('should access to the items index by clicking the items button', done => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-26 12:24:47 +00:00
});
2018-10-22 15:12:41 +00:00
it('should search for the item Gem of Time', done => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-26 12:24:47 +00:00
});
2018-10-22 15:12:41 +00:00
it(`should click on the search result to access to the item tax`, done => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemTax.taxButton)
.waitForURL('tax')
.url()
.then(url => {
expect(url).toContain('tax');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-26 12:24:47 +00:00
});
2018-10-22 15:12:41 +00:00
it(`should add the item tax to all countries`, done => {
2018-02-26 12:24:47 +00:00
return nightmare
.waitToClick(selectors.itemTax.firstClassSelect)
.waitToClick(selectors.itemTax.firstClassSelectOptionTwo)
.waitToClick(selectors.itemTax.secondClassSelect)
.waitToClick(selectors.itemTax.secondClassSelectOptionOne)
.waitToClick(selectors.itemTax.thirdClassSelect)
.waitToClick(selectors.itemTax.thirdClassSelectOptionTwo)
.click(selectors.itemTax.submitTaxButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should confirm the item tax class was edited`, done => {
2018-02-26 12:24:47 +00:00
return nightmare
.click(selectors.itemTags.tagsButton)
.wait(selectors.itemTags.firstTagDisabled)
.click(selectors.itemTax.taxButton)
.waitToClick(selectors.itemTax.taxButton)
.waitForTextInInput(selectors.itemTax.firstClassSelect, 'reduced')
.getInputValue(selectors.itemTax.firstClassSelect)
.then(result => {
expect(result).toEqual('Reduced VAT');
return nightmare
.getInputValue(selectors.itemTax.secondClassSelect);
})
.then(result => {
expect(result).toEqual('General VAT');
return nightmare
.getInputValue(selectors.itemTax.thirdClassSelect);
})
.then(result => {
expect(result).toEqual('Reduced VAT');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-02-26 12:24:47 +00:00
});
});
});