From ea3328756b47a961787a27873583aee79e9e7c21 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 1 Mar 2019 13:56:17 +0100 Subject: [PATCH] #1185 cambiar e2e client log --- e2e/helpers/selectors.js | 1 + e2e/paths/client-module/13_log.spec.js | 29 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index e653eb641..a37d63854 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -151,6 +151,7 @@ export default { }, clientLog: { logButton: `vn-left-menu a[ui-sref="client.card.log"]`, + lastModificationDate: 'vn-client-log > vn-log vn-table vn-tbody > vn-tr > vn-td:nth-child(1)', lastModificationPreviousValue: 'vn-client-log vn-table vn-td.before', lastModificationCurrentValue: 'vn-client-log vn-table vn-td.after' diff --git a/e2e/paths/client-module/13_log.spec.js b/e2e/paths/client-module/13_log.spec.js index 2a82744ff..54303599f 100644 --- a/e2e/paths/client-module/13_log.spec.js +++ b/e2e/paths/client-module/13_log.spec.js @@ -4,6 +4,8 @@ import createNightmare from '../../helpers/nightmare'; describe('Client log path', () => { const nightmare = createNightmare(); + let date; + beforeAll(() => { nightmare .loginAndModule('employee', 'client') @@ -17,6 +19,7 @@ describe('Client log path', () => { .write(selectors.clientBasicData.nameInput, 'this is a test') .waitToClick(selectors.clientBasicData.saveButton) .waitForLastSnackbar(); + date = new Date(); expect(result).toEqual('Data saved!'); }); @@ -38,9 +41,33 @@ describe('Client log path', () => { }); 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'); - expect(lastModificationCurrentValue).toContain('this is a test'); + 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) month = '0' + hours; + if (minutes.toString().length < 2) day = `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'); }); });