salix/e2e/paths/item-module/06_create_item_botanical.sp...

146 lines
5.8 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item', () => {
describe('Create botanical path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.waitForLogin('buyer');
});
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');
done();
}).catch(done.fail);
});
it('should search for the item Mjolnir', done => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Mjolnir')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
done();
}).catch(done.fail);
});
it(`should click on the search result to access to the item botanical`, done => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Mjolnir')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBotanical.botanicalButton)
.waitForURL('botanical')
.url()
.then(url => {
expect(url).toContain('botanical');
done();
}).catch(done.fail);
});
it(`should create a new botanical for the item with id Mjolnir`, done => {
return nightmare
.type(selectors.itemBotanical.botanicalInput, 'Cicuta maculata')
.waitToClick(selectors.itemBotanical.genusSelect)
.waitToClick(selectors.itemBotanical.genusSelectOptionOne)
.waitToClick(selectors.itemBotanical.speciesSelect)
.waitToClick(selectors.itemBotanical.speciesSelectOptionOne)
.waitToClick(selectors.itemBotanical.submitBotanicalButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
});
it(`should confirm the botanical for item Mjolnir was created`, done => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBotanical.botanicalButton)
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata')
.getInputValue(selectors.itemBotanical.botanicalInput)
.then(result => {
expect(result).toEqual('Cicuta maculata');
done();
}).catch(done.fail);
});
it(`should confirm the Genus for item Mjolnir was created`, done => {
return nightmare
.waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abelia')
.getInputValue(selectors.itemBotanical.genusSelect)
.then(result => {
expect(result).toEqual('Abelia');
done();
}).catch(done.fail);
});
it(`should confirm the Species for item Mjolnir was created`, done => {
return nightmare
.getInputValue(selectors.itemBotanical.speciesSelect)
.then(result => {
expect(result).toEqual('dealbata');
done();
}).catch(done.fail);
});
it(`should edit botanical for the item Mjolnir`, done => {
return nightmare
.clearInput(selectors.itemBotanical.botanicalInput)
.type(selectors.itemBotanical.botanicalInput, 'Herp Derp')
.waitToClick(selectors.itemBotanical.genusSelect)
.waitToClick(selectors.itemBotanical.genusSelectOptionTwo)
.waitToClick(selectors.itemBotanical.speciesSelect)
.waitToClick(selectors.itemBotanical.speciesSelectOptionTwo)
.waitToClick(selectors.itemBotanical.submitBotanicalButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
});
it(`should confirm the botanical for item Mjolnir was edited`, done => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBotanical.botanicalButton)
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp')
.getInputValue(selectors.itemBotanical.botanicalInput)
.then(result => {
expect(result).toEqual('Herp Derp');
done();
}).catch(done.fail);
});
it(`should confirm the Genus for item Mjolnir was edited`, done => {
return nightmare
.waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abies')
.getInputValue(selectors.itemBotanical.genusSelect)
.then(result => {
expect(result).toEqual('Abies');
done();
}).catch(done.fail);
});
it(`should confirm the Species for item Mjolnir was edited`, done => {
return nightmare
.getInputValue(selectors.itemBotanical.speciesSelect)
.then(result => {
expect(result).toEqual('decurrens');
done();
}).catch(done.fail);
});
});
});