Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
f30c14ea
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6016
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f30c14ea
编写于
1月 08, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 优化截图对比测试逻辑
上级
240ded57
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
9 deletion
+45
-9
pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
...reenshot-comparison/webview-screenshot-comparison.test.js
+45
-9
未找到文件。
pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
浏览文件 @
f30c14ea
...
@@ -80,6 +80,9 @@ const pages = [
...
@@ -80,6 +80,9 @@ const pages = [
"
pages/API/unicloud-database/unicloud-database
"
,
"
pages/API/unicloud-database/unicloud-database
"
,
"
pages/API/get-window-info/get-window-info
"
,
"
pages/API/get-window-info/get-window-info
"
,
"
pages/API/element-takesnapshot/element-takesnapshot
"
,
"
pages/API/element-takesnapshot/element-takesnapshot
"
,
"
pages/API/get-element-by-id/get-element-by-id
"
,
"
pages/API/get-element-by-id/get-element-by-id-multiple-root-node
"
,
"
pages/API/navigator/new-page/onLoad
"
,
"
pages/tabBar/CSS
"
,
"
pages/tabBar/CSS
"
,
"
pages/CSS/background/background-color
"
,
"
pages/CSS/background/background-color
"
,
"
pages/CSS/background/background-image
"
,
"
pages/CSS/background/background-image
"
,
...
@@ -152,14 +155,11 @@ const pages = [
...
@@ -152,14 +155,11 @@ const pages = [
// web 暂不支持
// web 暂不支持
// "pages/component/list-view/list-view",
// "pages/component/list-view/list-view",
// "pages/component/list-view/list-view-multiplex",
// "pages/API/element-draw/element-draw",
// "pages/template/swiper-list/swiper-list",
// "pages/template/swiper-list/swiper-list",
// "pages/template/swiper-list2/swiper-list2",
// "pages/template/swiper-list2/swiper-list2",
// "pages/API/element-draw/element-draw",
// "pages/API/get-element-by-id/get-element-by-id",
// "pages/API/get-element-by-id/get-element-by-id-multiple-root-node",
// "pages/API/navigator/new-page/onLoad",
// "pages/template/long-list2/long-list2",
// "pages/template/long-list2/long-list2",
// "pages/component/list-view/list-view-multiplex",
// 动态内容
// 动态内容
// "pages/component/web-view/web-view"
// "pages/component/web-view/web-view"
...
@@ -201,6 +201,13 @@ const pages = [
...
@@ -201,6 +201,13 @@ const pages = [
// pages/template/schema/schema
// pages/template/schema/schema
// pages/template/share/share
// pages/template/share/share
];
];
const
childToParentPagesMap
=
new
Map
([
[
"
pages/API/load-font-face/load-font-face-child
"
,
"
pages/API/load-font-face/load-font-face
"
,
],
]);
const
needAdbScreenshotPages
=
[
const
needAdbScreenshotPages
=
[
"
pages/tabBar/component
"
,
"
pages/tabBar/component
"
,
"
pages/tabBar/API
"
,
"
pages/tabBar/API
"
,
...
@@ -249,6 +256,20 @@ describe("shot-compare", () => {
...
@@ -249,6 +256,20 @@ describe("shot-compare", () => {
const
screenshotPath
=
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
);
const
screenshotPath
=
pages
[
pageIndex
].
replace
(
/
\/
/g
,
"
-
"
);
// web in webview screenshot
// web in webview screenshot
// 加载依赖页面
if
(
childToParentPagesMap
.
get
(
pages
[
pageIndex
]))
{
await
page
.
setData
({
src
:
`
${
baseSrc
}${
childToParentPagesMap
.
get
(
pages
[
pageIndex
])}
`
,
isLoaded
:
false
,
needRemoveWebHead
:
!
isNeedAdbScreenshot
,
});
await
page
.
waitFor
(
async
()
=>
{
const
isLoaded
=
page
.
data
(
"
isLoaded
"
);
return
isLoaded
||
Date
.
now
()
-
startTime
>
10000
;
});
// 这个等待无法保证 web 页面加载完成,可以等 web 服务调整为发行服务后进行优化
await
page
.
waitFor
(
4000
);
}
await
page
.
setData
({
await
page
.
setData
({
src
:
`
${
baseSrc
}${
pages
[
pageIndex
]}
`
,
src
:
`
${
baseSrc
}${
pages
[
pageIndex
]}
`
,
isLoaded
:
false
,
isLoaded
:
false
,
...
@@ -262,9 +283,17 @@ describe("shot-compare", () => {
...
@@ -262,9 +283,17 @@ describe("shot-compare", () => {
});
});
// 这个等待无法保证 web 页面加载完成,可以等 web 服务调整为发行服务后进行优化
// 这个等待无法保证 web 页面加载完成,可以等 web 服务调整为发行服务后进行优化
await
page
.
waitFor
(
4000
);
await
page
.
waitFor
(
4000
);
if
(
pages
[
pageIndex
].
includes
(
"
load-font-face
"
))
{
await
page
.
waitFor
(
3000
);
}
const
webSnapshot
=
await
program
.
screenshot
({
const
webSnapshot
=
await
program
.
screenshot
({
fullPage
:
isNeedAdbScreenshot
?
false
:
true
,
fullPage
:
isNeedAdbScreenshot
?
false
:
true
,
adb
:
isNeedAdbScreenshot
?
true
:
false
,
area
:
{
x
:
0
,
y
:
100
,
},
});
});
expect
(
webSnapshot
).
toMatchImageSnapshot
({
expect
(
webSnapshot
).
toMatchImageSnapshot
({
customSnapshotIdentifier
()
{
customSnapshotIdentifier
()
{
...
@@ -273,14 +302,21 @@ describe("shot-compare", () => {
...
@@ -273,14 +302,21 @@ describe("shot-compare", () => {
});
});
// app-android page screenshot comparison
// app-android page screenshot comparison
const
navigateMethod
=
pages
[
pageIndex
].
startsWith
(
"
pages/tabBar
"
)
const
navigateMethod
=
pages
[
pageIndex
].
startsWith
(
"
pages/tabBar
"
)
?
?
"
switchTab
"
"
switchTab
"
:
:
"
navigateTo
"
;
"
navigateTo
"
;
page
=
await
program
[
navigateMethod
](
`/
${
pages
[
pageIndex
]}
`
);
page
=
await
program
[
navigateMethod
](
`/
${
pages
[
pageIndex
]}
`
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
500
);
if
(
pages
[
pageIndex
].
includes
(
"
load-font-face
"
))
{
await
page
.
waitFor
(
2000
);
}
const
appAndroidSnapshot
=
await
program
.
screenshot
({
const
appAndroidSnapshot
=
await
program
.
screenshot
({
fullPage
:
isNeedAdbScreenshot
?
false
:
true
,
fullPage
:
isNeedAdbScreenshot
?
false
:
true
,
adb
:
isNeedAdbScreenshot
?
true
:
false
,
adb
:
isNeedAdbScreenshot
?
true
:
false
,
area
:
{
x
:
0
,
y
:
100
,
},
});
});
expect
(
appAndroidSnapshot
).
toMatchImageSnapshot
({
expect
(
appAndroidSnapshot
).
toMatchImageSnapshot
({
customSnapshotIdentifier
()
{
customSnapshotIdentifier
()
{
...
@@ -293,4 +329,4 @@ describe("shot-compare", () => {
...
@@ -293,4 +329,4 @@ describe("shot-compare", () => {
expect
(
1
).
toBe
(
1
);
expect
(
1
).
toBe
(
1
);
});
});
}
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录