From d95ace7a58402c46eef73568478d5ee9cfe0dbfc Mon Sep 17 00:00:00 2001 From: shutao Date: Thu, 25 Jan 2024 18:25:28 +0800 Subject: [PATCH] =?UTF-8?q?pages.test.js=E9=83=A8=E5=88=86scroll-view?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E8=87=AA=E5=8A=A8=E5=8C=96=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=BD=AC=E5=88=B0scroll-view=E7=9B=AE?= =?UTF-8?q?=E5=BD=95xx.test.js=E7=A4=BA=E4=BE=8B=E4=B8=AD=E3=80=82?= =?UTF-8?q?=E6=88=AA=E5=9B=BE=E6=97=B6=E9=99=90=E5=88=B6=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1=E6=98=BE=E7=A4=BA=20=E9=98=B2=E6=AD=A2=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E6=88=AA=E5=9B=BE=E5=8F=AF=E8=83=BD=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scroll-view/scroll-view-props.test.js | 13 ++++++++++++- .../scroll-view/scroll-view-refresher.test.js | 13 +++++++++++-- .../scroll-view/scroll-view-refresher.uvue | 5 +++-- .../component/scroll-view/scroll-view.test.js | 18 ++++++++++++++++++ pages/component/scroll-view/scroll-view.uvue | 5 +++-- pages/pages.test.js | 3 --- 6 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 pages/component/scroll-view/scroll-view.test.js diff --git a/pages/component/scroll-view/scroll-view-props.test.js b/pages/component/scroll-view/scroll-view-props.test.js index 9506178b..e4066d0f 100644 --- a/pages/component/scroll-view/scroll-view-props.test.js +++ b/pages/component/scroll-view/scroll-view-props.test.js @@ -1,6 +1,6 @@ // uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ -describe('component-native-scroll-view', () => { +describe('component-native-scroll-view-props', () => { let page; beforeAll(async () => { @@ -82,4 +82,15 @@ describe('component-native-scroll-view', () => { expect(scrollLeft-930).toBeGreaterThanOrEqual(0) }) + //截图对比 + it('scroll-view-props-screenshot', async () => { + //禁止滚动条 + await page.setData({ + showScrollbar: false + }) + await page.waitFor(300); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }) + }); diff --git a/pages/component/scroll-view/scroll-view-refresher.test.js b/pages/component/scroll-view/scroll-view-refresher.test.js index 27e8473e..99c34fea 100644 --- a/pages/component/scroll-view/scroll-view-refresher.test.js +++ b/pages/component/scroll-view/scroll-view-refresher.test.js @@ -1,13 +1,22 @@ // uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ -describe('test title', () => { +describe('component-native-scroll-view-refresher', () => { if (process.env.uniTestPlatformInfo.startsWith('android')) { let page; beforeAll(async () => { page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher'); await page.waitFor(300); }); - + + it('scroll-view-refresher-screenshot', async () => { + //禁止滚动条 + await page.setData({ + showScrollbar: false + }) + await page.waitFor(300); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }) it('check_refresher', async () => { await page.setData({ diff --git a/pages/component/scroll-view/scroll-view-refresher.uvue b/pages/component/scroll-view/scroll-view-refresher.uvue index ee42cb32..d92f76d9 100644 --- a/pages/component/scroll-view/scroll-view-refresher.uvue +++ b/pages/component/scroll-view/scroll-view-refresher.uvue @@ -3,7 +3,7 @@ + @refresherpulling="onRefresherpulling" @scrolltolower="onScrolltolower" :show-scrollbar="showScrollbar"> {{key}} @@ -18,7 +18,8 @@ return { scrollData: [] as Array, refresherTriggered: false, - refresherrefresh: false + refresherrefresh: false, + showScrollbar: true }; }, onLoad() { diff --git a/pages/component/scroll-view/scroll-view.test.js b/pages/component/scroll-view/scroll-view.test.js new file mode 100644 index 00000000..cc85304b --- /dev/null +++ b/pages/component/scroll-view/scroll-view.test.js @@ -0,0 +1,18 @@ +describe('component-native-scroll-view', () => { + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/scroll-view/scroll-view'); + await page.waitFor(300); + }); + + + it('scroll-view-screenshot', async () => { + //禁止滚动条 + await page.setData({ + showScrollbar: false + }) + await page.waitFor(300); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); +}); diff --git a/pages/component/scroll-view/scroll-view.uvue b/pages/component/scroll-view/scroll-view.uvue index ce6670c9..4a24f6f1 100644 --- a/pages/component/scroll-view/scroll-view.uvue +++ b/pages/component/scroll-view/scroll-view.uvue @@ -11,7 +11,7 @@ + @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll" :show-scrollbar="showScrollbar"> A B C @@ -26,7 +26,7 @@ 横向滚动 - + A B C @@ -70,6 +70,7 @@ return { scrollTop: 0, oldScrollTop: 0, + showScrollbar: true } }, methods: { diff --git a/pages/pages.test.js b/pages/pages.test.js index e5b35a33..a90a6d9f 100755 --- a/pages/pages.test.js +++ b/pages/pages.test.js @@ -22,10 +22,7 @@ const pages = [ '/pages/component/rich-text/rich-text-tags', '/pages/component/rich-text/rich-text', '/pages/component/scroll-view/scroll-view-custom-refresher-props', - '/pages/component/scroll-view/scroll-view-props', '/pages/component/scroll-view/scroll-view-refresher-props', - '/pages/component/scroll-view/scroll-view-refresher', - '/pages/component/scroll-view/scroll-view', '/pages/component/slider/slider', '/pages/component/slider-100/slider-100', '/pages/component/swiper/swiper', -- GitLab