rich-text-complex.test.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isAndroid = platformInfo.startsWith('android')
  3. const isMP = platformInfo.startsWith('mp')
  4. const isWeb = platformInfo.startsWith('web')
  5. const isHarmony = platformInfo.startsWith('harmony')
  6. const isIOS = platformInfo.startsWith('ios')
  7. const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
  8. const PAGE_PATH = '/pages/component/rich-text/rich-text-complex'
  9. describe('rich-text-test', () => {
  10. // 先屏蔽 android 及 web 平台
  11. if (isWeb || isMP || isHarmony) {
  12. it('other platform', () => {
  13. expect(1).toBe(1)
  14. })
  15. return
  16. }
  17. if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
  18. it('跳过横屏模式', () => {
  19. expect(1).toBe(1)
  20. })
  21. return
  22. }
  23. let page
  24. beforeAll(async () => {
  25. page = await program.reLaunch(PAGE_PATH)
  26. await page.waitFor(1500);
  27. })
  28. if (isAndroid && !isAppWebView) {
  29. it("test attr mode", async () => {
  30. await page.setData({
  31. mode: 'native'
  32. });
  33. await page.waitFor(1000);
  34. const image = await program.screenshot({ fullPage: true });
  35. expect(image).toSaveImageSnapshot();
  36. });
  37. return;
  38. }
  39. it('click-event', async () => {
  40. await program.tap({
  41. x: 210,
  42. y: 280,
  43. duration: 100
  44. })
  45. await page.waitFor(1000);
  46. const fViewClicked = await page.data('fViewClicked')
  47. const selfClicked = await page.data('selfClicked')
  48. expect(fViewClicked).toBe(true)
  49. expect(selfClicked).toBe(true)
  50. })
  51. it('itemclick-event', async () => {
  52. await program.tap({
  53. x: 66,
  54. y: 266,
  55. duration: 100
  56. })
  57. await page.waitFor(500);
  58. // 关闭弹窗逻辑各平台需要适配不同机型
  59. if (isIOS) {
  60. // 关闭弹窗 iPhone Pro 机型
  61. await program.tap({
  62. x: 200,
  63. y: 433,
  64. duration: 100
  65. })
  66. // 关闭弹窗 iPhone ProMax 机型
  67. await program.tap({
  68. x: 220,
  69. y: 476,
  70. duration: 100
  71. })
  72. // 关闭弹窗 iPhone plus 机型
  73. await program.tap({
  74. x: 220,
  75. y: 526,
  76. duration: 100
  77. })
  78. // 关闭弹窗 iPhone mini 机型
  79. await program.tap({
  80. x: 186,
  81. y: 400,
  82. duration: 100
  83. })
  84. }
  85. const imageClicked = await page.data('imageClicked')
  86. expect(imageClicked).toBe(true)
  87. })
  88. })