Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
52b1a23b
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52b1a23b
编写于
4月 27, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
load scripts by zentao modules
上级
b9bcbe49
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
94 addition
and
41 deletion
+94
-41
internal/comm/domain/testing.go
internal/comm/domain/testing.go
+2
-2
internal/comm/helper/script/asset.go
internal/comm/helper/script/asset.go
+42
-23
internal/comm/helper/script/generator.go
internal/comm/helper/script/generator.go
+4
-4
internal/comm/helper/zentao/case.go
internal/comm/helper/zentao/case.go
+15
-10
internal/server/modules/v1/controller/test-script.go
internal/server/modules/v1/controller/test-script.go
+6
-0
internal/server/modules/v1/service/test-script.go
internal/server/modules/v1/service/test-script.go
+10
-1
ui/src/views/script/component/tree.vue
ui/src/views/script/component/tree.vue
+15
-1
未找到文件。
internal/comm/domain/testing.go
浏览文件 @
52b1a23b
...
...
@@ -92,12 +92,12 @@ type ZtfCaseWrapper struct {
}
type
ZtfStep
struct
{
Id
string
Id
int
Desc
string
Expect
string
Type
string
Parent
string
Parent
int
Children
[]
ZtfStep
Numb
string
...
...
internal/comm/helper/script/asset.go
浏览文件 @
52b1a23b
...
...
@@ -2,6 +2,7 @@ package scriptHelper
import
(
"encoding/json"
"fmt"
commConsts
"github.com/easysoft/zentaoatf/internal/comm/consts"
commDomain
"github.com/easysoft/zentaoatf/internal/comm/domain"
langHelper
"github.com/easysoft/zentaoatf/internal/comm/helper/lang"
...
...
@@ -95,13 +96,13 @@ func loadScriptNodesInDir(folder string, parent *serverDomain.TestAsset, level i
caseId
,
_
:=
strconv
.
Atoi
(
caseIdStr
)
if
scriptIdsFromZentao
==
nil
||
caseId
<
1
{
// not to filter
AddScript
(
childPath
,
caseId
,
parent
)
AddScript
(
childPath
,
caseId
,
""
,
false
,
parent
)
continue
}
_
,
ok
:=
scriptIdsFromZentao
[
caseId
]
if
ok
{
AddScript
(
childPath
,
caseId
,
parent
)
AddScript
(
childPath
,
caseId
,
""
,
false
,
parent
)
}
}
}
...
...
@@ -155,31 +156,49 @@ func LoadScriptListInDir(path string, files *[]string, level int) error {
return
nil
}
func
AddScript
(
pth
string
,
caseId
int
,
parent
*
serverDomain
.
TestAsset
)
{
func
AddScript
(
pth
string
,
caseId
int
,
caseNameInZentao
string
,
showZentaoCaseWithNoScript
bool
,
parent
*
serverDomain
.
TestAsset
)
{
title
:=
caseNameInZentao
if
pth
!=
""
{
//title = fileUtils.GetFileName(pth)
}
else
{
pth
=
fmt
.
Sprintf
(
"zentao-%d"
,
caseId
)
}
childScript
:=
&
serverDomain
.
TestAsset
{
Type
:
commConsts
.
File
,
CaseId
:
caseId
,
WorkspaceId
:
parent
.
WorkspaceId
,
WorkspaceType
:
parent
.
WorkspaceType
,
Path
:
pth
,
Title
:
title
,
Slots
:
iris
.
Map
{
"icon"
:
"icon"
},
Checkable
:
true
,
IsLeaf
:
true
,
}
if
showZentaoCaseWithNoScript
{
parent
.
Children
=
append
(
parent
.
Children
,
childScript
)
parent
.
ScriptCount
+=
1
return
}
regx
:=
langHelper
.
GetSupportLanguageExtRegx
()
p
ass
,
_
:=
regexp
.
MatchString
(
"^*.
\\
."
+
regx
+
"$"
,
pth
)
langP
ass
,
_
:=
regexp
.
MatchString
(
"^*.
\\
."
+
regx
+
"$"
,
pth
)
if
pass
{
pass
=
CheckFileIsScript
(
pth
)
if
pass
{
childScript
:=
&
serverDomain
.
TestAsset
{
Type
:
commConsts
.
File
,
CaseId
:
caseId
,
WorkspaceId
:
parent
.
WorkspaceId
,
WorkspaceType
:
parent
.
WorkspaceType
,
Path
:
pth
,
Title
:
fileUtils
.
GetFileName
(
pth
),
Slots
:
iris
.
Map
{
"icon"
:
"icon"
},
Checkable
:
true
,
IsLeaf
:
true
,
}
if
!
langPass
{
return
}
parent
.
Children
=
append
(
parent
.
Children
,
childScript
)
parent
.
ScriptCount
+=
1
}
contentOk
:=
CheckFileIsScript
(
pth
)
if
!
contentOk
{
return
}
parent
.
Children
=
append
(
parent
.
Children
,
childScript
)
parent
.
ScriptCount
+=
1
}
func
AddDir
(
pth
string
,
moduleName
string
,
parent
*
serverDomain
.
TestAsset
)
(
dirNode
*
serverDomain
.
TestAsset
)
{
nodeType
:=
commConsts
.
Dir
...
...
internal/comm/helper/script/generator.go
浏览文件 @
52b1a23b
...
...
@@ -107,8 +107,8 @@ func generateTestStepAndScriptObsolete(testSteps []commDomain.ZtfStep, steps *[]
}
ts
:=
testSteps
[
idx
]
if
ts
.
Parent
==
"0"
&&
ts
.
Type
!=
"group"
{
// flat step
currGroup
=
commDomain
.
ZtfStep
{
Id
:
"-1"
,
Desc
:
"group"
,
Children
:
make
([]
commDomain
.
ZtfStep
,
0
)}
if
ts
.
Parent
==
0
&&
ts
.
Type
!=
"group"
{
// flat step
currGroup
=
commDomain
.
ZtfStep
{
Id
:
-
1
,
Desc
:
"group"
,
Children
:
make
([]
commDomain
.
ZtfStep
,
0
)}
currGroup
.
Children
=
append
(
currGroup
.
Children
,
ts
)
idx
++
...
...
@@ -165,7 +165,7 @@ func generateTestStepAndScriptObsolete(testSteps []commDomain.ZtfStep, steps *[]
stepNumb
:=
1
// print nested steps, only one level
for
_
,
group
:=
range
nestedSteps
{
if
group
.
Id
==
"-1"
{
// [group]
if
group
.
Id
==
-
1
{
// [group]
*
steps
=
append
(
*
steps
,
fmt
.
Sprintf
(
"
\n
[group]"
))
for
_
,
child
:=
range
group
.
Children
{
...
...
@@ -242,7 +242,7 @@ func generateTestStepAndScript(testSteps []commDomain.ZtfStep, steps *[]string,
func
computerTestStepWidth
(
steps
[]
commDomain
.
ZtfStep
,
stepSDisplayMaxWidth
*
int
,
stepWidth
int
)
{
for
_
,
ts
:=
range
steps
{
length
:=
len
(
ts
.
Id
)
length
:=
len
(
strconv
.
Itoa
(
ts
.
Id
)
)
if
length
>
*
stepSDisplayMaxWidth
{
*
stepSDisplayMaxWidth
=
length
}
...
...
internal/comm/helper/zentao/case.go
浏览文件 @
52b1a23b
...
...
@@ -86,19 +86,22 @@ func GetCaseById(baseUrl string, caseId int) (cs commDomain.ZtfCase) {
return
}
func
LoadTestCases
AsTree
(
workspace
model
.
Workspace
,
scriptIdsFromZentao
map
[
int
]
string
,
productId
int
,
config
commDomain
.
WorkspaceConf
)
(
root
serverDomain
.
TestAsset
,
err
error
)
{
func
LoadTestCases
InModuleTree
(
workspace
model
.
Workspace
,
scriptIdsFromZentao
map
[
int
]
string
,
productId
int
,
suiteId
,
taskId
int
,
config
commDomain
.
WorkspaceConf
)
(
root
serverDomain
.
TestAsset
,
err
error
)
{
casesInDir
,
_
:=
scriptHelper
.
LoadScriptTreeByDir
(
workspace
,
scriptIdsFromZentao
)
caseMapInDir
:=
map
[
int
]
*
serverDomain
.
TestAsset
{}
genCaseMap
(
casesInDir
,
&
caseMapInDir
)
// scripts in workspace dir
scriptsInDir
,
_
:=
scriptHelper
.
LoadScriptTreeByDir
(
workspace
,
scriptIdsFromZentao
)
scriptsMapInDir
:=
map
[
int
]
*
serverDomain
.
TestAsset
{}
genScriptMap
(
scriptsInDir
,
&
scriptsMapInDir
)
casesFromZentao
,
err
:=
LoadTestCases
(
productId
,
0
,
0
,
0
,
config
)
// cases in zentao by module
casesFromZentao
,
err
:=
LoadTestCases
(
productId
,
0
,
suiteId
,
taskId
,
config
)
caseMapByModuleFromZentao
:=
map
[
int
][]
commDomain
.
ZtfCase
{}
for
_
,
item
:=
range
casesFromZentao
{
caseMapByModuleFromZentao
[
item
.
Module
]
=
append
(
caseMapByModuleFromZentao
[
item
.
Module
],
item
)
}
// modules in zentao
modules
,
err
:=
LoadCaseModuleArr
(
uint
(
productId
),
config
)
root
=
serverDomain
.
TestAsset
{
...
...
@@ -114,13 +117,13 @@ func LoadTestCasesAsTree(workspace model.Workspace, scriptIdsFromZentao map[int]
}
for
_
,
item
:=
range
modules
{
genModuleTreeWithCases
(
item
,
case
MapInDir
,
caseMapByModuleFromZentao
,
&
root
)
genModuleTreeWithCases
(
item
,
scripts
MapInDir
,
caseMapByModuleFromZentao
,
&
root
)
}
return
}
func
gen
Case
Map
(
asset
serverDomain
.
TestAsset
,
mp
*
map
[
int
]
*
serverDomain
.
TestAsset
)
{
func
gen
Script
Map
(
asset
serverDomain
.
TestAsset
,
mp
*
map
[
int
]
*
serverDomain
.
TestAsset
)
{
if
asset
.
CaseId
>
0
{
(
*
mp
)[
asset
.
CaseId
]
=
&
asset
}
...
...
@@ -130,7 +133,7 @@ func genCaseMap(asset serverDomain.TestAsset, mp *map[int]*serverDomain.TestAsse
}
for
_
,
child
:=
range
asset
.
Children
{
gen
Case
Map
(
*
child
,
mp
)
gen
Script
Map
(
*
child
,
mp
)
}
return
...
...
@@ -153,6 +156,7 @@ func genModuleTreeWithCases(moduleInterface interface{},
// add cases in module
for
_
,
cs
:=
range
caseMapByModuleFromZentao
[
moduleId
]
{
caseId
:=
cs
.
Id
caseNameInZentao
:=
cs
.
Title
casePath
:=
""
// case info from dir
...
...
@@ -161,7 +165,8 @@ func genModuleTreeWithCases(moduleInterface interface{},
casePath
=
casesMapInDir
[
caseId
]
.
Path
}
scriptHelper
.
AddScript
(
casePath
,
caseId
,
dirNode
)
scriptHelper
.
AddScript
(
casePath
,
caseId
,
caseNameInZentao
,
true
,
dirNode
)
logUtils
.
Infof
(
"==="
,
cs
.
Title
)
}
if
moduleMap
[
"children"
]
==
nil
{
...
...
internal/server/modules/v1/controller/test-script.go
浏览文件 @
52b1a23b
...
...
@@ -10,6 +10,7 @@ import (
serverDomain
"github.com/easysoft/zentaoatf/internal/server/modules/v1/domain"
"github.com/easysoft/zentaoatf/internal/server/modules/v1/service"
"github.com/kataras/iris/v12"
"strings"
)
type
TestScriptCtrl
struct
{
...
...
@@ -48,6 +49,11 @@ func (c *TestScriptCtrl) Get(ctx iris.Context) {
return
}
if
strings
.
Index
(
scriptPath
,
"zentao"
)
==
0
{
ctx
.
JSON
(
c
.
SuccessResp
(
""
))
return
}
script
,
err
:=
scriptHelper
.
GetScriptContent
(
scriptPath
,
workspaceId
)
if
err
!=
nil
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
...
...
internal/server/modules/v1/service/test-script.go
浏览文件 @
52b1a23b
...
...
@@ -45,7 +45,16 @@ func (s *TestScriptService) LoadTestScriptsBySiteProduct(
// for testing
site
,
_
:=
s
.
SiteService
.
Get
(
siteId
)
config
:=
configHelper
.
LoadBySite
(
site
)
scriptsInDir
,
_
=
zentaoHelper
.
LoadTestCasesAsTree
(
workspace
,
scriptIdsFromZentao
,
1
,
config
)
suiteId
:=
0
taskId
:=
0
if
filerType
==
string
(
commConsts
.
FilterSuite
)
{
suiteId
=
filerValue
}
else
if
filerType
==
string
(
commConsts
.
FilterTask
)
{
taskId
=
filerValue
}
scriptsInDir
,
_
=
zentaoHelper
.
LoadTestCasesInModuleTree
(
workspace
,
scriptIdsFromZentao
,
int
(
productId
),
suiteId
,
taskId
,
config
)
}
else
{
scriptsInDir
,
_
=
codeHelper
.
LoadCodeTree
(
workspace
)
...
...
ui/src/views/script/component/tree.vue
浏览文件 @
52b1a23b
...
...
@@ -55,7 +55,9 @@
@
check=
"checkNode"
>
<
template
#title=
"slotProps"
>
{{
slotProps
.
title
!==
'
all
'
?
slotProps
.
title
:
t
(
'
all
'
)
}}
<span
:class=
"[
{'no-script': noScript(slotProps.path)}]">
{{
slotProps
.
title
}}
</span>
</
template
>
</a-tree>
...
...
@@ -433,6 +435,13 @@ export default defineComponent({
return
arr
}
const
noScript
=
(
str
)
=>
{
if
(
str
.
indexOf
(
'
zentao
'
)
==
0
)
{
return
true
}
return
false
}
return
{
t
,
isWin
,
...
...
@@ -473,6 +482,7 @@ export default defineComponent({
fromVisible
,
onSave
,
onCancel
,
noScript
,
}
}
...
...
@@ -493,6 +503,10 @@ export default defineComponent({
font-size: 16px;
}
}
.no-script {
color: #a9aeb4;
}
}
</
style
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录