show-modal.test.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. describe('API-loading', () => {
  2. let topSafeArea = 0
  3. let page;
  4. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  5. const isMP = platformInfo.startsWith('mp')
  6. const isHarmony = platformInfo.startsWith('harmony')
  7. const isIos = platformInfo.startsWith('ios')
  8. const isAndroid = platformInfo.startsWith('android')
  9. const isApp = isIos || isAndroid || isHarmony
  10. if(isMP) {
  11. // 微信小程序截图无法截到弹框
  12. it('not support', () => {
  13. expect(1).toBe(1)
  14. })
  15. return
  16. }
  17. if (
  18. isIos &&
  19. (
  20. platformInfo.indexOf('15.5') != -1 ||
  21. platformInfo.indexOf('14.5') != -1 ||
  22. platformInfo.indexOf('13.7') != -1 ||
  23. platformInfo.indexOf('12.4') != -1
  24. )
  25. ) {
  26. // TODO: 排查 ios 不兼容版本 测试异常原因
  27. it('ios 15.5 14.5 13.7 12.4 测试异常', () => {
  28. expect(1).toBe(1)
  29. })
  30. return
  31. }
  32. beforeAll(async () => {
  33. const windowInfo = await program.callUniMethod('getWindowInfo');
  34. topSafeArea = windowInfo.safeAreaInsets.top;
  35. page = await program.reLaunch('/pages/API/show-modal/show-modal')
  36. await page.waitFor('view');
  37. });
  38. it("onload-modal-test", async () => {
  39. if (isApp) {
  40. await page.waitFor(500);
  41. const image = await program.screenshot({
  42. deviceShot: true,
  43. area: {
  44. x: 0,
  45. y: topSafeArea + 44,
  46. },
  47. });
  48. expect(image).toSaveImageSnapshot();
  49. }else{
  50. const image = await program.screenshot({
  51. deviceShot: true,
  52. fullPage: true
  53. });
  54. expect(image).toSaveImageSnapshot()
  55. }
  56. })
  57. it("modal-test-current-0", async () => {
  58. /**
  59. * 延迟3s 关闭
  60. */
  61. const btnModalButtonHideAll = await page.$('#btn-modal-hide-all')
  62. await btnModalButtonHideAll.tap()
  63. await page.waitFor(500);
  64. await page.setData({
  65. current: 0,
  66. showCancelSelect: false,
  67. cancelTextSelect: false,
  68. confirmTextSelect: false,
  69. editableSelect: false,
  70. placeholderTextSelect: false,
  71. })
  72. const btnModalButton = await page.$('#btn-modal-show')
  73. await btnModalButton.tap()
  74. await page.waitFor(500);
  75. if (isApp) {
  76. const image = await program.screenshot({
  77. deviceShot: true,
  78. area: {
  79. x: 0,
  80. y: topSafeArea + 44,
  81. },
  82. });
  83. expect(image).toSaveImageSnapshot();
  84. }else{
  85. const image = await program.screenshot({
  86. deviceShot: true,
  87. fullPage: true
  88. });
  89. expect(image).toSaveImageSnapshot()
  90. }
  91. await page.waitFor(2000);
  92. })
  93. it("modal-test-current-1", async () => {
  94. await page.setData({
  95. current: 1,
  96. showCancelSelect: false,
  97. cancelTextSelect: false,
  98. confirmTextSelect: false,
  99. editableSelect: false,
  100. placeholderTextSelect: false,
  101. })
  102. /**
  103. * 延迟3s 关闭
  104. */
  105. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  106. await btnModalButtonHideLast.tap()
  107. await page.waitFor(500);
  108. const btnModalButton = await page.$('#btn-modal-show')
  109. await btnModalButton.tap()
  110. await page.waitFor(500);
  111. if (isApp) {
  112. const image = await program.screenshot({
  113. deviceShot: true,
  114. area: {
  115. x: 0,
  116. y: topSafeArea + 44,
  117. },
  118. });
  119. expect(image).toSaveImageSnapshot();
  120. }else{
  121. const image = await program.screenshot({
  122. deviceShot: true,
  123. fullPage: true
  124. });
  125. expect(image).toSaveImageSnapshot()
  126. }
  127. await page.waitFor(2000);
  128. })
  129. it("modal-test-current-2", async () => {
  130. /**
  131. * 延迟3s 关闭
  132. */
  133. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  134. await btnModalButtonHideLast.tap()
  135. await page.waitFor(500);
  136. await page.setData({
  137. current: 2,
  138. showCancelSelect: false,
  139. cancelTextSelect: false,
  140. confirmTextSelect: false,
  141. editableSelect: false,
  142. placeholderTextSelect: false,
  143. })
  144. const btnModalButton = await page.$('#btn-modal-show')
  145. await btnModalButton.tap()
  146. await page.waitFor(500);
  147. if (isApp) {
  148. const image = await program.screenshot({
  149. deviceShot: true,
  150. area: {
  151. x: 0,
  152. y: topSafeArea + 44,
  153. },
  154. });
  155. expect(image).toSaveImageSnapshot();
  156. }else{
  157. const image = await program.screenshot({
  158. deviceShot: true,
  159. fullPage: true
  160. });
  161. expect(image).toSaveImageSnapshot()
  162. }
  163. await page.waitFor(2000);
  164. })
  165. it("modal-test-current-2-showCancel", async () => {
  166. /**
  167. * 延迟3s 关闭
  168. */
  169. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  170. await btnModalButtonHideLast.tap()
  171. await page.waitFor(500);
  172. await page.setData({
  173. current: 2,
  174. showCancelSelect: true,
  175. cancelTextSelect: false,
  176. confirmTextSelect: false,
  177. editableSelect: false,
  178. placeholderTextSelect: false,
  179. })
  180. const btnModalButton = await page.$('#btn-modal-show')
  181. await btnModalButton.tap()
  182. await page.waitFor(500);
  183. if (isApp) {
  184. const image = await program.screenshot({
  185. deviceShot: true,
  186. area: {
  187. x: 0,
  188. y: topSafeArea + 44,
  189. },
  190. });
  191. expect(image).toSaveImageSnapshot();
  192. }else{
  193. const image = await program.screenshot({
  194. deviceShot: true,
  195. fullPage: true
  196. });
  197. expect(image).toSaveImageSnapshot()
  198. }
  199. await page.waitFor(2000);
  200. })
  201. it("modal-test-current-2-showCancel-cancelText", async () => {
  202. await page.setData({
  203. current: 2,
  204. showCancelSelect: true,
  205. cancelTextSelect: true,
  206. confirmTextSelect: false,
  207. editableSelect: false,
  208. placeholderTextSelect: false,
  209. })
  210. /**
  211. * 延迟3s 关闭
  212. */
  213. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  214. await btnModalButtonHideLast.tap()
  215. await page.waitFor(500);
  216. const btnModalButton = await page.$('#btn-modal-show')
  217. await btnModalButton.tap()
  218. await page.waitFor(500);
  219. if (isApp) {
  220. const image = await program.screenshot({
  221. deviceShot: true,
  222. area: {
  223. x: 0,
  224. y: topSafeArea + 44,
  225. },
  226. });
  227. expect(image).toSaveImageSnapshot();
  228. }else{
  229. const image = await program.screenshot({
  230. deviceShot: true,
  231. fullPage: true
  232. });
  233. expect(image).toSaveImageSnapshot()
  234. }
  235. await page.waitFor(2000);
  236. })
  237. it("modal-test-current-2-showCancel-cancelText-confirmText", async () => {
  238. await page.setData({
  239. current: 2,
  240. showCancelSelect: true,
  241. cancelTextSelect: true,
  242. confirmTextSelect: true,
  243. editableSelect: false,
  244. placeholderTextSelect: false,
  245. })
  246. /**
  247. * 延迟3s 关闭
  248. */
  249. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  250. await btnModalButtonHideLast.tap()
  251. await page.waitFor(500);
  252. const btnModalButton = await page.$('#btn-modal-show')
  253. await btnModalButton.tap()
  254. await page.waitFor(500);
  255. if (isApp) {
  256. const image = await program.screenshot({
  257. deviceShot: true,
  258. area: {
  259. x: 0,
  260. y: topSafeArea + 44,
  261. },
  262. });
  263. expect(image).toSaveImageSnapshot();
  264. }else{
  265. const image = await program.screenshot({
  266. deviceShot: true,
  267. fullPage: true
  268. });
  269. expect(image).toSaveImageSnapshot()
  270. }
  271. await page.waitFor(2000);
  272. })
  273. it("modal-test-current-2-showCancel-cancelText-confirmText-editable-placeholder", async () => {
  274. /**
  275. * 延迟3s 关闭
  276. */
  277. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  278. await btnModalButtonHideLast.tap()
  279. await page.waitFor(500);
  280. await page.setData({
  281. current: 2,
  282. showCancelSelect: true,
  283. cancelTextSelect: true,
  284. confirmTextSelect: true,
  285. editableSelect: true,
  286. placeholderTextSelect: true,
  287. })
  288. const btnModalButton = await page.$('#btn-modal-show')
  289. await btnModalButton.tap()
  290. await page.waitFor(500);
  291. if (isApp) {
  292. const image = await program.screenshot({
  293. deviceShot: true,
  294. area: {
  295. x: 0,
  296. y: topSafeArea + 44,
  297. },
  298. });
  299. expect(image).toSaveImageSnapshot();
  300. }else{
  301. const image = await program.screenshot({
  302. deviceShot: true,
  303. fullPage: true
  304. });
  305. expect(image).toSaveImageSnapshot()
  306. }
  307. await page.waitFor(2000);
  308. })
  309. it("modal-test-current-2-showCancel-confirmText-editable-placeholder", async () => {
  310. /**
  311. * 延迟3s 关闭
  312. */
  313. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  314. await btnModalButtonHideLast.tap()
  315. await page.waitFor(500);
  316. await page.setData({
  317. current: 2,
  318. showCancelSelect: true,
  319. cancelTextSelect: false,
  320. confirmTextSelect: true,
  321. editableSelect: true,
  322. placeholderTextSelect: true,
  323. })
  324. const btnModalButton = await page.$('#btn-modal-show')
  325. await btnModalButton.tap()
  326. await page.waitFor(500);
  327. if (isApp) {
  328. const image = await program.screenshot({
  329. deviceShot: true,
  330. area: {
  331. x: 0,
  332. y: topSafeArea + 44,
  333. },
  334. });
  335. expect(image).toSaveImageSnapshot();
  336. }else{
  337. const image = await program.screenshot({
  338. deviceShot: true,
  339. fullPage: true
  340. });
  341. expect(image).toSaveImageSnapshot()
  342. }
  343. await page.waitFor(2000);
  344. })
  345. it("modal-test-current-2-showCancel-editable-placeholder", async () => {
  346. /**
  347. * 延迟3s 关闭
  348. */
  349. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  350. await btnModalButtonHideLast.tap()
  351. await page.waitFor(500);
  352. await page.setData({
  353. current: 2,
  354. showCancelSelect: true,
  355. cancelTextSelect: false,
  356. confirmTextSelect: false,
  357. editableSelect: true,
  358. placeholderTextSelect: true,
  359. })
  360. const btnModalButton = await page.$('#btn-modal-show')
  361. await btnModalButton.tap()
  362. await page.waitFor(500);
  363. if (isApp) {
  364. const image = await program.screenshot({
  365. deviceShot: true,
  366. area: {
  367. x: 0,
  368. y: topSafeArea + 44,
  369. },
  370. });
  371. expect(image).toSaveImageSnapshot();
  372. }else{
  373. const image = await program.screenshot({
  374. deviceShot: true,
  375. fullPage: true
  376. });
  377. expect(image).toSaveImageSnapshot()
  378. }
  379. await page.waitFor(2000);
  380. })
  381. it("modal-test-current-2-showCancel-placeholder", async () => {
  382. /**
  383. * 延迟3s 关闭
  384. */
  385. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  386. await btnModalButtonHideLast.tap()
  387. await page.waitFor(500);
  388. await page.setData({
  389. current: 2,
  390. showCancelSelect: true,
  391. cancelTextSelect: false,
  392. confirmTextSelect: false,
  393. editableSelect: false,
  394. placeholderTextSelect: true,
  395. })
  396. const btnModalButton = await page.$('#btn-modal-show')
  397. await btnModalButton.tap()
  398. await page.waitFor(500);
  399. if (isApp) {
  400. const image = await program.screenshot({
  401. deviceShot: true,
  402. area: {
  403. x: 0,
  404. y: topSafeArea + 44,
  405. },
  406. });
  407. expect(image).toSaveImageSnapshot();
  408. }else{
  409. const image = await program.screenshot({
  410. deviceShot: true,
  411. fullPage: true
  412. });
  413. expect(image).toSaveImageSnapshot()
  414. }
  415. await page.waitFor(2000);
  416. })
  417. it("modal-test-current-2-showCancel", async () => {
  418. /**
  419. * 延迟3s 关闭
  420. */
  421. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  422. await btnModalButtonHideLast.tap()
  423. await page.waitFor(500);
  424. await page.setData({
  425. current: 2,
  426. showCancelSelect: true,
  427. cancelTextSelect: false,
  428. confirmTextSelect: false,
  429. editableSelect: false,
  430. placeholderTextSelect: false,
  431. })
  432. const btnModalButton = await page.$('#btn-modal-show')
  433. await btnModalButton.tap()
  434. await page.waitFor(500);
  435. if (isApp) {
  436. const image = await program.screenshot({
  437. deviceShot: true,
  438. area: {
  439. x: 0,
  440. y: topSafeArea + 44,
  441. },
  442. });
  443. expect(image).toSaveImageSnapshot();
  444. }else{
  445. const image = await program.screenshot({
  446. deviceShot: true,
  447. fullPage: true
  448. });
  449. expect(image).toSaveImageSnapshot()
  450. }
  451. await page.waitFor(2000);
  452. })
  453. it("modal-test-current-2-showCancel-cancelText-editable-placeholder", async () => {
  454. /**
  455. * 延迟3s 关闭
  456. */
  457. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  458. await btnModalButtonHideLast.tap()
  459. await page.waitFor(500);
  460. await page.setData({
  461. current: 2,
  462. showCancelSelect: true,
  463. cancelTextSelect: true,
  464. confirmTextSelect: false,
  465. editableSelect: true,
  466. placeholderTextSelect: true,
  467. })
  468. const btnModalButton = await page.$('#btn-modal-show')
  469. await btnModalButton.tap()
  470. await page.waitFor(500);
  471. if (isApp) {
  472. const image = await program.screenshot({
  473. deviceShot: true,
  474. area: {
  475. x: 0,
  476. y: topSafeArea + 44,
  477. },
  478. });
  479. expect(image).toSaveImageSnapshot();
  480. }else{
  481. const image = await program.screenshot({
  482. deviceShot: true,
  483. fullPage: true
  484. });
  485. expect(image).toSaveImageSnapshot()
  486. }
  487. await page.waitFor(2000);
  488. })
  489. it("modal-test-current-2-showCancel-cancelText-placeholder", async () => {
  490. /**
  491. * 延迟3s 关闭
  492. */
  493. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  494. await btnModalButtonHideLast.tap()
  495. await page.waitFor(500);
  496. await page.setData({
  497. current: 2,
  498. showCancelSelect: true,
  499. cancelTextSelect: true,
  500. confirmTextSelect: false,
  501. editableSelect: false,
  502. placeholderTextSelect: true,
  503. })
  504. const btnModalButton = await page.$('#btn-modal-show')
  505. await btnModalButton.tap()
  506. await page.waitFor(500);
  507. if (isApp) {
  508. const image = await program.screenshot({
  509. deviceShot: true,
  510. area: {
  511. x: 0,
  512. y: topSafeArea + 44,
  513. },
  514. });
  515. expect(image).toSaveImageSnapshot();
  516. }else{
  517. const image = await program.screenshot({
  518. deviceShot: true,
  519. fullPage: true
  520. });
  521. expect(image).toSaveImageSnapshot()
  522. }
  523. await page.waitFor(2000);
  524. })
  525. it("modal-test-current-2-showCancel-cancelText", async () => {
  526. /**
  527. * 延迟3s 关闭
  528. */
  529. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  530. await btnModalButtonHideLast.tap()
  531. await page.waitFor(500);
  532. await page.setData({
  533. current: 2,
  534. showCancelSelect: true,
  535. cancelTextSelect: true,
  536. confirmTextSelect: false,
  537. editableSelect: false,
  538. placeholderTextSelect: false,
  539. })
  540. const btnModalButton = await page.$('#btn-modal-show')
  541. await btnModalButton.tap()
  542. await page.waitFor(500);
  543. if (isApp) {
  544. const image = await program.screenshot({
  545. deviceShot: true,
  546. area: {
  547. x: 0,
  548. y: topSafeArea + 44,
  549. },
  550. });
  551. expect(image).toSaveImageSnapshot();
  552. }else{
  553. const image = await program.screenshot({
  554. deviceShot: true,
  555. fullPage: true
  556. });
  557. expect(image).toSaveImageSnapshot()
  558. }
  559. await page.waitFor(2000);
  560. })
  561. it("modal-test-current-2-showCancel-cancelText-confirmText-placeholder", async () => {
  562. /**
  563. * 延迟3s 关闭
  564. */
  565. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  566. await btnModalButtonHideLast.tap()
  567. await page.waitFor(500);
  568. await page.setData({
  569. current: 2,
  570. showCancelSelect: true,
  571. cancelTextSelect: true,
  572. confirmTextSelect: true,
  573. editableSelect: false,
  574. placeholderTextSelect: true,
  575. })
  576. const btnModalButton = await page.$('#btn-modal-show')
  577. await btnModalButton.tap()
  578. await page.waitFor(500);
  579. if (isApp) {
  580. const image = await program.screenshot({
  581. deviceShot: true,
  582. area: {
  583. x: 0,
  584. y: topSafeArea + 44,
  585. },
  586. });
  587. expect(image).toSaveImageSnapshot();
  588. }else{
  589. const image = await program.screenshot({
  590. deviceShot: true,
  591. fullPage: true
  592. });
  593. expect(image).toSaveImageSnapshot()
  594. }
  595. await page.waitFor(2000);
  596. })
  597. it("modal-test-current-2-showCancel-cancelText-confirmText", async () => {
  598. /**
  599. * 延迟3s 关闭
  600. */
  601. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  602. await btnModalButtonHideLast.tap()
  603. await page.waitFor(500);
  604. await page.setData({
  605. current: 2,
  606. showCancelSelect: true,
  607. cancelTextSelect: true,
  608. confirmTextSelect: true,
  609. editableSelect: false,
  610. placeholderTextSelect: false,
  611. })
  612. const btnModalButton = await page.$('#btn-modal-show')
  613. await btnModalButton.tap()
  614. await page.waitFor(500);
  615. if (isApp) {
  616. const image = await program.screenshot({
  617. deviceShot: true,
  618. area: {
  619. x: 0,
  620. y: topSafeArea + 44,
  621. },
  622. });
  623. expect(image).toSaveImageSnapshot();
  624. }else{
  625. const image = await program.screenshot({
  626. deviceShot: true,
  627. fullPage: true
  628. });
  629. expect(image).toSaveImageSnapshot()
  630. }
  631. await page.waitFor(2000);
  632. })
  633. it("modal-test-current-2-showCancel-cancelText-confirmText-editable", async () => {
  634. /**
  635. * 延迟3s 关闭
  636. */
  637. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  638. await btnModalButtonHideLast.tap()
  639. await page.waitFor(500);
  640. await page.setData({
  641. current: 2,
  642. showCancelSelect: true,
  643. cancelTextSelect: true,
  644. confirmTextSelect: true,
  645. editableSelect: true,
  646. placeholderTextSelect: false,
  647. })
  648. const btnModalButton = await page.$('#btn-modal-show')
  649. await btnModalButton.tap()
  650. await page.waitFor(500);
  651. if (isApp) {
  652. const image = await program.screenshot({
  653. deviceShot: true,
  654. area: {
  655. x: 0,
  656. y: topSafeArea + 44,
  657. },
  658. });
  659. expect(image).toSaveImageSnapshot();
  660. }else{
  661. const image = await program.screenshot({
  662. deviceShot: true,
  663. fullPage: true
  664. });
  665. expect(image).toSaveImageSnapshot()
  666. }
  667. await page.waitFor(2000);
  668. })
  669. it("modal-test-current-0-multi-time-show-hideall", async () => {
  670. await page.setData({
  671. current: 0,
  672. })
  673. /**
  674. * 延迟3s 关闭
  675. */
  676. const btnModalButtonHideAll = await page.$('#btn-modal-hide-all')
  677. await btnModalButtonHideAll.tap()
  678. await page.waitFor(500);
  679. /**
  680. * 等待1s 出现三个截图
  681. */
  682. const btnModalButtonMultiTime = await page.$('#btn-modal-show-multitime')
  683. await btnModalButtonMultiTime.tap()
  684. await page.waitFor(1000);
  685. if (isApp) {
  686. const image = await program.screenshot({
  687. deviceShot: true,
  688. area: {
  689. x: 0,
  690. y: topSafeArea + 44,
  691. },
  692. });
  693. expect(image).toSaveImageSnapshot();
  694. }else{
  695. const image = await program.screenshot({
  696. deviceShot: true,
  697. fullPage: true
  698. });
  699. expect(image).toSaveImageSnapshot()
  700. }
  701. /**
  702. * 等待2s 全部关闭全部
  703. */
  704. await page.waitFor(2000);
  705. if (isApp) {
  706. const image = await program.screenshot({
  707. deviceShot: true,
  708. area: {
  709. x: 0,
  710. y: topSafeArea + 44,
  711. },
  712. });
  713. expect(image).toSaveImageSnapshot();
  714. }else{
  715. const image = await program.screenshot({
  716. deviceShot: true,
  717. fullPage: true
  718. });
  719. expect(image).toSaveImageSnapshot()
  720. }
  721. })
  722. it("modal-test-current-1-multi-time-show-hidelast", async () => {
  723. await page.setData({
  724. current: 1,
  725. })
  726. /**
  727. * 延迟3s 关闭最后一个
  728. */
  729. const btnModalButtonHideLast = await page.$('#btn-modal-hide-last')
  730. await btnModalButtonHideLast.tap()
  731. await page.waitFor(500);
  732. /**
  733. * 等待1s 出现三个截图
  734. */
  735. const btnModalButtonMultiTime = await page.$('#btn-modal-show-multitime')
  736. await btnModalButtonMultiTime.tap()
  737. await page.waitFor(1000);
  738. if (isApp) {
  739. const image = await program.screenshot({
  740. deviceShot: true,
  741. area: {
  742. x: 0,
  743. y: topSafeArea + 44,
  744. },
  745. });
  746. expect(image).toSaveImageSnapshot();
  747. }else{
  748. const image = await program.screenshot({
  749. deviceShot: true,
  750. fullPage: true
  751. });
  752. expect(image).toSaveImageSnapshot()
  753. }
  754. /**
  755. * 等待2s 还剩下两个
  756. */
  757. await page.waitFor(2000);
  758. if (isApp) {
  759. const image = await program.screenshot({
  760. deviceShot: true,
  761. area: {
  762. x: 0,
  763. y: topSafeArea + 44,
  764. },
  765. });
  766. expect(image).toSaveImageSnapshot();
  767. }else{
  768. const image = await program.screenshot({
  769. deviceShot: true,
  770. fullPage: true
  771. });
  772. expect(image).toSaveImageSnapshot()
  773. }
  774. })
  775. });