提交 8c6d49f3 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 处理小程序兼容问题

上级 db9eea53
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
const PAGE_PATH = '/pages/component/global-events/global-events' const PAGE_PATH = '/pages/component/global-events/global-events'
describe('event trigger', () => { describe('event trigger', () => {
...@@ -177,55 +179,90 @@ describe('event trigger', () => { ...@@ -177,55 +179,90 @@ describe('event trigger', () => {
} }
}) })
it('click', async () => { it('click', async () => {
const el = await page.$('#longpress-target') if (isMP) {
await el.tap() page = await program.navigateTo(PAGE_PATH)
const targetX = '0' await page.waitFor('view')
const targetY = '0' const el = await page.$('#longpress-target')
const tapEventX = await page.$('#tap-event-x') await el.tap()
expect(await tapEventX.text()).toBe(targetX) await page.waitFor(500)
const tapEventY = await page.$('#tap-event-y') const clickEventX = await page.$('#click-event-x')
expect(await tapEventY.text()).toBe(targetY) expect(parseInt(await clickEventX.text())).toBeGreaterThan(0)
const clickEventX = await page.$('#click-event-x') const clickEventY = await page.$('#click-event-y')
expect(await clickEventX.text()).toBe(targetX) expect(parseInt(await clickEventY.text())).toBeGreaterThan(0)
const clickEventY = await page.$('#click-event-y') } else {
expect(await clickEventY.text()).toBe(targetY) const el = await page.$('#longpress-target')
await el.tap()
const targetX = '0'
const targetY = '0'
const tapEventX = await page.$('#tap-event-x')
expect(await tapEventX.text()).toBe(targetX)
const tapEventY = await page.$('#tap-event-y')
expect(await tapEventY.text()).toBe(targetY)
const clickEventX = await page.$('#click-event-x')
expect(await clickEventX.text()).toBe(targetX)
const clickEventY = await page.$('#click-event-y')
expect(await clickEventY.text()).toBe(targetY)
}
}) })
it('longPress', async () => { it('longPress', async () => {
if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) { if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
const el = await page.$('#longpress-target') const el = await page.$('#longpress-target')
await el.longpress() await el.longpress()
const longPressTouchTargetIdentifier = '1' if (isMP) {
const longPressTouchTargetValue = '0' const longPressTouchIdentifier = await page.$('#long-press-touch-identifier')
const longPressTouchIdentifier = await page.$('#long-press-touch-identifier') expect(await longPressTouchIdentifier.text()).toBe('0')
expect(await longPressTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier) const longPressTouchPageX = await page.$('#long-press-touch-page-x')
const longPressTouchPageX = await page.$('#long-press-touch-page-x') expect(parseInt(await longPressTouchPageX.text())).toBeGreaterThan(0)
expect(await longPressTouchPageX.text()).toBe(longPressTouchTargetValue) const longPressTouchPageY = await page.$('#long-press-touch-page-y')
const longPressTouchPageY = await page.$('#long-press-touch-page-y') expect(parseInt(await longPressTouchPageY.text())).toBeGreaterThan(0)
expect(await longPressTouchPageY.text()).toBe(longPressTouchTargetValue) const longPressTouchClientX = await page.$('#long-press-touch-client-x')
const longPressTouchClientX = await page.$('#long-press-touch-client-x') expect(parseInt(await longPressTouchClientX.text())).toBeGreaterThan(0)
expect(await longPressTouchClientX.text()).toBe(longPressTouchTargetValue) const longPressTouchClientY = await page.$('#long-press-touch-client-y')
const longPressTouchClientY = await page.$('#long-press-touch-client-y') expect(parseInt(await longPressTouchClientY.text())).toBeGreaterThan(0)
expect(await longPressTouchClientY.text()).toBe(longPressTouchTargetValue) const longPressChangedTouchIdentifier = await page.$('#long-press-changed-touch-identifier')
const longPressTouchScreenX = await page.$('#long-press-touch-screen-x') expect(await longPressChangedTouchIdentifier.text()).toBe('0')
expect(await longPressTouchScreenX.text()).toBe(longPressTouchTargetValue) const longPressChangedTouchPageX = await page.$('#long-press-changed-touch-page-x')
const longPressTouchScreenY = await page.$('#long-press-touch-screen-y') expect(parseInt(await longPressChangedTouchPageX.text())).toBeGreaterThan(0)
expect(await longPressTouchScreenY.text()).toBe(longPressTouchTargetValue) const longPressChangedTouchPageY = await page.$('#long-press-changed-touch-page-y')
const longPressChangedTouchIdentifier = await page.$('#long-press-changed-touch-identifier') expect(parseInt(await longPressChangedTouchPageY.text())).toBeGreaterThan(0)
expect(await longPressChangedTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier) const longPressChangedTouchClientX = await page.$('#long-press-changed-touch-client-x')
const longPressChangedTouchPageX = await page.$('#long-press-changed-touch-page-x') expect(parseInt(await longPressChangedTouchClientX.text())).toBeGreaterThan(0)
expect(await longPressChangedTouchPageX.text()).toBe(longPressTouchTargetValue) const longPressChangedTouchClientY = await page.$('#long-press-changed-touch-client-y')
const longPressChangedTouchPageY = await page.$('#long-press-changed-touch-page-y') expect(parseInt(await longPressChangedTouchClientY.text())).toBeGreaterThan(0)
expect(await longPressChangedTouchPageY.text()).toBe(longPressTouchTargetValue) } else {
const longPressChangedTouchClientX = await page.$('#long-press-changed-touch-client-x') const longPressTouchTargetIdentifier = '1'
expect(await longPressChangedTouchClientX.text()).toBe(longPressTouchTargetValue) const longPressTouchTargetValue = '0'
const longPressChangedTouchClientY = await page.$('#long-press-changed-touch-client-y') const longPressTouchIdentifier = await page.$('#long-press-touch-identifier')
expect(await longPressChangedTouchClientY.text()).toBe(longPressTouchTargetValue) expect(await longPressTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier)
const longPressChangedTouchScreenX = await page.$('#long-press-changed-touch-screen-x') const longPressTouchPageX = await page.$('#long-press-touch-page-x')
expect(await longPressChangedTouchScreenX.text()).toBe(longPressTouchTargetValue) expect(await longPressTouchPageX.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchScreenY = await page.$('#long-press-changed-touch-screen-y') const longPressTouchPageY = await page.$('#long-press-touch-page-y')
expect(await longPressChangedTouchScreenY.text()).toBe(longPressTouchTargetValue) expect(await longPressTouchPageY.text()).toBe(longPressTouchTargetValue)
const longPressTouchClientX = await page.$('#long-press-touch-client-x')
expect(await longPressTouchClientX.text()).toBe(longPressTouchTargetValue)
const longPressTouchClientY = await page.$('#long-press-touch-client-y')
expect(await longPressTouchClientY.text()).toBe(longPressTouchTargetValue)
const longPressTouchScreenX = await page.$('#long-press-touch-screen-x')
expect(await longPressTouchScreenX.text()).toBe(longPressTouchTargetValue)
const longPressTouchScreenY = await page.$('#long-press-touch-screen-y')
expect(await longPressTouchScreenY.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchIdentifier = await page.$('#long-press-changed-touch-identifier')
expect(await longPressChangedTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier)
const longPressChangedTouchPageX = await page.$('#long-press-changed-touch-page-x')
expect(await longPressChangedTouchPageX.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchPageY = await page.$('#long-press-changed-touch-page-y')
expect(await longPressChangedTouchPageY.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchClientX = await page.$('#long-press-changed-touch-client-x')
expect(await longPressChangedTouchClientX.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchClientY = await page.$('#long-press-changed-touch-client-y')
expect(await longPressChangedTouchClientY.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchScreenX = await page.$('#long-press-changed-touch-screen-x')
expect(await longPressChangedTouchScreenX.text()).toBe(longPressTouchTargetValue)
const longPressChangedTouchScreenY = await page.$('#long-press-changed-touch-screen-y')
expect(await longPressChangedTouchScreenY.text()).toBe(longPressTouchTargetValue)
}
if (isAndroid || isIos) { if (isAndroid || isIos) {
if (isIos) { if (isIos) {
...@@ -319,4 +356,4 @@ describe('event trigger', () => { ...@@ -319,4 +356,4 @@ describe('event trigger', () => {
expect(1).toBe(1) expect(1).toBe(1)
} }
}) })
}) })
...@@ -63,37 +63,42 @@ ...@@ -63,37 +63,42 @@
} }
// #ifdef APP // #ifdef APP
if (!generalTarget.classList.includes('general-class')) { if (!generalTarget.classList.includes('general-class')) {
// #endif this.validateGeneralAttrText = '基础属性 class 验证失败'
// #ifndef APP return
if (!Array.from(generalTarget.classList).includes('general-class')) { }
// #endif // #endif
this.validateGeneralAttrText = '基础属性 class 验证失败' // #ifdef WEB
return if (!Array.from(generalTarget.classList).includes('general-class')) {
} this.validateGeneralAttrText = '基础属性 class 验证失败'
const generalName = generalTarget.getAttribute('name') return
if (generalName != this.generalName) { }
this.validateGeneralAttrText = '基础属性 name 验证失败' // #endif
return // #ifndef MP
} const generalName = generalTarget.getAttribute('name')
const generalTitle = generalTarget.getAttribute('title') if (generalName != this.generalName) {
if (generalTitle != this.generalTitle) { this.validateGeneralAttrText = '基础属性 name 验证失败'
this.validateGeneralAttrText = '基础属性 title 验证失败' return
return }
} const generalTitle = generalTarget.getAttribute('title')
const generalData = generalTarget.getAttribute('data-test') if (generalTitle != this.generalTitle) {
if (generalData != this.generalData) { this.validateGeneralAttrText = '基础属性 title 验证失败'
this.validateGeneralAttrText = '基础属性 data-test 验证失败' return
return
}
this.validateGeneralAttrText = '基础属性验证成功'
},
changeHeight(){
const generalTarget = this.$refs['general-target'] as UniElement
this.changeHeightByRefText = '已通过 ref 修改高度'
generalTarget.style.setProperty('height', '200px')
} }
const generalData = generalTarget.getAttribute('data-test')
if (generalData != this.generalData) {
this.validateGeneralAttrText = '基础属性 data-test 验证失败'
return
}
// #endif
this.validateGeneralAttrText = '基础属性验证成功'
}, },
} changeHeight() {
const generalTarget = this.$refs['general-target'] as UniElement
this.changeHeightByRefText = '已通过 ref 修改高度'
generalTarget.style.setProperty('height', '200px')
}
},
}
</script> </script>
<style> <style>
...@@ -134,4 +139,4 @@ ...@@ -134,4 +139,4 @@
.hover-class { .hover-class {
background-color: red; background-color: red;
} }
</style> </style>
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('issue-2199', () => { describe('issue-2199', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/list-view/issue-2199') page = await program.reLaunch('/pages/component/list-view/issue-2199')
await page.waitFor(600) await page.waitFor(600)
...@@ -12,4 +22,4 @@ describe('issue-2199', () => { ...@@ -12,4 +22,4 @@ describe('issue-2199', () => {
expect(image).toSaveImageSnapshot(); expect(image).toSaveImageSnapshot();
}) })
}) })
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('list-view-children-in-slot', () => { describe('list-view-children-in-slot', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/list-view/list-view-children-in-slot') page = await program.reLaunch('/pages/component/list-view/list-view-children-in-slot')
......
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('component-native-list-view', () => { describe('component-native-list-view', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page let page
beforeAll(async () => { beforeAll(async () => {
//打开list-view-multiplex测试页 //打开list-view-multiplex测试页
......
describe('component-native-list-view', () => { const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
let page const isMP = platformInfo.startsWith('mp')
describe('component-native-list-view', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => { beforeAll(async () => {
//打开list-view测试页 //打开list-view测试页
page = await program.reLaunch('/pages/component/list-view/list-view') page = await program.reLaunch('/pages/component/list-view/list-view')
await page.waitFor(600) await page.waitFor(600)
}) })
//检测竖向scrolltop属性赋值 //检测竖向scrolltop属性赋值
...@@ -45,7 +55,7 @@ describe('component-native-list-view', () => { ...@@ -45,7 +55,7 @@ describe('component-native-list-view', () => {
expect([300, 299.8095]).toContain(scrollDetail.scrollTop); expect([300, 299.8095]).toContain(scrollDetail.scrollTop);
expect(scrollDetail.scrollHeight).toBeGreaterThan(0) expect(scrollDetail.scrollHeight).toBeGreaterThan(0)
expect(scrollDetail.scrollWidth).toBeGreaterThan(0) expect(scrollDetail.scrollWidth).toBeGreaterThan(0)
expect(scrollDetail.deltaX).toBe(0) expect(scrollDetail.deltaX).toBe(0)
//此处可判断安卓issues:9121的问题 //此处可判断安卓issues:9121的问题
expect([300.1905, 300, 299.8095]).toContain(scrollDetail.deltaY); expect([300.1905, 300, 299.8095]).toContain(scrollDetail.deltaY);
expect(await page.data('isScrollTest')).toBe('scroll:Success') expect(await page.data('isScrollTest')).toBe('scroll:Success')
......
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('component-native-nested-scroll-body', () => { describe('component-native-nested-scroll-body', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => { it('dummyTest', () => {
expect(1).toBe(1) expect(1).toBe(1)
......
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('component-native-nested-scroll-header', () => { describe('component-native-nested-scroll-header', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => { it('dummyTest', () => {
expect(1).toBe(1) expect(1).toBe(1)
......
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('component-native-sticky-header', () => { describe('component-native-sticky-header', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page let page
async function getWindowInfo() { async function getWindowInfo() {
const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info') const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info')
......
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('component-native-sticky-section', () => { describe('component-native-sticky-section', () => {
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/sticky-section/sticky-section') page = await program.reLaunch('/pages/component/sticky-section/sticky-section')
...@@ -6,7 +16,7 @@ describe('component-native-sticky-section', () => { ...@@ -6,7 +16,7 @@ describe('component-native-sticky-section', () => {
}) })
//检测吸顶上推效果 //检测吸顶上推效果
it('check_sticky_section', async () => { it('check_sticky_section', async () => {
page.waitFor(300) page.waitFor(300)
await page.callMethod('listViewScrollByY', 1000) await page.callMethod('listViewScrollByY', 1000)
const image = await program.screenshot({fullPage: true}); const image = await program.screenshot({fullPage: true});
......
...@@ -4,8 +4,10 @@ describe('swiper-touch-test', () => { ...@@ -4,8 +4,10 @@ describe('swiper-touch-test', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android') const isAndroid = platformInfo.startsWith('android')
const isWeb = platformInfo.startsWith('web') const isWeb = platformInfo.startsWith('web')
// 屏蔽 web * android 平台 const isMP = platformInfo.startsWith('mp')
if (isWeb || isAndroid) { // 屏蔽 web * android 平台, 需要针对调整坐标
// 屏蔽 小程序,不支持 program.swipe
if (isWeb || isAndroid || isMp) {
it('other platform', () => { it('other platform', () => {
expect(1).toBe(1) expect(1).toBe(1)
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册