salix/e2e/paths/client-module/13_log.spec.js

74 lines
2.7 KiB
JavaScript
Raw Normal View History

2018-10-30 09:22:47 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Client log path', () => {
const nightmare = createNightmare();
2019-03-01 12:56:17 +00:00
let date;
2018-10-30 09:22:47 +00:00
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
.loginAndModule('employee', 'client')
.accessToSearchResult('DavidCharlesHaller')
.accessToSection('client.card.basicData');
2018-10-30 09:22:47 +00:00
});
2019-01-11 11:41:07 +00:00
it('should update the clients name', async() => {
2018-10-30 09:22:47 +00:00
let result = await nightmare
.clearInput(selectors.clientBasicData.nameInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientBasicData.nameInput, 'this is a test')
2018-10-30 09:22:47 +00:00
.waitToClick(selectors.clientBasicData.saveButton)
.waitForLastSnackbar();
2019-03-01 12:56:17 +00:00
date = new Date();
2018-10-30 09:22:47 +00:00
expect(result).toEqual('Data saved!');
});
2019-01-11 11:41:07 +00:00
it('should navigate to the log section', async() => {
2018-10-30 09:22:47 +00:00
let url = await nightmare
.waitToClick(selectors.clientLog.logButton)
.waitForURL('log')
.parsedUrl();
expect(url.hash).toContain('log');
});
2019-01-11 11:41:07 +00:00
it('should check the previous value of the last logged change', async() => {
2018-10-30 09:22:47 +00:00
let lastModificationPreviousValue = await nightmare
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
2018-10-30 09:22:47 +00:00
expect(lastModificationPreviousValue).toContain('DavidCharlesHaller');
});
2019-01-11 11:41:07 +00:00
it('should check the current value of the last logged change', async() => {
2019-03-01 12:56:17 +00:00
let lastModificationDate = await nightmare
.waitToGetProperty(selectors.clientLog.lastModificationDate, 'innerText');
let lastModificationPreviousValue = await nightmare
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
2018-10-30 09:22:47 +00:00
let lastModificationCurrentValue = await nightmare
.waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText');
2018-10-30 09:22:47 +00:00
2019-03-01 12:56:17 +00:00
let month = date.getMonth() + 1;
let day = date.getDate();
let year = date.getFullYear();
let hours = date.getHours();
let minutes = date.getMinutes();
if (month.toString().length < 2) month = '0' + month;
if (day.toString().length < 2) day = `0${day}`;
2019-03-04 07:31:33 +00:00
if (hours.toString().length < 2) hours = '0' + hours;
if (minutes.toString().length < 2) minutes = `0${minutes}`;
2019-03-01 12:56:17 +00:00
let today = [day, month, year].join('/');
let time = [hours, minutes].join(':');
let now = [today, time].join(' ');
expect(lastModificationDate).toContain(now);
expect(lastModificationPreviousValue).toEqual('name: DavidCharlesHaller');
expect(lastModificationCurrentValue).toEqual('name: this is a test');
2018-10-30 09:22:47 +00:00
});
});