#7002 update direction if device exists #2206

Merged
alexm merged 5 commits from 7002-fixUpdateTimeEntry into dev 2024-03-28 07:04:18 +00:00
1 changed files with 29 additions and 1 deletions
Showing only changes of commit e7a29119d0 - Show all commits

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', () => { 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;
@ -144,7 +172,7 @@ describe('workerTimeControl clockIn()', () => {
const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options); const middleTime = await models.WorkerTimeControl.addTimeEntry(ctx, workerId, options);
const direction = 'out'; const direction = 'out';
const {id:outTimeEntryId} = await models.WorkerTimeControl.updateTimeEntry( const outTimeEntryId = await models.WorkerTimeControl.updateTimeEntry(
ctx, middleTime.id, direction, options ctx, middleTime.id, direction, options
); );