mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): move builtin logic + adapt unit tests
This commit is contained in:
@@ -223,20 +223,6 @@ export class NlpEntityController extends BaseController<
|
||||
throw new BadRequestException('No IDs provided for deletion.');
|
||||
}
|
||||
|
||||
const { count: builtinNlpEntitiesCount } = await this.filterCount({
|
||||
_id: { $in: ids },
|
||||
builtin: true,
|
||||
});
|
||||
|
||||
if (builtinNlpEntitiesCount > 0) {
|
||||
this.logger.warn(
|
||||
`Unable to delete NLP entities with provided IDs: ${ids}`,
|
||||
);
|
||||
throw new MethodNotAllowedException(
|
||||
'Deletion failed: Selection includes built-in NLP entities that are protected',
|
||||
);
|
||||
}
|
||||
|
||||
const deleteResult = await this.nlpEntityService.deleteMany({
|
||||
_id: { $in: ids },
|
||||
});
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('NlpValueController', () => {
|
||||
entity: intentNlpEntity!.id,
|
||||
value: 'updated',
|
||||
expressions: [],
|
||||
builtin: true,
|
||||
builtin: false,
|
||||
doc: '',
|
||||
};
|
||||
const result = await nlpValueController.updateOne(
|
||||
@@ -191,7 +191,6 @@ describe('NlpValueController', () => {
|
||||
describe('deleteMany', () => {
|
||||
it('should delete multiple nlp values', async () => {
|
||||
const valuesToDelete = [positiveValue!.id, negativeValue!.id];
|
||||
|
||||
const result = await nlpValueController.deleteMany(valuesToDelete);
|
||||
|
||||
expect(result.deletedCount).toEqual(valuesToDelete.length);
|
||||
|
||||
@@ -232,7 +232,7 @@ describe('NlpEntityService', () => {
|
||||
{
|
||||
value: 'jhon',
|
||||
expressions: ['john', 'joohn', 'jhonny'],
|
||||
builtin: true,
|
||||
builtin: false,
|
||||
doc: '',
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user