mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(server): standalone runtime module (#9120)
This commit is contained in:
@@ -4,7 +4,7 @@ import { INestApplication } from '@nestjs/common';
|
||||
import type { TestFn } from 'ava';
|
||||
import ava from 'ava';
|
||||
|
||||
import { Config, ConfigModule } from '../src/base/config';
|
||||
import { Runtime } from '../src/base';
|
||||
import { AuthService } from '../src/core/auth/service';
|
||||
import {
|
||||
FeatureManagementService,
|
||||
@@ -26,15 +26,7 @@ const test = ava as TestFn<{
|
||||
|
||||
test.beforeEach(async t => {
|
||||
const { app } = await createTestingApp({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
server: {
|
||||
host: 'example.org',
|
||||
https: true,
|
||||
},
|
||||
}),
|
||||
FeatureModule,
|
||||
],
|
||||
imports: [FeatureModule],
|
||||
providers: [WorkspaceResolver],
|
||||
tapModule: module => {
|
||||
module
|
||||
@@ -43,8 +35,8 @@ test.beforeEach(async t => {
|
||||
},
|
||||
});
|
||||
|
||||
const config = app.get(Config);
|
||||
await config.runtime.set('flags/earlyAccessControl', true);
|
||||
const runtime = app.get(Runtime);
|
||||
await runtime.set('flags/earlyAccessControl', true);
|
||||
t.context.app = app;
|
||||
t.context.auth = app.get(AuthService);
|
||||
t.context.feature = app.get(FeatureService);
|
||||
|
||||
@@ -7,8 +7,8 @@ import Sinon from 'sinon';
|
||||
import Stripe from 'stripe';
|
||||
|
||||
import { AppModule } from '../../src/app.module';
|
||||
import { EventEmitter } from '../../src/base';
|
||||
import { Config, ConfigModule, Runtime } from '../../src/base/config';
|
||||
import { EventEmitter, Runtime } from '../../src/base';
|
||||
import { ConfigModule } from '../../src/base/config';
|
||||
import { CurrentUser } from '../../src/core/auth';
|
||||
import { AuthService } from '../../src/core/auth/service';
|
||||
import {
|
||||
@@ -543,8 +543,8 @@ test('should get correct pro plan price for checking out', async t => {
|
||||
// any user, lifetime recurring
|
||||
{
|
||||
feature.isEarlyAccessUser.resolves(false);
|
||||
const config = app.get(Config);
|
||||
await config.runtime.set('plugins.payment/showLifetimePrice', true);
|
||||
const runtime = app.get(Runtime);
|
||||
await runtime.set('plugins.payment/showLifetimePrice', true);
|
||||
|
||||
await service.checkout(
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { Response } from 'supertest';
|
||||
import supertest from 'supertest';
|
||||
|
||||
import { AppModule, FunctionalityModules } from '../../src/app.module';
|
||||
import { Config, GlobalExceptionFilter } from '../../src/base';
|
||||
import { GlobalExceptionFilter, Runtime } from '../../src/base';
|
||||
import { GqlModule } from '../../src/base/graphql';
|
||||
import { AuthGuard, AuthModule } from '../../src/core/auth';
|
||||
import { UserFeaturesInit1698652531198 } from '../../src/data/migrations/1698652531198-user-features-init';
|
||||
@@ -111,9 +111,9 @@ export async function createTestingModule(
|
||||
if (init) {
|
||||
await m.init();
|
||||
|
||||
const config = m.get(Config);
|
||||
const runtime = m.get(Runtime);
|
||||
// by pass password min length validation
|
||||
await config.runtime.set('auth/password.min', 1);
|
||||
await runtime.set('auth/password.min', 1);
|
||||
}
|
||||
|
||||
return m;
|
||||
@@ -145,9 +145,9 @@ export async function createTestingApp(moduleDef: TestingModuleMeatdata = {}) {
|
||||
|
||||
await app.init();
|
||||
|
||||
const config = app.get(Config);
|
||||
const runtime = app.get(Runtime);
|
||||
// by pass password min length validation
|
||||
await config.runtime.set('auth/password.min', 1);
|
||||
await runtime.set('auth/password.min', 1);
|
||||
|
||||
return {
|
||||
module: m,
|
||||
|
||||
Reference in New Issue
Block a user