feat: refs #7211 add test & changelog
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-04-25 09:35:53 +02:00
parent 88b06ebef5
commit c9dfccbc53
2 changed files with 30 additions and 0 deletions

View File

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [24.20.01] - 2024-05-14 ## [24.20.01] - 2024-05-14
### Fixed
- (Worker -> time-control) Corrección de errores
## [24.18.01] - 2024-05-07 ## [24.18.01] - 2024-05-07
## [24.16.01] - 2024-04-18 ## [24.16.01] - 2024-04-18

View File

@ -1,5 +1,6 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
const { async } = require('regenerator-runtime');
describe('workerTimeControl clockIn()', () => { describe('workerTimeControl clockIn()', () => {
const workerId = 9; const workerId = 9;
@ -99,6 +100,32 @@ describe('workerTimeControl clockIn()', () => {
} }
}); });
it('should throw an error trying to add an "in" entry if the last clockIn is not out', async() => {
activeCtx.accessToken.userId = HHRRId;
const workerId = teamBossId;
const tx = await models.WorkerTimeControl.beginTransaction({});
try {
const options = {transaction: tx};
ctx.args = {timed: "2000-12-25T21:00:00.000Z", direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
ctx.args = {timed: "2000-12-25T22:00:00.000Z", direction: 'middle'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
ctx.args = {timed: "2000-12-25T22:30:00.000Z", direction: 'middle'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
ctx.args = {timed: "2000-12-26T01:00:00.000Z", direction: 'in'};
await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
await tx.rollback();
} catch (e) {
expect(e.message).toBe('Dirección incorrecta');
await tx.rollback();
}
});
describe('as Role errors', () => { describe('as Role errors', () => {
it('should add if the current user is team boss and the target user is himself', async() => { it('should add if the current user is team boss and the target user is himself', async() => {
activeCtx.accessToken.userId = teamBossId; activeCtx.accessToken.userId = teamBossId;