74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Client log path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
let date;
|
|
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('employee', 'client')
|
|
.accessToSearchResult('DavidCharlesHaller')
|
|
.accessToSection('client.card.basicData');
|
|
});
|
|
|
|
it('should update the clients name', async() => {
|
|
let result = await nightmare
|
|
.clearInput(selectors.clientBasicData.nameInput)
|
|
.write(selectors.clientBasicData.nameInput, 'this is a test')
|
|
.waitToClick(selectors.clientBasicData.saveButton)
|
|
.waitForLastSnackbar();
|
|
date = new Date();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should navigate to the log section', async() => {
|
|
let url = await nightmare
|
|
.waitToClick(selectors.clientLog.logButton)
|
|
.waitForURL('log')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('log');
|
|
});
|
|
|
|
it('should check the previous value of the last logged change', async() => {
|
|
let lastModificationPreviousValue = await nightmare
|
|
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
|
|
|
|
expect(lastModificationPreviousValue).toContain('DavidCharlesHaller');
|
|
});
|
|
|
|
it('should check the current value of the last logged change', async() => {
|
|
let lastModificationDate = await nightmare
|
|
.waitToGetProperty(selectors.clientLog.lastModificationDate, 'innerText');
|
|
|
|
let lastModificationPreviousValue = await nightmare
|
|
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
|
|
|
|
let lastModificationCurrentValue = await nightmare
|
|
.waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText');
|
|
|
|
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}`;
|
|
if (hours.toString().length < 2) hours = '0' + hours;
|
|
if (minutes.toString().length < 2) minutes = `0${minutes}`;
|
|
|
|
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');
|
|
});
|
|
});
|