提交 df550ad2 编写于 作者: DCloud-yinjiacheng's avatar DCloud-yinjiacheng

更新rich-text自动化测试用例

上级 3c3dafa3
...@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/component/rich-text/rich-text' ...@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/component/rich-text/rich-text'
describe('rich-text-test', () => { describe('rich-text-test', () => {
// 先屏蔽 android 及 web 平台 // 先屏蔽 android 及 web 平台
if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) { if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('other platform', () => { it('other platform', () => {
expect(1).toBe(1) expect(1).toBe(1)
}) })
...@@ -32,5 +32,24 @@ describe('rich-text-test', () => { ...@@ -32,5 +32,24 @@ describe('rich-text-test', () => {
console.log('afterValue:', afterValue) console.log('afterValue:', afterValue)
expect(beforeValue).toBe(afterValue) expect(beforeValue).toBe(afterValue)
}) })
it('test selectable itemclick', async () => {
await page.setData({
autoTest: true,
isItemClickTrigger: false
});
await page.waitFor(1000);
const info = await page.callMethod('getWindowInfoForTest');
const rect = await page.callMethod('getBoundingClientRectForTest');
await program.tap({
x: (rect.right - rect.left) / 2,
y: info.statusBarHeight + 44 + (rect.bottom - rect.top) / 2
});
await page.waitFor(1000);
expect(await page.data('isItemClickTrigger')).toBe(true);
await page.setData({
autoTest: false
});
});
}) })
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
:nodes="text"></rich-text> :nodes="text"></rich-text>
</view> </view>
</view> </view>
</view> </view>
<rich-text v-if="autoTest" id="test-rich-text" :nodes="testNodes" :selectable="true" @itemclick="itemClickForTest" style="position: fixed;width: 100px;height: 100px;"></rich-text>
</template> </template>
<script> <script>
...@@ -30,7 +31,11 @@ ...@@ -30,7 +31,11 @@
return { return {
text: "<span>hello uni-app x!</span><br/><span>uni-app x,终极跨平台方案</span>", text: "<span>hello uni-app x!</span><br/><span>uni-app x,终极跨平台方案</span>",
richTextHeight: 0, richTextHeight: 0,
richTextElement: null as UniElement | null richTextElement: null as UniElement | null,
// 自动化测试
autoTest: false,
testNodes: '<img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img>',
isItemClickTrigger: false
} }
}, },
onReady() { onReady() {
...@@ -56,6 +61,16 @@ ...@@ -56,6 +61,16 @@
this.richTextHeight = elRect.height this.richTextHeight = elRect.height
console.log('richTextHeight:', this.richTextHeight) console.log('richTextHeight:', this.richTextHeight)
} }
},
// 自动化测试
itemClickForTest(_ : RichTextItemClickEvent) {
this.isItemClickTrigger = true;
},
getBoundingClientRectForTest() : DOMRect {
return uni.getElementById('test-rich-text')?.getBoundingClientRect()!;
},
getWindowInfoForTest() : GetWindowInfoResult {
return uni.getWindowInfo();
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册