Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
97976ea4
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97976ea4
编写于
4月 23, 2020
作者:
Q
q4speed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
api测试界面,未完待续
上级
83c6442b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
115 addition
and
106 deletion
+115
-106
frontend/src/business/App.vue
frontend/src/business/App.vue
+1
-4
frontend/src/business/components/api/test/ApiTestConfig.vue
frontend/src/business/components/api/test/ApiTestConfig.vue
+10
-12
frontend/src/business/components/api/test/ApiTestList.vue
frontend/src/business/components/api/test/ApiTestList.vue
+15
-19
frontend/src/business/components/api/test/model/ScenarioModel.js
...d/src/business/components/api/test/model/ScenarioModel.js
+63
-63
frontend/src/business/components/common/head/RecentList.vue
frontend/src/business/components/common/head/RecentList.vue
+26
-8
未找到文件。
frontend/src/business/App.vue
浏览文件 @
97976ea4
...
...
@@ -13,7 +13,6 @@
</el-row>
<ms-view/>
<ms-web-socket/>
</el-col>
</
template
>
...
...
@@ -21,7 +20,6 @@
import
MsTopMenus
from
"
./components/common/head/HeaderTopMenus
"
;
import
MsView
from
"
./components/common/router/View
"
;
import
MsUser
from
"
./components/common/head/HeaderUser
"
;
import
MsWebSocket
from
"
./components/common/websocket/WebSocket
"
;
export
default
{
name
:
'
app
'
,
...
...
@@ -33,7 +31,6 @@
beforeCreate
()
{
this
.
$get
(
"
/isLogin
"
).
then
(
response
=>
{
if
(
response
.
data
.
success
)
{
window
.
console
.
log
(
response
.
data
);
this
.
$setLang
(
response
.
data
.
data
);
this
.
auth
=
true
;
}
else
{
...
...
@@ -43,7 +40,7 @@
window
.
location
.
href
=
"
/login
"
});
},
components
:
{
Ms
WebSocket
,
Ms
User
,
MsView
,
MsTopMenus
},
components
:
{
MsUser
,
MsView
,
MsTopMenus
},
methods
:
{}
}
</
script
>
...
...
frontend/src/business/components/api/test/ApiTestConfig.vue
浏览文件 @
97976ea4
...
...
@@ -11,7 +11,7 @@
<el-option
v-for=
"project in projects"
:key=
"project.id"
:label=
"project.name"
:value=
"project.id"
/>
</el-select>
</el-input>
<el-button
type=
"primary"
plain
:disabled=
"isDisabled"
@
click=
"saveTest"
>
保存
</el-button>
<el-button
type=
"primary"
plain
:disabled=
"isDisabled"
@
click=
"saveTest"
>
{{
$t
(
'
commons.save
'
)
}}
</el-button>
</el-row>
</el-header>
<ms-api-scenario-config
:scenarios=
"test.scenarioDefinition"
ref=
"config"
/>
...
...
@@ -41,17 +41,15 @@
}
},
beforeRouteUpdate
(
to
,
from
,
next
)
{
if
(
to
.
params
.
type
===
"
edit
"
)
{
this
.
getTest
(
to
.
query
.
id
);
}
else
{
this
.
test
=
new
Test
();
this
.
$refs
.
config
.
reset
();
}
next
();
},
watch
:
{
'
$route
'
(
to
)
{
if
(
to
.
params
.
type
===
"
edit
"
)
{
this
.
getTest
(
to
.
query
.
id
);
}
else
{
this
.
test
=
new
Test
();
this
.
$refs
.
config
.
reset
();
}
},
test
:
{
handler
:
function
()
{
this
.
change
=
true
;
...
...
@@ -65,7 +63,7 @@
this
.
result
=
this
.
$get
(
"
/api/get/
"
+
id
,
response
=>
{
let
item
=
response
.
data
;
this
.
test
.
rese
t
({
this
.
test
=
new
Tes
t
({
id
:
item
.
id
,
projectId
:
item
.
projectId
,
name
:
item
.
name
,
...
...
frontend/src/business/components/api/test/ApiTestList.vue
浏览文件 @
97976ea4
...
...
@@ -3,17 +3,8 @@
<div
class=
"main-content"
>
<el-card>
<template
v-slot:header
>
<div>
<el-row
type=
"flex"
justify=
"space-between"
align=
"middle"
>
<span
class=
"title"
>
{{
$t
(
'
commons.test
'
)
}}
</span>
<span
class=
"search"
>
<el-input
type=
"text"
size=
"small"
:placeholder=
"$t('load_test.search_by_name')"
prefix-icon=
"el-icon-search"
maxlength=
"60"
v-model=
"condition"
@
change=
"search"
clearable
/>
</span>
</el-row>
</div>
<ms-table-header
:condition.sync=
"condition"
@
search=
"search"
:title=
"$t('commons.test')"
@
create=
"create"
/>
</
template
>
<el-table
:data=
"tableData"
class=
"test-content"
>
<el-table-column
...
...
@@ -65,13 +56,14 @@
<
script
>
import
MsTablePagination
from
"
../../common/pagination/TablePagination
"
;
import
MsTableHeader
from
"
../../common/components/MsTableHeader
"
;
export
default
{
components
:
{
MsTablePagination
},
components
:
{
MsTable
Header
,
MsTable
Pagination
},
data
()
{
return
{
result
:
{},
condition
:
""
,
condition
:
{
name
:
""
}
,
projectId
:
null
,
tableData
:
[],
multipleSelection
:
[],
...
...
@@ -83,10 +75,11 @@
}
},
beforeRouteUpdate
(
to
,
from
,
next
)
{
this
.
projectId
=
to
.
params
.
projectId
;
this
.
search
();
next
();
watch
:
{
'
$route
'
(
to
)
{
this
.
projectId
=
to
.
params
.
projectId
;
this
.
initTableData
();
}
},
created
:
function
()
{
...
...
@@ -95,9 +88,12 @@
},
methods
:
{
create
()
{
this
.
$router
.
push
(
'
/api/test/create
'
);
},
search
()
{
let
param
=
{
name
:
this
.
condition
,
name
:
this
.
condition
.
name
,
};
if
(
this
.
projectId
!==
'
all
'
)
{
...
...
@@ -129,7 +125,7 @@
message
:
this
.
$t
(
'
commons.delete_success
'
),
type
:
'
success
'
});
this
.
initTableData
();
this
.
search
();
});
}
}
...
...
frontend/src/business/components/api/test/model/ScenarioModel.js
浏览文件 @
97976ea4
import
{
generateId
}
from
"
element-ui/src/utils/util
"
;
const
assign
=
function
(
obj
,
options
)
{
if
(
options
)
{
for
(
let
name
in
options
)
{
if
(
options
.
hasOwnProperty
(
name
))
{
if
(
!
(
obj
[
name
]
instanceof
Array
))
{
obj
[
name
]
=
options
[
name
];
}
}
}
}
}
const
assigns
=
function
(
target
,
source
,
type
)
{
if
(
target
instanceof
Array
&&
source
instanceof
Array
)
{
if
(
source
&&
source
.
length
>
0
)
{
source
.
forEach
((
options
)
=>
{
target
.
push
(
new
type
(
options
));
})
}
}
}
export
const
BODY_TYPE
=
{
KV
:
"
KV
"
,
TEXT
:
"
TEXT
"
...
...
@@ -33,54 +11,80 @@ export const ASSERTION_TYPE = {
RESPONSE_TIME
:
"
RESPONSE_TIME
"
}
export
class
Test
{
constructor
(
options
)
{
this
.
reset
(
options
);
class
BaseConfig
{
set
(
options
)
{
options
=
this
.
initOptions
(
options
)
for
(
let
name
in
options
)
{
if
(
options
.
hasOwnProperty
(
name
))
{
if
(
!
(
this
[
name
]
instanceof
Array
))
{
this
[
name
]
=
options
[
name
];
}
}
}
}
reset
(
options
)
{
options
=
this
.
getDefaultOptions
(
options
);
sets
(
types
,
options
)
{
options
=
this
.
initOptions
(
options
)
if
(
types
)
{
for
(
let
name
in
types
)
{
if
(
types
.
hasOwnProperty
(
name
)
&&
options
.
hasOwnProperty
(
name
))
{
options
[
name
].
forEach
((
o
)
=>
{
this
[
name
].
push
(
new
types
[
name
](
o
));
})
}
}
}
}
initOptions
(
options
)
{
return
options
||
{};
}
}
export
class
Test
extends
BaseConfig
{
constructor
(
options
)
{
super
();
this
.
id
=
null
;
this
.
name
=
null
;
this
.
projectId
=
null
;
this
.
scenarioDefinition
=
[];
assign
(
this
,
options
);
assigns
(
this
.
scenarioDefinition
,
options
.
scenarioDefinition
,
Scenario
);
this
.
set
(
options
);
this
.
sets
({
scenarioDefinition
:
Scenario
},
options
);
}
getDefaul
tOptions
(
options
)
{
ini
tOptions
(
options
)
{
options
=
options
||
{};
options
.
scenarioDefinition
=
options
.
scenarioDefinition
||
[
new
Scenario
()];
return
options
;
}
}
export
class
Scenario
{
export
class
Scenario
extends
BaseConfig
{
constructor
(
options
)
{
options
=
this
.
getDefaultOptions
(
options
);
super
(
);
this
.
name
=
null
;
this
.
url
=
null
;
this
.
variables
=
[];
this
.
headers
=
[];
this
.
requests
=
[];
assign
(
this
,
options
);
assigns
(
this
.
variables
,
options
.
variables
,
KeyValue
);
assigns
(
this
.
headers
,
options
.
headers
,
KeyValue
);
assigns
(
this
.
requests
,
options
.
requests
,
Request
);
this
.
set
(
options
);
this
.
sets
({
variables
:
KeyValue
,
headers
:
KeyValue
,
requests
:
Request
},
options
);
}
getDefaul
tOptions
(
options
)
{
ini
tOptions
(
options
)
{
options
=
options
||
{};
options
.
requests
=
options
.
requests
||
[
new
Request
()];
return
options
;
}
}
export
class
Request
{
export
class
Request
extends
BaseConfig
{
constructor
(
options
)
{
options
=
this
.
getDefaultOptions
(
options
);
super
(
);
this
.
randomId
=
generateId
();
this
.
name
=
null
;
this
.
url
=
null
;
...
...
@@ -91,13 +95,12 @@ export class Request {
this
.
assertions
=
null
;
this
.
extract
=
[];
assign
(
this
,
options
);
assigns
(
this
.
parameters
,
options
.
parameters
,
KeyValue
);
assigns
(
this
.
headers
,
options
.
headers
,
KeyValue
);
this
.
set
(
options
);
this
.
sets
({
parameters
:
KeyValue
,
headers
:
KeyValue
},
options
);
// TODO assigns extract
}
getDefaul
tOptions
(
options
)
{
ini
tOptions
(
options
)
{
options
=
options
||
{};
options
.
method
=
"
GET
"
;
options
.
body
=
new
Body
(
options
.
body
);
...
...
@@ -106,15 +109,15 @@ export class Request {
}
}
export
class
Body
{
export
class
Body
extends
BaseConfig
{
constructor
(
options
)
{
options
=
options
||
{}
;
super
()
;
this
.
type
=
null
;
this
.
text
=
null
;
this
.
kvs
=
[];
assign
(
this
,
options
);
assigns
(
this
.
kvs
,
options
.
kvs
,
KeyValue
);
this
.
set
(
options
);
this
.
sets
({
kvs
:
KeyValue
},
options
);
}
isKV
()
{
...
...
@@ -122,72 +125,69 @@ export class Body {
}
}
export
class
KeyValue
{
export
class
KeyValue
extends
BaseConfig
{
constructor
(
options
)
{
options
=
options
||
{}
;
super
()
;
this
.
key
=
null
;
this
.
value
=
null
;
assign
(
this
,
options
);
this
.
set
(
options
);
}
}
export
class
Assertions
{
export
class
Assertions
extends
BaseConfig
{
constructor
(
options
)
{
options
=
this
.
getDefaultOptions
(
options
);
super
(
);
this
.
text
=
[];
this
.
regex
=
[];
this
.
responseTime
=
null
;
assign
(
this
,
options
);
assigns
(
this
.
text
,
options
.
text
,
KeyValue
);
assigns
(
this
.
regex
,
options
.
regex
,
KeyValue
);
this
.
set
(
options
);
this
.
sets
({
text
:
KeyValue
,
regex
:
KeyValue
},
options
);
}
getDefaul
tOptions
(
options
)
{
ini
tOptions
(
options
)
{
options
=
options
||
{};
options
.
responseTime
=
new
ResponseTime
(
options
.
responseTime
);
return
options
;
}
}
class
AssertionType
{
class
AssertionType
extends
BaseConfig
{
constructor
(
type
)
{
super
();
this
.
type
=
type
;
}
}
export
class
Text
extends
AssertionType
{
constructor
(
options
)
{
options
=
options
||
{};
super
(
ASSERTION_TYPE
.
TEXT
);
this
.
subject
=
null
;
this
.
condition
=
null
;
this
.
value
=
null
;
assign
(
this
,
options
);
this
.
set
(
options
);
}
}
export
class
Regex
extends
AssertionType
{
constructor
(
options
)
{
options
=
options
||
{};
super
(
ASSERTION_TYPE
.
REGEX
);
this
.
subject
=
null
;
this
.
expression
=
null
;
this
.
description
=
null
;
assign
(
this
,
options
);
this
.
set
(
options
);
}
}
export
class
ResponseTime
extends
AssertionType
{
constructor
(
options
)
{
options
=
options
||
{};
super
(
ASSERTION_TYPE
.
RESPONSE_TIME
);
this
.
responseInTime
=
null
;
assign
(
this
,
options
);
this
.
set
(
options
);
}
}
frontend/src/business/components/common/head/RecentList.vue
浏览文件 @
97976ea4
<
template
>
<div>
<div
v-loading=
"result.loading"
>
<div
class=
"recent-text"
>
<i
class=
"el-icon-time"
/>
<span>
{{
options
.
title
}}
</span>
<i
class=
"el-icon-refresh"
@
click=
"recent"
/>
</div>
<el-menu-item
:key=
"i.id"
v-for=
"i in items"
:index=
"getIndex(i)"
:route=
"getRouter(i)"
>
<el-menu-item
:key=
"i.id"
v-for=
"i in items"
:index=
"getIndex(i)"
:route=
"getRouter(i)"
>
<span
class=
"title"
>
{{
i
.
name
}}
</span>
</el-menu-item>
</div>
...
...
@@ -21,14 +21,11 @@
options
:
Object
},
mounted
()
{
if
(
hasRoles
(
ROLE_TEST_VIEWER
,
ROLE_TEST_USER
,
ROLE_TEST_MANAGER
))
{
this
.
$get
(
this
.
options
.
url
,
(
response
)
=>
{
this
.
items
=
response
.
data
;
});
}
this
.
recent
();
},
data
()
{
return
{
result
:
{},
items
:
[]
}
},
...
...
@@ -45,6 +42,16 @@
}
}
}
},
methods
:
{
recent
:
function
()
{
if
(
hasRoles
(
ROLE_TEST_VIEWER
,
ROLE_TEST_USER
,
ROLE_TEST_MANAGER
))
{
this
.
result
=
this
.
$get
(
this
.
options
.
url
,
(
response
)
=>
{
this
.
items
=
response
.
data
;
});
}
}
}
}
</
script
>
...
...
@@ -60,6 +67,17 @@
.recent-text
span
{
padding-left
:
6px
;
line-height
:
36px
;
}
.recent-text
.el-icon-refresh
{
cursor
:
pointer
;
float
:
right
;
line-height
:
36px
;
}
.recent-text
.el-icon-refresh
:hover
{
color
:
#BBBBBB
;
}
.title
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录