Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
c53687d3
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,发现更多精彩内容 >>
提交
c53687d3
编写于
1月 18, 2021
作者:
C
chenjianxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 接口测试文件上传失败
上级
b024c5da
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
68 deletion
+54
-68
frontend/src/business/components/api/automation/scenario/ApiComponent.vue
...iness/components/api/automation/scenario/ApiComponent.vue
+4
-3
frontend/src/business/components/api/definition/components/Run.vue
...src/business/components/api/definition/components/Run.vue
+1
-1
frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue
...components/api/definition/components/case/ApiCaseItem.vue
+3
-32
frontend/src/common/js/utils.js
frontend/src/common/js/utils.js
+46
-32
未找到文件。
frontend/src/business/components/api/automation/scenario/ApiComponent.vue
浏览文件 @
c53687d3
...
...
@@ -24,6 +24,10 @@
<el-tag
size=
"mini"
style=
"margin-left: 20px"
v-if=
"request.referenced==='Deleted'"
type=
"danger"
>
{{
$t
(
'
api_test.automation.reference_deleted
'
)
}}
</el-tag>
<el-tag
size=
"mini"
style=
"margin-left: 20px"
v-if=
"request.referenced==='Copy'"
>
{{
$t
(
'
commons.copy
'
)
}}
</el-tag>
<el-tag
size=
"mini"
style=
"margin-left: 20px"
v-if=
"request.referenced ==='REF'"
>
{{
$t
(
'
api_test.scenario.reference
'
)
}}
</el-tag>
<ms-run
:debug=
"false"
:reportId=
"reportId"
:run-data=
"runData"
@
runRefresh=
"runRefresh"
ref=
"runTest"
/>
</
template
>
<
template
v-slot:button
>
...
...
@@ -56,9 +60,6 @@
{{$t('commons.save')}}
</el-button>
<ms-run
:debug=
"false"
:reportId=
"reportId"
:run-data=
"runData"
@
runRefresh=
"runRefresh"
ref=
"runTest"
/>
</api-base-component>
</template>
...
...
frontend/src/business/components/api/definition/components/Run.vue
浏览文件 @
c53687d3
<
template
>
<
div></div
>
<
span></span
>
</
template
>
<
script
>
import
{
getUUID
,
getBodyUploadFiles
}
from
"
@/common/js/utils
"
;
...
...
frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue
浏览文件 @
c53687d3
...
...
@@ -92,7 +92,7 @@
</
template
>
<
script
>
import
{
getCurrentProjectID
,
getUUID
}
from
"
../../../../../../common/js/utils
"
;
import
{
_getBodyUploadFiles
,
getCurrentProjectID
,
getUUID
}
from
"
../../../../../../common/js/utils
"
;
import
{
PRIORITY
,
RESULT_MAP
}
from
"
../../model/JsonData
"
;
import
MsTag
from
"
../../../../common/components/MsTag
"
;
import
MsTipButton
from
"
../../../../common/components/MsTipButton
"
;
...
...
@@ -223,6 +223,7 @@
if
(
this
.
validate
(
tmp
))
{
return
;
}
tmp
.
request
.
body
=
row
.
request
.
body
;
let
bodyFiles
=
this
.
getBodyUploadFiles
(
tmp
);
tmp
.
projectId
=
getCurrentProjectID
();
tmp
.
active
=
true
;
...
...
@@ -278,37 +279,7 @@
getBodyUploadFiles
(
row
)
{
let
bodyUploadFiles
=
[];
row
.
bodyUploadIds
=
[];
let
request
=
row
.
request
;
if
(
request
.
body
&&
request
.
body
.
kvs
)
{
request
.
body
.
kvs
.
forEach
(
param
=>
{
if
(
param
.
files
)
{
param
.
files
.
forEach
(
item
=>
{
if
(
item
.
file
)
{
let
fileId
=
getUUID
().
substring
(
0
,
8
);
item
.
name
=
item
.
file
.
name
;
item
.
id
=
fileId
;
row
.
bodyUploadIds
.
push
(
fileId
);
bodyUploadFiles
.
push
(
item
.
file
);
}
});
}
});
if
(
request
.
body
.
binary
)
{
request
.
body
.
binary
.
forEach
(
param
=>
{
if
(
param
.
files
)
{
param
.
files
.
forEach
(
item
=>
{
if
(
item
.
file
)
{
let
fileId
=
getUUID
().
substring
(
0
,
8
);
item
.
name
=
item
.
file
.
name
;
item
.
id
=
fileId
;
row
.
bodyUploadIds
.
push
(
fileId
);
bodyUploadFiles
.
push
(
item
.
file
);
}
});
}
});
}
}
_getBodyUploadFiles
(
row
.
request
,
bodyUploadFiles
,
row
);
return
bodyUploadFiles
;
},
}
...
...
frontend/src/common/js/utils.js
浏览文件 @
c53687d3
...
...
@@ -303,42 +303,56 @@ export function getBodyUploadFiles(obj, runData) {
let
bodyUploadFiles
=
[];
obj
.
bodyUploadIds
=
[];
if
(
runData
)
{
runData
.
forEach
(
request
=>
{
if
(
request
.
body
)
{
request
.
body
.
kvs
.
forEach
(
param
=>
{
if
(
param
.
files
)
{
param
.
files
.
forEach
(
item
=>
{
if
(
item
.
file
)
{
if
(
!
item
.
id
)
{
let
fileId
=
getUUID
().
substring
(
0
,
12
);
item
.
name
=
item
.
file
.
name
;
item
.
id
=
fileId
;
}
obj
.
bodyUploadIds
.
push
(
item
.
id
);
bodyUploadFiles
.
push
(
item
.
file
);
}
});
if
(
runData
instanceof
Array
)
{
runData
.
forEach
(
request
=>
{
_getBodyUploadFiles
(
request
,
bodyUploadFiles
,
obj
);
});
}
else
{
_getBodyUploadFiles
(
runData
,
bodyUploadFiles
,
obj
);
}
}
return
bodyUploadFiles
;
}
export
function
_getBodyUploadFiles
(
request
,
bodyUploadFiles
,
obj
)
{
let
body
=
null
;
if
(
request
.
hashTree
&&
request
.
hashTree
.
length
>
0
&&
request
.
hashTree
[
0
].
body
)
{
body
=
request
.
hashTree
[
0
].
body
;
}
else
if
(
request
.
body
)
{
body
=
request
.
body
;
}
if
(
body
)
{
body
.
kvs
.
forEach
(
param
=>
{
if
(
param
.
files
)
{
param
.
files
.
forEach
(
item
=>
{
if
(
item
.
file
)
{
if
(
!
item
.
id
)
{
let
fileId
=
getUUID
().
substring
(
0
,
12
);
item
.
name
=
item
.
file
.
name
;
item
.
id
=
fileId
;
}
obj
.
bodyUploadIds
.
push
(
item
.
id
);
bodyUploadFiles
.
push
(
item
.
file
);
}
});
if
(
request
.
body
.
binary
)
{
request
.
body
.
binary
.
forEach
(
param
=>
{
if
(
param
.
files
)
{
param
.
files
.
forEach
(
ite
m
=>
{
if
(
item
.
file
)
{
if
(
!
item
.
id
)
{
let
fileId
=
getUUID
().
substring
(
0
,
12
);
item
.
name
=
item
.
file
.
name
;
item
.
id
=
fileId
;
}
obj
.
bodyUploadIds
.
push
(
item
.
id
)
;
bodyUploadFiles
.
push
(
item
.
file
);
}
}
);
}
});
if
(
body
.
binary
)
{
body
.
binary
.
forEach
(
para
m
=>
{
if
(
param
.
files
)
{
param
.
files
.
forEach
(
item
=>
{
if
(
item
.
file
)
{
if
(
!
item
.
id
)
{
let
fileId
=
getUUID
().
substring
(
0
,
12
)
;
item
.
name
=
item
.
file
.
name
;
item
.
id
=
fileId
;
}
obj
.
bodyUploadIds
.
push
(
item
.
id
);
bodyUploadFiles
.
push
(
item
.
file
);
}
});
}
}
}
);
}
);
}
}
return
bodyUploadFiles
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录