rich-text.test.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const PAGE_PATH = '/pages/component/rich-text/rich-text'
  2. describe('rich-text-test', () => {
  3. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  4. const isMP = platformInfo.startsWith('mp')
  5. const isWeb = platformInfo.startsWith('web')
  6. const isiOS = platformInfo.startsWith('ios')
  7. const isAndroid = platformInfo.startsWith('android')
  8. const isHarmony = platformInfo.startsWith('harmony')
  9. let page
  10. beforeAll(async () => {
  11. page = await program.reLaunch(PAGE_PATH)
  12. await page.waitFor(1500);
  13. })
  14. it('richt-text-height', async () => {
  15. let beforeValue = await page.data('richTextHeight')
  16. if (beforeValue < 10) {
  17. await page.waitFor(2000)
  18. beforeValue = await page.data('richTextHeight')
  19. if (beforeValue < 10) {
  20. await page.waitFor(2000)
  21. beforeValue = await page.data('richTextHeight')
  22. }
  23. }
  24. await page.callMethod('changeText')
  25. await page.waitFor(500)
  26. await page.callMethod('changeText')
  27. await page.waitFor(1500)
  28. let afterValue = await page.data('richTextHeight')
  29. console.log('beforeValue:', beforeValue)
  30. console.log('afterValue:', afterValue)
  31. expect(beforeValue).toBe(afterValue)
  32. })
  33. if (isAndroid || isiOS || isHarmony) {
  34. it('test selectable itemclick', async () => {
  35. await page.setData({
  36. autoTest: true,
  37. isItemClickTrigger: false
  38. });
  39. await page.waitFor(1000);
  40. const windowInfo = await program.callUniMethod('getWindowInfo');
  41. const rect = await page.callMethod('getBoundingClientRectForTest');
  42. await program.tap({
  43. x: (rect.right - rect.left) / 2,
  44. y: windowInfo.statusBarHeight + 44 + (rect.bottom - rect.top) / 2
  45. });
  46. await page.waitFor(1000);
  47. expect(await page.data('isItemClickTrigger')).toBe(true);
  48. await page.setData({
  49. isItemClickTrigger: false
  50. });
  51. await program.navigateTo("/pages/component/rich-text/rich-text-tags");
  52. await page.waitFor(500);
  53. await program.navigateBack();
  54. await program.tap({
  55. x: (rect.right - rect.left) / 2,
  56. y: windowInfo.statusBarHeight + 44 + (rect.bottom - rect.top) / 2
  57. });
  58. await page.waitFor(1000);
  59. expect(await page.data('isItemClickTrigger')).toBe(true);
  60. await page.setData({
  61. autoTest: false
  62. });
  63. });
  64. }
  65. it('rich-text parent click', async () => {
  66. const element = await page.$('#rich-text-parent')
  67. await element.tap()
  68. await page.waitFor(500)
  69. const element2 = await page.$('#rich-text-str')
  70. expect(await element2.text()).toBe("true")
  71. })
  72. })