chore: vitest support (#4026)

* chore: vitest

* chore: move test files

* chore: support vitest

* fix: exclude test files

* chore(ci): add test workflow

* feat: remove read env
This commit is contained in:
Finley Ge
2025-03-12 19:27:53 +08:00
committed by GitHub
parent 139e934345
commit bb30ca4859
32 changed files with 2393 additions and 892 deletions

34
test/datas/users.ts Normal file
View File

@@ -0,0 +1,34 @@
import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant';
import { MongoUser } from '@fastgpt/service/support/user/schema';
import { MongoTeamMember } from '@fastgpt/service/support/user/team/teamMemberSchema';
import { MongoTeam } from '@fastgpt/service/support/user/team/teamSchema';
import { parseHeaderCertRet } from 'test/mocks/request';
export async function getRootUser(): Promise<parseHeaderCertRet> {
const rootUser = await MongoUser.create({
username: 'root',
password: '123456'
});
const team = await MongoTeam.create({
name: 'test team',
ownerId: rootUser._id
});
const tmb = await MongoTeamMember.create({
teamId: team._id,
userId: rootUser._id,
status: 'active'
});
return {
userId: rootUser._id,
apikey: '',
appId: '',
authType: AuthUserTypeEnum.token,
isRoot: true,
sourceName: undefined,
teamId: tmb?.teamId,
tmbId: tmb?._id
};
}