111 lines
3.5 KiB
JavaScript
111 lines
3.5 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('Add notes 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 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.clientNotes.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.clientNotes.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.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am')
|
|
.click(selectors.clientNotes.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.clientNotes.firstNoteText)
|
|
.getInnerText(selectors.clientNotes.firstNoteText)
|
|
.then(value => {
|
|
expect(value).toEqual('Meeting with Black Widow 21st 9am');
|
|
done();
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
});
|