5918-worker.time-control_resend #1685
|
@ -0,0 +1,103 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('workerTimeControl getMailStates()', () => {
|
||||
it('should update WorkerTimeControlMail if exist record', async() => {
|
||||
const tx = await models.WorkerTimeControlMail.beginTransaction({});
|
||||
const args = {
|
||||
workerId: 9,
|
||||
week: 50,
|
||||
year: 2000,
|
||||
state: 'CONFIRMED'
|
||||
};
|
||||
const ctx = {args};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const beforeMail = await models.WorkerTimeControlMail.findOne({
|
||||
where: {
|
||||
workerFk: args.workerId,
|
||||
year: args.year,
|
||||
week: args.week,
|
||||
}
|
||||
}, options);
|
||||
await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options);
|
||||
const afterMail = await models.WorkerTimeControlMail.findOne({
|
||||
where: {
|
||||
workerFk: args.workerId,
|
||||
year: args.year,
|
||||
week: args.week,
|
||||
}
|
||||
}, options);
|
||||
|
||||
expect(beforeMail.state).toEqual('SENDED');
|
||||
expect(afterMail.state).toEqual(args.state);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should insert WorkerTimeControlMail if exist record', async() => {
|
||||
const tx = await models.WorkerTimeControlMail.beginTransaction({});
|
||||
const args = {
|
||||
workerId: 1,
|
||||
week: 51,
|
||||
year: 2000,
|
||||
state: 'SENDED'
|
||||
};
|
||||
const ctx = {args};
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const beforeMail = await models.WorkerTimeControlMail.find({
|
||||
where: {
|
||||
workerFk: args.workerId,
|
||||
year: args.year,
|
||||
week: args.week,
|
||||
}
|
||||
}, options);
|
||||
await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options);
|
||||
const afterMail = await models.WorkerTimeControlMail.find({
|
||||
where: {
|
||||
workerFk: args.workerId,
|
||||
year: args.year,
|
||||
week: args.week,
|
||||
}
|
||||
}, options);
|
||||
|
||||
expect(beforeMail).toEqual([]);
|
||||
expect(afterMail.length).toEqual(1);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw error if not exist any record in this week', async() => {
|
||||
const tx = await models.WorkerTimeControlMail.beginTransaction({});
|
||||
const ctx = {args: {
|
||||
workerId: 1,
|
||||
week: 1,
|
||||
year: 0,
|
||||
state: 'SENDED'
|
||||
}};
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(`There aren't records for this week`);
|
||||
});
|
||||
});
|
||||
|
|
@ -98,11 +98,11 @@
|
|||
ng-click="reason.show()">
|
||||
</vn-button>
|
||||
<vn-button
|
||||
label="Resend"
|
||||
label="{{$ctrl.state ? 'Resend' : 'Send'}}"
|
||||
ng-click="sendEmailConfirmation.show()"
|
||||
class="right"
|
||||
vn-tooltip="Resend email of this week to the user"
|
||||
ng-show="$ctrl.isHr && $ctrl.state != 'CONFIRMED' && $ctrl.canResend">
|
||||
vn-tooltip="{{$ctrl.state ? 'Resend' : 'Send'}} email of this week to the user"
|
||||
ng-if="$ctrl.isHr && $ctrl.state != 'CONFIRMED' && $ctrl.canResend">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue