From f7cdbd39f08e2119f110ae66f4ec34bc9d752568 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 25 Apr 2024 16:08:52 +0200 Subject: [PATCH] fix: refs #7211 tests --- .../procedures/workerTimeControl_clockIn.sql | 9 +++++-- .../worker-time-control/specs/clockIn.spec.js | 26 ------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/db/routines/vn/procedures/workerTimeControl_clockIn.sql b/db/routines/vn/procedures/workerTimeControl_clockIn.sql index a3991913e..a1ce53bc2 100644 --- a/db/routines/vn/procedures/workerTimeControl_clockIn.sql +++ b/db/routines/vn/procedures/workerTimeControl_clockIn.sql @@ -139,12 +139,17 @@ BEGIN SET vIsError = TRUE; END IF; - DROP TEMPORARY TABLE tmp.workerTimeControlDirection; + IF vIsError THEN SET vErrorCode = 'WRONG_DIRECTION'; + IF(SELECT option1 IS NULL AND option2 IS NULL + FROM tmp.workerTimeControlDirection) THEN + + SET vErrorCode = 'DAY_MAX_TIME'; + END IF; CALL util.throw(vErrorCode); END IF; - + DROP TEMPORARY TABLE tmp.workerTimeControlDirection; -- FICHADAS IMPARES SELECT timed INTO vLastIn FROM workerTimeControl 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 826ea6077..cfff42172 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 @@ -1,6 +1,5 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -const { async } = require('regenerator-runtime'); describe('workerTimeControl clockIn()', () => { const workerId = 9; @@ -47,31 +46,6 @@ describe('workerTimeControl clockIn()', () => { } }); - 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; const workerId = teamBossId;