@@ -44,19 +44,18 @@ import {
4444} from '@teable/openapi' ;
4545import type { AxiosInstance } from 'axios' ;
4646import axios from 'axios' ;
47- import { ClsService } from 'nestjs-cls ' ;
47+ import { vi } from 'vitest ' ;
4848import { AUTH_SESSION_COOKIE_NAME } from '../src/const' ;
4949import { SettingService } from '../src/features/setting/setting.service' ;
50- import type { IClsStore } from '../src/types/cls' ;
5150import { createNewUserAxios } from './utils/axios-instance/new-user' ;
5251import { getError } from './utils/get-error' ;
53- import { initApp , runWithTestUser } from './utils/init-app' ;
52+ import { initApp } from './utils/init-app' ;
5453
5554describe ( 'Auth Controller (e2e)' , ( ) => {
5655 let app : INestApplication ;
5756 let prismaService : PrismaService ;
5857 let settingService : SettingService ;
59- let clsService : ClsService < IClsStore > ;
58+
6059 const authTestEmail = 'auth@test-auth.com' ;
6160
6261 beforeAll ( async ( ) => {
@@ -66,7 +65,6 @@ describe('Auth Controller (e2e)', () => {
6665
6766 const appCtx = await initApp ( ) ;
6867 app = appCtx . app ;
69- clsService = app . get ( ClsService ) ;
7068 prismaService = app . get ( PrismaService ) ;
7169 settingService = app . get ( SettingService ) ;
7270 } ) ;
@@ -137,23 +135,18 @@ describe('Auth Controller (e2e)', () => {
137135 } ) ;
138136
139137 describe ( 'sign up with email verification' , ( ) => {
140- let preEnableEmailVerification : boolean | null | undefined ;
141138 beforeEach ( async ( ) => {
142- await runWithTestUser ( clsService , async ( ) => {
143- const setting = await settingService . getSetting ( ) ;
144- preEnableEmailVerification = setting . enableEmailVerification ;
145- await settingService . updateSetting ( {
139+ const originalGetSetting = settingService . getSetting . bind ( settingService ) ;
140+ vi . spyOn ( settingService , 'getSetting' ) . mockImplementation ( async ( ) => {
141+ return {
142+ ... ( await originalGetSetting ( ) ) ,
146143 enableEmailVerification : true ,
147- } ) ;
144+ } ;
148145 } ) ;
149146 } ) ;
150147
151- afterEach ( async ( ) => {
152- await runWithTestUser ( clsService , async ( ) => {
153- await settingService . updateSetting ( {
154- enableEmailVerification : preEnableEmailVerification ,
155- } ) ;
156- } ) ;
148+ afterEach ( ( ) => {
149+ vi . restoreAllMocks ( ) ;
157150 } ) ;
158151
159152 it ( 'api/auth/signup - email verification is required' , async ( ) => {
0 commit comments