2018-01-08 14:06:20 +00:00
|
|
|
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;
|
|
|
|
|
2018-01-10 13:03:52 +00:00
|
|
|
describe('Add greuge path', () => {
|
2018-01-08 14:06:20 +00:00
|
|
|
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)
|
2018-01-09 08:26:45 +00:00
|
|
|
.waitForURL('greuge/create')
|
2018-01-08 14:06:20 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2018-01-09 08:26:45 +00:00
|
|
|
expect(url).toContain('greuge/create');
|
2018-01-08 14:06:20 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
2018-01-09 14:31:25 +00:00
|
|
|
it(`should receive an error if all fields are empty but date on submit`, done => {
|
|
|
|
nightmare
|
|
|
|
.click(selectors.credit.saveButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-12 08:47:51 +00:00
|
|
|
expect(result).toContain('Some fields are invalid');
|
2018-01-09 14:31:25 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
2018-01-11 14:25:03 +00:00
|
|
|
it(`should receive an error if all fields are empty but date and amount on submit`, done => {
|
|
|
|
nightmare
|
|
|
|
.type(selectors.greuge.amountInput, 999)
|
|
|
|
.click(selectors.greuge.saveButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Some fields are invalid');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
2018-01-08 14:06:20 +00:00
|
|
|
|
2018-01-12 08:47:51 +00:00
|
|
|
it(`should receive an error if all fields are empty but date and description on submit`, done => {
|
|
|
|
nightmare
|
|
|
|
.clearInput(selectors.greuge.amountInput)
|
|
|
|
.type(selectors.greuge.descriptionInput, 'new armor for Batman!')
|
|
|
|
.click(selectors.greuge.saveButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Some fields are invalid');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should receive an error if all fields are empty but date and type on submit`, done => {
|
|
|
|
nightmare
|
|
|
|
.clearInput(selectors.greuge.descriptionInput)
|
|
|
|
.waitToClick(selectors.greuge.typeInput)
|
|
|
|
.waitToClick(selectors.greuge.typeSecondOption)
|
|
|
|
.click(selectors.greuge.saveButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Some fields are invalid');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should create a new greuge with all its data`, done => {
|
|
|
|
nightmare
|
2018-01-26 07:26:01 +00:00
|
|
|
.clearInput(selectors.greuge.amountInput)
|
2018-01-12 08:47:51 +00:00
|
|
|
.type(selectors.greuge.amountInput, 999)
|
|
|
|
.type(selectors.greuge.descriptionInput, 'new armor for Batman!')
|
|
|
|
.click(selectors.greuge.saveButton)
|
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('Data saved!');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
2018-01-09 14:31:25 +00:00
|
|
|
|
2018-01-12 10:16:46 +00:00
|
|
|
it('should confirm the greuge was added to the list', done => {
|
2018-01-12 08:47:51 +00:00
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
|
|
|
.wait(selectors.greuge.firstGreugeText)
|
|
|
|
.getInnerText(selectors.greuge.firstGreugeText)
|
|
|
|
.then(value => {
|
|
|
|
expect(value).toContain(999);
|
2018-01-12 10:19:48 +00:00
|
|
|
expect(value).toContain('new armor for Batman!');
|
|
|
|
expect(value).toContain('Diff');
|
2018-01-12 08:47:51 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
2018-01-08 14:06:20 +00:00
|
|
|
});
|