107 lines
3.8 KiB
JavaScript
107 lines
3.8 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/helpers';
|
|
|
|
describe('create item niche path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
beforeAll(() => {
|
|
return nightmare
|
|
.waitForLogin('developer');
|
|
});
|
|
|
|
it('should access to the items index by clicking the items button', () => {
|
|
return nightmare
|
|
.click(selectors.moduleAccessView.itemsSectionButton)
|
|
.wait(selectors.itemsIndex.createItemButton)
|
|
.parsedUrl()
|
|
.then(url => {
|
|
expect(url.hash).toEqual('#!/item/list');
|
|
});
|
|
});
|
|
|
|
it('should search for the item Gem of Time', () => {
|
|
return nightmare
|
|
.wait(selectors.itemsIndex.searchResult)
|
|
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
|
|
.click(selectors.itemsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
|
|
.countSearchResults(selectors.itemsIndex.searchResult)
|
|
.then(result => {
|
|
expect(result).toEqual(1);
|
|
});
|
|
});
|
|
|
|
it(`should click on the search result to access to the item niches`, () => {
|
|
return nightmare
|
|
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
|
|
.waitToClick(selectors.itemsIndex.searchResult)
|
|
.waitToClick(selectors.itemNiches.nicheButton)
|
|
.waitForURL('niche')
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toContain('niche');
|
|
});
|
|
});
|
|
|
|
it(`should click create a new niche, edit another and delete a former one`, () => {
|
|
return nightmare
|
|
.waitToClick(selectors.itemNiches.addNicheButton)
|
|
.waitToClick(selectors.itemNiches.firstWarehouseSelect)
|
|
.waitToClick(selectors.itemNiches.firstWarehouseSelectSecondOption)
|
|
.clearInput(selectors.itemNiches.firstCodeInput)
|
|
.type(selectors.itemNiches.firstCodeInput, 'A2')
|
|
.waitToClick(selectors.itemNiches.secondNicheRemoveButton)
|
|
.waitToClick(selectors.itemNiches.thirdWarehouseSelect)
|
|
.waitToClick(selectors.itemNiches.thirdWarehouseSelectFourthOption)
|
|
.type(selectors.itemNiches.thirdCodeInput, 'A4')
|
|
.click(selectors.itemNiches.submitNichesButton)
|
|
.waitForSnackbar()
|
|
.then(result => {
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
});
|
|
|
|
it(`should confirm the first niche is the expected one`, () => {
|
|
return nightmare
|
|
.click(selectors.itemBasicData.basicDataButton)
|
|
.wait(selectors.itemBasicData.nameInput)
|
|
.click(selectors.itemNiches.nicheButton)
|
|
.waitForTextInInput(selectors.itemNiches.firstWarehouseSelect, 'Warehouse Two')
|
|
.getInputValue(selectors.itemNiches.firstWarehouseSelect)
|
|
.then(result => {
|
|
expect(result).toEqual('Warehouse Two');
|
|
return nightmare
|
|
.getInputValue(selectors.itemNiches.firstCodeInput);
|
|
})
|
|
.then(result => {
|
|
expect(result).toEqual('A2');
|
|
});
|
|
});
|
|
|
|
it(`should confirm the second niche is the expected one`, () => {
|
|
return nightmare
|
|
.getInputValue(selectors.itemNiches.secondWarehouseSelect)
|
|
.then(result => {
|
|
expect(result).toEqual('Warehouse Three');
|
|
return nightmare
|
|
.getInputValue(selectors.itemNiches.secondCodeInput);
|
|
})
|
|
.then(result => {
|
|
expect(result).toEqual('A3');
|
|
});
|
|
});
|
|
|
|
it(`should confirm the third niche is the expected one`, () => {
|
|
return nightmare
|
|
.getInputValue(selectors.itemNiches.thirdWarehouseSelect)
|
|
.then(result => {
|
|
expect(result).toEqual('Warehouse Four');
|
|
return nightmare
|
|
.getInputValue(selectors.itemNiches.thirdCodeInput);
|
|
})
|
|
.then(result => {
|
|
expect(result).toEqual('A4');
|
|
});
|
|
});
|
|
});
|