Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
efad4c10
authored
Apr 15, 2025
by
Finley Ge
Committed by
GitHub
Apr 15, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: add opreationLog mock (#4542)
parent
bed68718
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
projects/app/test/api/core/app/create.test.ts
+3
-0
test/datas/users.ts
+6
-8
test/mocks/index.ts
+7
-0
No files found.
projects/app/test/api/core/app/create.test.ts
View file @
efad4c10
import
*
as
createapi
from
'@/pages/api/core/app/create'
;
import
*
as
createapi
from
'@/pages/api/core/app/create'
;
import
{
AppErrEnum
}
from
'@fastgpt/global/common/error/code/app'
;
import
{
AppErrEnum
}
from
'@fastgpt/global/common/error/code/app'
;
import
{
delay
}
from
'@fastgpt/global/common/system/utils'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
import
{
TeamAppCreatePermissionVal
}
from
'@fastgpt/global/support/permission/user/constant'
;
import
{
TeamAppCreatePermissionVal
}
from
'@fastgpt/global/support/permission/user/constant'
;
import
{
MongoResourcePermission
}
from
'@fastgpt/service/support/permission/schema'
;
import
{
MongoResourcePermission
}
from
'@fastgpt/service/support/permission/schema'
;
...
@@ -17,6 +18,7 @@ describe('create api', () => {
...
@@ -17,6 +18,7 @@ describe('create api', () => {
tmbId
:
users
.
members
[
0
].
tmbId
,
tmbId
:
users
.
members
[
0
].
tmbId
,
permission
:
TeamAppCreatePermissionVal
permission
:
TeamAppCreatePermissionVal
});
});
await
delay
(
100
);
const
res
=
await
Call
<
createapi
.
CreateAppBody
,
{},
{}
>
(
createapi
.
default
,
{
const
res
=
await
Call
<
createapi
.
CreateAppBody
,
{},
{}
>
(
createapi
.
default
,
{
auth
:
users
.
members
[
0
],
auth
:
users
.
members
[
0
],
body
:
{
body
:
{
...
@@ -38,6 +40,7 @@ describe('create api', () => {
...
@@ -38,6 +40,7 @@ describe('create api', () => {
parentId
:
String
(
folderId
)
parentId
:
String
(
folderId
)
}
}
});
});
await
delay
(
500
);
expect
(
res2
.
error
).
toBeUndefined
();
expect
(
res2
.
error
).
toBeUndefined
();
expect
(
res2
.
code
).
toBe
(
200
);
expect
(
res2
.
code
).
toBe
(
200
);
expect
(
res2
.
data
).
toBeDefined
();
expect
(
res2
.
data
).
toBeDefined
();
...
...
test/datas/users.ts
View file @
efad4c10
...
@@ -146,14 +146,12 @@ export async function getFakeUsers(num: number = 10) {
...
@@ -146,14 +146,12 @@ export async function getFakeUsers(num: number = 10) {
export
async
function
getFakeGroups
(
num
:
number
=
5
)
{
export
async
function
getFakeGroups
(
num
:
number
=
5
)
{
// create 5 groups
// create 5 groups
const
teamId
=
(
await
getFakeUser
(
'Owner'
)).
teamId
;
const
teamId
=
(
await
getFakeUser
(
'Owner'
)).
teamId
;
return
MongoMemberGroupModel
.
create
([
return
MongoMemberGroupModel
.
create
(
...
Array
(
num
)
[...
Array
(
num
).
keys
()].
map
((
i
)
=>
({
.
keys
()
name
:
`group
${
i
+
1
}
`
,
.
map
((
i
)
=>
({
teamId
name
:
`group
${
i
+
1
}
`
,
}))
teamId
)
as
Promise
<
MemberGroupSchemaType
[]
>
;
}))
])
as
Promise
<
MemberGroupSchemaType
[]
>
;
}
}
export
async
function
getFakeOrgs
()
{
export
async
function
getFakeOrgs
()
{
...
...
test/mocks/index.ts
View file @
efad4c10
import
{
vi
}
from
'vitest'
;
import
'./request'
;
import
'./request'
;
vi
.
mock
(
import
(
'@fastgpt/service/support/operationLog/addOperationLog'
),
()
=>
{
return
{
addOperationLog
:
vi
.
fn
()
};
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment