overflow-visible-event.test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
  2. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  3. const isAndroid = platformInfo.startsWith('android')
  4. const isIos = platformInfo.startsWith('ios')
  5. if(isIos && platformInfo.indexOf('12.4') != -1){
  6. // TODO: 排查 ios 不兼容版本 测试异常原因
  7. it('ios 12.4 测试异常', () => {
  8. expect(1).toBe(1)
  9. })
  10. return
  11. }
  12. if (!(isIos || isAndroid)) {
  13. it('dummyTest', async () => {
  14. expect(1).toBe(1)
  15. })
  16. return
  17. }
  18. let page;
  19. let res;
  20. beforeAll(async () => {
  21. page = await program.reLaunch('/pages/CSS/overflow/overflow-visible-event')
  22. await page.waitFor(600);
  23. })
  24. beforeEach(async () => {
  25. await page.setData({
  26. jest_result: false,
  27. jest_click_x: -1,
  28. jest_click_y: -1
  29. })
  30. });
  31. it('Check Overflow Visible Part Click', async () => {
  32. res = await page.callMethod('jest_getRect')
  33. const point_x = await page.data('jest_click_x');
  34. const point_y = await page.data('jest_click_y');
  35. if (isAndroid){
  36. await program.adbCommand("input tap" + " " + point_x + " " + point_y)
  37. } else {
  38. await program.tap({x: point_x, y: point_y})
  39. }
  40. await page.waitFor(500);
  41. res = await page.data('jest_result');
  42. expect(res).toBe(true)
  43. });
  44. // 此测试针对开发者使用 translate 移动view
  45. it('Check Overflow Visible Part Use translate Drag', async ()=> {
  46. await page.callMethod('jest_getRect')
  47. const point_x = await page.data('jest_click_x');
  48. const point_y = await page.data('jest_click_y');
  49. const distance = 100;
  50. const destY = point_y + 100
  51. const duration = 1000
  52. if (isAndroid) {
  53. await program.adbCommand("input swipe" + " " + point_x + " " + point_y + " " + point_x + " " + destY + " " + duration)
  54. } else {
  55. await program.swipe({
  56. startPoint: {
  57. x: point_x,
  58. y: point_y
  59. },
  60. endPoint: {
  61. x: point_x,
  62. y: destY
  63. },
  64. duration: duration
  65. })
  66. }
  67. await page.waitFor(1500);
  68. await page.callMethod('jest_getParentRect')
  69. const currentParentTop = await page.data('jest_parent_top');
  70. const offset = 4
  71. const diff = Math.abs(currentParentTop - distance) < offset
  72. console.log("current ", currentParentTop);
  73. console.log("diff", diff);
  74. expect(diff).toBe(true)
  75. })
  76. it('Check Overflow Visible Block View Click', async () => {
  77. await page.callMethod('jest_getAbsoluteViewRect')
  78. const point_x = await page.data('jest_click_x');
  79. const point_y = await page.data('jest_click_y');
  80. console.log("input tap" + " " + point_x + " " + point_y);
  81. if (isAndroid) {
  82. await program.adbCommand("input tap" + " " + point_x + " " + point_y)
  83. } else {
  84. await program.tap({x: point_x, y: point_y})
  85. }
  86. await page.waitFor(500);
  87. res = await page.data('jest_result');
  88. expect(res).toBe(true)
  89. })
  90. it('Check Overflow Visible Deep Level Click', async () => {
  91. await page.callMethod('jest_scrollToDeepOverflow')
  92. await page.waitFor(500);
  93. const point_x = await page.data('jest_click_x');
  94. const point_y = await page.data('jest_click_y');
  95. console.log("input tap" + " " + point_x + " " + point_y);
  96. if (isAndroid) {
  97. await program.adbCommand("input tap" + " " + point_x + " " + point_y)
  98. } else {
  99. await program.tap({x: point_x, y: point_y})
  100. }
  101. await page.waitFor(500);
  102. res = await page.data('jest_result');
  103. expect(res).toBe(true)
  104. })
  105. });