提交 6485d0bd 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 优化截图对比测试例

上级 5a024040
...@@ -58,61 +58,61 @@ const pages = [ ...@@ -58,61 +58,61 @@ const pages = [
'pages/composition/setup/setup', 'pages/composition/setup/setup',
'pages/examples/nested-component-communication/nested-component-communication', 'pages/examples/nested-component-communication/nested-component-communication',
'pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class', 'pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class',
'pages/composition-api/basic/define-slots/define-slots', 'pages/composition-api/basic/define-slots/define-slots',
// 新增 // 新增
'pages/composition-api/basic/define-emits/define-emits', 'pages/composition-api/basic/define-emits/define-emits',
'pages/composition-api/basic/define-expose/define-expose', 'pages/composition-api/basic/define-expose/define-expose',
'pages/composition-api/basic/use-attrs/use-attrs', 'pages/composition-api/basic/use-attrs/use-attrs',
'pages/composition-api/basic/use-slots/use-slots', 'pages/composition-api/basic/use-slots/use-slots',
'pages/composition-api/reactivity/ref/ref', 'pages/composition-api/reactivity/ref/ref',
'pages/composition-api/reactivity/computed/computed', 'pages/composition-api/reactivity/computed/computed',
'pages/composition-api/reactivity/reactive/reactive', 'pages/composition-api/reactivity/reactive/reactive',
'pages/composition-api/reactivity/readonly/readonly', 'pages/composition-api/reactivity/readonly/readonly',
'pages/composition-api/reactivity/watch/watch', 'pages/composition-api/reactivity/watch/watch',
'pages/composition-api/reactivity/watch-effect/watch-effect', 'pages/composition-api/reactivity/watch-effect/watch-effect',
'pages/composition-api/reactivity/watch-post-effect/watch-post-effect', 'pages/composition-api/reactivity/watch-post-effect/watch-post-effect',
'pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect', 'pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect',
'pages/composition-api/reactivity/is-ref/is-ref', 'pages/composition-api/reactivity/is-ref/is-ref',
'pages/composition-api/reactivity/un-ref/un-ref', 'pages/composition-api/reactivity/un-ref/un-ref',
'pages/composition-api/reactivity/to-ref/to-ref', 'pages/composition-api/reactivity/to-ref/to-ref',
'pages/composition-api/reactivity/is-proxy/is-proxy', 'pages/composition-api/reactivity/is-proxy/is-proxy',
'pages/composition-api/reactivity/is-reactive/is-reactive', 'pages/composition-api/reactivity/is-reactive/is-reactive',
'pages/composition-api/reactivity/is-readonly/is-readonly', 'pages/composition-api/reactivity/is-readonly/is-readonly',
'pages/composition-api/reactivity/shallow-ref/shallow-ref', 'pages/composition-api/reactivity/shallow-ref/shallow-ref',
'pages/composition-api/reactivity/trigger-ref/trigger-ref', 'pages/composition-api/reactivity/trigger-ref/trigger-ref',
'pages/composition-api/reactivity/custom-ref/custom-ref', 'pages/composition-api/reactivity/custom-ref/custom-ref',
'pages/composition-api/reactivity/shallow-reactive/shallow-reactive', 'pages/composition-api/reactivity/shallow-reactive/shallow-reactive',
'pages/composition-api/reactivity/shallow-readonly/shallow-readonly', 'pages/composition-api/reactivity/shallow-readonly/shallow-readonly',
'pages/composition-api/reactivity/to-raw/to-raw', 'pages/composition-api/reactivity/to-raw/to-raw',
'pages/composition-api/reactivity/mark-raw/mark-raw', 'pages/composition-api/reactivity/mark-raw/mark-raw',
'pages/composition-api/reactivity/effect-scope/effect-scope', 'pages/composition-api/reactivity/effect-scope/effect-scope',
'pages/composition-api/reactivity/get-current-scope/get-current-scope', 'pages/composition-api/reactivity/get-current-scope/get-current-scope',
'pages/composition-api/reactivity/on-scope-dispose/on-scope-dispose', 'pages/composition-api/reactivity/on-scope-dispose/on-scope-dispose',
'pages/composition-api/lifecycle/page-lifecycle/page-lifecycle', 'pages/composition-api/lifecycle/page-lifecycle/page-lifecycle',
'pages/composition-api/lifecycle/component-lifecycle/component-lifecycle', 'pages/composition-api/lifecycle/component-lifecycle/component-lifecycle',
'pages/composition-api/dependency-injection/provide/provide', 'pages/composition-api/dependency-injection/provide/provide',
'pages/built-in-component/teleport/teleport' 'pages/built-in-component/teleport/teleport'
// web暂不支持 // web暂不支持
// 'pages/composition/mixins/mixins', // 'pages/composition/mixins/mixins',
// 'pages/composition/mixins/mixins-page2', // 'pages/composition/mixins/mixins-page2',
// 'pages/directive/v-once/v-once', // 'pages/directive/v-once/v-once',
// 'pages/component-instance/parent/parent', // 'pages/component-instance/parent/parent',
// 'pages/component-instance/root/root', // 'pages/component-instance/root/root',
// 'pages/composition-api/basic/define-model/define-model' // 'pages/composition-api/basic/define-model/define-model'
// 'pages/composition-api/basic/define-options/define-option' // 'pages/composition-api/basic/define-options/define-option'
// 动态内容 // 动态内容
// 'pages/component-instance/force-update/force-update', // 'pages/component-instance/force-update/force-update',
// 空白页面无内容 // 空白页面无内容
// 'pages/component-instance/methods/call-method-easycom-uni-modules', // 'pages/component-instance/methods/call-method-easycom-uni-modules',
// 'pages/component-instance/methods/call-method-easycom', // 'pages/component-instance/methods/call-method-easycom',
] ]
const childToParentPagesMap = new Map([ const childToParentPagesMap = new Map([
...@@ -123,7 +123,7 @@ const customNavigationPages = [ ...@@ -123,7 +123,7 @@ const customNavigationPages = [
] ]
const needAdbScreenshotPages = [ const needAdbScreenshotPages = [
'pages/tab-bar/options-api', 'pages/tab-bar/options-api',
'pages/tab-bar/composition-api' 'pages/tab-bar/composition-api'
]; ];
...@@ -145,7 +145,7 @@ describe("shot-compare", () => { ...@@ -145,7 +145,7 @@ describe("shot-compare", () => {
if (!shouldCompareScreenShot) { if (!shouldCompareScreenShot) {
it("other platform not support", async () => { it("other platform not support", async () => {
expect(1).toBe(1); expect(1).toBe(1);
}); });
return return
} }
...@@ -159,7 +159,7 @@ describe("shot-compare", () => { ...@@ -159,7 +159,7 @@ describe("shot-compare", () => {
// set webview-screenshot-comparison page baseSrc // set webview-screenshot-comparison page baseSrc
baseSrc = baseSrc =
process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` : process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` :
"http://192.168.31.223:5173/#/"; "http://test.dcloud.io/unix_h5_build/98_dev_hello-uvue/#/";
page.setData({ page.setData({
baseSrc, baseSrc,
}); });
...@@ -179,7 +179,7 @@ describe("shot-compare", () => { ...@@ -179,7 +179,7 @@ describe("shot-compare", () => {
const { const {
statusBarHeight, statusBarHeight,
devicePixelRatio devicePixelRatio
} = await page.data(); } = await page.data();
const screenshotParams = { const screenshotParams = {
fullPage: true, fullPage: true,
adb: isNeedAdbScreenshot, adb: isNeedAdbScreenshot,
...@@ -215,14 +215,14 @@ describe("shot-compare", () => { ...@@ -215,14 +215,14 @@ describe("shot-compare", () => {
const isLoaded = await page.data("isLoaded"); const isLoaded = await page.data("isLoaded");
return isLoaded || Date.now() - startTime > 3000; return isLoaded || Date.now() - startTime > 3000;
}); });
await page.waitFor(3000); await page.waitFor(800);
// web 端非 adb 截图时设置 offsetY 移除导航栏 // web 端非 adb 截图时设置 offsetY 移除导航栏
const webSnapshot = await program.screenshot({ const webSnapshot = await program.screenshot({
...screenshotParams, ...screenshotParams,
id: 'webview-screenshot-comparison', id: 'webview-screenshot-comparison',
offsetY: `${isCustomNavigationBar ? 0 : 44}` offsetY: `${isCustomNavigationBar ? 0 : 44}`
}); });
expect(webSnapshot).toMatchImageSnapshot({ expect(webSnapshot).toMatchImageSnapshot({
customSnapshotIdentifier() { customSnapshotIdentifier() {
return screenshotPath; return screenshotPath;
...@@ -242,4 +242,4 @@ describe("shot-compare", () => { ...@@ -242,4 +242,4 @@ describe("shot-compare", () => {
}, },
}); });
}); });
}); });
...@@ -27,33 +27,15 @@ ...@@ -27,33 +27,15 @@
this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this) this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this)
}, },
methods: { methods: {
customNavigationBarPageAppendWebHeadPlaceholder() {
if (this.src.indexOf('pages/template/navbar-lite/navbar-lite') > -1) {
this.webviewContext?.evalJS(`
const uniNavbar = document.querySelector('.uni-navbar');
uniNavbar.style.paddingTop = '${this.statusBarHeight}px';
`)
} else if (this.src.indexOf('pages/template/scroll-fold-nav/scroll-fold-nav') > -1) {
this.webviewContext?.evalJS(`
const heightSeat = document.querySelector('.height-seat');
heightSeat.style.height = '125px';
heightSeat.style.backgroundColor = '#f0f8ff';
const topBox = document.querySelector('.top-box');
topBox.style.top = '35px';
`)
}
},
loaded() { loaded() {
this.isLoaded = true this.isLoaded = true
this.customNavigationBarPageAppendWebHeadPlaceholder();
}, },
error(event : WebViewErrorEvent) { error(event : WebViewErrorEvent) {
console.log('webview load error', JSON.stringify(event.detail)); console.log('webview load error', JSON.stringify(event.detail));
}, },
getWindowInfo() { getWindowInfo() {
const res = uni.getWindowInfo(); const res = uni.getWindowInfo();
// 获取状态栏+导航栏高度, 供截图对比使用 // 获取状态栏, 供截图对比使用
this.statusBarHeight = res.statusBarHeight; this.statusBarHeight = res.statusBarHeight;
}, },
getDeviceInfo: function () { getDeviceInfo: function () {
......
...@@ -58,59 +58,59 @@ const pages = [ ...@@ -58,59 +58,59 @@ const pages = [
'pages/composition/setup/setup', 'pages/composition/setup/setup',
'pages/examples/nested-component-communication/nested-component-communication', 'pages/examples/nested-component-communication/nested-component-communication',
'pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class', 'pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class',
'pages/composition-api/basic/define-slots/define-slots', 'pages/composition-api/basic/define-slots/define-slots',
// 新增 // 新增
'pages/composition-api/basic/define-emits/define-emits', 'pages/composition-api/basic/define-emits/define-emits',
'pages/composition-api/basic/define-expose/define-expose', 'pages/composition-api/basic/define-expose/define-expose',
'pages/composition-api/basic/use-attrs/use-attrs', 'pages/composition-api/basic/use-attrs/use-attrs',
'pages/composition-api/basic/use-slots/use-slots', 'pages/composition-api/basic/use-slots/use-slots',
'pages/composition-api/reactivity/ref/ref', 'pages/composition-api/reactivity/ref/ref',
'pages/composition-api/reactivity/computed/computed', 'pages/composition-api/reactivity/computed/computed',
'pages/composition-api/reactivity/reactive/reactive', 'pages/composition-api/reactivity/reactive/reactive',
'pages/composition-api/reactivity/readonly/readonly', 'pages/composition-api/reactivity/readonly/readonly',
'pages/composition-api/reactivity/watch/watch', 'pages/composition-api/reactivity/watch/watch',
'pages/composition-api/reactivity/watch-effect/watch-effect', 'pages/composition-api/reactivity/watch-effect/watch-effect',
'pages/composition-api/reactivity/watch-post-effect/watch-post-effect', 'pages/composition-api/reactivity/watch-post-effect/watch-post-effect',
'pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect', 'pages/composition-api/reactivity/watch-sync-effect/watch-sync-effect',
'pages/composition-api/reactivity/is-ref/is-ref', 'pages/composition-api/reactivity/is-ref/is-ref',
'pages/composition-api/reactivity/un-ref/un-ref', 'pages/composition-api/reactivity/un-ref/un-ref',
'pages/composition-api/reactivity/to-ref/to-ref', 'pages/composition-api/reactivity/to-ref/to-ref',
'pages/composition-api/reactivity/is-proxy/is-proxy', 'pages/composition-api/reactivity/is-proxy/is-proxy',
'pages/composition-api/reactivity/is-reactive/is-reactive', 'pages/composition-api/reactivity/is-reactive/is-reactive',
'pages/composition-api/reactivity/is-readonly/is-readonly', 'pages/composition-api/reactivity/is-readonly/is-readonly',
'pages/composition-api/reactivity/shallow-ref/shallow-ref', 'pages/composition-api/reactivity/shallow-ref/shallow-ref',
'pages/composition-api/reactivity/trigger-ref/trigger-ref', 'pages/composition-api/reactivity/trigger-ref/trigger-ref',
'pages/composition-api/reactivity/custom-ref/custom-ref', 'pages/composition-api/reactivity/custom-ref/custom-ref',
'pages/composition-api/reactivity/shallow-reactive/shallow-reactive', 'pages/composition-api/reactivity/shallow-reactive/shallow-reactive',
'pages/composition-api/reactivity/shallow-readonly/shallow-readonly', 'pages/composition-api/reactivity/shallow-readonly/shallow-readonly',
'pages/composition-api/reactivity/to-raw/to-raw', 'pages/composition-api/reactivity/to-raw/to-raw',
'pages/composition-api/reactivity/mark-raw/mark-raw', 'pages/composition-api/reactivity/mark-raw/mark-raw',
'pages/composition-api/reactivity/effect-scope/effect-scope', 'pages/composition-api/reactivity/effect-scope/effect-scope',
'pages/composition-api/reactivity/get-current-scope/get-current-scope', 'pages/composition-api/reactivity/get-current-scope/get-current-scope',
'pages/composition-api/reactivity/on-scope-dispose/on-scope-dispose', 'pages/composition-api/reactivity/on-scope-dispose/on-scope-dispose',
'pages/composition-api/lifecycle/page-lifecycle/page-lifecycle', 'pages/composition-api/lifecycle/page-lifecycle/page-lifecycle',
'pages/composition-api/lifecycle/component-lifecycle/component-lifecycle', 'pages/composition-api/lifecycle/component-lifecycle/component-lifecycle',
'pages/composition-api/dependency-injection/provide/provide', 'pages/composition-api/dependency-injection/provide/provide',
'pages/built-in-component/teleport/teleport' 'pages/built-in-component/teleport/teleport'
// web暂不支持 // web暂不支持
// 'pages/composition/mixins/mixins', // 'pages/composition/mixins/mixins',
// 'pages/composition/mixins/mixins-page2', // 'pages/composition/mixins/mixins-page2',
// 'pages/directive/v-once/v-once', // 'pages/directive/v-once/v-once',
// 'pages/component-instance/parent/parent', // 'pages/component-instance/parent/parent',
// 'pages/component-instance/root/root', // 'pages/component-instance/root/root',
// 'pages/composition-api/basic/define-model/define-model' // 'pages/composition-api/basic/define-model/define-model'
// 'pages/composition-api/basic/define-options/define-option' // 'pages/composition-api/basic/define-options/define-option'
// 动态内容 // 动态内容
// 'pages/component-instance/force-update/force-update', // 'pages/component-instance/force-update/force-update',
// 空白页面无内容 // 空白页面无内容
// 'pages/component-instance/methods/call-method-easycom-uni-modules', // 'pages/component-instance/methods/call-method-easycom-uni-modules',
// 'pages/component-instance/methods/call-method-easycom', // 'pages/component-instance/methods/call-method-easycom',
] ]
...@@ -156,7 +156,7 @@ describe("shot-compare", () => { ...@@ -156,7 +156,7 @@ describe("shot-compare", () => {
// set webview-screenshot page baseSrc // set webview-screenshot page baseSrc
baseSrc = baseSrc =
process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` : process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` :
"http://192.168.31.223:5173/#/"; "http://test.dcloud.io/unix_h5_build/98_dev_hello-uvue/#/";
page.setData({ page.setData({
baseSrc, baseSrc,
}); });
...@@ -212,7 +212,7 @@ describe("shot-compare", () => { ...@@ -212,7 +212,7 @@ describe("shot-compare", () => {
const isLoaded = await page.data("isLoaded"); const isLoaded = await page.data("isLoaded");
return isLoaded || Date.now() - startTime > 3000; return isLoaded || Date.now() - startTime > 3000;
}); });
await page.waitFor(4000); await page.waitFor(800);
// web 端非 adb 截图时设置 offsetY 移除导航栏 // web 端非 adb 截图时设置 offsetY 移除导航栏
const webSnapshot = await program.screenshot({ const webSnapshot = await program.screenshot({
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
}, },
getWindowInfo() { getWindowInfo() {
const res = uni.getWindowInfo(); const res = uni.getWindowInfo();
// 获取状态栏+导航栏高度, 供截图对比使用 // 获取状态栏, 供截图对比使用
this.headerHeight = res.statusBarHeight; this.headerHeight = res.statusBarHeight;
}, },
getDeviceInfo: function () { getDeviceInfo: function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册