refactor(server): mail service (#10934)
This commit is contained in:
@@ -12,11 +12,13 @@ import { AppModule, FunctionalityModules } from '../../app.module';
|
||||
import { AFFiNELogger, Runtime } from '../../base';
|
||||
import { GqlModule } from '../../base/graphql';
|
||||
import { AuthGuard, AuthModule } from '../../core/auth';
|
||||
import { Mailer, MailModule } from '../../core/mail';
|
||||
import { ModelsModule } from '../../models';
|
||||
// for jsdoc inference
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
import type { createModule } from '../create-module';
|
||||
import { createFactory } from '../mocks';
|
||||
import { MockMailer } from '../mocks/mailer.mock';
|
||||
import { initTestingDB, TEST_LOG_LEVEL } from './utils';
|
||||
|
||||
interface TestingModuleMeatdata extends ModuleMetadata {
|
||||
@@ -26,6 +28,7 @@ interface TestingModuleMeatdata extends ModuleMetadata {
|
||||
export interface TestingModule extends BaseTestingModule {
|
||||
initTestingDB(): Promise<void>;
|
||||
create: ReturnType<typeof createFactory>;
|
||||
mails: MockMailer;
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -68,6 +71,7 @@ export async function createTestingModule(
|
||||
ModelsModule,
|
||||
AuthModule,
|
||||
GqlModule,
|
||||
MailModule,
|
||||
...imports,
|
||||
]);
|
||||
|
||||
@@ -87,6 +91,7 @@ export async function createTestingModule(
|
||||
if (moduleDef.tapModule) {
|
||||
moduleDef.tapModule(builder);
|
||||
}
|
||||
builder.overrideProvider(Mailer).useClass(MockMailer);
|
||||
|
||||
const module = await builder.compile();
|
||||
|
||||
@@ -108,6 +113,8 @@ export async function createTestingModule(
|
||||
await module.close();
|
||||
};
|
||||
|
||||
testingModule.mails = module.get(Mailer, { strict: false }) as MockMailer;
|
||||
|
||||
const logger = new AFFiNELogger();
|
||||
// we got a lot smoking tests try to break nestjs
|
||||
// can't tolerate the noisy logs
|
||||
|
||||
Reference in New Issue
Block a user