提交 a7266173 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

1.添加 rich-text-complex.test.js 测试例 用于测试点击事件;

2.添加 view.test.js 测试例,仅用于关闭iOS系统弹窗;

(cherry picked from commit 440b0417)
上级 ebca2fba
const PAGE_PATH = '/pages/component/rich-text/rich-text-complex'
describe('rich-text-test', () => {
// 先屏蔽 android 及 web 平台
if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1500);
})
it('click-event', async () => {
await program.tap({
x: 210,
y: 280,
duration: 100
})
await page.waitFor(1000);
const fViewClicked = await page.data('fViewClicked')
const selfClicked = await page.data('selfClicked')
expect(fViewClicked).toBe(true)
expect(selfClicked).toBe(true)
})
it('itemclick-event', async () => {
await program.tap({
x: 66,
y: 266,
duration: 100
})
await page.waitFor(500);
// 关闭弹窗逻辑各平台需要适配不同机型
if (process.env.uniTestPlatformInfo.startsWith('IOS')) {
// 关闭弹窗 iPhone Pro 机型
await program.tap({
x: 200,
y: 433,
duration: 100
})
// 关闭弹窗 iPhone ProMax 机型
await program.tap({
x: 220,
y: 476,
duration: 100
})
// 关闭弹窗 iPhone mini 机型
await program.tap({
x: 186,
y: 400,
duration: 100
})
}
const imageClicked = await page.data('imageClicked')
expect(imageClicked).toBe(true)
})
})
......@@ -4,8 +4,8 @@
<!-- #endif -->
<view>
<page-head title="rich-text-complex"></page-head>
<view class="uni-padding-wrap uni-common-mt" @click="testClick('触发父 view click 事件')">
<rich-text :nodes="htmlString" @itemclick="itemClick" @click="testClick('触发 richtext click 事件')"></rich-text>
<view class="uni-padding-wrap uni-common-mt" @click="fViewClick('触发父 view click 事件')">
<rich-text :nodes="htmlString" @itemclick="itemClick" @click="selfClick('触发 richtext click 事件')"></rich-text>
</view>
</view>
<!-- #ifdef APP -->
......@@ -17,6 +17,9 @@
export default {
data() {
return {
imageClicked: false,
fViewClicked: false,
selfClicked: false,
htmlString: '<p><a href="https://www.dcloud.io/hbuilderx.html">HBuilderX</a><br/><img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img><h1>HBuilderX,轻巧、极速,极客编辑器</h1><p style="color:red;"><small>HBuilderX,轻巧、极速,极客编辑器 </small><big>HBuilderX,轻巧、极速,极客编辑器</big><strong>HBuilderX,轻巧、极速,极客编辑器</strong><i>HBuilderX,轻巧、极速,极客编辑器 </i><u>HBuilderX,轻巧、极速,极客编辑器</u><del>HBuilderX,轻巧、极速,极客编辑器</del></p><h2>uni-app x,终极跨平台方案</h2>、<p style="background-color: yellow;"><small>uni-app x,终极跨平台方案 </small><big>uni-app x,终极跨平台方案</big><strong>uni-appx,终极跨平台方案 </strong><i>uni-app x,终极跨平台方案 </i><u>uni-app x,终极跨平台方案 </u><del>uni-appx,终极跨平台方案</del></p><h3>uniCloud,js serverless云服务</h3><p style="text-decoration: line-through;"><small>uniCloud,js serverless云服务 </small><big>uniCloud,jsserverless云服务</big><strong>uniCloud,js serverless云服务 </strong><i>uniCloud,js serverless云服务 </i><u>uniCloud,jsserverless云服务</u><del>uniCloud,js serverless云服务</del></p><h4>uts,大一统语言</h4><p style="text-align: center;"><small>uts,大一统语言 </small><big>uts,大一统语言 </big><strong>uts,大一统语言</strong><i>uts,大一统语言</i><u>uts,大一统语言 </u><del>uts,大一统语言</del></p><h5>uniMPSdk,让你的App具备小程序能力</h5><h6>uni-admin,开源、现成的全端管理后台</h6><ul><li style="color: red; text-align: left;">uni-app x,终极跨平台方案</li><li style="color: green; text-align: center;">uni-app x,终极跨平台方案</li><li style="color: blue; text-align: right;">uni-app x,终极跨平台方案</li></ul><a href="https://uniapp.dcloud.net.cn">uni-app</a><br/><img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img></p>'
}
},
......@@ -26,6 +29,7 @@
let clicktext = '';
if (e.detail.src != null) {
clicktext = '点击了图片,src = ' + e.detail.src;
this.imageClicked = true
} else if (e.detail.href != null) {
clicktext = '点击了链接,href = ' + e.detail.href;
}
......@@ -34,9 +38,13 @@
showCancel:false
});
},
testClick(e:string) {
// 测试点击rich-text是否正常触发自身及父节点 click 事件
fViewClick(e:string) {
console.log(e)
this.fViewClicked = true
},
selfClick(e:string) {
console.log(e)
this.selfClicked = true
}
}
}
......
const PAGE_PATH = '/pages/component/view/view'
// 此用例仅用于模拟点击关闭iOS弹窗逻辑,无实际意义
describe('view-test', () => {
// 先屏蔽 android 及 web 平台
if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1000);
})
it('itemclick-event', async () => {
// 关闭弹窗 iPhone Pro 机型
await program.tap({
x: 220,
y: 516,
duration: 100
})
// 关闭弹窗 iPhone ProMax 机型
await program.tap({
x: 220,
y: 546,
duration: 100
})
// 关闭弹窗 iPhone mini 机型
await program.tap({
x: 186,
y: 463,
duration: 100
})
expect(1).toBe(1)
})
})
const Sequencer = require("@jest/test-sequencer").default
const sortTestFilePaths = [
"pages/component/view/view.test.js",
"pages/API/pull-down-refresh/pull-down-refresh.test.js",
"pages/component/global-events/global-events.test.js",
"pages/component/list-view/list-view-refresh.test.js"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册