diff --git a/e2e/helpers/components_selectors.js b/e2e/helpers/components_selectors.js index 8b13b14be..4b33bce61 100644 --- a/e2e/helpers/components_selectors.js +++ b/e2e/helpers/components_selectors.js @@ -4,6 +4,7 @@ // delete me, this comment is to add a commit export default { vnTextfield: 'vn-textfield > div > input', + vnTextarea: 'vn-textarea', vnSubmit: 'vn-submit > input', vnTopbar: 'vn-topbar > header', vnIcon: 'vn-icon', diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 4b9562a26..be0848254 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -107,5 +107,12 @@ export default { enableWebAccessCheckbox: `${components.vnCheck}[label='Enable web access'] > label > input`, userNameInput: `${components.vnTextfield}[name="name"]`, saveButton: `${components.vnSubmit}` + }, + notes: { + notesButton: `${components.vnMenuItem}[ui-sref="clientCard.notes.list"]`, + addNoteFloatButton: `${components.vnFloatButton}`, + noteInput: `${components.vnTextarea}[label="Note"]`, + saveButton: `${components.vnSubmit}`, + firstNoteText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-notes > vn-card > div > vn-vertical > vn-one:nth-child(2) > vn-horizontal:nth-child(2) > b' } }; diff --git a/e2e/paths/05_edit_web_access.spec.js b/e2e/paths/06_edit_web_access.spec.js similarity index 100% rename from e2e/paths/05_edit_web_access.spec.js rename to e2e/paths/06_edit_web_access.spec.js diff --git a/e2e/paths/07_add_notes.spec.js b/e2e/paths/07_add_notes.spec.js new file mode 100644 index 000000000..a0b464afe --- /dev/null +++ b/e2e/paths/07_add_notes.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('Edit notes 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 Bruce Banner', done => { + nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .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 notes`, done => { + nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.notes.notesButton) + .waitForURL('notes/list') + .url() + .then(url => { + expect(url).toContain('notes/list'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the add note button`, done => { + nightmare + .waitToClick(selectors.notes.addNoteFloatButton) + .waitForURL('/notes/create') + .url() + .then(url => { + expect(url).toContain('/notes/create'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should create a note`, done => { + nightmare + .type(selectors.notes.noteInput, 'Meeting with Black Widow 21th 9am') + .click(selectors.notes.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toEqual('Data saved!'); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should confirm the note was created', done => { + nightmare + .waitForSnackbarReset() + .wait(selectors.notes.firstNoteText) + .getInnerText(selectors.notes.firstNoteText) + .then(value => { + expect(value).toEqual('Meeting with Black Widow 21th 9am'); + done(); + }) + .catch(catchErrors(done)); + }); +});