提交 5c285042 编写于 作者: W wangjinxin613

Merge branch 'dev' of gitcode.net:dcloud/hello-uvue into dev

......@@ -66,7 +66,7 @@ const pages = [
'pages/composition-api/lifecycle/page-lifecycle/page-lifecycle',
'pages/composition-api/lifecycle/component-lifecycle/component-lifecycle',
'pages/built-in-component/teleport/teleport',
'pages/component-instance/watch-function/watch-function'
'pages/component-instance/watch-function/watch-function'
// 仅app
// 'pages/composition/mixins/mixins',
......@@ -102,13 +102,13 @@ const pages = [
// 'pages/composition-api/reactivity/watch-effect/watch-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/watch',
// 'pages/composition/provide/provide',
// 'pages/composition/provide/provide-page2',
// 'pages/composition-api/reactivity/watch/watch',
// 'pages/composition/provide/provide',
// 'pages/composition/provide/provide-page2',
// 'pages/state/data/data',
// 功能差异
// 'pages/composition/setup/setup',
// 'pages/composition/setup/setup',
// 'pages/component-instance/el/el',
// 样式差异
......@@ -144,12 +144,12 @@ describe("shot-compare", () => {
shouldCompareScreenShot = version > 9
}
if (!shouldCompareScreenShot) {
it("other platform not support", async () => {
expect(1).toBe(1);
});
return
}
if (!shouldCompareScreenShot) {
it("other platform not support", async () => {
expect(1).toBe(1);
});
return
}
let page = null;
let pageIndex = 0;
......@@ -158,14 +158,14 @@ describe("shot-compare", () => {
page = await program.reLaunch(PAGE_PATH);
await page.waitFor(500);
// set webview-screenshot-comparison page baseSrc
baseSrc =
process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` :
"http://192.168.31.223:5173/#/";
page.setData({
baseSrc,
});
});
// set webview-screenshot-comparison page baseSrc
baseSrc =
process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` :
"http://test.dcloud.io/unix_h5_build/98_dev_hello-uvue/#/";
page.setData({
baseSrc,
});
});
beforeEach(async () => {
page = await program.reLaunch(PAGE_PATH);
......@@ -175,23 +175,23 @@ describe("shot-compare", () => {
pageIndex++;
});
test.each(pages)("%s", async () => {
const isNeedAdbScreenshot = needAdbScreenshot(pages[pageIndex]);
const isCustomNavigationBar = customNavigationPages.includes(pages[pageIndex]);
const {
statusBarHeight,
devicePixelRatio
} = await page.data();
const screenshotParams = {
fullPage: true,
adb: isNeedAdbScreenshot,
// adb 截图时跳过状态栏
area: {
x: 0,
y: statusBarHeight * devicePixelRatio,
},
}
const screenshotPath = `__webview__${pages[pageIndex].replace(/\//g, "-")}`;
test.each(pages)("%s", async () => {
const isNeedAdbScreenshot = needAdbScreenshot(pages[pageIndex]);
const isCustomNavigationBar = customNavigationPages.includes(pages[pageIndex]);
const {
statusBarHeight,
devicePixelRatio
} = await page.data();
const screenshotParams = {
fullPage: true,
adb: isNeedAdbScreenshot,
// adb 截图时跳过状态栏
area: {
x: 0,
y: statusBarHeight * devicePixelRatio,
},
}
const screenshotPath = `__webview__${pages[pageIndex].replace(/\//g, "-")}`;
// web in webview screenshot
// 加载依赖页面
......@@ -212,36 +212,36 @@ describe("shot-compare", () => {
isCustomNavigationBar,
});
const startTime = Date.now();
await page.waitFor(async () => {
const isLoaded = await page.data("isLoaded");
return isLoaded || Date.now() - startTime > 3000;
});
await page.waitFor(4500);
// web 端非 adb 截图时设置 offsetY 移除导航栏
const webSnapshot = await program.screenshot({
...screenshotParams,
id: 'webview-screenshot-comparison',
offsetY: `${isCustomNavigationBar ? 0 : 44}`
});
expect(webSnapshot).toMatchImageSnapshot({
customSnapshotIdentifier() {
return screenshotPath;
},
});
// app-android page screenshot comparison
const navigateMethod = pages[pageIndex].startsWith("pages/tab-bar") ?
"switchTab" :
"navigateTo";
page = await program[navigateMethod](`/${pages[pageIndex]}`);
await page.waitFor(500);
const appAndroidSnapshot = await program.screenshot(screenshotParams);
expect(appAndroidSnapshot).toMatchImageSnapshot({
customSnapshotIdentifier() {
return screenshotPath;
},
});
});
});
\ No newline at end of file
const startTime = Date.now();
await page.waitFor(async () => {
const isLoaded = await page.data("isLoaded");
return isLoaded || Date.now() - startTime > 3000;
});
await page.waitFor(800);
// web 端非 adb 截图时设置 offsetY 移除导航栏
const webSnapshot = await program.screenshot({
...screenshotParams,
id: 'webview-screenshot-comparison',
offsetY: `${isCustomNavigationBar ? 0 : 44}`
});
expect(webSnapshot).toMatchImageSnapshot({
customSnapshotIdentifier() {
return screenshotPath;
},
});
// app-android page screenshot comparison
const navigateMethod = pages[pageIndex].startsWith("pages/tab-bar") ?
"switchTab" :
"navigateTo";
page = await program[navigateMethod](`/${pages[pageIndex]}`);
await page.waitFor(500);
const appAndroidSnapshot = await program.screenshot(screenshotParams);
expect(appAndroidSnapshot).toMatchImageSnapshot({
customSnapshotIdentifier() {
return screenshotPath;
},
});
});
});
......@@ -27,33 +27,15 @@
this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this)
},
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() {
this.isLoaded = true
this.customNavigationBarPageAppendWebHeadPlaceholder();
},
error(event : WebViewErrorEvent) {
console.log('webview load error', JSON.stringify(event.detail));
},
getWindowInfo() {
const res = uni.getWindowInfo();
// 获取状态栏+导航栏高度, 供截图对比使用
// 获取状态栏, 供截图对比使用
this.statusBarHeight = res.statusBarHeight;
},
getDeviceInfo: function () {
......
......@@ -152,7 +152,7 @@ describe("shot-compare", () => {
// set webview-screenshot page baseSrc
baseSrc =
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({
baseSrc,
});
......@@ -208,8 +208,7 @@ describe("shot-compare", () => {
const isLoaded = await page.data("isLoaded");
return isLoaded || Date.now() - startTime > 3000;
});
await page.waitFor(5000)
await page.waitFor(800);
// web 端非 adb 截图时设置 offsetY 移除导航栏
const webSnapshot = await program.screenshot({
......
......@@ -34,7 +34,7 @@
},
getWindowInfo() {
const res = uni.getWindowInfo();
// 获取状态栏+导航栏高度, 供截图对比使用
// 获取状态栏, 供截图对比使用
this.headerHeight = res.statusBarHeight;
},
getDeviceInfo: function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册