From 22fd0e91b0c167da9e3014f8aa9a66b8d9859e36 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 28 Jun 2022 12:10:37 +0200 Subject: [PATCH] title translations, and getWorkedHours test --- db/dump/fixtures.sql | 2 +- e2e/helpers/selectors.js | 2 +- e2e/paths/03-worker/04_time_control.spec.js | 16 +++---- loopback/locale/en.json | 4 +- .../specs/timeEntry.spec.js | 42 +++++++++---------- .../worker/specs/getWorkedHours.spec.js | 2 +- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 01dc0486c..f752916b9 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2239,7 +2239,7 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) (1106, CONCAT(util.VN_CURDATE(), ' 07:00'), TRUE, 'in'), (1106, CONCAT(util.VN_CURDATE(), ' 10:00'), TRUE, 'middle'), (1106, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle'), - (1106, CONCAT(util.VN_CURDATE(), ' 15:00'), TRUE, 'out'); + (1106, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out'); INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `code`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 46dd41856..c4607c737 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -918,7 +918,7 @@ export default { weekWorkedHours: 'vn-worker-time-control vn-side-menu vn-label-value > section > span', nextMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_right]', previousMonthButton: 'vn-worker-time-control vn-side-menu vn-calendar vn-button[icon=keyboard_arrow_left]', - nameOfMonth: 'vn-worker-time-control vn-side-menu vn-calendar div > .title', + monthName: 'vn-worker-time-control vn-side-menu vn-calendar div > .title', secondWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(8) > .day-number', thrirdWeekDay: 'vn-worker-time-control vn-side-menu vn-calendar .day:nth-child(15) > .day-number', navigateBackToIndex: 'vn-worker-descriptor [name="goToModuleIndex"]' diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index 2aa15fec1..be8df3cf0 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -17,7 +17,7 @@ describe('Worker time control path', () => { await browser.close(); }); - const heightAm = '08:00'; + const eightAm = '08:00'; const fourPm = '16:00'; const hankPymId = 1107; @@ -27,7 +27,7 @@ describe('Worker time control path', () => { const month = date.toLocaleString('default', {month: 'long'}); await page.waitToClick(selectors.workerTimeControl.nextMonthButton); - const result = await page.waitToGetProperty(selectors.workerTimeControl.nameOfMonth, 'innerText'); + const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); }); @@ -37,7 +37,7 @@ describe('Worker time control path', () => { const month = date.toLocaleString('default', {month: 'long'}); await page.waitToClick(selectors.workerTimeControl.previousMonthButton); - const result = await page.waitToGetProperty(selectors.workerTimeControl.nameOfMonth, 'innerText'); + const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); }); @@ -52,14 +52,14 @@ describe('Worker time control path', () => { await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`); await page.waitToClick(selectors.workerTimeControl.secondWeekDay); - const result = await page.waitToGetProperty(selectors.workerTimeControl.nameOfMonth, 'innerText'); + const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); }); it(`should return error when insert 'out' of first entry`, async() => { await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, heightAm); + await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm); await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); await page.respondToDialog('accept'); const message = await page.waitForSnackbar(); @@ -69,12 +69,12 @@ describe('Worker time control path', () => { it(`should insert 'in' monday`, async() => { await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); - await page.pickTime(selectors.workerTimeControl.dialogTimeInput, heightAm); + await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm); await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); await page.respondToDialog('accept'); const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); - expect(result).toEqual(heightAm); + expect(result).toEqual(eightAm); }); it(`should insert 'out' monday`, async() => { @@ -93,7 +93,7 @@ describe('Worker time control path', () => { }); it('should remove first entry of monday', async() => { - await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, heightAm); + await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm); await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm); await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete); await page.respondToDialog('accept'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 600224224..460b37889 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -125,9 +125,9 @@ "routeFk": "routeFk", "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", "Can't change the password of another worker": "Can't change the password of another worker", - "No hay un contrato en vigor": "There is no contract in force", + "No hay un contrato en vigor": "There is no existing contract", "No está permitido trabajar": "Not allowed to work", - "Dirección incorrecta": "Wrong address", + "Dirección incorrecta": "Wrong direction", "No se permite fichar a futuro": "It is not allowed to sign in the future", "Descanso diario 12h.": "Daily rest 12h.", "Fichadas impares": "Odd signs", diff --git a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js index 18a1fd6f4..b5ef86c37 100644 --- a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js @@ -63,7 +63,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`You don't have enough privileges`); }); - it('should add if the current user is team boss and the target user is a himself', async() => { + it('should add if the current user is team boss and the target user is himself', async() => { activeCtx.accessToken.userId = teamBossId; const workerId = teamBossId; @@ -199,8 +199,8 @@ describe('workerTimeControl add/delete timeEntry()', () => { }); }); - describe('as WorkerTimeControl_clockIn calls', () => { - it('should fail to add a time entry if the target user has absent that day', async() => { + describe('WorkerTimeControl_clockIn calls', () => { + it('should fail to add a time entry if the target user has an absence that day', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; const date = new Date(); @@ -223,7 +223,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`No está permitido trabajar`); }); - it('should fail to add a time entry if worker no have business', async() => { + it('should fail to add a time entry for a worker without an existing contract', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; const date = new Date(); @@ -245,8 +245,8 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`No hay un contrato en vigor`); }); - describe('as direction errors', () => { - it('should return error when set in with in', async() => { + describe('direction errors', () => { + it('should throw an error when trying "in" direction twice', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -275,7 +275,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Dirección incorrecta`); }); - it('should return error when set in with in, middle', async() => { + it('should throw an error when trying "in" direction after insert "in" and "middle"', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -308,7 +308,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Dirección incorrecta`); }); - it('should return error when set out with in, middle', async() => { + it('Should throw an error when trying "out" before closing a "middle" couple', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -341,7 +341,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Dirección incorrecta`); }); - it('should return error when set middle with in, out', async() => { + it('should throw an error when trying "middle" after "out"', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -374,7 +374,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Dirección incorrecta`); }); - it('should return error when set out with in, out', async() => { + it('should throw an error when trying "out" direction twice', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -408,8 +408,8 @@ describe('workerTimeControl add/delete timeEntry()', () => { }); }); - describe('as break 12h', () => { - it('should return error when not fulfilled 12H break', async() => { + describe('12h rest', () => { + it('should throw an error when the 12h rest is not fulfilled yet', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -443,7 +443,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Descanso diario 12h.`); }); - it('should not fail when fulfilled 12H break', async() => { + it('should not fail as the 12h rest is fulfilled', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -478,8 +478,8 @@ describe('workerTimeControl add/delete timeEntry()', () => { }); }); - describe('as break 9h for conductors of 3500kg', () => { - it('should return error when not fulfilled 9H break', async() => { + describe('for 3500kg drivers with enforced 9h rest', () => { + it('should throw an error when the 9h enforced rest is not fulfilled', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = jessicaJonesId; @@ -513,7 +513,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Descanso diario 9h.`); }); - it('should not fail when fulfilled 9H break', async() => { + it('should not fail when the 9h enforced rest is fulfilled', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = jessicaJonesId; @@ -548,8 +548,8 @@ describe('workerTimeControl add/delete timeEntry()', () => { }); }); - describe('as short break', () => { - it('should return error when not fulfilled 36H week break', async() => { + describe('for 36h weekly rest', () => { + it('should throw an error when the 36h weekly rest is not fulfilled', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -583,7 +583,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { expect(error.message).toBe(`Descanso semanal 36h. / 72h.`); }); - it('should return error when not fulfilled 36H week break again', async() => { + it('should throw an error when the 36h weekly rest is not fulfilled again', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; @@ -615,8 +615,8 @@ describe('workerTimeControl add/delete timeEntry()', () => { }); }); - describe('as long break', () => { - it('should return error when not fulfilled 72H week break', async() => { + describe('for 72h weekly rest', () => { + it('should throw when the 72h weekly rest is not fulfilled yet', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js index 1337b1626..054a829e5 100644 --- a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -12,6 +12,6 @@ describe('Worker getWorkedHours()', () => { const [result] = await models.Worker.getWorkedHours(workerID, started, ended); expect(result.expectedHours).toEqual(28800); // 8:00 hours in seconds - expect(result.workedHours).toEqual(28800); // 8:00 hours in seconds + expect(result.workedHours).toEqual(28200); // 7:50 hours in seconds }); });