#7002 update direction if device exists #2206
|
@ -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
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue