mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat(api): add automatic DI to NLP module
This commit is contained in:
parent
ec17bfb805
commit
04e7aa3288
@ -6,14 +6,12 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import {
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
MethodNotAllowedException,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { IGNORED_TEST_FIELDS } from '@/utils/test/constants';
|
||||
import { nlpEntityFixtures } from '@/utils/test/fixtures/nlpentity';
|
||||
@ -30,16 +28,7 @@ import { TFixtures } from '@/utils/test/types';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntityCreateDto, NlpEntityUpdateDto } from '../dto/nlp-entity.dto';
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import {
|
||||
NlpEntity,
|
||||
NlpEntityFull,
|
||||
NlpEntityModel,
|
||||
} from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpEntity, NlpEntityFull } from '../schemas/nlp-entity.schema';
|
||||
import { NlpEntityService } from '../services/nlp-entity.service';
|
||||
import { NlpValueService } from '../services/nlp-value.service';
|
||||
|
||||
@ -54,28 +43,9 @@ describe('NlpEntityController', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
autoInjectFrom: ['controllers'],
|
||||
controllers: [NlpEntityController],
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpEntityModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpValueModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpEntityService,
|
||||
NlpEntityRepository,
|
||||
NlpValueService,
|
||||
NlpSampleEntityRepository,
|
||||
NlpValueRepository,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
imports: [rootMongooseTestModule(installNlpValueFixtures)],
|
||||
});
|
||||
[nlpEntityController, nlpValueService, nlpEntityService] = await getMocks([
|
||||
NlpEntityController,
|
||||
|
@ -6,20 +6,11 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { NlpValueMatchPattern } from '@/chat/schemas/types/pattern';
|
||||
import { HelperService } from '@/helper/helper.service';
|
||||
import { LanguageRepository } from '@/i18n/repositories/language.repository';
|
||||
import { Language, LanguageModel } from '@/i18n/schemas/language.schema';
|
||||
import { I18nService } from '@/i18n/services/i18n.service';
|
||||
import { Language } from '@/i18n/schemas/language.schema';
|
||||
import { LanguageService } from '@/i18n/services/language.service';
|
||||
import { SettingRepository } from '@/setting/repositories/setting.repository';
|
||||
import { SettingModel } from '@/setting/schemas/setting.schema';
|
||||
import { SettingSeeder } from '@/setting/seeds/setting.seed';
|
||||
import { SettingService } from '@/setting/services/setting.service';
|
||||
import { getUpdateOneError } from '@/utils/test/errors/messages';
|
||||
import { installAttachmentFixtures } from '@/utils/test/fixtures/attachment';
|
||||
import { nlpSampleFixtures } from '@/utils/test/fixtures/nlpsample';
|
||||
@ -33,18 +24,7 @@ import { TFixtures } from '@/utils/test/types';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpSampleDto } from '../dto/nlp-sample.dto';
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpSampleRepository } from '../repositories/nlp-sample.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import { NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import {
|
||||
NlpSample,
|
||||
NlpSampleFull,
|
||||
NlpSampleModel,
|
||||
} from '../schemas/nlp-sample.schema';
|
||||
import { NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpSample, NlpSampleFull } from '../schemas/nlp-sample.schema';
|
||||
import { NlpSampleState } from '../schemas/types';
|
||||
import { NlpEntityService } from '../services/nlp-entity.service';
|
||||
import { NlpSampleEntityService } from '../services/nlp-sample-entity.service';
|
||||
@ -65,50 +45,13 @@ describe('NlpSampleController', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
autoInjectFrom: ['controllers'],
|
||||
controllers: [NlpSampleController],
|
||||
imports: [
|
||||
rootMongooseTestModule(async () => {
|
||||
await installNlpSampleEntityFixtures();
|
||||
await installAttachmentFixtures();
|
||||
}),
|
||||
MongooseModule.forFeature([
|
||||
NlpSampleModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpEntityModel,
|
||||
NlpValueModel,
|
||||
SettingModel,
|
||||
LanguageModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpSampleRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpEntityService,
|
||||
NlpEntityRepository,
|
||||
NlpValueService,
|
||||
NlpValueRepository,
|
||||
NlpSampleService,
|
||||
NlpSampleEntityService,
|
||||
LanguageRepository,
|
||||
LanguageService,
|
||||
HelperService,
|
||||
SettingRepository,
|
||||
SettingService,
|
||||
SettingSeeder,
|
||||
{
|
||||
provide: I18nService,
|
||||
useValue: {
|
||||
t: jest.fn().mockImplementation((t) => t),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
[
|
||||
|
@ -6,9 +6,7 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { getUpdateOneError } from '@/utils/test/errors/messages';
|
||||
import {
|
||||
@ -22,12 +20,7 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpValueCreateDto } from '../dto/nlp-value.dto';
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import { NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpValue, NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpValue } from '../schemas/nlp-value.schema';
|
||||
import { NlpEntityService } from '../services/nlp-entity.service';
|
||||
import { NlpValueService } from '../services/nlp-value.service';
|
||||
|
||||
@ -43,28 +36,9 @@ describe('NlpValueController', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
autoInjectFrom: ['controllers'],
|
||||
controllers: [NlpValueController],
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpValueModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpEntityModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpValueRepository,
|
||||
NlpValueService,
|
||||
NlpSampleEntityRepository,
|
||||
NlpEntityService,
|
||||
NlpEntityRepository,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
imports: [rootMongooseTestModule(installNlpValueFixtures)],
|
||||
});
|
||||
[nlpValueController, nlpValueService, nlpEntityService] = await getMocks([
|
||||
NlpValueController,
|
||||
|
@ -6,8 +6,6 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { nlpEntityFixtures } from '@/utils/test/fixtures/nlpentity';
|
||||
import { installNlpValueFixtures } from '@/utils/test/fixtures/nlpvalue';
|
||||
import { getPageQuery } from '@/utils/test/pagination';
|
||||
@ -17,12 +15,9 @@ import {
|
||||
} from '@/utils/test/test';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntity, NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpEntity } from '../schemas/nlp-entity.schema';
|
||||
|
||||
import { NlpEntityRepository } from './nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from './nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from './nlp-value.repository';
|
||||
|
||||
describe('NlpEntityRepository', () => {
|
||||
@ -32,19 +27,9 @@ describe('NlpEntityRepository', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpEntityModel,
|
||||
NlpValueModel,
|
||||
NlpSampleEntityModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpEntityRepository,
|
||||
NlpValueRepository,
|
||||
NlpSampleEntityRepository,
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpValueFixtures)],
|
||||
providers: [NlpEntityRepository],
|
||||
});
|
||||
[nlpEntityRepository, nlpValueRepository] = await getMocks([
|
||||
NlpEntityRepository,
|
||||
|
@ -6,10 +6,8 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { LanguageRepository } from '@/i18n/repositories/language.repository';
|
||||
import { Language, LanguageModel } from '@/i18n/schemas/language.schema';
|
||||
import { Language } from '@/i18n/schemas/language.schema';
|
||||
import { nlpSampleFixtures } from '@/utils/test/fixtures/nlpsample';
|
||||
import {
|
||||
installNlpSampleEntityFixtures,
|
||||
@ -24,18 +22,15 @@ import {
|
||||
import { TFixtures } from '@/utils/test/types';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntity, NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpEntity } from '../schemas/nlp-entity.schema';
|
||||
import {
|
||||
NlpSampleEntity,
|
||||
NlpSampleEntityFull,
|
||||
NlpSampleEntityModel,
|
||||
} from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpSampleModel } from '../schemas/nlp-sample.schema';
|
||||
import { NlpValueModel, NlpValueStub } from '../schemas/nlp-value.schema';
|
||||
import { NlpValueStub } from '../schemas/nlp-value.schema';
|
||||
|
||||
import { NlpEntityRepository } from './nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from './nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from './nlp-value.repository';
|
||||
|
||||
describe('NlpSampleEntityRepository', () => {
|
||||
let nlpSampleEntityRepository: NlpSampleEntityRepository;
|
||||
@ -47,20 +42,12 @@ describe('NlpSampleEntityRepository', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpSampleEntityFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpSampleEntityModel,
|
||||
NlpEntityModel,
|
||||
NlpValueModel,
|
||||
NlpSampleModel,
|
||||
LanguageModel,
|
||||
]),
|
||||
],
|
||||
models: ['NlpSampleModel'],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpSampleEntityFixtures)],
|
||||
providers: [
|
||||
NlpSampleEntityRepository,
|
||||
NlpEntityRepository,
|
||||
NlpValueRepository,
|
||||
LanguageRepository,
|
||||
],
|
||||
});
|
||||
|
@ -6,11 +6,10 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
import { Types } from 'mongoose';
|
||||
|
||||
import { LanguageRepository } from '@/i18n/repositories/language.repository';
|
||||
import { Language, LanguageModel } from '@/i18n/schemas/language.schema';
|
||||
import { Language } from '@/i18n/schemas/language.schema';
|
||||
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
||||
import { nlpSampleFixtures } from '@/utils/test/fixtures/nlpsample';
|
||||
import { installNlpSampleEntityFixtures } from '@/utils/test/fixtures/nlpsampleentity';
|
||||
@ -22,16 +21,9 @@ import {
|
||||
import { TFixtures } from '@/utils/test/types';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import {
|
||||
NlpSampleEntity,
|
||||
NlpSampleEntityModel,
|
||||
} from '../schemas/nlp-sample-entity.schema';
|
||||
import {
|
||||
NlpSample,
|
||||
NlpSampleFull,
|
||||
NlpSampleModel,
|
||||
} from '../schemas/nlp-sample.schema';
|
||||
import { NlpValue, NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpSampleEntity } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpSample, NlpSampleFull } from '../schemas/nlp-sample.schema';
|
||||
import { NlpValue } from '../schemas/nlp-value.schema';
|
||||
|
||||
import { NlpSampleEntityRepository } from './nlp-sample-entity.repository';
|
||||
import { NlpSampleRepository } from './nlp-sample.repository';
|
||||
@ -48,21 +40,9 @@ describe('NlpSampleRepository', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpSampleEntityFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpSampleModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpValueModel,
|
||||
LanguageModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpSampleRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpValueRepository,
|
||||
LanguageRepository,
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpSampleEntityFixtures)],
|
||||
providers: [NlpSampleRepository, NlpValueRepository, LanguageRepository],
|
||||
});
|
||||
[
|
||||
nlpSampleRepository,
|
||||
|
@ -6,8 +6,6 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { nlpEntityFixtures } from '@/utils/test/fixtures/nlpentity';
|
||||
import { installNlpSampleEntityFixtures } from '@/utils/test/fixtures/nlpsampleentity';
|
||||
import { nlpValueFixtures } from '@/utils/test/fixtures/nlpvalue';
|
||||
@ -19,13 +17,7 @@ import {
|
||||
import { TFixtures } from '@/utils/test/types';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import {
|
||||
NlpValue,
|
||||
NlpValueFull,
|
||||
NlpValueModel,
|
||||
} from '../schemas/nlp-value.schema';
|
||||
import { NlpValue, NlpValueFull } from '../schemas/nlp-value.schema';
|
||||
|
||||
import { NlpSampleEntityRepository } from './nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from './nlp-value.repository';
|
||||
@ -37,15 +29,10 @@ describe('NlpValueRepository', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpSampleEntityFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpValueModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpEntityModel,
|
||||
]),
|
||||
],
|
||||
providers: [NlpValueRepository, NlpSampleEntityRepository],
|
||||
models: ['NlpEntityModel'],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpSampleEntityFixtures)],
|
||||
providers: [NlpValueRepository],
|
||||
});
|
||||
[nlpValueRepository, nlpSampleEntityRepository] = await getMocks([
|
||||
NlpValueRepository,
|
||||
|
@ -6,9 +6,6 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { NOT_FOUND_ID } from '@/utils/constants/mock';
|
||||
import { nlpEntityFixtures } from '@/utils/test/fixtures/nlpentity';
|
||||
import { installNlpValueFixtures } from '@/utils/test/fixtures/nlpvalue';
|
||||
@ -20,14 +17,10 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import { NlpEntity, NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpEntity } from '../schemas/nlp-entity.schema';
|
||||
|
||||
import { NlpEntityService } from './nlp-entity.service';
|
||||
import { NlpValueService } from './nlp-value.service';
|
||||
|
||||
describe('NlpEntityService', () => {
|
||||
let nlpEntityService: NlpEntityService;
|
||||
@ -36,29 +29,9 @@ describe('NlpEntityService', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpEntityModel,
|
||||
NlpValueModel,
|
||||
NlpSampleEntityModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpEntityService,
|
||||
NlpEntityRepository,
|
||||
NlpValueService,
|
||||
NlpValueRepository,
|
||||
NlpSampleEntityRepository,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
set: jest.fn(),
|
||||
get: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpValueFixtures)],
|
||||
providers: [NlpEntityService],
|
||||
});
|
||||
[nlpEntityService, nlpEntityRepository, nlpValueRepository] =
|
||||
await getMocks([
|
||||
|
@ -6,11 +6,8 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { LanguageRepository } from '@/i18n/repositories/language.repository';
|
||||
import { Language, LanguageModel } from '@/i18n/schemas/language.schema';
|
||||
import { Language } from '@/i18n/schemas/language.schema';
|
||||
import { nlpSampleFixtures } from '@/utils/test/fixtures/nlpsample';
|
||||
import {
|
||||
installNlpSampleEntityFixtures,
|
||||
@ -28,19 +25,13 @@ import { buildTestingMocks } from '@/utils/test/utils';
|
||||
import { NlpSampleEntityCreateDto } from '../dto/nlp-sample-entity.dto';
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import { NlpEntity, NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpEntity } from '../schemas/nlp-entity.schema';
|
||||
import {
|
||||
NlpSampleEntity,
|
||||
NlpSampleEntityFull,
|
||||
NlpSampleEntityModel,
|
||||
} from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpSample, NlpSampleModel } from '../schemas/nlp-sample.schema';
|
||||
import {
|
||||
NlpValue,
|
||||
NlpValueModel,
|
||||
NlpValueStub,
|
||||
} from '../schemas/nlp-value.schema';
|
||||
import { NlpSample } from '../schemas/nlp-sample.schema';
|
||||
import { NlpValue, NlpValueStub } from '../schemas/nlp-value.schema';
|
||||
|
||||
import { NlpEntityService } from './nlp-entity.service';
|
||||
import { NlpSampleEntityService } from './nlp-sample-entity.service';
|
||||
@ -59,31 +50,10 @@ describe('NlpSampleEntityService', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpSampleEntityFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpSampleEntityModel,
|
||||
NlpEntityModel,
|
||||
NlpSampleModel,
|
||||
NlpValueModel,
|
||||
LanguageModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpSampleEntityRepository,
|
||||
NlpEntityRepository,
|
||||
NlpValueRepository,
|
||||
LanguageRepository,
|
||||
NlpSampleEntityService,
|
||||
NlpEntityService,
|
||||
NlpValueService,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
models: ['NlpSampleModel'],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpSampleEntityFixtures)],
|
||||
providers: [NlpSampleEntityService, LanguageRepository],
|
||||
});
|
||||
[
|
||||
nlpSampleEntityService,
|
||||
|
@ -6,13 +6,11 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { NlpValueMatchPattern } from '@/chat/schemas/types/pattern';
|
||||
import { LanguageRepository } from '@/i18n/repositories/language.repository';
|
||||
import { Language, LanguageModel } from '@/i18n/schemas/language.schema';
|
||||
import { Language } from '@/i18n/schemas/language.schema';
|
||||
import { LanguageService } from '@/i18n/services/language.service';
|
||||
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
||||
import { nlpSampleFixtures } from '@/utils/test/fixtures/nlpsample';
|
||||
@ -25,25 +23,11 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpSampleEntityCreateDto } from '../dto/nlp-sample-entity.dto';
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpSampleRepository } from '../repositories/nlp-sample.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import {
|
||||
NlpEntity,
|
||||
NlpEntityFull,
|
||||
NlpEntityModel,
|
||||
} from '../schemas/nlp-entity.schema';
|
||||
import {
|
||||
NlpSampleEntity,
|
||||
NlpSampleEntityModel,
|
||||
} from '../schemas/nlp-sample-entity.schema';
|
||||
import {
|
||||
NlpSample,
|
||||
NlpSampleFull,
|
||||
NlpSampleModel,
|
||||
} from '../schemas/nlp-sample.schema';
|
||||
import { NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
import { NlpEntity, NlpEntityFull } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntity } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpSample, NlpSampleFull } from '../schemas/nlp-sample.schema';
|
||||
|
||||
import { NlpEntityService } from './nlp-entity.service';
|
||||
import { NlpSampleEntityService } from './nlp-sample-entity.service';
|
||||
@ -65,37 +49,9 @@ describe('NlpSampleService', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpSampleEntityFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpSampleModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpValueModel,
|
||||
NlpEntityModel,
|
||||
LanguageModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpSampleRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpEntityRepository,
|
||||
NlpValueRepository,
|
||||
LanguageRepository,
|
||||
NlpSampleService,
|
||||
NlpSampleEntityService,
|
||||
NlpEntityService,
|
||||
NlpValueService,
|
||||
LanguageService,
|
||||
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpSampleEntityFixtures)],
|
||||
providers: [NlpSampleService],
|
||||
});
|
||||
[
|
||||
nlpEntityService,
|
||||
|
@ -6,9 +6,6 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { BaseSchema } from '@/utils/generics/base-schema';
|
||||
import { nlpEntityFixtures } from '@/utils/test/fixtures/nlpentity';
|
||||
import {
|
||||
@ -23,15 +20,9 @@ import {
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import { NlpEntity, NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import {
|
||||
NlpValue,
|
||||
NlpValueFull,
|
||||
NlpValueModel,
|
||||
} from '../schemas/nlp-value.schema';
|
||||
import { NlpEntity } from '../schemas/nlp-entity.schema';
|
||||
import { NlpValue, NlpValueFull } from '../schemas/nlp-value.schema';
|
||||
|
||||
import { NlpEntityService } from './nlp-entity.service';
|
||||
import { NlpValueService } from './nlp-value.service';
|
||||
@ -45,29 +36,9 @@ describe('NlpValueService', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpValueModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpEntityModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpValueRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpEntityRepository,
|
||||
NlpValueService,
|
||||
NlpEntityService,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
set: jest.fn(),
|
||||
get: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpValueFixtures)],
|
||||
providers: [NlpValueService, NlpEntityService],
|
||||
});
|
||||
[
|
||||
nlpValueService,
|
||||
|
@ -6,17 +6,6 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { HelperService } from '@/helper/helper.service';
|
||||
import { LanguageRepository } from '@/i18n/repositories/language.repository';
|
||||
import { LanguageModel } from '@/i18n/schemas/language.schema';
|
||||
import { LanguageService } from '@/i18n/services/language.service';
|
||||
import { SettingRepository } from '@/setting/repositories/setting.repository';
|
||||
import { SettingModel } from '@/setting/schemas/setting.schema';
|
||||
import { SettingSeeder } from '@/setting/seeds/setting.seed';
|
||||
import { SettingService } from '@/setting/services/setting.service';
|
||||
import { installNlpValueFixtures } from '@/utils/test/fixtures/nlpvalue';
|
||||
import {
|
||||
closeInMongodConnection,
|
||||
@ -24,19 +13,6 @@ import {
|
||||
} from '@/utils/test/test';
|
||||
import { buildTestingMocks } from '@/utils/test/utils';
|
||||
|
||||
import { NlpEntityRepository } from '../repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '../repositories/nlp-sample-entity.repository';
|
||||
import { NlpSampleRepository } from '../repositories/nlp-sample.repository';
|
||||
import { NlpValueRepository } from '../repositories/nlp-value.repository';
|
||||
import { NlpEntityModel } from '../schemas/nlp-entity.schema';
|
||||
import { NlpSampleEntityModel } from '../schemas/nlp-sample-entity.schema';
|
||||
import { NlpSampleModel } from '../schemas/nlp-sample.schema';
|
||||
import { NlpValueModel } from '../schemas/nlp-value.schema';
|
||||
|
||||
import { NlpEntityService } from './nlp-entity.service';
|
||||
import { NlpSampleEntityService } from './nlp-sample-entity.service';
|
||||
import { NlpSampleService } from './nlp-sample.service';
|
||||
import { NlpValueService } from './nlp-value.service';
|
||||
import { NlpService } from './nlp.service';
|
||||
|
||||
describe('NlpService', () => {
|
||||
@ -44,42 +20,9 @@ describe('NlpService', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const { getMocks } = await buildTestingMocks({
|
||||
imports: [
|
||||
rootMongooseTestModule(installNlpValueFixtures),
|
||||
MongooseModule.forFeature([
|
||||
NlpEntityModel,
|
||||
NlpValueModel,
|
||||
NlpSampleEntityModel,
|
||||
NlpSampleModel,
|
||||
LanguageModel,
|
||||
SettingModel,
|
||||
]),
|
||||
],
|
||||
providers: [
|
||||
NlpService,
|
||||
NlpEntityService,
|
||||
NlpEntityRepository,
|
||||
NlpValueService,
|
||||
NlpSampleService,
|
||||
NlpSampleEntityService,
|
||||
HelperService,
|
||||
LanguageService,
|
||||
SettingService,
|
||||
NlpValueRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpSampleRepository,
|
||||
SettingRepository,
|
||||
SettingSeeder,
|
||||
LanguageRepository,
|
||||
{
|
||||
provide: CACHE_MANAGER,
|
||||
useValue: {
|
||||
del: jest.fn(),
|
||||
set: jest.fn(),
|
||||
get: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
autoInjectFrom: ['providers'],
|
||||
imports: [rootMongooseTestModule(installNlpValueFixtures)],
|
||||
providers: [NlpService],
|
||||
});
|
||||
[nlpService] = await getMocks([NlpService]);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user