102 lines
3.4 KiB
JavaScript
102 lines
3.4 KiB
JavaScript
import config from '../../helpers/config.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
import selectors from '../../helpers/selectors.js';
|
|
import {catchErrors} from '../../../services/utils/jasmineHelpers';
|
|
const nightmare = createNightmare();
|
|
const moduleAccessViewHashURL = '#!/';
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
|
|
describe('create item barcodes path', () => {
|
|
it('should log in', done => {
|
|
nightmare
|
|
.login()
|
|
.waitForURL(moduleAccessViewHashURL)
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toEqual(config.url + moduleAccessViewHashURL);
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should make sure the language is English', done => {
|
|
nightmare
|
|
.changeLanguageToEnglish()
|
|
.then(() => {
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should access to the items index by clicking the items button', done => {
|
|
nightmare
|
|
.click(selectors.moduleAccessView.itemsSectionButton)
|
|
.wait(selectors.itemsIndex.createItemButton)
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toEqual(config.url + '#!/item/list');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it('should search for the item Gem of Time', done => {
|
|
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);
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it(`should click on the search result to access to the item barcodes`, done => {
|
|
nightmare
|
|
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
|
|
.waitToClick(selectors.itemsIndex.searchResult)
|
|
.waitToClick(selectors.itemBarcodes.barcodeButton)
|
|
.waitForURL('barcode')
|
|
.url()
|
|
.then(url => {
|
|
expect(url).toContain('barcode');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it(`should click create a new code and delete a former one`, done => {
|
|
nightmare
|
|
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
|
|
.type(selectors.itemBarcodes.fourthCodeInput, '5')
|
|
.click(selectors.itemBarcodes.firstCodeRemoveButton)
|
|
.click(selectors.itemBarcodes.submitBarcodesButton)
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
.then(result => {
|
|
expect(result).toContain('Data saved!');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
|
|
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => {
|
|
nightmare
|
|
.waitForSnackbarReset()
|
|
.click(selectors.itemBasicData.basicDataButton)
|
|
.wait(selectors.itemBasicData.nameInput)
|
|
.click(selectors.itemBarcodes.barcodeButton)
|
|
.wait(200)
|
|
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
|
|
.then(result => {
|
|
expect(result).toEqual('5');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
});
|