Merge branch '1132-issue---api-make-sure-hookentityprepostcreate-is-used-across-the-board' into 1134-issue---api-make-sure-hookentityprepostupdate-is-used-across-the-board

This commit is contained in:
yassinedorbozgithub 2025-06-13 16:00:50 +01:00
commit 8801e540ab
2 changed files with 12 additions and 12 deletions

View File

@ -116,16 +116,17 @@ describe('NlpEntityRepository', () => {
describe('The deleteCascadeOne function', () => {
it('should delete a nlp entity', async () => {
nlpValueRepository.eventEmitter.on(
'hook:nlpEntity:preDelete',
async (...args) => {
await nlpService.handleEntityDelete(args[0], args[1]);
},
);
const intentNlpEntity = await nlpEntityRepository.findOne({
name: 'intent',
});
const result = await nlpEntityRepository.deleteOne(intentNlpEntity!.id);
await nlpService.handleEntityDelete(
{},
{ _id: intentNlpEntity!.id, builtin: { $ne: true } },
);
expect(result.deletedCount).toEqual(1);
const intentNlpValues = await nlpValueRepository.find({

View File

@ -75,8 +75,6 @@ describe('NlpValueRepository', () => {
{
provide: CACHE_MANAGER,
useValue: {
del: jest.fn(),
get: jest.fn(),
set: jest.fn(),
},
},
@ -169,12 +167,13 @@ describe('NlpValueRepository', () => {
describe('The deleteCascadeOne function', () => {
it('should delete a nlp Value', async () => {
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
await nlpService.handleValueDelete(
{},
{ _id: nlpValues[1].id, builtin: { $ne: true } },
nlpValueRepository.eventEmitter.on(
'hook:nlpValue:preDelete',
async (...args) => {
await nlpService.handleValueDelete(args[0], args[1]);
},
);
const result = await nlpValueRepository.deleteOne(nlpValues[1].id);
expect(result.deletedCount).toEqual(1);
const sampleEntities = await nlpSampleEntityRepository.find({