fix(ee): use entity service directly for emit event calls

This commit is contained in:
Jamie Howard 2023-06-19 16:37:20 +01:00
parent 34483f58ea
commit b9a173fce8
2 changed files with 15 additions and 11 deletions

View File

@ -108,7 +108,6 @@ describe('Entity service decorator', () => {
const defaultService = {
update: jest.fn(() => Promise.resolve(entry)),
emitEvent: jest.fn(),
};
global.strapi = {
@ -117,6 +116,7 @@ describe('Entity service decorator', () => {
findOne: jest.fn(() => {
return { strapi_reviewWorkflows_stage: { id: 2, workflow: { id: 1 } } };
}),
emitEvent: jest.fn(),
},
};
@ -126,7 +126,10 @@ describe('Entity service decorator', () => {
const input = { data: { title: 'title ', strapi_reviewWorkflows_stage: 1 } };
await service.update(uid, id, input);
expect(defaultService.emitEvent).toHaveBeenCalledWith(uid, WORKFLOW_UPDATE_STAGE, {
expect(global.strapi.entityService.emitEvent).toHaveBeenCalledWith(
uid,
WORKFLOW_UPDATE_STAGE,
{
entityId: 1,
workflow: {
id: 1,
@ -135,7 +138,8 @@ describe('Entity service decorator', () => {
to: 1,
},
},
});
}
);
expect(defaultService.update).toHaveBeenCalledWith(uid, id, {
...input,

View File

@ -84,7 +84,7 @@ const decorator = (service) => ({
},
},
};
await service.emitEvent.call(this, uid, WORKFLOW_UPDATE_STAGE, webhookPayload);
await strapi.entityService.emitEvent(uid, WORKFLOW_UPDATE_STAGE, webhookPayload);
}
return updatedEntity;