overflow-visible-event.test.js 3.7 KB
Newer Older
1 2 3
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/

describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
4
  let isAndroid = process.env.uniTestPlatformInfo.startsWith('android')
5 6 7 8 9 10 11 12 13
  const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  if(platformInfo.indexOf('12.4') != -1){
    // TODO: 排查 ios 不兼容版本 测试异常原因
    it('ios 12.4 测试异常', () => {
      expect(1).toBe(1)
    })
    return
  }

14
  if (!process.env.uniTestPlatformInfo.startsWith('android') && !process.env.uniTestPlatformInfo.toLowerCase().includes('ios')) {
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    it('dummyTest', async () => {
      expect(1).toBe(1)
    })
    return
  }

	let page;
  let res;
	beforeAll(async () => {
	  page = await program.reLaunch('/pages/CSS/overflow/overflow-visible-event')
	  await page.waitFor(600);
	})
  beforeEach(async () => {
    await page.setData({
      jest_result: false,
30 31
      jest_click_x: -1,
      jest_click_y: -1
32 33 34 35 36 37 38
    })
  });

  it('Check Overflow Visible Part Click', async () => {
    res = await page.callMethod('jest_getRect')
    const point_x = await page.data('jest_click_x');
    const point_y = await page.data('jest_click_y');
39 40 41 42 43
    if (isAndroid){
      await program.adbCommand("input tap" + " " + point_x + " " + point_y)
    } else {
      await program.tap({x: point_x, y: point_y})
    }
44 45 46 47
    await page.waitFor(500);
    res = await page.data('jest_result');
    expect(res).toBe(true)
  });
48 49 50 51 52 53 54 55 56

  // 此测试针对开发者使用 translate 移动view
  it('Check Overflow Visible Part Use translate Drag', async ()=> {
    await page.callMethod('jest_getRect')
    const point_x = await page.data('jest_click_x');
    const point_y = await page.data('jest_click_y');
    const distance = 100;
    const destY = point_y + 100
    const duration = 1000
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    if (isAndroid) {
      await program.adbCommand("input swipe" + " " + point_x + " " + point_y + " " + point_x + " " + destY + " " + duration)
    } else {
      await program.swipe({
            startPoint: {
              x: point_x,
              y: point_y
            },
            endPoint: {
              x: point_x,
              y: destY
            },
            duration: duration
          })
    }
72 73 74
    await page.waitFor(1500);
    await page.callMethod('jest_getParentRect')
    const currentParentTop = await page.data('jest_parent_top');
75
    const offset = 4
76 77 78 79 80
    const diff = Math.abs(currentParentTop - distance) < offset
    console.log("current ", currentParentTop);
    console.log("diff", diff);
    expect(diff).toBe(true)
  })
81 82 83 84 85 86

  it('Check Overflow Visible Block View Click', async () => {
    await page.callMethod('jest_getAbsoluteViewRect')
    const point_x = await page.data('jest_click_x');
    const point_y = await page.data('jest_click_y');
    console.log("input tap" + " " + point_x + " " + point_y);
87 88 89 90 91
    if (isAndroid) {
      await program.adbCommand("input tap" + " " + point_x + " " + point_y)
    } else {
      await program.tap({x: point_x, y: point_y})
    }
92 93 94 95
    await page.waitFor(500);
    res = await page.data('jest_result');
    expect(res).toBe(true)
  })
96 97 98 99 100 101 102

  it('Check Overflow Visible Deep Level Click', async () => {
    await page.callMethod('jest_scrollToDeepOverflow')
    await page.waitFor(500);
    const point_x = await page.data('jest_click_x');
    const point_y = await page.data('jest_click_y');
    console.log("input tap" + " " + point_x + " " + point_y);
103 104 105 106 107
    if (isAndroid) {
      await program.adbCommand("input tap" + " " + point_x + " " + point_y)
    } else {
      await program.tap({x: point_x, y: point_y})
    }
108 109 110 111
    await page.waitFor(500);
    res = await page.data('jest_result');
    expect(res).toBe(true)
  })
112
});