From e7a29119d0ca53d37b6b9696eaf78d0d0ddb82da Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Mar 2024 13:38:04 +0100 Subject: [PATCH] feat: refs #7002 add test --- .../worker-time-control/specs/clockIn.spec.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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 0ee439941..343eb2a71 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 @@ -71,6 +71,34 @@ describe('workerTimeControl clockIn()', () => { } }); + it('should updates the time entry direction and remaining not be manual', 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-25T16:00:00.000Z"; + ctx.args = {timed: middleTime, direction: 'middle'}; + const middleEntryTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); + middleEntryTime.updateAttribute('manual', false); + + const direction = 'out'; + const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(ctx, middleEntryTime.id, direction, options); + + const outTimeEntry = await models.WorkerTimeControl.findById(outTimeEntryId, null, options); + expect(outTimeEntry.manual).toBeFalsy(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + }); + describe('as Role errors', () => { it('should add if the current user is team boss and the target user is himself', async() => { activeCtx.accessToken.userId = teamBossId; @@ -144,7 +172,7 @@ describe('workerTimeControl clockIn()', () => { const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); const direction = 'out'; - const {id:outTimeEntryId} = await models.WorkerTimeControl.updateTimeEntry( + const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry( ctx, middleTime.id, direction, options );