Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
5d78d510
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,发现更多精彩内容 >>
提交
5d78d510
编写于
3月 30, 2021
作者:
F
fit2-zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(接口自动化): 检查场景步骤是否都是全路径
上级
6313a666
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
230 addition
and
106 deletion
+230
-106
frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
...ss/components/api/automation/scenario/EditApiScenario.vue
+1
-1
frontend/src/business/components/api/automation/scenario/EnvPopover.vue
...usiness/components/api/automation/scenario/EnvPopover.vue
+2
-2
frontend/src/business/components/api/automation/scenario/EnvSelect.vue
...business/components/api/automation/scenario/EnvSelect.vue
+227
-103
未找到文件。
frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
浏览文件 @
5d78d510
...
...
@@ -767,7 +767,7 @@
},
runDebug
()
{
/*触发执行操作*/
let
sign
=
this
.
$refs
.
envPopover
.
checkEnv
();
let
sign
=
this
.
$refs
.
envPopover
.
checkEnv
(
this
.
scenarioDefinition
);
if
(
!
sign
)
{
return
;
}
...
...
frontend/src/business/components/api/automation/scenario/EnvPopover.vue
浏览文件 @
5d78d510
...
...
@@ -44,8 +44,8 @@ export default {
setProjectEnvMap
(
map
)
{
this
.
$emit
(
"
setProjectEnvMap
"
,
map
);
},
checkEnv
()
{
return
this
.
$refs
.
envSelect
.
checkEnv
();
checkEnv
(
data
)
{
return
this
.
$refs
.
envSelect
.
checkEnv
(
data
);
}
}
...
...
frontend/src/business/components/api/automation/scenario/EnvSelect.vue
浏览文件 @
5d78d510
...
...
@@ -29,133 +29,257 @@
</template>
<
script
>
import
{
parseEnvironment
}
from
"
@/business/components/api/test/model/EnvironmentModel
"
;
import
ApiEnvironmentConfig
from
"
@/business/components/api/definition/components/environment/ApiEnvironmentConfig
"
;
import
{
parseEnvironment
}
from
"
@/business/components/api/test/model/EnvironmentModel
"
;
import
ApiEnvironmentConfig
from
"
@/business/components/api/definition/components/environment/ApiEnvironmentConfig
"
;
import
{
ELEMENTS
}
from
"
./Setting
"
;
export
default
{
name
:
"
EnvironmentSelect
"
,
components
:
{
ApiEnvironmentConfig
},
props
:
{
envMap
:
Map
,
projectIds
:
Set
,
projectList
:
Array
},
data
()
{
return
{
data
:
[],
result
:
{},
projects
:
[],
environments
:
[],
dialogVisible
:
false
}
},
methods
:
{
init
()
{
this
.
projectIds
.
forEach
(
id
=>
{
let
item
=
{
id
:
id
,
envs
:
[],
selectEnv
:
""
};
this
.
data
.
push
(
item
);
this
.
result
=
this
.
$get
(
'
/api/environment/list/
'
+
id
,
res
=>
{
let
envs
=
res
.
data
;
envs
.
forEach
(
environment
=>
{
parseEnvironment
(
environment
);
});
// 固定环境列表渲染顺序
let
temp
=
this
.
data
.
find
(
dt
=>
dt
.
id
===
id
);
temp
.
envs
=
envs
;
let
envId
=
this
.
envMap
.
get
(
id
);
// 选中环境是否存在
temp
.
selectEnv
=
envs
.
filter
(
e
=>
e
.
id
===
envId
).
length
===
0
?
null
:
envId
;
})
})
},
open
()
{
this
.
data
=
[];
if
(
this
.
projectIds
.
size
>
0
)
{
this
.
init
();
}
},
getProjectName
(
id
)
{
const
project
=
this
.
projectList
.
find
(
p
=>
p
.
id
===
id
);
return
project
?
project
.
name
:
""
;
export
default
{
name
:
"
EnvironmentSelect
"
,
components
:
{
ApiEnvironmentConfig
},
props
:
{
envMap
:
Map
,
projectIds
:
Set
,
projectList
:
Array
},
openEnvironmentConfig
(
projectId
,
envId
)
{
if
(
!
projectId
)
{
this
.
$error
(
this
.
$t
(
'
api_test.select_project
'
));
return
;
data
()
{
return
{
data
:
[],
result
:
{},
projects
:
[],
environments
:
[],
dialogVisible
:
false
,
isFullUrl
:
true
,
}
this
.
$refs
.
environmentConfig
.
open
(
projectId
,
envId
);
},
handleConfirm
()
{
let
map
=
new
Map
();
let
sign
=
true
;
this
.
data
.
forEach
(
dt
=>
{
if
(
!
dt
.
selectEnv
)
{
sign
=
false
;
methods
:
{
init
()
{
this
.
projectIds
.
forEach
(
id
=>
{
let
item
=
{
id
:
id
,
envs
:
[],
selectEnv
:
""
};
this
.
data
.
push
(
item
);
this
.
result
=
this
.
$get
(
'
/api/environment/list/
'
+
id
,
res
=>
{
let
envs
=
res
.
data
;
envs
.
forEach
(
environment
=>
{
parseEnvironment
(
environment
);
});
// 固定环境列表渲染顺序
let
temp
=
this
.
data
.
find
(
dt
=>
dt
.
id
===
id
);
temp
.
envs
=
envs
;
let
envId
=
this
.
envMap
.
get
(
id
);
// 选中环境是否存在
temp
.
selectEnv
=
envs
.
filter
(
e
=>
e
.
id
===
envId
).
length
===
0
?
null
:
envId
;
})
})
},
open
()
{
this
.
data
=
[];
if
(
this
.
projectIds
.
size
>
0
)
{
this
.
init
();
}
},
getProjectName
(
id
)
{
const
project
=
this
.
projectList
.
find
(
p
=>
p
.
id
===
id
);
return
project
?
project
.
name
:
""
;
},
openEnvironmentConfig
(
projectId
,
envId
)
{
if
(
!
projectId
)
{
this
.
$error
(
this
.
$t
(
'
api_test.select_project
'
));
return
;
}
map
.
set
(
dt
.
id
,
dt
.
selectEnv
);
})
if
(
!
sign
)
{
this
.
$warning
(
"
请为每个项目选择一个运行环境!
"
);
return
;
}
this
.
$emit
(
'
setProjectEnvMap
'
,
map
);
this
.
$emit
(
'
close
'
);
},
checkEnv
()
{
let
sign
=
true
;
if
(
this
.
data
.
length
>
0
)
{
this
.
$refs
.
environmentConfig
.
open
(
projectId
,
envId
);
},
handleConfirm
()
{
let
map
=
new
Map
();
let
sign
=
true
;
this
.
data
.
forEach
(
dt
=>
{
if
(
!
dt
.
selectEnv
)
{
sign
=
false
;
return
false
;
return
;
}
map
.
set
(
dt
.
id
,
dt
.
selectEnv
);
})
}
else
{
// 如果有环境,检查环境
if
(
this
.
envMap
&&
this
.
envMap
.
size
>
0
)
{
this
.
projectIds
.
forEach
(
id
=>
{
if
(
!
this
.
envMap
.
get
(
id
))
{
if
(
!
sign
)
{
this
.
$warning
(
"
请为每个项目选择一个运行环境!
"
);
return
;
}
this
.
$emit
(
'
setProjectEnvMap
'
,
map
);
this
.
$emit
(
'
close
'
);
},
getApiInfo
(
request
)
{
if
(
request
.
id
&&
request
.
referenced
===
'
REF
'
)
{
let
requestResult
=
request
.
requestResult
;
let
url
=
request
.
refType
&&
request
.
refType
===
'
CASE
'
?
"
/api/testcase/get/
"
:
"
/api/definition/get/
"
;
let
enable
=
request
.
enable
;
this
.
$get
(
url
+
request
.
id
,
response
=>
{
if
(
response
.
data
)
{
Object
.
assign
(
request
,
JSON
.
parse
(
response
.
data
.
request
));
request
.
name
=
response
.
data
.
name
;
request
.
enable
=
enable
;
if
(
response
.
data
.
path
&&
response
.
data
.
path
!=
null
)
{
request
.
path
=
response
.
data
.
path
;
request
.
url
=
response
.
data
.
url
;
this
.
setUrl
(
request
.
path
);
}
if
(
response
.
data
.
method
&&
response
.
data
.
method
!=
null
)
{
request
.
method
=
response
.
data
.
method
;
}
request
.
requestResult
=
requestResult
;
request
.
id
=
response
.
data
.
id
;
request
.
disabled
=
true
;
request
.
root
=
true
;
if
(
!
request
.
projectId
)
{
request
.
projectId
=
response
.
data
.
projectId
;
}
this
.
reload
();
this
.
sort
();
}
else
{
request
.
referenced
=
"
Deleted
"
;
}
})
}
},
getScenario
(
scenario
)
{
this
.
result
=
this
.
$get
(
"
/api/automation/getApiScenario/
"
+
scenario
.
id
,
response
=>
{
if
(
response
.
data
)
{
scenario
.
loaded
=
true
;
let
obj
=
{};
if
(
response
.
data
.
scenarioDefinition
)
{
obj
=
JSON
.
parse
(
response
.
data
.
scenarioDefinition
);
scenario
.
hashTree
=
obj
.
hashTree
;
}
//scenario.disabled = true;
scenario
.
name
=
response
.
data
.
name
;
if
(
!
scenario
.
projectId
)
{
scenario
.
projectId
=
response
.
data
.
projectId
;
}
scenario
.
headers
=
obj
.
headers
;
scenario
.
variables
=
obj
.
variables
;
scenario
.
environmentMap
=
obj
.
environmentMap
;
this
.
$emit
(
'
refReload
'
);
}
else
{
scenario
.
referenced
=
"
Deleted
"
;
}
})
},
recursiveSorting
(
arr
)
{
for
(
let
i
in
arr
)
{
if
(
arr
[
i
].
referenced
===
'
REF
'
)
{
// 分场景和接口
if
(
arr
[
i
].
type
===
"
HTTPSamplerProxy
"
)
{
// 获取源头内容
this
.
getApiInfo
(
arr
[
i
]);
// 校验是否是全路径
if
(
!
arr
[
i
].
url
||
(
!
arr
[
i
].
url
.
startsWith
(
"
http://
"
)
&&
!
arr
[
i
].
url
.
startsWith
(
"
https://
"
)))
{
this
.
isFullUrl
=
false
;
}
}
else
if
(
arr
[
i
].
type
===
"
scenario
"
)
{
this
.
getScenario
(
arr
[
i
]);
}
}
else
{
if
(
arr
[
i
].
type
===
"
HTTPSamplerProxy
"
)
{
// 校验是否是全路径
if
(
arr
[
i
].
enable
)
{
if
(
!
arr
[
i
].
url
||
(
!
arr
[
i
].
url
.
startsWith
(
"
http://
"
)
&&
!
arr
[
i
].
url
.
startsWith
(
"
https://
"
)))
{
this
.
isFullUrl
=
false
;
}
}
}
}
if
(
arr
[
i
].
hashTree
!=
undefined
&&
arr
[
i
].
hashTree
.
length
>
0
)
{
this
.
recursiveSorting
(
arr
[
i
].
hashTree
);
}
}
},
checkFullUrl
(
scenarioDefinition
)
{
for
(
let
i
in
scenarioDefinition
)
{
// 设置项目ID
let
request
=
scenarioDefinition
[
i
];
if
(
request
.
referenced
===
'
REF
'
)
{
if
(
request
.
type
===
"
HTTPSamplerProxy
"
)
{
this
.
getApiInfo
(
request
);
// 校验是否是全路径
if
(
!
request
.
url
||
(
!
request
.
url
.
startsWith
(
"
http://
"
)
&&
!
request
.
url
.
startsWith
(
"
https://
"
)))
{
this
.
isFullUrl
=
false
;
}
}
else
if
(
request
.
type
===
"
scenario
"
)
{
this
.
getScenario
(
request
);
}
}
else
{
if
(
request
.
type
===
"
HTTPSamplerProxy
"
)
{
// 校验是否是全路径
if
(
request
.
enable
)
{
if
(
!
request
.
url
||
(
!
request
.
url
.
startsWith
(
"
http://
"
)
&&
!
request
.
url
.
startsWith
(
"
https://
"
)))
{
this
.
isFullUrl
=
false
;
}
}
}
}
if
(
scenarioDefinition
[
i
].
hashTree
!=
undefined
&&
scenarioDefinition
[
i
].
hashTree
.
length
>
0
)
{
this
.
recursiveSorting
(
scenarioDefinition
[
i
].
hashTree
);
}
}
},
checkEnv
(
data
)
{
let
sign
=
true
;
this
.
isFullUrl
=
true
;
if
(
this
.
data
.
length
>
0
)
{
this
.
data
.
forEach
(
dt
=>
{
if
(
!
dt
.
selectEnv
)
{
sign
=
false
;
return
false
;
}
})
}
else
{
sign
=
false
;
// 如果有环境,检查环境
if
(
this
.
envMap
&&
this
.
envMap
.
size
>
0
)
{
this
.
projectIds
.
forEach
(
id
=>
{
if
(
!
this
.
envMap
.
get
(
id
))
{
sign
=
false
;
return
false
;
}
})
}
else
{
// this.checkFullUrl(data);
// sign = this.isFullUrl;
sign
=
false
;
}
// 校验是否全是全路径
}
}
if
(
!
sign
)
{
this
.
$warning
(
"
请为每个项目选择一个运行环境!
"
);
return
false
;
if
(
!
sign
)
{
this
.
$warning
(
"
请为每个项目选择一个运行环境!
"
);
return
false
;
}
return
true
;
},
environmentConfigClose
()
{
// todo 关闭处理
}
return
true
;
},
environmentConfigClose
()
{
// todo 关闭处理
}
}
}
</
script
>
<
style
scoped
>
.ms-scenario-button
{
margin-left
:
20px
;
}
.ms-scenario-button
{
margin-left
:
20px
;
}
.env-confirm
{
margin-left
:
20px
;
width
:
360px
;
margin-top
:
10px
;
}
.env-confirm
{
margin-left
:
20px
;
width
:
360px
;
margin-top
:
10px
;
}
.project-name
{
display
:
inline-block
;
white-space
:
nowrap
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
width
:
150px
;
margin-left
:
8px
;
vertical-align
:
middle
;
}
.project-name
{
display
:
inline-block
;
white-space
:
nowrap
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
width
:
150px
;
margin-left
:
8px
;
vertical-align
:
middle
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录