Updated unit test
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
f39719cc46
commit
0695ec01bc
|
@ -103,11 +103,9 @@ describe('regularizeClaim()', () => {
|
|||
claimEnd.updateAttributes({claimDestinationFk: okDestination});
|
||||
});
|
||||
|
||||
const claim = await app.models.Claim.findById(claimFk);
|
||||
await claim.updateAttribute('hasToPickUp', true);
|
||||
await app.models.Claim.regularizeClaim(ctx, claimFk);
|
||||
|
||||
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
|
||||
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(5);
|
||||
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -70,19 +70,25 @@ describe('Update Claim', () => {
|
|||
});
|
||||
|
||||
it('should change some sensible fields as salesAssistant', async() => {
|
||||
const chatModel = app.models.Chat;
|
||||
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||
|
||||
const salesAssistantId = 21;
|
||||
let data = {
|
||||
claimStateFk: 3,
|
||||
workerFk: 5,
|
||||
observation: 'another valid observation'
|
||||
observation: 'another valid observation',
|
||||
hasToPickUp: true
|
||||
};
|
||||
let ctx = {
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {
|
||||
userId: salesAssistantId
|
||||
}
|
||||
accessToken: {userId: salesAssistantId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
ctx.req.__ = (value, params) => {
|
||||
return params.nickname;
|
||||
};
|
||||
await app.models.Claim.updateClaim(ctx, newInstance.id, data);
|
||||
|
||||
let claimUpdated = await app.models.Claim.findById(newInstance.id);
|
||||
|
@ -90,5 +96,6 @@ describe('Update Claim', () => {
|
|||
expect(claimUpdated.observation).toEqual(data.observation);
|
||||
expect(claimUpdated.claimStateFk).toEqual(data.claimStateFk);
|
||||
expect(claimUpdated.workerFk).toEqual(data.workerFk);
|
||||
expect(chatModel.sendCheckingPresence).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -46,9 +46,11 @@ module.exports = Self => {
|
|||
if (!canUpdate || !hasRights)
|
||||
throw new UserError(`You don't have enough privileges to change that field`);
|
||||
|
||||
const updatedClaim = await claim.updateAttributes(data);
|
||||
|
||||
// Get sales person from claim client
|
||||
const salesPerson = claim.client().salesPerson();
|
||||
if (salesPerson && claim.hasToPickUp) {
|
||||
if (salesPerson && updatedClaim.hasToPickUp) {
|
||||
const origin = ctx.req.headers.origin;
|
||||
const message = $t('Claim will be picked', {
|
||||
claimId: claim.id,
|
||||
|
@ -58,7 +60,7 @@ module.exports = Self => {
|
|||
await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message);
|
||||
}
|
||||
|
||||
return await claim.updateAttributes(data);
|
||||
return updatedClaim;
|
||||
};
|
||||
|
||||
async function canChangeState(ctx, id) {
|
||||
|
|
Loading…
Reference in New Issue