choose-location.test.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isMP = platformInfo.startsWith('mp')
  3. const isIos = platformInfo.startsWith('ios')
  4. const isHarmony = platformInfo.startsWith('harmony')
  5. const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
  6. describe('dialog page', () => {
  7. if (isAppWebView || isMP) {
  8. it('skip not support', () => {
  9. expect(1).toBe(1)
  10. })
  11. return
  12. }
  13. let page;
  14. let originLifeCycleNum;
  15. beforeAll(async () => {
  16. page = await program.reLaunch('/pages/API/choose-location/choose-location')
  17. await page.waitFor('view');
  18. originLifeCycleNum = await page.callMethod('getLifeCycleNum')
  19. await page.callMethod('chooseLocation')
  20. if (isHarmony) {
  21. await program.tap({ x: 100, y: 525 })
  22. await page.waitFor(1000)
  23. await program.tap({x: 100, y: 525})
  24. await page.waitFor(1000)
  25. }
  26. await page.waitFor(1000)
  27. });
  28. it('dialogPage should empty', async () => {
  29. const dialogPagesNum = await page.data('dialogPagesNum')
  30. expect(dialogPagesNum).toBe(0)
  31. })
  32. it('should trigger parent hide', async () => {
  33. const lifecycleNum = await page.callMethod('getLifeCycleNum')
  34. expect(lifecycleNum).toBe(originLifeCycleNum - 1)
  35. })
  36. if (isIos) {
  37. // 15以下的模拟器所对应的xcode不能编译自定义插件,大于15是因为某台设备,会用xcode14.1跑15.5的设备
  38. let version = process.env.uniTestPlatformInfo
  39. let split = version.split(" ")
  40. version = parseInt(split[split.length - 1])
  41. if (version > 15) {
  42. it('call chooseLocation in uts plugin', async () => {
  43. page = await program.reLaunch('/pages/API/choose-location/choose-location')
  44. await page.waitFor('view');
  45. await page.callMethod('chooseLocationByPlugin')
  46. await page.waitFor(1000)
  47. const lifecycleNum = await page.callMethod('getLifeCycleNum')
  48. expect(lifecycleNum).toBe(originLifeCycleNum - 1)
  49. })
  50. }
  51. }
  52. afterAll(async () => {
  53. await page.callMethod('setLifeCycleNum', originLifeCycleNum)
  54. });
  55. })