workerTImeControlCheck test
gitea/salix/pipeline/head This commit has test failures
Details
gitea/salix/pipeline/head This commit has test failures
Details
This commit is contained in:
parent
5e86f67b37
commit
f3e4bc7aeb
|
@ -27,7 +27,7 @@ fdescribe('worker workerTimeControl_check()', () => {
|
||||||
expect(err.sqlMessage).toEqual('No perteneces a este departamento.');
|
expect(err.sqlMessage).toEqual('No perteneces a este departamento.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should EL TRABAJDOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => {
|
it('should EL TRABAJADOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => {
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
const workerId = 110;
|
const workerId = 110;
|
||||||
|
@ -312,24 +312,46 @@ fdescribe('worker workerTimeControl_check()', () => {
|
||||||
expect(err.sqlMessage).toEqual('No hay un contrato en vigor');
|
expect(err.sqlMessage).toEqual('No hay un contrato en vigor');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if NO TIENE DESCANSO SEMANAL', async() => {
|
it('should throw an error if NO TIENE DESCANSO SEMANAL 36h', async() => {
|
||||||
const workerIdBreak12Hours = 109;
|
const workerIdBreak12Hours = 109;
|
||||||
const tabletId = 1;
|
const tabletId = 1;
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
let err;
|
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
stmts.push('START TRANSACTION');
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [
|
|
||||||
workerIdBreak12Hours
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
|
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
|
||||||
VALUES
|
VALUES
|
||||||
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
|
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
|
||||||
(?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [
|
(?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out")`, [
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
workerIdBreak12Hours,
|
workerIdBreak12Hours,
|
||||||
workerIdBreak12Hours
|
workerIdBreak12Hours
|
||||||
]);
|
]);
|
||||||
|
@ -342,36 +364,37 @@ fdescribe('worker workerTimeControl_check()', () => {
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
stmts.push('ROLLBACK');
|
stmts.push('ROLLBACK');
|
||||||
|
|
||||||
|
let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1;
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
let result = await app.models.Worker.rawStmt(sql);
|
||||||
|
|
||||||
try {
|
expect(result[warningMessageIndex][0].warning).toEqual('Descansos 36 h');
|
||||||
await app.models.Worker.rawStmt(sql);
|
|
||||||
} catch (e) {
|
|
||||||
await app.models.Worker.rawSql('ROLLBACK');
|
|
||||||
err = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(err.sqlMessage).toEqual('No hay un contrato en vigor');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should DESCANSO 32h', async() => {
|
it('should throw an error if CUMPLE DESCANSO SEMANAL 36h', async() => {
|
||||||
const workerIdBreak12Hours = 109;
|
const workerIdBreak12Hours = 109;
|
||||||
const tabletId = 1;
|
const tabletId = 1;
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
let err;
|
|
||||||
|
|
||||||
stmts.push('START TRANSACTION');
|
stmts.push('START TRANSACTION');
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [
|
|
||||||
workerIdBreak12Hours
|
|
||||||
]);
|
|
||||||
stmts.push(stmt);
|
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
|
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
|
||||||
VALUES
|
VALUES
|
||||||
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
|
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
|
||||||
(?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [
|
(?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out")`, [
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
workerIdBreak12Hours,
|
workerIdBreak12Hours,
|
||||||
workerIdBreak12Hours
|
workerIdBreak12Hours
|
||||||
]);
|
]);
|
||||||
|
@ -384,6 +407,90 @@ fdescribe('worker workerTimeControl_check()', () => {
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
stmts.push('ROLLBACK');
|
stmts.push('ROLLBACK');
|
||||||
|
|
||||||
|
let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1;
|
||||||
|
|
||||||
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
let result = await app.models.Worker.rawStmt(sql);
|
||||||
|
|
||||||
|
console.log('warningMessageIndex', result[warningMessageIndex][0]);
|
||||||
|
// HABLAR CON CARLOS, falla aeatoriamente
|
||||||
|
expect(result[warningMessageIndex][0].warning).toBe(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if NO TIENE DESCANSO SEMANAL 72h', async() => {
|
||||||
|
const workerIdBreak12Hours = 109;
|
||||||
|
const tabletId = 1;
|
||||||
|
let stmts = [];
|
||||||
|
let stmt;
|
||||||
|
let err;
|
||||||
|
stmts.push('START TRANSACTION');
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
|
||||||
|
VALUES
|
||||||
|
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-216,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-208,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-240,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-312,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-304,NOW()),0,"out")`, [
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours
|
||||||
|
]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
tabletId
|
||||||
|
]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
stmts.push('ROLLBACK');
|
||||||
|
|
||||||
|
stmts.push('SELECT @warn AS warning') - 1;
|
||||||
|
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -393,6 +500,88 @@ fdescribe('worker workerTimeControl_check()', () => {
|
||||||
err = e;
|
err = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(err.sqlMessage).toEqual('No hay un contrato en vigor');
|
expect(err.sqlMessage).toEqual('Descansos 72 h');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error if CUMPLE DESCANSO QUINCENAL 72h', async() => {
|
||||||
|
const workerIdBreak12Hours = 109;
|
||||||
|
const tabletId = 1;
|
||||||
|
let stmts = [];
|
||||||
|
let stmt;
|
||||||
|
let err;
|
||||||
|
stmts.push('START TRANSACTION');
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction)
|
||||||
|
VALUES
|
||||||
|
(?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-216,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-208,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-240,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"),
|
||||||
|
(?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
workerIdBreak12Hours
|
||||||
|
]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [
|
||||||
|
workerIdBreak12Hours,
|
||||||
|
tabletId
|
||||||
|
]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
stmts.push('ROLLBACK');
|
||||||
|
|
||||||
|
stmts.push('SELECT @warn AS warning') - 1;
|
||||||
|
|
||||||
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await app.models.Worker.rawStmt(sql);
|
||||||
|
} catch (e) {
|
||||||
|
await app.models.Worker.rawSql('ROLLBACK');
|
||||||
|
err = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(err).not.toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue