feat: refs #7002 add test
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-03-27 13:38:04 +01:00
parent 227d123247
commit e7a29119d0
1 changed files with 29 additions and 1 deletions

View File

@ -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
);