mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): optimize helper injection
This commit is contained in:
parent
1468da3d54
commit
b7253c99ec
@ -47,11 +47,9 @@ describe('NlpEntityRepository', () => {
|
||||
let nlpValueRepository: NlpValueRepository;
|
||||
let firstNameNlpEntity: NlpEntity | null;
|
||||
let nlpService: NlpService;
|
||||
let helperService: HelperService;
|
||||
let llmNluHelper: LlmNluHelper;
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
const { getMocks, module } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
@ -86,9 +84,6 @@ describe('NlpEntityRepository', () => {
|
||||
{
|
||||
provide: SettingService,
|
||||
useValue: {
|
||||
getConfig: jest.fn(() => ({
|
||||
chatbot: { lang: { default: 'fr' } },
|
||||
})),
|
||||
getSettings: jest.fn(() => ({
|
||||
chatbot_settings: {
|
||||
default_nlu_helper: 'llm-nlu-helper',
|
||||
@ -103,23 +98,16 @@ describe('NlpEntityRepository', () => {
|
||||
],
|
||||
});
|
||||
|
||||
[
|
||||
nlpEntityRepository,
|
||||
nlpValueRepository,
|
||||
nlpService,
|
||||
helperService,
|
||||
llmNluHelper,
|
||||
] = await getMocks([
|
||||
[nlpEntityRepository, nlpValueRepository, nlpService] = await getMocks([
|
||||
NlpEntityRepository,
|
||||
NlpValueRepository,
|
||||
NlpService,
|
||||
HelperService,
|
||||
LlmNluHelper,
|
||||
]);
|
||||
firstNameNlpEntity = await nlpEntityRepository.findOne({
|
||||
name: 'firstname',
|
||||
});
|
||||
helperService.register(llmNluHelper);
|
||||
const llmNluHelper = module.get(LlmNluHelper);
|
||||
module.get(HelperService).register(llmNluHelper);
|
||||
});
|
||||
|
||||
afterAll(closeInMongodConnection);
|
||||
|
@ -54,11 +54,9 @@ describe('NlpValueRepository', () => {
|
||||
let nlpSampleEntityRepository: NlpSampleEntityRepository;
|
||||
let nlpValues: NlpValue[];
|
||||
let nlpService: NlpService;
|
||||
let helperService: HelperService;
|
||||
let llmNluHelper: LlmNluHelper;
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
const { getMocks, module } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpSampleEntityFixtures),
|
||||
MongooseModule.forFeature([
|
||||
@ -95,9 +93,6 @@ describe('NlpValueRepository', () => {
|
||||
{
|
||||
provide: SettingService,
|
||||
useValue: {
|
||||
getConfig: jest.fn(() => ({
|
||||
chatbot: { lang: { default: 'fr' } },
|
||||
})),
|
||||
getSettings: jest.fn(() => ({
|
||||
chatbot_settings: {
|
||||
default_nlu_helper: 'llm-nlu-helper',
|
||||
@ -111,21 +106,15 @@ describe('NlpValueRepository', () => {
|
||||
],
|
||||
});
|
||||
|
||||
[
|
||||
nlpValueRepository,
|
||||
nlpSampleEntityRepository,
|
||||
nlpService,
|
||||
helperService,
|
||||
llmNluHelper,
|
||||
] = await getMocks([
|
||||
NlpValueRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpService,
|
||||
HelperService,
|
||||
LlmNluHelper,
|
||||
]);
|
||||
[nlpValueRepository, nlpSampleEntityRepository, nlpService] =
|
||||
await getMocks([
|
||||
NlpValueRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpService,
|
||||
]);
|
||||
nlpValues = await nlpValueRepository.findAll();
|
||||
helperService.register(llmNluHelper);
|
||||
const llmNluHelper = module.get(LlmNluHelper);
|
||||
module.get(HelperService).register(llmNluHelper);
|
||||
});
|
||||
|
||||
afterAll(closeInMongodConnection);
|
||||
|
Loading…
Reference in New Issue
Block a user