feat(server): use user model (#9710)

This commit is contained in:
forehalo
2025-01-17 07:06:11 +00:00
parent a2d16f4b78
commit 44de4474c3
25 changed files with 179 additions and 521 deletions
@@ -8,12 +8,11 @@ import { MailService } from '../../base';
import { AuthModule, CurrentUser } from '../../core/auth';
import { AuthService } from '../../core/auth/service';
import { FeatureModule } from '../../core/features';
import { UserModule, UserService } from '../../core/user';
import { UserModule } from '../../core/user';
import { createTestingApp, getSession, sessionCookie } from '../utils';
const test = ava as TestFn<{
auth: AuthService;
user: UserService;
u1: CurrentUser;
db: PrismaClient;
mailer: Sinon.SinonStubbedInstance<MailService>;
@@ -31,7 +30,6 @@ test.before(async t => {
});
t.context.auth = app.get(AuthService);
t.context.user = app.get(UserService);
t.context.db = app.get(PrismaClient);
t.context.mailer = app.get(MailService);
t.context.app = app;
@@ -6,12 +6,13 @@ import { CurrentUser } from '../../core/auth';
import { AuthService } from '../../core/auth/service';
import { FeatureModule } from '../../core/features';
import { QuotaModule } from '../../core/quota';
import { UserModule, UserService } from '../../core/user';
import { UserModule } from '../../core/user';
import { Models } from '../../models';
import { createTestingModule, initTestingDB } from '../utils';
const test = ava as TestFn<{
auth: AuthService;
user: UserService;
models: Models;
u1: CurrentUser;
db: PrismaClient;
m: TestingModule;
@@ -24,7 +25,7 @@ test.before(async t => {
});
t.context.auth = m.get(AuthService);
t.context.user = m.get(UserService);
t.context.models = m.get(Models);
t.context.db = m.get(PrismaClient);
t.context.m = m;
});
@@ -55,9 +56,9 @@ test('should throw if user not found', async t => {
});
test('should throw if password not set', async t => {
const { user, auth } = t.context;
const { models, auth } = t.context;
await user.createUser({
await models.user.create({
email: 'u2@affine.pro',
name: 'u2',
});