From 180a484c558195926366f51b145aa759309bd0d9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 25 Apr 2024 16:14:34 +0200 Subject: [PATCH] fix: refs #7211 rollback --- .../worker-time-control/specs/clockIn.spec.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js b/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js index cfff42172..daf7284ac 100644 --- a/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js @@ -45,6 +45,31 @@ describe('workerTimeControl clockIn()', () => { throw e; } }); + + it('should throw an error trying to change a middle hour to out not resting 12h', async() => { + activeCtx.accessToken.userId = HHRRId; + const workerId = teamBossId; + + const tx = await models.WorkerTimeControl.beginTransaction({}); + try { + const options = {transaction: tx}; + + const entryTime = "2000-12-25T11:00:00.000Z"; + ctx.args = {timed: entryTime, direction: 'in'}; + await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + const middleTime ="2000-12-26T11:00:00.000Z"; + ctx.args = {timed: middleTime, direction: 'middle'}; + const middleEntryTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + + const direction = 'out'; + await models.WorkerTimeControl.updateTimeEntry(ctx, middleEntryTime.id, direction, options); + await tx.rollback(); + } catch (e) { + expect(e.message).toBe('Superado el tiempo máximo entre entrada y salida'); + await tx.rollback(); + } + }); it('should updates the time entry direction and remaining not be manual', async() => { activeCtx.accessToken.userId = HHRRId;