diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 80a41a954..610bab6a9 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -121,5 +121,12 @@ export default { creditInput: `${components.vnTextfield}[name="credit"]`, saveButton: `${components.vnSubmit}`, firstCreditText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-credit-list > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(1) > vn-one' + }, + greuge: { + greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`, + addGreugeFloatButton: `${components.vnFloatButton}`, + // creditInput: `${components.vnTextfield}[name="credit"]`, + saveButton: `${components.vnSubmit}` + // firstGreugeText: '' } }; diff --git a/e2e/paths/09_add_greuge.spec.js b/e2e/paths/09_add_greuge.spec.js new file mode 100644 index 000000000..1cac339fe --- /dev/null +++ b/e2e/paths/09_add_greuge.spec.js @@ -0,0 +1,123 @@ +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('Add greuge path', () => { + describe('warm up', () => { + it('should warm up login and fixtures', done => { + nightmare + .login() + .waitForURL(moduleAccessViewHashURL) + .waitToClick(selectors.globalItems.logOutButton) + .then(() => { + done(); + }) + .catch(catchErrors(done)); + }); + }); + + 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 click on the Clients button of the top bar menu', done => { + nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .url() + .then(url => { + expect(url).toEqual(config.url + '#!/clients'); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should search for the user Petter Parker', done => { + nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countSearchResults(selectors.clientsIndex.searchResult) + .then(result => { + expect(result).toEqual(1); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the search result to access to the client's greuge`, done => { + nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.greuge.greugeButton) + .waitForURL('greuge/list') + .url() + .then(url => { + expect(url).toContain('greuge/list'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the add greuge button`, done => { + nightmare + .waitToClick(selectors.greuge.addGreugeFloatButton) + .waitForURL('/greuge/create') + .url() + .then(url => { + expect(url).toContain('/greuge/create'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should add a new greuge`, done => { + // nightmare + // .type(selectors.credit.creditInput, 999) + // .click(selectors.credit.saveButton) + // .wait(selectors.globalItems.snackbarIsActive) + // .getInnerText(selectors.globalItems.snackbarIsActive) + // .then(result => { + // expect(result).toEqual('Data saved!'); + // done(); + // }) + // .catch(catchErrors(done)); + }); + + // it('should confirm the credit was updated', done => { + // nightmare + // .waitForSnackbarReset() + // .wait(selectors.credit.firstCreditText) + // .getInnerText(selectors.credit.firstCreditText) + // .then(value => { + // expect(value).toContain(999); + // done(); + // }) + // .catch(catchErrors(done)); + // }); +}); diff --git a/gulpfile.js b/gulpfile.js index 0438a8f3c..ecfec7057 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -50,6 +50,21 @@ gulp.task('services', () => { }); }); +gulp.task('servicesDev', callback => { + let isWindows = /^win/.test(process.platform); + let command = isWindows ? 'docker inspect dblocal |findstr Status' : 'docker inspect dblocal |grep Status'; + gutil.env.env = 'test'; + exec(command, (err, stdout, stderr) => { + let isNotRunning = !stdout.includes('running'); + if (isNotRunning) { + runSequence('docker', 'waitForMySQL', 'services'); + } else { + runSequence('services'); + } + callback(err); + }); +}); + gulp.task('clean', function() { return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true}); });