Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
d4ad0f92
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d4ad0f92
编写于
8月 29, 2019
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: Add tests select and run control in dashboard
上级
ea440f6b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
66 addition
and
31 deletion
+66
-31
test/runTest/cli.js
test/runTest/cli.js
+13
-12
test/runTest/client/client.js
test/runTest/client/client.js
+48
-14
test/runTest/client/index.html
test/runTest/client/index.html
+5
-2
test/runTest/serve.js
test/runTest/serve.js
+0
-3
未找到文件。
test/runTest/cli.js
浏览文件 @
d4ad0f92
...
...
@@ -227,15 +227,15 @@ async function runTest(browser, testOpt) {
sortScreenshots
(
actualShots
);
const
results
=
[];
expectedShots
.
forEach
(
async
(
shot
,
idx
)
=>
{
let
idx
=
0
;
for
(
let
shot
of
expectedShots
)
{
let
expected
=
shot
;
let
actual
=
actualShots
[
idx
];
let
actual
=
actualShots
[
idx
++
];
let
{
diffRatio
,
diffPNG
}
=
await
compareScreenshot
(
expected
.
screenshotPath
,
actual
.
screenshotPath
);
let
diffPath
=
`
${
path
.
resolve
(
__dirname
,
getScreenshotDir
())}
/
${
shot
.
testName
}
-diff.png`
;
diffPNG
.
pack
().
pipe
(
fs
.
createWriteStream
(
diffPath
));
...
...
@@ -247,7 +247,7 @@ async function runTest(browser, testOpt) {
desc
:
actual
.
desc
,
diffRatio
});
}
);
}
testOpt
.
results
=
results
;
testOpt
.
status
=
'
finished
'
;
...
...
@@ -289,19 +289,15 @@ async function start() {
// Start a static server for puppeteer open the html test cases.
let
{
broadcast
,
io
}
=
serve
();
open
(
`
${
origin
}
/test/runTest/client/index.html`
);
const
browser
=
await
puppeteer
.
launch
({
/* headless: false */
});
const
tests
=
await
getTestsList
();
broadcast
({
tests
});
io
.
on
(
'
connect
'
,
socket
=>
{
broadcast
(
{
tests
});
socket
.
emit
(
'
update
'
,
{
tests
});
// TODO Stop previous?
socket
.
on
(
'
run
'
,
async
testsNameList
=>
{
console
.
log
(
testsNameList
);
console
.
log
(
testsNameList
.
join
(
'
,
'
)
);
const
pendingTests
=
tests
.
filter
(
testOpt
=>
{
return
testsNameList
.
includes
(
testOpt
.
name
);
...
...
@@ -313,21 +309,26 @@ async function start() {
testOpt
.
results
=
[];
}
broadcast
(
{
tests
});
socket
.
emit
(
'
update
'
,
{
tests
});
try
{
for
(
let
testOpt
of
pendingTests
)
{
console
.
log
(
'
Running Test
'
,
testOpt
.
name
);
await
runTest
(
browser
,
testOpt
);
broadcast
(
{
tests
});
socket
.
emit
(
'
update
'
,
{
tests
});
writeTestsToCache
(
tests
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
socket
.
emit
(
'
finish
'
);
});
});
console
.
log
(
`Dashboard:
${
origin
}
/test/runTest/client/index.html`
);
// open(`${origin}/test/runTest/client/index.html`);
// runTests(browser, tests, tests);
}
...
...
test/runTest/client/client.js
浏览文件 @
d4ad0f92
const
socket
=
io
();
function
processTestsData
(
tests
)
{
tests
.
forEach
(
test
=>
{
function
processTestsData
(
tests
,
oldTestsData
)
{
tests
.
forEach
(
(
test
,
idx
)
=>
{
let
passed
=
0
;
test
.
index
=
idx
;
test
.
results
.
forEach
(
result
=>
{
// Threshold?
if
(
result
.
diffRatio
<
0.001
)
{
...
...
@@ -19,7 +20,14 @@ function processTestsData(tests) {
else
{
test
.
summary
=
'
warning
'
}
test
.
selected
=
false
;
// Keep select status not change.
if
(
oldTestsData
&&
oldTestsData
[
idx
])
{
test
.
selected
=
oldTestsData
[
idx
].
selected
;
}
else
{
test
.
selected
=
false
;
}
});
return
tests
;
}
...
...
@@ -35,7 +43,8 @@ socket.on('connect', () => {
searchString
:
''
,
running
:
false
,
allSelected
:
false
allSelected
:
false
,
lastSelectedIndex
:
-
1
},
computed
:
{
tests
()
{
...
...
@@ -60,13 +69,16 @@ socket.on('connect', () => {
return
currentTest
;
},
isSelectAllIndeterminate
()
{
if
(
!
this
.
tests
.
length
)
{
return
true
;
}
return
this
.
tests
.
some
(
test
=>
{
return
test
.
selected
!==
this
.
tests
[
0
].
selected
;
});
isSelectAllIndeterminate
:
{
get
()
{
if
(
!
this
.
tests
.
length
)
{
return
true
;
}
return
this
.
tests
.
some
(
test
=>
{
return
test
.
selected
!==
this
.
tests
[
0
].
selected
;
});
},
set
()
{}
}
},
methods
:
{
...
...
@@ -82,15 +94,34 @@ socket.on('connect', () => {
test
.
selected
=
val
;
});
this
.
isSelectAllIndeterminate
=
false
;
},
handleSelect
(
idx
)
{
Vue
.
nextTick
(()
=>
{
this
.
lastSelectedIndex
=
idx
;
});
},
handleShiftSelect
(
idx
)
{
if
(
this
.
lastSelectedIndex
<
0
)
{
return
;
}
let
start
=
Math
.
min
(
this
.
lastSelectedIndex
,
idx
);
let
end
=
Math
.
max
(
this
.
lastSelectedIndex
,
idx
);
let
selected
=
!
this
.
tests
[
idx
].
selected
;
// Will change
for
(
let
i
=
start
;
i
<
end
;
i
++
)
{
this
.
tests
[
i
].
selected
=
selected
;
}
},
refreshList
()
{
},
runSelectedTests
()
{
this
.
running
=
true
;
const
tests
=
this
.
fullTests
.
filter
(
test
=>
{
return
test
.
selected
;
}).
map
(
test
=>
{
return
test
.
name
});
if
(
tests
.
length
>
0
)
{
this
.
running
=
true
;
socket
.
emit
(
'
run
'
,
tests
);
}
},
...
...
@@ -102,8 +133,11 @@ socket.on('connect', () => {
});
app
.
$el
.
style
.
display
=
'
block
'
;
socket
.
on
(
'
broadcast
'
,
msg
=>
{
app
.
fullTests
=
processTestsData
(
msg
.
tests
);
socket
.
on
(
'
update
'
,
msg
=>
{
app
.
fullTests
=
processTestsData
(
msg
.
tests
,
app
.
fullTests
);
});
socket
.
on
(
'
finish
'
,
()
=>
{
app
.
running
=
false
;
});
function
updateTestHash
()
{
...
...
test/runTest/client/index.html
浏览文件 @
d4ad0f92
...
...
@@ -32,15 +32,18 @@
<el-button
title=
"Run Selected"
@
click=
"runSelectedTests"
:loading=
"running"
circle
size=
"mini"
type=
"primary"
icon=
"el-icon-caret-right"
></el-button>
<el-button
v-if=
"running"
title=
"Run Selected"
@
click=
"stopTests"
circle
size=
"mini"
type=
"primary"
icon=
"el-icon-close"
></el-button>
</el-button-group>
<el-button
title=
"Refresh List"
@
click=
"refreshList"
circle
size=
"mini"
type=
"primary"
icon=
"el-icon-refresh"
></el-button>
</div>
</div>
<ul
class=
"test-list"
>
<li
v-for=
"
test
in tests"
<li
v-for=
"
(test, index)
in tests"
:title=
"test.name"
:class=
"{active: currentTest && currentTest.name === test.name}"
@
click.self=
"goto(test.name)"
>
<el-checkbox
v-model=
"test.selected"
></el-checkbox>
<span
@
mouseup=
"handleSelect(index)"
@
mouseup.shift=
"handleShiftSelect(index)"
>
<el-checkbox
v-model=
"test.selected"
></el-checkbox>
</span>
<i
class=
"el-icon-loading"
v-if=
"test.status === 'pending' && running"
></i>
<el-progress
v-if=
"test.status === 'finished'"
...
...
test/runTest/serve.js
浏览文件 @
d4ad0f92
...
...
@@ -19,9 +19,6 @@ function serve() {
const
io
=
require
(
'
socket.io
'
)(
server
);
return
{
broadcast
(
data
)
{
io
.
emit
(
'
broadcast
'
,
data
);
},
io
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录