122 lines
4.8 KiB
JavaScript
122 lines
4.8 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Item Create botanical path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
beforeAll(() => {
|
|
nightmare
|
|
.waitForLogin('buyer');
|
|
});
|
|
|
|
it('should access to the items index by clicking the items button', async () => {
|
|
const url = await nightmare
|
|
.click(selectors.moduleAccessView.itemsSectionButton)
|
|
.wait(selectors.itemsIndex.createItemButton)
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/item/index');
|
|
});
|
|
|
|
it('should search for the item Mjolnir', async () => {
|
|
const result = await nightmare
|
|
.wait(selectors.itemsIndex.searchItemInput)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Mjolnir')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
|
|
.countElement(selectors.itemsIndex.searchResult);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the item botanical`, async () => {
|
|
const url = await nightmare
|
|
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Mjolnir')
|
|
.waitToClick(selectors.itemsIndex.searchResult)
|
|
.waitToClick(selectors.itemBotanical.botanicalButton)
|
|
.waitForURL('botanical')
|
|
.url();
|
|
|
|
expect(url).toContain('botanical');
|
|
});
|
|
|
|
it(`should create a new botanical for the item with id Mjolnir`, async () => {
|
|
const result = await 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();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the botanical for item Mjolnir was created`, async () => {
|
|
const result = await nightmare
|
|
.click(selectors.itemBasicData.basicDataButton)
|
|
.wait(selectors.itemBasicData.nameInput)
|
|
.click(selectors.itemBotanical.botanicalButton)
|
|
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Cicuta maculata')
|
|
.getInputValue(selectors.itemBotanical.botanicalInput);
|
|
|
|
expect(result).toEqual('Cicuta maculata');
|
|
});
|
|
|
|
it(`should confirm the Genus for item Mjolnir was created`, async () => {
|
|
const result = await nightmare
|
|
.waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abelia')
|
|
.getInputValue(selectors.itemBotanical.genusSelect);
|
|
|
|
expect(result).toEqual('Abelia');
|
|
});
|
|
|
|
it(`should confirm the Species for item Mjolnir was created`, async () => {
|
|
const result = await nightmare
|
|
.getInputValue(selectors.itemBotanical.speciesSelect);
|
|
|
|
expect(result).toEqual('dealbata');
|
|
});
|
|
|
|
it(`should edit botanical for the item Mjolnir`, async () => {
|
|
const result = await 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();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it(`should confirm the botanical for item Mjolnir was edited`, async () => {
|
|
const result = await nightmare
|
|
.click(selectors.itemBasicData.basicDataButton)
|
|
.wait(selectors.itemBasicData.nameInput)
|
|
.click(selectors.itemBotanical.botanicalButton)
|
|
.waitForTextInInput(selectors.itemBotanical.botanicalInput, 'Herp Derp')
|
|
.getInputValue(selectors.itemBotanical.botanicalInput);
|
|
|
|
expect(result).toEqual('Herp Derp');
|
|
});
|
|
|
|
it(`should confirm the Genus for item Mjolnir was edited`, async () => {
|
|
const result = await nightmare
|
|
.waitForTextInInput(selectors.itemBotanical.genusSelect, 'Abies')
|
|
.getInputValue(selectors.itemBotanical.genusSelect);
|
|
|
|
expect(result).toEqual('Abies');
|
|
});
|
|
|
|
it(`should confirm the Species for item Mjolnir was edited`, async () => {
|
|
const result = await nightmare
|
|
.getInputValue(selectors.itemBotanical.speciesSelect);
|
|
|
|
expect(result).toEqual('decurrens');
|
|
});
|
|
});
|