spana-test 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/dist/accessibility-audit-IWTD2HPR.js +17 -0
  2. package/dist/agent/index.js +35 -33
  3. package/dist/agent/index.js.map +1 -1
  4. package/dist/{agent-fixture-H6GOUHNX.js → agent-fixture-WQVCNL73.js} +4 -3
  5. package/dist/{allure-XOM7BXL5.js → allure-LF4CALKP.js} +3 -2
  6. package/dist/{allure-XOM7BXL5.js.map → allure-LF4CALKP.js.map} +1 -1
  7. package/dist/{android-C2S4B4TH.js → android-TPO53H5Q.js} +4 -3
  8. package/dist/api/app.d.ts +76 -13
  9. package/dist/api/app.d.ts.map +1 -1
  10. package/dist/api/expect.d.ts +1 -0
  11. package/dist/api/expect.d.ts.map +1 -1
  12. package/dist/api/flow.d.ts +37 -14
  13. package/dist/api/flow.d.ts.map +1 -1
  14. package/dist/app-TX4RYRBY.js +17 -0
  15. package/dist/{appium-CC77BJNK.js → appium-OI2CQON6.js} +13 -12
  16. package/dist/{appium-CC77BJNK.js.map → appium-OI2CQON6.js.map} +1 -1
  17. package/dist/{appium-server-M6CWWUWF.js → appium-server-CCTQQGTV.js} +3 -2
  18. package/dist/{appium-server-M6CWWUWF.js.map → appium-server-CCTQQGTV.js.map} +1 -1
  19. package/dist/{baseline-manager-LVUVH2MJ.js → baseline-manager-XJ3LADKC.js} +3 -2
  20. package/dist/{baseline-manager-LVUVH2MJ.js.map → baseline-manager-XJ3LADKC.js.map} +1 -1
  21. package/dist/bridge-server-X5W4PCAR.js +13 -0
  22. package/dist/cache-command-OMV6DPC7.js +13 -0
  23. package/dist/channels/cdp-client.d.ts +15 -2
  24. package/dist/channels/cdp-client.d.ts.map +1 -1
  25. package/dist/channels/dom-channel.d.ts +28 -1
  26. package/dist/channels/dom-channel.d.ts.map +1 -1
  27. package/dist/{chunk-GMEVJQTT.js → chunk-22VPSGCA.js} +5 -4
  28. package/dist/{chunk-GMEVJQTT.js.map → chunk-22VPSGCA.js.map} +1 -1
  29. package/dist/{chunk-WJH5K42V.js → chunk-3HQKY24K.js} +4 -3
  30. package/dist/{chunk-WJH5K42V.js.map → chunk-3HQKY24K.js.map} +1 -1
  31. package/dist/{chunk-7O5YXVCD.js → chunk-3NZRRXDP.js} +4 -3
  32. package/dist/{chunk-7O5YXVCD.js.map → chunk-3NZRRXDP.js.map} +1 -1
  33. package/dist/{chunk-HJZT6YOA.js → chunk-4GESFVZL.js} +6 -5
  34. package/dist/{chunk-HJZT6YOA.js.map → chunk-4GESFVZL.js.map} +1 -1
  35. package/dist/{chunk-4LJ3KYCX.js → chunk-5DSPPJ76.js} +4 -3
  36. package/dist/{chunk-4LJ3KYCX.js.map → chunk-5DSPPJ76.js.map} +1 -1
  37. package/dist/{accessibility-audit-F5KLUHLS.js → chunk-5TAHLRZD.js} +8 -5
  38. package/dist/chunk-5TAHLRZD.js.map +1 -0
  39. package/dist/{chunk-7K7WVTFZ.js → chunk-7YJBZ4HB.js} +19 -18
  40. package/dist/{chunk-7K7WVTFZ.js.map → chunk-7YJBZ4HB.js.map} +1 -1
  41. package/dist/{chunk-2MA5G2VH.js → chunk-AGG2RJGU.js} +4 -3
  42. package/dist/{chunk-2MA5G2VH.js.map → chunk-AGG2RJGU.js.map} +1 -1
  43. package/dist/{chunk-NWGA3R2E.js → chunk-B4FOISOF.js} +3 -2
  44. package/dist/{chunk-NWGA3R2E.js.map → chunk-B4FOISOF.js.map} +1 -1
  45. package/dist/{chunk-7Q7TSUNL.js → chunk-B6NTHBPF.js} +3 -2
  46. package/dist/{chunk-7Q7TSUNL.js.map → chunk-B6NTHBPF.js.map} +1 -1
  47. package/dist/{chunk-CA66JCX2.js → chunk-CR55BHI2.js} +729 -187
  48. package/dist/chunk-CR55BHI2.js.map +1 -0
  49. package/dist/{chunk-JRGJTUPS.js → chunk-CXXK3JAI.js} +5 -4
  50. package/dist/{chunk-JRGJTUPS.js.map → chunk-CXXK3JAI.js.map} +1 -1
  51. package/dist/{chunk-GDVHJBR2.js → chunk-CZAFFUMN.js} +5 -4
  52. package/dist/{chunk-GDVHJBR2.js.map → chunk-CZAFFUMN.js.map} +1 -1
  53. package/dist/{chunk-FSPMFRJO.js → chunk-FBJPNZUN.js} +3 -2
  54. package/dist/{chunk-FSPMFRJO.js.map → chunk-FBJPNZUN.js.map} +1 -1
  55. package/dist/{chunk-HIEOI3WN.js → chunk-FCUT3OKD.js} +261 -51
  56. package/dist/chunk-FCUT3OKD.js.map +1 -0
  57. package/dist/{chunk-WBCAF7SC.js → chunk-FPCMRYOS.js} +283 -152
  58. package/dist/chunk-FPCMRYOS.js.map +1 -0
  59. package/dist/{chunk-6C2EILMC.js → chunk-FWFT3FEP.js} +3 -2
  60. package/dist/{chunk-6C2EILMC.js.map → chunk-FWFT3FEP.js.map} +1 -1
  61. package/dist/{chunk-X5FRYDZ3.js → chunk-GACJRITH.js} +4 -3
  62. package/dist/{chunk-X5FRYDZ3.js.map → chunk-GACJRITH.js.map} +1 -1
  63. package/dist/{chunk-EA7DZ5TN.js → chunk-GS7DRAOQ.js} +38 -4
  64. package/dist/chunk-GS7DRAOQ.js.map +1 -0
  65. package/dist/{chunk-K4K2ACT2.js → chunk-H5ZMLSVC.js} +8 -7
  66. package/dist/chunk-H5ZMLSVC.js.map +1 -0
  67. package/dist/{chunk-5WPPWTC3.js → chunk-HFQ3KKIB.js} +1620 -528
  68. package/dist/chunk-HFQ3KKIB.js.map +1 -0
  69. package/dist/{chunk-MUMIMDRJ.js → chunk-IKMNHITS.js} +3 -2
  70. package/dist/{chunk-MUMIMDRJ.js.map → chunk-IKMNHITS.js.map} +1 -1
  71. package/dist/{chunk-UZU7VYKN.js → chunk-KRATI3A5.js} +169 -28
  72. package/dist/chunk-KRATI3A5.js.map +1 -0
  73. package/dist/{chunk-TFEXYI6N.js → chunk-KRTQZPYL.js} +3 -2
  74. package/dist/{chunk-TFEXYI6N.js.map → chunk-KRTQZPYL.js.map} +1 -1
  75. package/dist/{chunk-ZCSH3QKX.js → chunk-L5EVAGCV.js} +1188 -891
  76. package/dist/chunk-L5EVAGCV.js.map +1 -0
  77. package/dist/{chunk-MPJCUL2B.js → chunk-MQRGWQI5.js} +3 -2
  78. package/dist/{chunk-MPJCUL2B.js.map → chunk-MQRGWQI5.js.map} +1 -1
  79. package/dist/{chunk-ZIETAMAD.js → chunk-NQYTD3JG.js} +3 -2
  80. package/dist/{chunk-ZIETAMAD.js.map → chunk-NQYTD3JG.js.map} +1 -1
  81. package/dist/{chunk-YFTHJRDO.js → chunk-ODRB22QA.js} +3 -2
  82. package/dist/{chunk-YFTHJRDO.js.map → chunk-ODRB22QA.js.map} +1 -1
  83. package/dist/{chunk-KIFNHFFI.js → chunk-OKU46IDG.js} +273 -33
  84. package/dist/chunk-OKU46IDG.js.map +1 -0
  85. package/dist/{chunk-HNQLWFHL.js → chunk-OYME74M3.js} +3 -2
  86. package/dist/{chunk-HNQLWFHL.js.map → chunk-OYME74M3.js.map} +1 -1
  87. package/dist/{chunk-62SDNQKK.js → chunk-QJPIPZ4S.js} +7 -6
  88. package/dist/{chunk-62SDNQKK.js.map → chunk-QJPIPZ4S.js.map} +1 -1
  89. package/dist/{chunk-UKUXNFQP.js → chunk-QU365GZA.js} +3 -2
  90. package/dist/{chunk-UKUXNFQP.js.map → chunk-QU365GZA.js.map} +1 -1
  91. package/dist/{chunk-HIGFQRWM.js → chunk-R52P4KQC.js} +3 -2
  92. package/dist/{chunk-HIGFQRWM.js.map → chunk-R52P4KQC.js.map} +1 -1
  93. package/dist/{chunk-U56N5JCJ.js → chunk-RL3ICBAB.js} +3 -2
  94. package/dist/{chunk-U56N5JCJ.js.map → chunk-RL3ICBAB.js.map} +1 -1
  95. package/dist/{chunk-HUYC4OAL.js → chunk-RQRJ2I2Z.js} +3 -2
  96. package/dist/{chunk-HUYC4OAL.js.map → chunk-RQRJ2I2Z.js.map} +1 -1
  97. package/dist/{chunk-LGFTUVN4.js → chunk-RXQKH6Z7.js} +11 -10
  98. package/dist/{chunk-LGFTUVN4.js.map → chunk-RXQKH6Z7.js.map} +1 -1
  99. package/dist/{chunk-NXET4BFJ.js → chunk-SPGD4QGA.js} +3 -2
  100. package/dist/{chunk-NXET4BFJ.js.map → chunk-SPGD4QGA.js.map} +1 -1
  101. package/dist/{chunk-XVL4FHXA.js → chunk-T46S4VA3.js} +3 -2
  102. package/dist/{chunk-XVL4FHXA.js.map → chunk-T46S4VA3.js.map} +1 -1
  103. package/dist/{chunk-GLNTGHR6.js → chunk-T7Z2T3NP.js} +4 -3
  104. package/dist/{chunk-GLNTGHR6.js.map → chunk-T7Z2T3NP.js.map} +1 -1
  105. package/dist/{chunk-RIXZISMX.js → chunk-V6PEMZCL.js} +3 -2
  106. package/dist/{chunk-RIXZISMX.js.map → chunk-V6PEMZCL.js.map} +1 -1
  107. package/dist/{chunk-FTXUQMGH.js → chunk-VBAPZMPX.js} +2 -1
  108. package/dist/{chunk-FTXUQMGH.js.map → chunk-VBAPZMPX.js.map} +1 -1
  109. package/dist/{chunk-DMF2BPPA.js → chunk-VILLVGBP.js} +3 -2
  110. package/dist/{chunk-DMF2BPPA.js.map → chunk-VILLVGBP.js.map} +1 -1
  111. package/dist/{chunk-A7Z52TDQ.js → chunk-WPG77TPT.js} +3 -2
  112. package/dist/{chunk-A7Z52TDQ.js.map → chunk-WPG77TPT.js.map} +1 -1
  113. package/dist/{chunk-7WHQIQPM.js → chunk-WZY3MBNG.js} +3 -2
  114. package/dist/{chunk-7WHQIQPM.js.map → chunk-WZY3MBNG.js.map} +1 -1
  115. package/dist/{chunk-XD6A3VXB.js → chunk-X5W7LV2O.js} +8 -7
  116. package/dist/chunk-X5W7LV2O.js.map +1 -0
  117. package/dist/{chunk-4TYO6O7T.js → chunk-XG6UF6BP.js} +12 -11
  118. package/dist/{chunk-4TYO6O7T.js.map → chunk-XG6UF6BP.js.map} +1 -1
  119. package/dist/{chunk-NHT3XSX3.js → chunk-XGXOE3DF.js} +3 -2
  120. package/dist/{chunk-NHT3XSX3.js.map → chunk-XGXOE3DF.js.map} +1 -1
  121. package/dist/{chunk-PRQTAIYA.js → chunk-XPEWAHAK.js} +4 -3
  122. package/dist/{chunk-PRQTAIYA.js.map → chunk-XPEWAHAK.js.map} +1 -1
  123. package/dist/{chunk-FHCOPLYB.js → chunk-YNA6LFBF.js} +3 -2
  124. package/dist/{chunk-FHCOPLYB.js.map → chunk-YNA6LFBF.js.map} +1 -1
  125. package/dist/{chunk-HWS3XUEF.js → chunk-YWASMWPK.js} +5 -4
  126. package/dist/{chunk-HWS3XUEF.js.map → chunk-YWASMWPK.js.map} +1 -1
  127. package/dist/cli/test-command.d.ts +2 -0
  128. package/dist/cli/test-command.d.ts.map +1 -1
  129. package/dist/cli.js +102 -35
  130. package/dist/cli.js.map +1 -1
  131. package/dist/{compiler-44UW2FID.js → compiler-UOVKUQHE.js} +4 -3
  132. package/dist/{compiler-44UW2FID.js.map → compiler-UOVKUQHE.js.map} +1 -1
  133. package/dist/config-loader-OSHDDKH5.js +11 -0
  134. package/dist/{console-T6TVZ65G.js → console-OHKVJLW3.js} +39 -6
  135. package/dist/console-OHKVJLW3.js.map +1 -0
  136. package/dist/core/accessibility-audit.d.ts.map +1 -1
  137. package/dist/core/engine.d.ts +1 -1
  138. package/dist/core/engine.d.ts.map +1 -1
  139. package/dist/core/orchestrator.d.ts +1 -0
  140. package/dist/core/orchestrator.d.ts.map +1 -1
  141. package/dist/core/projects.d.ts +10 -6
  142. package/dist/core/projects.d.ts.map +1 -1
  143. package/dist/{daemon-manager-2SK5PHJR.js → daemon-manager-VEMRSZ5R.js} +4 -3
  144. package/dist/discover-AHMM7QLN.js +16 -0
  145. package/dist/{doctor-command-UUQ4RFMK.js → doctor-command-2O4VK3QR.js} +17 -16
  146. package/dist/{doctor-command-UUQ4RFMK.js.map → doctor-command-2O4VK3QR.js.map} +1 -1
  147. package/dist/driver-BHHIEDX6.js +20 -0
  148. package/dist/driver-ZVDLV6QF.js +20 -0
  149. package/dist/drivers/cdp-browser.d.ts +21 -2
  150. package/dist/drivers/cdp-browser.d.ts.map +1 -1
  151. package/dist/drivers/cdp-embed.d.ts +104 -0
  152. package/dist/drivers/cdp-embed.d.ts.map +1 -0
  153. package/dist/drivers/playwright.d.ts +16 -7
  154. package/dist/drivers/playwright.d.ts.map +1 -1
  155. package/dist/drivers/raw-driver.d.ts +36 -3
  156. package/dist/drivers/raw-driver.d.ts.map +1 -1
  157. package/dist/electrobun-4Z66F5NW.js +16 -0
  158. package/dist/electron-ZXM6SMZU.js +10 -0
  159. package/dist/{filters-5DCGGJRN.js → filters-6W73R3IV.js} +4 -3
  160. package/dist/gherkin/steps.js +3 -2
  161. package/dist/gherkin/steps.js.map +1 -1
  162. package/dist/github-pr-XZZZ3YE6.js +11 -0
  163. package/dist/{html-KJ2QAGF4.js → html-GDWXFYFL.js} +4 -3
  164. package/dist/{html-KJ2QAGF4.js.map → html-GDWXFYFL.js.map} +1 -1
  165. package/dist/index.d.ts +8 -5
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.js +200 -84
  168. package/dist/index.js.map +1 -1
  169. package/dist/{init-command-V5VGN3IS.js → init-command-PYZ5X6M5.js} +3 -2
  170. package/dist/{init-command-V5VGN3IS.js.map → init-command-PYZ5X6M5.js.map} +1 -1
  171. package/dist/{init-flow-command-INYUCC6N.js → init-flow-command-SLLEGSRZ.js} +4 -3
  172. package/dist/{init-flow-command-INYUCC6N.js.map → init-flow-command-SLLEGSRZ.js.map} +1 -1
  173. package/dist/installer-6HV5CU2I.js +18 -0
  174. package/dist/{installer-DMTY47SI.js → installer-DYGA4MRU.js} +6 -5
  175. package/dist/{ios-SZ4RBI7Q.js → ios-YFRAK2CL.js} +5 -4
  176. package/dist/{json-67HY4VQK.js → json-QVHG6I3O.js} +3 -2
  177. package/dist/{json-67HY4VQK.js.map → json-QVHG6I3O.js.map} +1 -1
  178. package/dist/{junit-MHD5AXBU.js → junit-G5LNOYUL.js} +3 -2
  179. package/dist/{junit-MHD5AXBU.js.map → junit-G5LNOYUL.js.map} +1 -1
  180. package/dist/local-OYNEJSSQ.js +37 -0
  181. package/dist/{machine-NOOFRT45.js → machine-VEVBT2GU.js} +4 -3
  182. package/dist/pagesource-GQLIXL5R.js +10 -0
  183. package/dist/pagesource-HKLE3FZN.js +10 -0
  184. package/dist/playwright-SZP56NN2.js +29 -0
  185. package/dist/provider-FKT6FEQS.js +13 -0
  186. package/dist/{redact-OG4M3IEU.js → redact-YWR6GHBX.js} +3 -2
  187. package/dist/{redact-OG4M3IEU.js.map → redact-YWR6GHBX.js.map} +1 -1
  188. package/dist/report/console.d.ts +2 -0
  189. package/dist/report/console.d.ts.map +1 -1
  190. package/dist/report/types.d.ts +2 -0
  191. package/dist/report/types.d.ts.map +1 -1
  192. package/dist/{runner-ABGUVOJG.js → runner-P2BFG4VZ.js} +4 -3
  193. package/dist/runtime/local.d.ts +13 -0
  194. package/dist/runtime/local.d.ts.map +1 -1
  195. package/dist/runtime/web-server.d.ts +5 -1
  196. package/dist/runtime/web-server.d.ts.map +1 -1
  197. package/dist/schemas/config.d.ts +74 -5
  198. package/dist/schemas/config.d.ts.map +1 -1
  199. package/dist/schemas/selector.d.ts +6 -2
  200. package/dist/schemas/selector.d.ts.map +1 -1
  201. package/dist/screenshot-compare-7TE44H7F.js +13 -0
  202. package/dist/{server-RTDMJIQZ.js → server-7QYNULRB.js} +36 -34
  203. package/dist/{server-RTDMJIQZ.js.map → server-7QYNULRB.js.map} +1 -1
  204. package/dist/server-VIXRVKP5.js +15 -0
  205. package/dist/session-3KME2U42.js +41 -0
  206. package/dist/smart/auto-wait.d.ts.map +1 -1
  207. package/dist/smart/coordinator.d.ts +11 -2
  208. package/dist/smart/coordinator.d.ts.map +1 -1
  209. package/dist/smart/diagnostics.d.ts.map +1 -1
  210. package/dist/smart/element-matcher.d.ts.map +1 -1
  211. package/dist/{studio-command-PZHMLCKE.js → studio-command-ALDWIKEE.js} +4 -3
  212. package/dist/{studio-command-PZHMLCKE.js.map → studio-command-ALDWIKEE.js.map} +1 -1
  213. package/dist/{test-command-FJOP2GYD.js → test-command-HP5YE675.js} +444 -83
  214. package/dist/test-command-HP5YE675.js.map +1 -0
  215. package/dist/validator-6XP3PGCP.js +18 -0
  216. package/dist/watch-mode-HWZ4XCKH.js +11 -0
  217. package/dist/watch-mode-HWZ4XCKH.js.map +1 -0
  218. package/native/darwin-arm64/libspana_native.dylib +0 -0
  219. package/native/darwin-x64/libspana_native.dylib +0 -0
  220. package/native/linux-arm64/libspana_native.so +0 -0
  221. package/native/linux-x64/libspana_native.so +0 -0
  222. package/native/win32-x64/spana_native.dll +0 -0
  223. package/package.json +1 -1
  224. package/dist/accessibility-audit-F5KLUHLS.js.map +0 -1
  225. package/dist/app-C353NGBT.js +0 -13
  226. package/dist/bridge-server-S3DHK7XE.js +0 -12
  227. package/dist/cache-command-OL7HUK2K.js +0 -12
  228. package/dist/chunk-5WPPWTC3.js.map +0 -1
  229. package/dist/chunk-CA66JCX2.js.map +0 -1
  230. package/dist/chunk-EA7DZ5TN.js.map +0 -1
  231. package/dist/chunk-HIEOI3WN.js.map +0 -1
  232. package/dist/chunk-K4K2ACT2.js.map +0 -1
  233. package/dist/chunk-KIFNHFFI.js.map +0 -1
  234. package/dist/chunk-UZU7VYKN.js.map +0 -1
  235. package/dist/chunk-WBCAF7SC.js.map +0 -1
  236. package/dist/chunk-XD6A3VXB.js.map +0 -1
  237. package/dist/chunk-ZCSH3QKX.js.map +0 -1
  238. package/dist/config-loader-TSADVSBY.js +0 -10
  239. package/dist/console-T6TVZ65G.js.map +0 -1
  240. package/dist/discover-6ULCTB5T.js +0 -15
  241. package/dist/driver-3HBDKESK.js +0 -19
  242. package/dist/driver-LKXSKNG3.js +0 -19
  243. package/dist/electrobun-HILYDIJ3.js +0 -15
  244. package/dist/electron-SQACDON3.js +0 -9
  245. package/dist/github-pr-RYO6IAKD.js +0 -10
  246. package/dist/installer-KL2NCILK.js +0 -17
  247. package/dist/local-J2NC6YKI.js +0 -30
  248. package/dist/pagesource-KIQ5T5MA.js +0 -9
  249. package/dist/pagesource-KKG7WMFJ.js +0 -9
  250. package/dist/playwright-JMHCABDJ.js +0 -28
  251. package/dist/provider-CBAXZ2VA.js +0 -12
  252. package/dist/screenshot-compare-BJRJHKNQ.js +0 -12
  253. package/dist/server-RHAHCANZ.js +0 -14
  254. package/dist/session-7CWHTQ2E.js +0 -39
  255. package/dist/test-command-FJOP2GYD.js.map +0 -1
  256. package/dist/validator-AJNOFBQM.js +0 -17
  257. package/dist/watch-mode-NR5MHNNL.js +0 -10
  258. /package/dist/{agent-fixture-H6GOUHNX.js.map → accessibility-audit-IWTD2HPR.js.map} +0 -0
  259. /package/dist/{android-C2S4B4TH.js.map → agent-fixture-WQVCNL73.js.map} +0 -0
  260. /package/dist/{app-C353NGBT.js.map → android-TPO53H5Q.js.map} +0 -0
  261. /package/dist/{bridge-server-S3DHK7XE.js.map → app-TX4RYRBY.js.map} +0 -0
  262. /package/dist/{cache-command-OL7HUK2K.js.map → bridge-server-X5W4PCAR.js.map} +0 -0
  263. /package/dist/{config-loader-TSADVSBY.js.map → cache-command-OMV6DPC7.js.map} +0 -0
  264. /package/dist/{daemon-manager-2SK5PHJR.js.map → config-loader-OSHDDKH5.js.map} +0 -0
  265. /package/dist/{discover-6ULCTB5T.js.map → daemon-manager-VEMRSZ5R.js.map} +0 -0
  266. /package/dist/{driver-3HBDKESK.js.map → discover-AHMM7QLN.js.map} +0 -0
  267. /package/dist/{driver-LKXSKNG3.js.map → driver-BHHIEDX6.js.map} +0 -0
  268. /package/dist/{electrobun-HILYDIJ3.js.map → driver-ZVDLV6QF.js.map} +0 -0
  269. /package/dist/{electron-SQACDON3.js.map → electrobun-4Z66F5NW.js.map} +0 -0
  270. /package/dist/{filters-5DCGGJRN.js.map → electron-ZXM6SMZU.js.map} +0 -0
  271. /package/dist/{github-pr-RYO6IAKD.js.map → filters-6W73R3IV.js.map} +0 -0
  272. /package/dist/{installer-DMTY47SI.js.map → github-pr-XZZZ3YE6.js.map} +0 -0
  273. /package/dist/{installer-KL2NCILK.js.map → installer-6HV5CU2I.js.map} +0 -0
  274. /package/dist/{ios-SZ4RBI7Q.js.map → installer-DYGA4MRU.js.map} +0 -0
  275. /package/dist/{local-J2NC6YKI.js.map → ios-YFRAK2CL.js.map} +0 -0
  276. /package/dist/{machine-NOOFRT45.js.map → local-OYNEJSSQ.js.map} +0 -0
  277. /package/dist/{pagesource-KIQ5T5MA.js.map → machine-VEVBT2GU.js.map} +0 -0
  278. /package/dist/{pagesource-KKG7WMFJ.js.map → pagesource-GQLIXL5R.js.map} +0 -0
  279. /package/dist/{playwright-JMHCABDJ.js.map → pagesource-HKLE3FZN.js.map} +0 -0
  280. /package/dist/{provider-CBAXZ2VA.js.map → playwright-SZP56NN2.js.map} +0 -0
  281. /package/dist/{runner-ABGUVOJG.js.map → provider-FKT6FEQS.js.map} +0 -0
  282. /package/dist/{screenshot-compare-BJRJHKNQ.js.map → runner-P2BFG4VZ.js.map} +0 -0
  283. /package/dist/{server-RHAHCANZ.js.map → screenshot-compare-7TE44H7F.js.map} +0 -0
  284. /package/dist/{session-7CWHTQ2E.js.map → server-VIXRVKP5.js.map} +0 -0
  285. /package/dist/{validator-AJNOFBQM.js.map → session-3KME2U42.js.map} +0 -0
  286. /package/dist/{watch-mode-NR5MHNNL.js.map → validator-6XP3PGCP.js.map} +0 -0
@@ -1,32 +1,38 @@
1
+ import { createRequire as __spanaCreateRequire } from "node:module"; const require = __spanaCreateRequire(import.meta.url);
1
2
  import {
2
3
  splitGraphemes
3
- } from "./chunk-MUMIMDRJ.js";
4
+ } from "./chunk-IKMNHITS.js";
4
5
  import {
5
6
  mergeLaunchOptions
6
- } from "./chunk-NWGA3R2E.js";
7
+ } from "./chunk-B4FOISOF.js";
7
8
  import {
8
9
  buildDomActionabilityDiagScript,
9
10
  buildDomFindElementScript,
10
11
  buildDomFocusScript,
12
+ buildDomFrameEvaluateScript,
11
13
  buildDomSelectOptionScript,
12
14
  domMatchToElement,
13
15
  formatByteSize,
14
16
  isWasmTrapError,
15
17
  parseByteSize
16
- } from "./chunk-CA66JCX2.js";
18
+ } from "./chunk-CR55BHI2.js";
17
19
  import {
18
20
  DriverError,
19
21
  ElementNotFoundError,
20
22
  TextMismatchError,
21
23
  WaitTimeoutError
22
- } from "./chunk-A7Z52TDQ.js";
24
+ } from "./chunk-WPG77TPT.js";
23
25
  import {
24
26
  compareScreenshots,
25
27
  cropToElement
26
- } from "./chunk-6C2EILMC.js";
28
+ } from "./chunk-FWFT3FEP.js";
29
+ import {
30
+ filterViolations,
31
+ formatViolationSummary
32
+ } from "./chunk-5TAHLRZD.js";
27
33
  import {
28
34
  init_esm_shims
29
- } from "./chunk-FTXUQMGH.js";
35
+ } from "./chunk-VBAPZMPX.js";
30
36
 
31
37
  // src/api/app.ts
32
38
  init_esm_shims();
@@ -49,6 +55,7 @@ var _RoleSelectorSchema = Schema.Struct({
49
55
  name: Schema.optional(Schema.String),
50
56
  exact: Schema.optional(Schema.Boolean),
51
57
  level: Schema.optional(Schema.Number),
58
+ pressed: Schema.optional(Schema.Boolean),
52
59
  includeHidden: Schema.optional(Schema.Boolean)
53
60
  });
54
61
  var _CssSelectorSchema = Schema.Struct({
@@ -187,26 +194,41 @@ function flattenElements(root) {
187
194
  }
188
195
  return result;
189
196
  }
197
+ function normalizeWs(s) {
198
+ return s.replaceAll(/[\s\u00a0\u202f]+/g, " ").trim();
199
+ }
200
+ function matchTextSpec(actual, spec, exact) {
201
+ const normActual = normalizeWs(actual);
202
+ if (spec instanceof RegExp) {
203
+ return spec.test(actual) || spec.test(normActual);
204
+ }
205
+ const normSpec = normalizeWs(spec);
206
+ return exact ? normActual === normSpec : normActual.toLowerCase().includes(normSpec.toLowerCase());
207
+ }
190
208
  function matchesSelector(element, selector) {
191
209
  if (typeof selector === "string") {
192
- return element.text?.toLowerCase().includes(selector.toLowerCase()) ?? false;
210
+ return element.text !== void 0 && matchTextSpec(element.text, selector, false);
193
211
  }
194
212
  let baseMatch = false;
195
213
  if ("testID" in selector) {
196
214
  baseMatch = element.id === selector.testID;
197
215
  } else if ("text" in selector) {
198
- baseMatch = selector.exact ? element.text === selector.text : element.text?.toLowerCase().includes(selector.text.toLowerCase()) ?? false;
216
+ baseMatch = element.text !== void 0 && matchTextSpec(element.text, selector.text, selector.exact);
199
217
  } else if ("accessibilityLabel" in selector) {
200
218
  baseMatch = element.accessibilityLabel === selector.accessibilityLabel;
201
219
  } else if ("role" in selector) {
202
220
  const elRole = (element.attributes?.role ?? element.elementType ?? "").toLowerCase();
203
221
  const roleMatch = elRole === selector.role.toLowerCase();
204
222
  if (!roleMatch) return false;
223
+ if (selector.pressed !== void 0) {
224
+ const ariaPressed = (element.attributes?.["aria-pressed"] ?? "").trim().toLowerCase();
225
+ if (selector.pressed ? ariaPressed !== "true" : ariaPressed !== "false") return false;
226
+ }
205
227
  if (selector.name === void 0) {
206
228
  baseMatch = true;
207
229
  } else {
208
230
  const candidateName = element.accessibilityLabel ?? element.text ?? "";
209
- baseMatch = selector.name instanceof RegExp ? selector.name.test(candidateName) : selector.exact ? candidateName === selector.name : candidateName.toLowerCase().includes(selector.name.toLowerCase());
231
+ baseMatch = matchTextSpec(candidateName, selector.name, selector.exact);
210
232
  }
211
233
  } else if ("css" in selector) {
212
234
  baseMatch = false;
@@ -221,12 +243,10 @@ function matchesSelector(element, selector) {
221
243
  if (!("point" in selector)) {
222
244
  const text = element.text ?? element.accessibilityLabel ?? "";
223
245
  if (selector.hasText !== void 0) {
224
- const ok = selector.hasText instanceof RegExp ? selector.hasText.test(text) : text.toLowerCase().includes(selector.hasText.toLowerCase());
225
- if (!ok) return false;
246
+ if (!matchTextSpec(text, selector.hasText, false)) return false;
226
247
  }
227
248
  if (selector.hasNotText !== void 0) {
228
- const bad = selector.hasNotText instanceof RegExp ? selector.hasNotText.test(text) : text.toLowerCase().includes(selector.hasNotText.toLowerCase());
229
- if (bad) return false;
249
+ if (matchTextSpec(text, selector.hasNotText, false)) return false;
230
250
  }
231
251
  if (selector.has !== void 0) {
232
252
  const descendants = flattenElements(element).slice(1);
@@ -319,7 +339,8 @@ function formatSimpleSelector(sel) {
319
339
  if (typeof sel === "string") return `"${sel}"`;
320
340
  let base;
321
341
  if ("testID" in sel) base = `testID: "${sel.testID}"`;
322
- else if ("text" in sel) base = `text: "${sel.text}"`;
342
+ else if ("text" in sel)
343
+ base = `text: ${sel.text instanceof RegExp ? sel.text.toString() : JSON.stringify(sel.text)}`;
323
344
  else if ("accessibilityLabel" in sel) base = `accessibilityLabel: "${sel.accessibilityLabel}"`;
324
345
  else if ("role" in sel) {
325
346
  const parts = [`role: "${sel.role}"`];
@@ -457,7 +478,7 @@ function diagnoseElementNotFound(root, selector) {
457
478
  } else if ("testID" in simpleSelector && simpleSelector.testID) {
458
479
  const similar = findSimilarByTestID(allElements, simpleSelector.testID);
459
480
  suggestions.push(...similar);
460
- } else if ("text" in simpleSelector && simpleSelector.text) {
481
+ } else if ("text" in simpleSelector && typeof simpleSelector.text === "string" && simpleSelector.text) {
461
482
  const similar = findSimilarByText(allElements, simpleSelector.text);
462
483
  suggestions.push(...similar);
463
484
  }
@@ -726,7 +747,8 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
726
747
  const reactiveMatches = yield* Effect2.tryPromise({
727
748
  try: () => initialDomChannel.waitForSelector(selector, {
728
749
  timeoutMs: remaining,
729
- forAction: opts?.force ? false : forAction,
750
+ forAction,
751
+ ...opts?.force ? { force: true } : {},
730
752
  checkHitTest: opts?.force ? false : void 0,
731
753
  failFastWhenIdle: opts?.failFastWhenIdle,
732
754
  idleQuietMs: opts?.idleQuietMs,
@@ -1015,10 +1037,42 @@ async function loadCachedAxeSource() {
1015
1037
  const { readFileSync: readFileSync2 } = await import("fs");
1016
1038
  const { createRequire } = await import("module");
1017
1039
  const require2 = createRequire(import.meta.url);
1018
- const axePath = require2.resolve("axe-core/axe.js");
1040
+ let axePath;
1041
+ try {
1042
+ axePath = require2.resolve("axe-core/axe.min.js");
1043
+ } catch {
1044
+ axePath = require2.resolve("axe-core/axe.js");
1045
+ }
1019
1046
  cachedAxeSource = readFileSync2(axePath, "utf-8");
1020
1047
  return cachedAxeSource;
1021
1048
  }
1049
+ function withIncludeHiddenSelector(selector) {
1050
+ if (typeof selector !== "object" || selector === null) return selector;
1051
+ const obj = selector;
1052
+ const next = { ...obj };
1053
+ if ("role" in next) next["includeHidden"] = true;
1054
+ if ("includeHidden" in next || "role" in next) next["includeHidden"] = true;
1055
+ if (next["within"] && typeof next["within"] === "object") {
1056
+ next["within"] = withIncludeHiddenSelector(next["within"]);
1057
+ }
1058
+ if (next["target"] && typeof next["target"] === "object") {
1059
+ next["target"] = withIncludeHiddenSelector(next["target"]);
1060
+ }
1061
+ if (next["has"] && typeof next["has"] === "object") {
1062
+ next["has"] = withIncludeHiddenSelector(next["has"]);
1063
+ }
1064
+ if (next["hasNot"] && typeof next["hasNot"] === "object") {
1065
+ next["hasNot"] = withIncludeHiddenSelector(next["hasNot"]);
1066
+ }
1067
+ if (Array.isArray(next["or"])) {
1068
+ next["or"] = next["or"].map((s) => withIncludeHiddenSelector(s));
1069
+ }
1070
+ if (Array.isArray(next["and"])) {
1071
+ next["and"] = next["and"].map((s) => withIncludeHiddenSelector(s));
1072
+ }
1073
+ next["includeHidden"] = true;
1074
+ return next;
1075
+ }
1022
1076
  var DEFAULT_MAX_SCROLLS = 5;
1023
1077
  var DEFAULT_DISMISS_KEYBOARD_STRATEGY = "auto";
1024
1078
  var DEFAULT_MAX_BACKS = 3;
@@ -1143,7 +1197,7 @@ function createCoordinator(driver, config) {
1143
1197
  };
1144
1198
  return directionMap[direction];
1145
1199
  };
1146
- const normalizeWhitespace = (s) => s.replaceAll(/\s+/g, " ").trim();
1200
+ const normalizeWhitespace = (s) => s.replaceAll(/[\s\u00a0\u202f]+/g, " ").trim();
1147
1201
  const collectContainerText = (el) => {
1148
1202
  if (el.text) return el.text;
1149
1203
  const parts = [];
@@ -1318,906 +1372,992 @@ function createCoordinator(driver, config) {
1318
1372
  { kind: "enabled" },
1319
1373
  !expectedEnabled
1320
1374
  );
1321
- const createAssertions = () => ({
1322
- assertVisible: (selector, opts) => waitForElement(driver, selector, parse, { ...defaults, ...opts }, cache),
1323
- assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
1324
- assertText: (selector, expected, opts, negate = false) => {
1325
- if (expected instanceof RegExp) {
1375
+ const createAssertions = () => {
1376
+ let hasInjectedAxe = false;
1377
+ return {
1378
+ assertVisible: (selector, opts) => waitForElement(driver, selector, parse, { ...defaults, ...opts }, cache),
1379
+ assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
1380
+ assertText: (selector, expected, opts, negate = false) => {
1381
+ if (expected instanceof RegExp) {
1382
+ return pollUntilMatch(
1383
+ selector,
1384
+ opts,
1385
+ (el) => {
1386
+ const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1387
+ return { matched: expected.test(actual), actual };
1388
+ },
1389
+ (actual, timeout) => ({
1390
+ message: negate ? `Expected text NOT to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1391
+ expected: negate ? `not ${String(expected)}` : String(expected)
1392
+ }),
1393
+ { kind: "matchesText", patternSource: expected.source, patternFlags: expected.flags },
1394
+ negate
1395
+ );
1396
+ }
1397
+ const normalizedExpected = normalizeWhitespace(expected);
1326
1398
  return pollUntilMatch(
1327
1399
  selector,
1328
1400
  opts,
1329
1401
  (el) => {
1330
- const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1331
- return { matched: expected.test(actual), actual };
1402
+ const raw = el.textContent ?? el.text;
1403
+ const actual = raw !== void 0 ? normalizeWhitespace(raw) : void 0;
1404
+ return { matched: actual === normalizedExpected, actual };
1332
1405
  },
1333
1406
  (actual, timeout) => ({
1334
- message: negate ? `Expected text NOT to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1335
- expected: negate ? `not ${String(expected)}` : String(expected)
1407
+ message: negate ? `Expected text NOT to be "${expected}" after ${timeout}ms` : `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1408
+ expected: negate ? `not ${expected}` : expected
1336
1409
  }),
1337
- { kind: "matchesText", patternSource: expected.source, patternFlags: expected.flags },
1410
+ { kind: "text", expected },
1338
1411
  negate
1339
1412
  );
1340
- }
1341
- const normalizedExpected = normalizeWhitespace(expected);
1342
- return pollUntilMatch(
1413
+ },
1414
+ assertContainsText: (selector, expected, opts, negate = false) => {
1415
+ const ignoreCase = Boolean(opts?.ignoreCase);
1416
+ const normalizedExpected = ignoreCase ? normalizeWhitespace(expected).toLowerCase() : normalizeWhitespace(expected);
1417
+ return pollUntilMatch(
1418
+ selector,
1419
+ opts,
1420
+ (el) => {
1421
+ const raw = el.textContent ?? el.text ?? "";
1422
+ const actual = normalizeWhitespace(raw);
1423
+ const matched = ignoreCase ? actual.toLowerCase().includes(normalizedExpected) : actual.includes(normalizedExpected);
1424
+ return { matched, actual };
1425
+ },
1426
+ (actual, timeout) => ({
1427
+ message: negate ? `Expected text NOT to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1428
+ expected: negate ? `not containing ${expected}` : expected
1429
+ }),
1430
+ { kind: "containsText", expected, ...ignoreCase ? { ignoreCase: true } : {} },
1431
+ negate
1432
+ );
1433
+ },
1434
+ assertEnabled: (selector, opts) => assertEnabledState(selector, true, opts),
1435
+ assertDisabled: (selector, opts) => assertEnabledState(selector, false, opts),
1436
+ getText: (selector, opts) => Effect4.gen(function* () {
1437
+ const element = yield* waitForElement(
1438
+ driver,
1439
+ selector,
1440
+ parse,
1441
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1442
+ cache
1443
+ );
1444
+ return collectContainerText(element);
1445
+ }),
1446
+ count: (selector, opts) => Effect4.gen(function* () {
1447
+ cache.invalidate();
1448
+ const includeHidden = opts?.includeHidden;
1449
+ const visibleOnly = includeHidden === false || Boolean(opts?.visible);
1450
+ const effectiveSelector = includeHidden === true ? withIncludeHiddenSelector(selector) : selector;
1451
+ const domChannel = driver.domChannel;
1452
+ if (!isSystemUISelector(effectiveSelector) && !isRelativeSelectorLike2(effectiveSelector) && domChannel?.isConnected()) {
1453
+ const matches = yield* Effect4.tryPromise({
1454
+ try: () => domChannel.query(effectiveSelector),
1455
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1456
+ }).pipe(
1457
+ Effect4.catch(
1458
+ (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1459
+ )
1460
+ );
1461
+ if (matches) {
1462
+ return visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
1463
+ }
1464
+ }
1465
+ const raw = yield* driver.dumpHierarchy();
1466
+ const root = parse(raw);
1467
+ if (isRelativeSelectorLike2(effectiveSelector)) {
1468
+ const resolved = yield* resolveElementAcrossChannels(
1469
+ driver,
1470
+ effectiveSelector,
1471
+ parse,
1472
+ cache,
1473
+ {
1474
+ forAction: false,
1475
+ platform: opts?.platform ?? config.platform
1476
+ }
1477
+ );
1478
+ return resolved ? 1 : 0;
1479
+ }
1480
+ const matched = findElements(root, effectiveSelector);
1481
+ return visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
1482
+ }),
1483
+ isElementEnabled: (selector, opts) => Effect4.gen(function* () {
1484
+ if (opts?.includeHidden && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && driver.domChannel?.isConnected()) {
1485
+ const timeout = opts.timeout ?? defaults?.timeout ?? 5e3;
1486
+ const pollInterval = opts.pollInterval ?? defaults?.pollInterval ?? 100;
1487
+ const effectiveSelector = withIncludeHiddenSelector(selector);
1488
+ const start = Date.now();
1489
+ while (true) {
1490
+ const matches = yield* Effect4.tryPromise({
1491
+ try: () => driver.domChannel.query(effectiveSelector),
1492
+ catch: () => null
1493
+ }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1494
+ if (matches && matches.length > 0) {
1495
+ const target = matches[matches.length - 1];
1496
+ return target.enabled !== false;
1497
+ }
1498
+ if (Date.now() - start >= timeout) {
1499
+ return yield* new ElementNotFoundError({
1500
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1501
+ selector,
1502
+ timeoutMs: timeout
1503
+ });
1504
+ }
1505
+ yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
1506
+ }
1507
+ }
1508
+ const element = yield* waitForElement(
1509
+ driver,
1510
+ selector,
1511
+ parse,
1512
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1513
+ cache
1514
+ );
1515
+ return element.enabled !== false;
1516
+ }),
1517
+ isChecked: (selector, opts) => Effect4.gen(function* () {
1518
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1519
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1520
+ const domChannel = driver.domChannel;
1521
+ if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1522
+ const effectiveSelector = opts?.includeHidden ? withIncludeHiddenSelector(selector) : selector;
1523
+ const start = Date.now();
1524
+ while (true) {
1525
+ const matches = yield* Effect4.tryPromise({
1526
+ try: () => domChannel.query(effectiveSelector),
1527
+ catch: () => null
1528
+ }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1529
+ if (matches && matches.length > 0) {
1530
+ const visibleMatches = matches.filter((m) => m.visible);
1531
+ const target = opts?.includeHidden === false ? visibleMatches[visibleMatches.length - 1] : visibleMatches[visibleMatches.length - 1] ?? matches[matches.length - 1];
1532
+ if (target) {
1533
+ return Boolean(
1534
+ target.checked === true || target.attributes?.["aria-checked"] === "true"
1535
+ );
1536
+ }
1537
+ }
1538
+ if (Date.now() - start >= timeout) {
1539
+ return yield* new ElementNotFoundError({
1540
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1541
+ selector,
1542
+ timeoutMs: timeout
1543
+ });
1544
+ }
1545
+ yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
1546
+ }
1547
+ }
1548
+ const element = yield* waitForElement(
1549
+ driver,
1550
+ selector,
1551
+ parse,
1552
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1553
+ cache
1554
+ );
1555
+ return Boolean(
1556
+ element.checked === true || element.attributes?.["aria-checked"] === "true"
1557
+ );
1558
+ }),
1559
+ assertValue: (selector, expected, opts, negate = false) => {
1560
+ const isRe = expected instanceof RegExp;
1561
+ const expectedStr = isRe ? String(expected) : String(expected);
1562
+ return pollUntilMatch(
1563
+ selector,
1564
+ opts,
1565
+ (el) => {
1566
+ const actual = el.value ?? "";
1567
+ const matched = isRe ? expected.test(actual) : actual === expectedStr;
1568
+ return { matched, actual };
1569
+ },
1570
+ (actual, timeout) => ({
1571
+ message: negate ? `Expected value NOT to ${isRe ? "match" : "be"} ${isRe ? expectedStr : JSON.stringify(expectedStr)} after ${timeout}ms` : `Expected value ${isRe ? expectedStr : JSON.stringify(expectedStr)} but got "${actual ?? "(no value)"}" after ${timeout}ms`,
1572
+ expected: negate ? `not ${expectedStr}` : expectedStr
1573
+ }),
1574
+ isRe ? { kind: "value", patternSource: expected.source, patternFlags: expected.flags } : { kind: "value", expected: expectedStr },
1575
+ negate
1576
+ );
1577
+ },
1578
+ assertAttribute: (selector, name, expectedValue, opts, negate = false) => {
1579
+ const isRe = expectedValue instanceof RegExp;
1580
+ return pollUntilMatch(
1581
+ selector,
1582
+ opts,
1583
+ (el) => {
1584
+ const actual = el.attributes?.[name];
1585
+ if (expectedValue === void 0) {
1586
+ return { matched: actual !== void 0, actual };
1587
+ }
1588
+ const matched = isRe ? actual !== void 0 && expectedValue.test(actual) : actual === expectedValue;
1589
+ return { matched, actual };
1590
+ },
1591
+ (actual, timeout) => negate ? expectedValue === void 0 ? {
1592
+ message: `Expected attribute "${name}" NOT to exist but got "${actual ?? ""}" after ${timeout}ms`,
1593
+ expected: `not ${name}`
1594
+ } : {
1595
+ message: `Expected attribute "${name}" NOT to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} after ${timeout}ms`,
1596
+ expected: `not ${String(expectedValue)}`
1597
+ } : expectedValue === void 0 ? {
1598
+ message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
1599
+ expected: name
1600
+ } : {
1601
+ message: `Expected attribute "${name}" to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} but got "${actual ?? "(not found)"}" after ${timeout}ms`,
1602
+ expected: String(expectedValue)
1603
+ },
1604
+ isRe ? {
1605
+ kind: "attribute",
1606
+ attributeName: name,
1607
+ patternSource: expectedValue.source,
1608
+ patternFlags: expectedValue.flags
1609
+ } : { kind: "attribute", attributeName: name, expected: expectedValue },
1610
+ negate
1611
+ );
1612
+ },
1613
+ assertAttached: (selector, opts, negate = false) => Effect4.gen(function* () {
1614
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1615
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1616
+ const start = Date.now();
1617
+ const deadline = start + timeout;
1618
+ let lastActual;
1619
+ while (true) {
1620
+ const domChannel = driver.domChannel;
1621
+ if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
1622
+ const remaining = Math.max(50, deadline - Date.now());
1623
+ const reactive = yield* Effect4.tryPromise({
1624
+ try: () => domChannel.waitForMatch(selector, {
1625
+ kind: "attached",
1626
+ ...negate ? { negate: true } : {},
1627
+ timeoutMs: remaining
1628
+ }),
1629
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1630
+ }).pipe(
1631
+ Effect4.catch(
1632
+ (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1633
+ )
1634
+ );
1635
+ if (reactive) {
1636
+ if (reactive.matched) return;
1637
+ if (reactive.actual !== void 0) lastActual = reactive.actual;
1638
+ if (Date.now() >= deadline) break;
1639
+ yield* Effect4.sleep(
1640
+ Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
1641
+ );
1642
+ continue;
1643
+ }
1644
+ }
1645
+ cache.invalidate();
1646
+ let attached = false;
1647
+ if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1648
+ const matches = yield* Effect4.tryPromise({
1649
+ try: () => domChannel.query(selector),
1650
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1651
+ }).pipe(
1652
+ Effect4.catch(
1653
+ (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1654
+ )
1655
+ );
1656
+ if (matches) {
1657
+ attached = matches.length > 0;
1658
+ }
1659
+ } else {
1660
+ const raw = yield* driver.dumpHierarchy();
1661
+ const root = parse(raw);
1662
+ attached = findElements(root, selector).length > 0;
1663
+ }
1664
+ lastActual = attached ? "attached" : "detached";
1665
+ if (negate ? !attached : attached) return;
1666
+ if (Date.now() >= deadline) break;
1667
+ yield* Effect4.sleep(
1668
+ Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1669
+ );
1670
+ }
1671
+ return yield* new TextMismatchError({
1672
+ message: negate ? `Expected element NOT to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1673
+ expected: negate ? "detached" : "attached",
1674
+ actual: lastActual ?? (negate ? "attached" : "detached"),
1675
+ selector
1676
+ });
1677
+ }),
1678
+ assertInViewport: (selector, opts, negate = false) => pollUntilMatch(
1343
1679
  selector,
1344
1680
  opts,
1345
1681
  (el) => {
1346
- const raw = el.textContent ?? el.text;
1347
- const actual = raw !== void 0 ? normalizeWhitespace(raw) : void 0;
1348
- return { matched: actual === normalizedExpected, actual };
1682
+ const vpW = config.screenWidth ?? 1280;
1683
+ const vpH = config.screenHeight ?? 720;
1684
+ const b = el.bounds;
1685
+ const inVp = b.width > 0 && b.height > 0 && b.x + b.width > 0 && b.y + b.height > 0 && b.x < vpW && b.y < vpH;
1686
+ return { matched: inVp, actual: inVp ? "in viewport" : "outside viewport" };
1349
1687
  },
1350
1688
  (actual, timeout) => ({
1351
- message: negate ? `Expected text NOT to be "${expected}" after ${timeout}ms` : `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1352
- expected: negate ? `not ${expected}` : expected
1689
+ message: negate ? `Expected element NOT to be in viewport after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be in viewport but it was "${actual ?? "outside viewport"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1690
+ expected: negate ? "outside viewport" : "in viewport"
1353
1691
  }),
1354
- { kind: "text", expected },
1692
+ { kind: "inViewport" },
1355
1693
  negate
1356
- );
1357
- },
1358
- assertContainsText: (selector, expected, opts, negate = false) => {
1359
- const ignoreCase = Boolean(opts?.ignoreCase);
1360
- const normalizedExpected = ignoreCase ? normalizeWhitespace(expected).toLowerCase() : normalizeWhitespace(expected);
1361
- return pollUntilMatch(
1694
+ ),
1695
+ assertJSProperty: (selector, propertyName, expectedValue, opts, negate = false) => pollUntilMatch(
1362
1696
  selector,
1363
1697
  opts,
1364
1698
  (el) => {
1365
- const raw = el.textContent ?? el.text ?? "";
1366
- const actual = normalizeWhitespace(raw);
1367
- const matched = ignoreCase ? actual.toLowerCase().includes(normalizedExpected) : actual.includes(normalizedExpected);
1368
- return { matched, actual };
1699
+ const raw = el[propertyName];
1700
+ const matched = JSON.stringify(raw) === JSON.stringify(expectedValue);
1701
+ return {
1702
+ matched,
1703
+ actual: typeof raw === "string" ? raw : JSON.stringify(raw)
1704
+ };
1369
1705
  },
1370
1706
  (actual, timeout) => ({
1371
- message: negate ? `Expected text NOT to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1372
- expected: negate ? `not containing ${expected}` : expected
1707
+ message: negate ? `Expected JS property "${propertyName}" NOT to equal ${JSON.stringify(expectedValue)} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected JS property "${propertyName}" to equal ${JSON.stringify(expectedValue)} but got ${actual ?? "undefined"} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1708
+ expected: negate ? `not ${JSON.stringify(expectedValue)}` : JSON.stringify(expectedValue)
1373
1709
  }),
1374
- { kind: "containsText", expected, ...ignoreCase ? { ignoreCase: true } : {} },
1710
+ { kind: "jsProperty", propertyName, expectedValue },
1375
1711
  negate
1376
- );
1377
- },
1378
- assertEnabled: (selector, opts) => assertEnabledState(selector, true, opts),
1379
- assertDisabled: (selector, opts) => assertEnabledState(selector, false, opts),
1380
- getText: (selector, opts) => Effect4.gen(function* () {
1381
- const element = yield* waitForElement(
1382
- driver,
1712
+ ),
1713
+ assertMatchesText: (selector, pattern, opts, negate = false) => pollUntilMatch(
1383
1714
  selector,
1384
- parse,
1385
- { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1386
- cache
1387
- );
1388
- return collectContainerText(element);
1389
- }),
1390
- count: (selector, opts) => Effect4.gen(function* () {
1391
- cache.invalidate();
1392
- const visibleOnly = Boolean(opts?.visible);
1393
- const domChannel = driver.domChannel;
1394
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1395
- const matches = yield* Effect4.tryPromise({
1396
- try: () => domChannel.query(selector),
1397
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1398
- }).pipe(
1399
- Effect4.catch(
1400
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1401
- )
1715
+ opts,
1716
+ (el) => {
1717
+ const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1718
+ return { matched: pattern.test(actual), actual };
1719
+ },
1720
+ (actual, timeout) => ({
1721
+ message: negate ? `Expected text NOT to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1722
+ expected: negate ? `not ${String(pattern)}` : String(pattern)
1723
+ }),
1724
+ { kind: "matchesText", patternSource: pattern.source, patternFlags: pattern.flags },
1725
+ negate
1726
+ ),
1727
+ getAttribute: (selector, name, opts) => Effect4.gen(function* () {
1728
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1729
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1730
+ const domChannel = driver.domChannel;
1731
+ const effectiveSelector = opts?.includeHidden ? withIncludeHiddenSelector(selector) : selector;
1732
+ if (!isSystemUISelector(effectiveSelector) && !isRelativeSelectorLike2(effectiveSelector) && domChannel?.isConnected()) {
1733
+ const start = Date.now();
1734
+ while (true) {
1735
+ const matches = yield* Effect4.tryPromise({
1736
+ try: () => domChannel.query(effectiveSelector),
1737
+ catch: () => null
1738
+ }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1739
+ if (matches && matches.length > 0) {
1740
+ const target = opts?.includeHidden === false ? matches.filter((m) => m.visible).at(-1) : matches[matches.length - 1];
1741
+ if (target) {
1742
+ return target.attributes?.[name] ?? null;
1743
+ }
1744
+ }
1745
+ if (Date.now() - start >= timeout) {
1746
+ return yield* new ElementNotFoundError({
1747
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1748
+ selector,
1749
+ timeoutMs: timeout
1750
+ });
1751
+ }
1752
+ yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
1753
+ }
1754
+ }
1755
+ const element = yield* waitForElement(
1756
+ driver,
1757
+ effectiveSelector,
1758
+ parse,
1759
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1760
+ cache
1761
+ );
1762
+ return element.attributes?.[name] ?? null;
1763
+ }),
1764
+ assertScreenshot: (selector, name, flowFilePath, flowName, platform, options) => Effect4.gen(function* () {
1765
+ const { resolveBaselinePath, readBaseline, writeBaseline } = yield* Effect4.promise(
1766
+ () => import("./baseline-manager-XJ3LADKC.js")
1402
1767
  );
1403
- if (matches) {
1404
- return visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
1768
+ const { cropToElement: cropToElement2, applyMask, compareScreenshots: compareScreenshots2 } = yield* Effect4.promise(
1769
+ () => import("./screenshot-compare-7TE44H7F.js")
1770
+ );
1771
+ const raw = options.fullPage && driver.takeFullPageScreenshot ? yield* driver.takeFullPageScreenshot() : yield* driver.takeScreenshot();
1772
+ const resolvedMasks = [
1773
+ ...options.mask ?? []
1774
+ ];
1775
+ let cropOriginX = 0;
1776
+ let cropOriginY = 0;
1777
+ if (options.maskSelectors && options.maskSelectors.length > 0) {
1778
+ for (const maskSel of options.maskSelectors) {
1779
+ const found = yield* resolveElementAcrossChannels(driver, maskSel, parse, cache, {
1780
+ forAction: false,
1781
+ platform: config.platform
1782
+ });
1783
+ if (found?.element?.bounds) {
1784
+ resolvedMasks.push(found.element.bounds);
1785
+ }
1786
+ }
1405
1787
  }
1406
- }
1407
- const raw = yield* driver.dumpHierarchy();
1408
- const root = parse(raw);
1409
- if (isRelativeSelectorLike2(selector)) {
1410
- const resolved = yield* resolveElementAcrossChannels(driver, selector, parse, cache, {
1411
- forAction: false,
1412
- platform: opts?.platform ?? config.platform
1788
+ let screenshotBuf;
1789
+ if (selector !== void 0) {
1790
+ const element = yield* waitForElement(driver, selector, parse, { ...defaults }, cache);
1791
+ cropOriginX = element.bounds.x;
1792
+ cropOriginY = element.bounds.y;
1793
+ screenshotBuf = yield* Effect4.promise(() => cropToElement2(raw, element.bounds));
1794
+ } else {
1795
+ screenshotBuf = Buffer.from(raw);
1796
+ }
1797
+ const effectiveMasks = selector !== void 0 ? resolvedMasks.map((m) => ({
1798
+ x: Math.max(0, m.x - cropOriginX),
1799
+ y: Math.max(0, m.y - cropOriginY),
1800
+ width: m.width,
1801
+ height: m.height
1802
+ })) : resolvedMasks;
1803
+ const baselinePath = resolveBaselinePath(
1804
+ flowFilePath,
1805
+ flowName,
1806
+ platform,
1807
+ name,
1808
+ options.baselinesDir
1809
+ );
1810
+ if (options.updateBaselines) {
1811
+ const toWrite = effectiveMasks.length > 0 ? yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks)) : screenshotBuf;
1812
+ yield* Effect4.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1813
+ return;
1814
+ }
1815
+ const existing = readBaseline(baselinePath);
1816
+ if (existing === null) {
1817
+ const toWrite = effectiveMasks.length > 0 ? yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks)) : screenshotBuf;
1818
+ yield* Effect4.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1819
+ return;
1820
+ }
1821
+ let actualBuf = screenshotBuf;
1822
+ let expectedBuf = existing;
1823
+ if (effectiveMasks.length > 0) {
1824
+ actualBuf = yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks));
1825
+ expectedBuf = yield* Effect4.promise(() => applyMask(existing, effectiveMasks));
1826
+ }
1827
+ const result = compareScreenshots2(expectedBuf, actualBuf, {
1828
+ threshold: options.threshold,
1829
+ maxDiffPixelRatio: options.maxDiffPixelRatio
1413
1830
  });
1414
- return resolved ? 1 : 0;
1415
- }
1416
- const matched = findElements(root, selector);
1417
- return visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
1418
- }),
1419
- isElementEnabled: (selector, opts) => Effect4.gen(function* () {
1420
- const element = yield* waitForElement(
1421
- driver,
1831
+ if (!result.match) {
1832
+ const { writeFileSync: writeFileSync2, mkdirSync: mkdirSync2 } = yield* Effect4.promise(() => import("fs"));
1833
+ const { join: join2 } = yield* Effect4.promise(() => import("path"));
1834
+ const outDir = options.outputDir ?? config.outputDir ?? "spana-output";
1835
+ mkdirSync2(outDir, { recursive: true });
1836
+ const safeFlowName = flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
1837
+ const prefix = join2(outDir, `${safeFlowName}-${platform}-${name}`);
1838
+ writeFileSync2(`${prefix}-expected.png`, existing);
1839
+ writeFileSync2(`${prefix}-actual.png`, actualBuf);
1840
+ if (result.diffImage) {
1841
+ writeFileSync2(`${prefix}-diff.png`, result.diffImage);
1842
+ }
1843
+ const detail = result.sizeMismatch ? "image dimensions differ" : `${result.diffPixelCount} differing pixels (ratio: ${(result.diffPixelRatio * 100).toFixed(2)}%)`;
1844
+ return yield* new DriverError({
1845
+ message: `Screenshot mismatch for "${name}": ${detail}. Expected: ${prefix}-expected.png, Actual: ${prefix}-actual.png${result.diffImage ? `, Diff: ${prefix}-diff.png` : ""}`
1846
+ });
1847
+ }
1848
+ }),
1849
+ assertAccessibilityLabel: (selector, expected, opts) => pollUntilMatch(
1422
1850
  selector,
1423
- parse,
1424
- { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1425
- cache
1426
- );
1427
- return element.enabled !== false;
1428
- }),
1429
- assertValue: (selector, expected, opts, negate = false) => {
1430
- const isRe = expected instanceof RegExp;
1431
- const expectedStr = isRe ? String(expected) : String(expected);
1432
- return pollUntilMatch(
1851
+ opts,
1852
+ (el) => {
1853
+ const label = el.accessibilityLabel;
1854
+ if (expected === void 0) {
1855
+ return { matched: label !== void 0 && label.length > 0, actual: label };
1856
+ }
1857
+ return { matched: label === expected, actual: label };
1858
+ },
1859
+ (actual, timeout) => expected === void 0 ? {
1860
+ message: `Expected element to have a non-empty accessibilityLabel but got "${actual ?? "(none)"}" after ${timeout}ms`,
1861
+ expected: "(non-empty)"
1862
+ } : {
1863
+ message: `Expected accessibilityLabel "${expected}" but got "${actual ?? "(none)"}" after ${timeout}ms`,
1864
+ expected
1865
+ },
1866
+ { kind: "accessibilityLabel", expected }
1867
+ ),
1868
+ assertAccessibleName: (selector, expected, opts, negate = false) => pollUntilMatch(
1433
1869
  selector,
1434
1870
  opts,
1435
1871
  (el) => {
1436
- const actual = el.value ?? "";
1437
- const matched = isRe ? expected.test(actual) : actual === expectedStr;
1872
+ const actual = el.accessibilityLabel || el.text || "";
1873
+ const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1438
1874
  return { matched, actual };
1439
1875
  },
1440
1876
  (actual, timeout) => ({
1441
- message: negate ? `Expected value NOT to ${isRe ? "match" : "be"} ${isRe ? expectedStr : JSON.stringify(expectedStr)} after ${timeout}ms` : `Expected value ${isRe ? expectedStr : JSON.stringify(expectedStr)} but got "${actual ?? "(no value)"}" after ${timeout}ms`,
1442
- expected: negate ? `not ${expectedStr}` : expectedStr
1877
+ message: negate ? `Expected accessible name NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible name ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1878
+ expected: negate ? `not ${String(expected)}` : String(expected)
1443
1879
  }),
1444
- isRe ? { kind: "value", patternSource: expected.source, patternFlags: expected.flags } : { kind: "value", expected: expectedStr },
1880
+ expected instanceof RegExp ? {
1881
+ kind: "accessibleName",
1882
+ patternSource: expected.source,
1883
+ patternFlags: expected.flags
1884
+ } : { kind: "accessibleName", expected },
1445
1885
  negate
1446
- );
1447
- },
1448
- assertAttribute: (selector, name, expectedValue, opts, negate = false) => {
1449
- const isRe = expectedValue instanceof RegExp;
1450
- return pollUntilMatch(
1886
+ ),
1887
+ assertAccessibleDescription: (selector, expected, opts, negate = false) => pollUntilMatch(
1451
1888
  selector,
1452
1889
  opts,
1453
1890
  (el) => {
1454
- const actual = el.attributes?.[name];
1455
- if (expectedValue === void 0) {
1456
- return { matched: actual !== void 0, actual };
1457
- }
1458
- const matched = isRe ? actual !== void 0 && expectedValue.test(actual) : actual === expectedValue;
1891
+ const actual = el.accessibleDescription ?? el.attributes?.["aria-description"] ?? "";
1892
+ const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1459
1893
  return { matched, actual };
1460
1894
  },
1461
- (actual, timeout) => negate ? expectedValue === void 0 ? {
1462
- message: `Expected attribute "${name}" NOT to exist but got "${actual ?? ""}" after ${timeout}ms`,
1463
- expected: `not ${name}`
1464
- } : {
1465
- message: `Expected attribute "${name}" NOT to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} after ${timeout}ms`,
1466
- expected: `not ${String(expectedValue)}`
1467
- } : expectedValue === void 0 ? {
1468
- message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
1469
- expected: name
1470
- } : {
1471
- message: `Expected attribute "${name}" to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} but got "${actual ?? "(not found)"}" after ${timeout}ms`,
1472
- expected: String(expectedValue)
1895
+ (actual, timeout) => ({
1896
+ message: negate ? `Expected accessible description NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible description ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1897
+ expected: negate ? `not ${String(expected)}` : String(expected)
1898
+ }),
1899
+ expected instanceof RegExp ? {
1900
+ kind: "accessibleDescription",
1901
+ patternSource: expected.source,
1902
+ patternFlags: expected.flags
1903
+ } : { kind: "accessibleDescription", expected },
1904
+ negate
1905
+ ),
1906
+ assertFocused: (selector, opts, negate = false) => pollUntilMatch(
1907
+ selector,
1908
+ opts,
1909
+ (el) => ({
1910
+ matched: el.focused === true,
1911
+ actual: el.focused ? "focused" : "not focused"
1912
+ }),
1913
+ (actual, timeout) => ({
1914
+ message: negate ? `Expected element NOT to be focused but it was "${actual ?? "focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be focused but it was "${actual ?? "not focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1915
+ expected: negate ? "not focused" : "focused"
1916
+ }),
1917
+ { kind: "focused" },
1918
+ negate
1919
+ ),
1920
+ assertChecked: (selector, opts, negate = false) => pollUntilMatch(
1921
+ selector,
1922
+ opts,
1923
+ (el) => ({
1924
+ matched: el.checked === true || el.attributes?.["aria-checked"] === "true",
1925
+ actual: el.checked ? "checked" : "unchecked"
1926
+ }),
1927
+ (actual, timeout) => ({
1928
+ message: negate ? `Expected element NOT to be checked but it was "${actual ?? "checked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be checked but it was "${actual ?? "unchecked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1929
+ expected: negate ? "unchecked" : "checked"
1930
+ }),
1931
+ { kind: "checked" },
1932
+ negate
1933
+ ),
1934
+ assertEditable: (selector, opts, negate = false) => pollUntilMatch(
1935
+ selector,
1936
+ opts,
1937
+ (el) => ({
1938
+ matched: el.editable === true,
1939
+ actual: el.editable ? "editable" : "not editable"
1940
+ }),
1941
+ (actual, timeout) => ({
1942
+ message: negate ? `Expected element NOT to be editable but it was "${actual ?? "editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be editable but it was "${actual ?? "not editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1943
+ expected: negate ? "not editable" : "editable"
1944
+ }),
1945
+ { kind: "editable" },
1946
+ negate
1947
+ ),
1948
+ assertEmpty: (selector, opts, negate = false) => pollUntilMatch(
1949
+ selector,
1950
+ opts,
1951
+ (el) => {
1952
+ const isEmpty = el.empty !== void 0 ? el.empty : (el.value ?? el.textContent ?? el.text ?? "").trim().length === 0;
1953
+ return {
1954
+ matched: isEmpty,
1955
+ actual: isEmpty ? "empty" : el.value ?? el.text ?? "non-empty"
1956
+ };
1473
1957
  },
1474
- isRe ? {
1475
- kind: "attribute",
1476
- attributeName: name,
1477
- patternSource: expectedValue.source,
1478
- patternFlags: expectedValue.flags
1479
- } : { kind: "attribute", attributeName: name, expected: expectedValue },
1958
+ (actual, timeout) => ({
1959
+ message: negate ? `Expected element NOT to be empty after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be empty but got "${actual ?? "(non-empty)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1960
+ expected: negate ? "non-empty" : "empty"
1961
+ }),
1962
+ { kind: "empty" },
1480
1963
  negate
1481
- );
1482
- },
1483
- assertAttached: (selector, opts, negate = false) => Effect4.gen(function* () {
1484
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1485
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1486
- const start = Date.now();
1487
- const deadline = start + timeout;
1488
- let lastActual;
1489
- while (true) {
1490
- const domChannel = driver.domChannel;
1491
- if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
1492
- const remaining = Math.max(50, deadline - Date.now());
1493
- const reactive = yield* Effect4.tryPromise({
1494
- try: () => domChannel.waitForMatch(selector, {
1495
- kind: "attached",
1496
- ...negate ? { negate: true } : {},
1497
- timeoutMs: remaining
1498
- }),
1499
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1500
- }).pipe(
1501
- Effect4.catch(
1502
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1503
- )
1504
- );
1505
- if (reactive) {
1506
- if (reactive.matched) return;
1507
- if (reactive.actual !== void 0) lastActual = reactive.actual;
1508
- if (Date.now() >= deadline) break;
1509
- yield* Effect4.sleep(
1510
- Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
1511
- );
1512
- continue;
1513
- }
1514
- }
1515
- cache.invalidate();
1516
- let attached = false;
1517
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1518
- const matches = yield* Effect4.tryPromise({
1519
- try: () => domChannel.query(selector),
1520
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1521
- }).pipe(
1522
- Effect4.catch(
1523
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1524
- )
1525
- );
1526
- if (matches) {
1527
- attached = matches.length > 0;
1528
- }
1529
- } else {
1530
- const raw = yield* driver.dumpHierarchy();
1531
- const root = parse(raw);
1532
- attached = findElements(root, selector).length > 0;
1533
- }
1534
- lastActual = attached ? "attached" : "detached";
1535
- if (negate ? !attached : attached) return;
1536
- if (Date.now() >= deadline) break;
1537
- yield* Effect4.sleep(
1538
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1539
- );
1540
- }
1541
- return yield* new TextMismatchError({
1542
- message: negate ? `Expected element NOT to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1543
- expected: negate ? "detached" : "attached",
1544
- actual: lastActual ?? (negate ? "attached" : "detached"),
1545
- selector
1546
- });
1547
- }),
1548
- assertInViewport: (selector, opts, negate = false) => pollUntilMatch(
1549
- selector,
1550
- opts,
1551
- (el) => {
1552
- const vpW = config.screenWidth ?? 1280;
1553
- const vpH = config.screenHeight ?? 720;
1554
- const b = el.bounds;
1555
- const inVp = b.width > 0 && b.height > 0 && b.x + b.width > 0 && b.y + b.height > 0 && b.x < vpW && b.y < vpH;
1556
- return { matched: inVp, actual: inVp ? "in viewport" : "outside viewport" };
1557
- },
1558
- (actual, timeout) => ({
1559
- message: negate ? `Expected element NOT to be in viewport after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be in viewport but it was "${actual ?? "outside viewport"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1560
- expected: negate ? "outside viewport" : "in viewport"
1561
- }),
1562
- { kind: "inViewport" },
1563
- negate
1564
- ),
1565
- assertJSProperty: (selector, propertyName, expectedValue, opts, negate = false) => pollUntilMatch(
1566
- selector,
1567
- opts,
1568
- (el) => {
1569
- const raw = el[propertyName];
1570
- const matched = JSON.stringify(raw) === JSON.stringify(expectedValue);
1571
- return {
1572
- matched,
1573
- actual: typeof raw === "string" ? raw : JSON.stringify(raw)
1574
- };
1575
- },
1576
- (actual, timeout) => ({
1577
- message: negate ? `Expected JS property "${propertyName}" NOT to equal ${JSON.stringify(expectedValue)} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected JS property "${propertyName}" to equal ${JSON.stringify(expectedValue)} but got ${actual ?? "undefined"} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1578
- expected: negate ? `not ${JSON.stringify(expectedValue)}` : JSON.stringify(expectedValue)
1579
- }),
1580
- { kind: "jsProperty", propertyName, expectedValue },
1581
- negate
1582
- ),
1583
- assertMatchesText: (selector, pattern, opts, negate = false) => pollUntilMatch(
1584
- selector,
1585
- opts,
1586
- (el) => {
1587
- const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1588
- return { matched: pattern.test(actual), actual };
1589
- },
1590
- (actual, timeout) => ({
1591
- message: negate ? `Expected text NOT to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1592
- expected: negate ? `not ${String(pattern)}` : String(pattern)
1593
- }),
1594
- { kind: "matchesText", patternSource: pattern.source, patternFlags: pattern.flags },
1595
- negate
1596
- ),
1597
- getAttribute: (selector, name, opts) => Effect4.gen(function* () {
1598
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1599
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1600
- const domChannel = driver.domChannel;
1601
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1602
- const start = Date.now();
1603
- while (true) {
1604
- const matches = yield* Effect4.tryPromise({
1605
- try: () => domChannel.query(selector),
1606
- catch: () => null
1607
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1608
- if (matches && matches.length > 0) {
1609
- const target = matches[matches.length - 1];
1610
- return target.attributes?.[name] ?? null;
1611
- }
1612
- if (Date.now() - start >= timeout) {
1613
- return yield* new ElementNotFoundError({
1614
- message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1615
- selector,
1616
- timeoutMs: timeout
1617
- });
1618
- }
1619
- yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
1620
- }
1621
- }
1622
- const element = yield* waitForElement(
1623
- driver,
1964
+ ),
1965
+ assertClass: (selector, expected, opts, negate = false) => pollUntilMatch(
1624
1966
  selector,
1625
- parse,
1626
- { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1627
- cache
1628
- );
1629
- return element.attributes?.[name] ?? null;
1630
- }),
1631
- assertScreenshot: (selector, name, flowFilePath, flowName, platform, options) => Effect4.gen(function* () {
1632
- const { resolveBaselinePath, readBaseline, writeBaseline } = yield* Effect4.promise(
1633
- () => import("./baseline-manager-LVUVH2MJ.js")
1634
- );
1635
- const { cropToElement: cropToElement2, applyMask, compareScreenshots: compareScreenshots2 } = yield* Effect4.promise(
1636
- () => import("./screenshot-compare-BJRJHKNQ.js")
1637
- );
1638
- const raw = options.fullPage && driver.takeFullPageScreenshot ? yield* driver.takeFullPageScreenshot() : yield* driver.takeScreenshot();
1639
- const resolvedMasks = [
1640
- ...options.mask ?? []
1641
- ];
1642
- let cropOriginX = 0;
1643
- let cropOriginY = 0;
1644
- if (options.maskSelectors && options.maskSelectors.length > 0) {
1645
- for (const maskSel of options.maskSelectors) {
1646
- const found = yield* resolveElementAcrossChannels(driver, maskSel, parse, cache, {
1647
- forAction: false,
1648
- platform: config.platform
1649
- });
1650
- if (found?.element?.bounds) {
1651
- resolvedMasks.push(found.element.bounds);
1652
- }
1653
- }
1654
- }
1655
- let screenshotBuf;
1656
- if (selector !== void 0) {
1657
- const element = yield* waitForElement(driver, selector, parse, { ...defaults }, cache);
1658
- cropOriginX = element.bounds.x;
1659
- cropOriginY = element.bounds.y;
1660
- screenshotBuf = yield* Effect4.promise(() => cropToElement2(raw, element.bounds));
1661
- } else {
1662
- screenshotBuf = Buffer.from(raw);
1663
- }
1664
- const effectiveMasks = selector !== void 0 ? resolvedMasks.map((m) => ({
1665
- x: Math.max(0, m.x - cropOriginX),
1666
- y: Math.max(0, m.y - cropOriginY),
1667
- width: m.width,
1668
- height: m.height
1669
- })) : resolvedMasks;
1670
- const baselinePath = resolveBaselinePath(
1671
- flowFilePath,
1672
- flowName,
1673
- platform,
1674
- name,
1675
- options.baselinesDir
1676
- );
1677
- if (options.updateBaselines) {
1678
- const toWrite = effectiveMasks.length > 0 ? yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks)) : screenshotBuf;
1679
- yield* Effect4.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1680
- return;
1681
- }
1682
- const existing = readBaseline(baselinePath);
1683
- if (existing === null) {
1684
- const toWrite = effectiveMasks.length > 0 ? yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks)) : screenshotBuf;
1685
- yield* Effect4.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1686
- return;
1687
- }
1688
- let actualBuf = screenshotBuf;
1689
- let expectedBuf = existing;
1690
- if (effectiveMasks.length > 0) {
1691
- actualBuf = yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks));
1692
- expectedBuf = yield* Effect4.promise(() => applyMask(existing, effectiveMasks));
1693
- }
1694
- const result = compareScreenshots2(expectedBuf, actualBuf, {
1695
- threshold: options.threshold,
1696
- maxDiffPixelRatio: options.maxDiffPixelRatio
1697
- });
1698
- if (!result.match) {
1699
- const { writeFileSync: writeFileSync2, mkdirSync: mkdirSync2 } = yield* Effect4.promise(() => import("fs"));
1700
- const { join: join2 } = yield* Effect4.promise(() => import("path"));
1701
- const outDir = options.outputDir ?? config.outputDir ?? "spana-output";
1702
- mkdirSync2(outDir, { recursive: true });
1703
- const safeFlowName = flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
1704
- const prefix = join2(outDir, `${safeFlowName}-${platform}-${name}`);
1705
- writeFileSync2(`${prefix}-expected.png`, existing);
1706
- writeFileSync2(`${prefix}-actual.png`, actualBuf);
1707
- if (result.diffImage) {
1708
- writeFileSync2(`${prefix}-diff.png`, result.diffImage);
1709
- }
1710
- const detail = result.sizeMismatch ? "image dimensions differ" : `${result.diffPixelCount} differing pixels (ratio: ${(result.diffPixelRatio * 100).toFixed(2)}%)`;
1711
- return yield* new DriverError({
1712
- message: `Screenshot mismatch for "${name}": ${detail}. Expected: ${prefix}-expected.png, Actual: ${prefix}-actual.png${result.diffImage ? `, Diff: ${prefix}-diff.png` : ""}`
1713
- });
1714
- }
1715
- }),
1716
- assertAccessibilityLabel: (selector, expected, opts) => pollUntilMatch(
1717
- selector,
1718
- opts,
1719
- (el) => {
1720
- const label = el.accessibilityLabel;
1721
- if (expected === void 0) {
1722
- return { matched: label !== void 0 && label.length > 0, actual: label };
1723
- }
1724
- return { matched: label === expected, actual: label };
1725
- },
1726
- (actual, timeout) => expected === void 0 ? {
1727
- message: `Expected element to have a non-empty accessibilityLabel but got "${actual ?? "(none)"}" after ${timeout}ms`,
1728
- expected: "(non-empty)"
1729
- } : {
1730
- message: `Expected accessibilityLabel "${expected}" but got "${actual ?? "(none)"}" after ${timeout}ms`,
1731
- expected
1732
- },
1733
- { kind: "accessibilityLabel", expected }
1734
- ),
1735
- assertAccessibleName: (selector, expected, opts, negate = false) => pollUntilMatch(
1736
- selector,
1737
- opts,
1738
- (el) => {
1739
- const actual = el.accessibilityLabel || el.text || "";
1740
- const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1741
- return { matched, actual };
1742
- },
1743
- (actual, timeout) => ({
1744
- message: negate ? `Expected accessible name NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible name ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1745
- expected: negate ? `not ${String(expected)}` : String(expected)
1746
- }),
1747
- expected instanceof RegExp ? {
1748
- kind: "accessibleName",
1749
- patternSource: expected.source,
1750
- patternFlags: expected.flags
1751
- } : { kind: "accessibleName", expected },
1752
- negate
1753
- ),
1754
- assertAccessibleDescription: (selector, expected, opts, negate = false) => pollUntilMatch(
1755
- selector,
1756
- opts,
1757
- (el) => {
1758
- const actual = el.accessibleDescription ?? el.attributes?.["aria-description"] ?? "";
1759
- const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1760
- return { matched, actual };
1761
- },
1762
- (actual, timeout) => ({
1763
- message: negate ? `Expected accessible description NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible description ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1764
- expected: negate ? `not ${String(expected)}` : String(expected)
1765
- }),
1766
- expected instanceof RegExp ? {
1767
- kind: "accessibleDescription",
1768
- patternSource: expected.source,
1769
- patternFlags: expected.flags
1770
- } : { kind: "accessibleDescription", expected },
1771
- negate
1772
- ),
1773
- assertFocused: (selector, opts, negate = false) => pollUntilMatch(
1774
- selector,
1775
- opts,
1776
- (el) => ({
1777
- matched: el.focused === true,
1778
- actual: el.focused ? "focused" : "not focused"
1779
- }),
1780
- (actual, timeout) => ({
1781
- message: negate ? `Expected element NOT to be focused but it was "${actual ?? "focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be focused but it was "${actual ?? "not focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1782
- expected: negate ? "not focused" : "focused"
1783
- }),
1784
- { kind: "focused" },
1785
- negate
1786
- ),
1787
- assertChecked: (selector, opts, negate = false) => pollUntilMatch(
1788
- selector,
1789
- opts,
1790
- (el) => ({
1791
- matched: el.checked === true || el.attributes?.["aria-checked"] === "true",
1792
- actual: el.checked ? "checked" : "unchecked"
1793
- }),
1794
- (actual, timeout) => ({
1795
- message: negate ? `Expected element NOT to be checked but it was "${actual ?? "checked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be checked but it was "${actual ?? "unchecked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1796
- expected: negate ? "unchecked" : "checked"
1797
- }),
1798
- { kind: "checked" },
1799
- negate
1800
- ),
1801
- assertEditable: (selector, opts, negate = false) => pollUntilMatch(
1802
- selector,
1803
- opts,
1804
- (el) => ({
1805
- matched: el.editable === true,
1806
- actual: el.editable ? "editable" : "not editable"
1807
- }),
1808
- (actual, timeout) => ({
1809
- message: negate ? `Expected element NOT to be editable but it was "${actual ?? "editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be editable but it was "${actual ?? "not editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1810
- expected: negate ? "not editable" : "editable"
1811
- }),
1812
- { kind: "editable" },
1813
- negate
1814
- ),
1815
- assertEmpty: (selector, opts, negate = false) => pollUntilMatch(
1816
- selector,
1817
- opts,
1818
- (el) => {
1819
- const isEmpty = el.empty !== void 0 ? el.empty : (el.value ?? el.textContent ?? el.text ?? "").trim().length === 0;
1820
- return {
1821
- matched: isEmpty,
1822
- actual: isEmpty ? "empty" : el.value ?? el.text ?? "non-empty"
1823
- };
1824
- },
1825
- (actual, timeout) => ({
1826
- message: negate ? `Expected element NOT to be empty after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be empty but got "${actual ?? "(non-empty)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1827
- expected: negate ? "non-empty" : "empty"
1828
- }),
1829
- { kind: "empty" },
1830
- negate
1831
- ),
1832
- assertClass: (selector, expected, opts, negate = false) => pollUntilMatch(
1833
- selector,
1834
- opts,
1835
- (el) => {
1836
- const cls = el.className ?? el.attributes?.["class"] ?? "";
1837
- const matched = expected instanceof RegExp ? expected.test(cls) : expected.trim().split(/\s+/).filter(Boolean).every((tok) => cls.trim().split(/\s+/).includes(tok));
1838
- return { matched, actual: cls };
1839
- },
1840
- (actual, timeout) => ({
1841
- message: negate ? `Expected class NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected class ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1842
- expected: negate ? `not ${String(expected)}` : String(expected)
1843
- }),
1844
- expected instanceof RegExp ? { kind: "class", patternSource: expected.source, patternFlags: expected.flags } : { kind: "class", expected },
1845
- negate
1846
- ),
1847
- assertCss: (selector, property, expected, opts, negate = false) => pollUntilMatch(
1848
- selector,
1849
- opts,
1850
- (el) => {
1851
- const actual = el.attributes?.[`style:${property}`] ?? "";
1852
- const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1853
- return { matched, actual };
1854
- },
1855
- (actual, timeout) => ({
1856
- message: negate ? `Expected CSS "${property}" NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected CSS "${property}" to be ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1857
- expected: negate ? `not ${String(expected)}` : String(expected)
1858
- }),
1859
- expected instanceof RegExp ? {
1860
- kind: "css",
1861
- cssProperty: property,
1862
- patternSource: expected.source,
1863
- patternFlags: expected.flags
1864
- } : { kind: "css", cssProperty: property, expected },
1865
- negate
1866
- ),
1867
- waitForTitle: (expected, opts, negate = false) => Effect4.gen(function* () {
1868
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1869
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1870
- const start = Date.now();
1871
- const deadline = start + timeout;
1872
- let lastTitle = "";
1873
- const matchesTitle = (t) => expected instanceof RegExp ? expected.test(t) : t === expected;
1874
- while (true) {
1875
- const domChannel = driver.domChannel;
1876
- if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
1877
- const remaining = Math.max(50, deadline - Date.now());
1878
- const reactive = yield* Effect4.tryPromise({
1879
- try: () => domChannel.waitForMatch("", {
1880
- kind: "title",
1881
- ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
1882
- ...negate ? { negate: true } : {},
1883
- timeoutMs: remaining
1884
- }),
1885
- catch: () => null
1886
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1887
- if (reactive) {
1888
- if (reactive.matched) return;
1889
- if (reactive.actual !== void 0) lastTitle = reactive.actual;
1890
- if (Date.now() >= deadline) break;
1891
- yield* Effect4.sleep(
1892
- Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
1893
- );
1894
- continue;
1967
+ opts,
1968
+ (el) => {
1969
+ const cls = el.className ?? el.attributes?.["class"] ?? "";
1970
+ const matched = expected instanceof RegExp ? expected.test(cls) : expected.trim().split(/\s+/).filter(Boolean).every((tok) => cls.trim().split(/\s+/).includes(tok));
1971
+ return { matched, actual: cls };
1972
+ },
1973
+ (actual, timeout) => ({
1974
+ message: negate ? `Expected class NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected class ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1975
+ expected: negate ? `not ${String(expected)}` : String(expected)
1976
+ }),
1977
+ expected instanceof RegExp ? { kind: "class", patternSource: expected.source, patternFlags: expected.flags } : { kind: "class", expected },
1978
+ negate
1979
+ ),
1980
+ assertCss: (selector, property, expected, opts, negate = false) => pollUntilMatch(
1981
+ selector,
1982
+ opts,
1983
+ (el) => {
1984
+ const actual = el.attributes?.[`style:${property}`] ?? "";
1985
+ const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1986
+ return { matched, actual };
1987
+ },
1988
+ (actual, timeout) => ({
1989
+ message: negate ? `Expected CSS "${property}" NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected CSS "${property}" to be ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1990
+ expected: negate ? `not ${String(expected)}` : String(expected)
1991
+ }),
1992
+ expected instanceof RegExp ? {
1993
+ kind: "css",
1994
+ cssProperty: property,
1995
+ patternSource: expected.source,
1996
+ patternFlags: expected.flags
1997
+ } : { kind: "css", cssProperty: property, expected },
1998
+ negate
1999
+ ),
2000
+ waitForTitle: (expected, opts, negate = false) => Effect4.gen(function* () {
2001
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2002
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2003
+ const start = Date.now();
2004
+ const deadline = start + timeout;
2005
+ let lastTitle = "";
2006
+ const matchesTitle = (t) => expected instanceof RegExp ? expected.test(t) : t === expected;
2007
+ while (true) {
2008
+ const domChannel = driver.domChannel;
2009
+ if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
2010
+ const remaining = Math.max(50, deadline - Date.now());
2011
+ const reactive = yield* Effect4.tryPromise({
2012
+ try: () => domChannel.waitForMatch("", {
2013
+ kind: "title",
2014
+ ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
2015
+ ...negate ? { negate: true } : {},
2016
+ timeoutMs: remaining
2017
+ }),
2018
+ catch: () => null
2019
+ }).pipe(Effect4.catch(() => Effect4.succeed(null)));
2020
+ if (reactive) {
2021
+ if (reactive.matched) return;
2022
+ if (reactive.actual !== void 0) lastTitle = reactive.actual;
2023
+ if (Date.now() >= deadline) break;
2024
+ yield* Effect4.sleep(
2025
+ Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
2026
+ );
2027
+ continue;
2028
+ }
1895
2029
  }
1896
- }
1897
- const title = yield* driver.evaluate("typeof document !== 'undefined' ? String(document.title || '') : ''").pipe(Effect4.catch(() => Effect4.succeed("")));
1898
- lastTitle = title;
1899
- if (negate ? !matchesTitle(title) : matchesTitle(title)) return;
1900
- if (Date.now() >= deadline) break;
1901
- yield* Effect4.sleep(
1902
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1903
- );
1904
- }
1905
- return yield* new TextMismatchError({
1906
- message: negate ? `Expected title NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms` : `Expected title ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms`,
1907
- expected: negate ? `not ${String(expected)}` : String(expected),
1908
- actual: lastTitle,
1909
- selector: "title"
1910
- });
1911
- }),
1912
- assertCount: (selector, expectedCount, opts, negate = false) => Effect4.gen(function* () {
1913
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1914
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 200;
1915
- const visibleOnly = Boolean(opts?.visible);
1916
- const start = Date.now();
1917
- const deadline = start + timeout;
1918
- let lastCount = -1;
1919
- let lastActualStr;
1920
- while (true) {
1921
- const domChannel = driver.domChannel;
1922
- if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
1923
- const remaining = Math.max(50, deadline - Date.now());
1924
- const reactive = yield* Effect4.tryPromise({
1925
- try: () => domChannel.waitForMatch(selector, {
1926
- kind: "count",
1927
- expectedCount,
1928
- ...visibleOnly ? { visibleOnly: true } : {},
1929
- ...negate ? { negate: true } : {},
1930
- timeoutMs: remaining
1931
- }),
1932
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1933
- }).pipe(
1934
- Effect4.catch(
1935
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1936
- )
2030
+ const title = yield* driver.evaluate(
2031
+ "typeof document !== 'undefined' ? String(document.title || '') : ''"
2032
+ ).pipe(Effect4.catch(() => Effect4.succeed("")));
2033
+ lastTitle = title;
2034
+ if (negate ? !matchesTitle(title) : matchesTitle(title)) return;
2035
+ if (Date.now() >= deadline) break;
2036
+ yield* Effect4.sleep(
2037
+ Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1937
2038
  );
1938
- if (reactive) {
1939
- if (reactive.matched) return;
1940
- if (reactive.actual !== void 0) lastActualStr = reactive.actual;
1941
- if (Date.now() >= deadline) break;
1942
- yield* Effect4.sleep(
1943
- Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
2039
+ }
2040
+ return yield* new TextMismatchError({
2041
+ message: negate ? `Expected title NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms` : `Expected title ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms`,
2042
+ expected: negate ? `not ${String(expected)}` : String(expected),
2043
+ actual: lastTitle,
2044
+ selector: "title"
2045
+ });
2046
+ }),
2047
+ assertCount: (selector, expectedCount, opts, negate = false) => Effect4.gen(function* () {
2048
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2049
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 200;
2050
+ const visibleOnly = Boolean(opts?.visible);
2051
+ const start = Date.now();
2052
+ const deadline = start + timeout;
2053
+ let lastCount = -1;
2054
+ let lastActualStr;
2055
+ while (true) {
2056
+ const domChannel = driver.domChannel;
2057
+ if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
2058
+ const remaining = Math.max(50, deadline - Date.now());
2059
+ const reactive = yield* Effect4.tryPromise({
2060
+ try: () => domChannel.waitForMatch(selector, {
2061
+ kind: "count",
2062
+ expectedCount,
2063
+ ...visibleOnly ? { visibleOnly: true } : {},
2064
+ ...negate ? { negate: true } : {},
2065
+ timeoutMs: remaining
2066
+ }),
2067
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
2068
+ }).pipe(
2069
+ Effect4.catch(
2070
+ (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
2071
+ )
1944
2072
  );
1945
- continue;
2073
+ if (reactive) {
2074
+ if (reactive.matched) return;
2075
+ if (reactive.actual !== void 0) lastActualStr = reactive.actual;
2076
+ if (Date.now() >= deadline) break;
2077
+ yield* Effect4.sleep(
2078
+ Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
2079
+ );
2080
+ continue;
2081
+ }
1946
2082
  }
1947
- }
1948
- cache.invalidate();
1949
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1950
- const matches = yield* Effect4.tryPromise({
1951
- try: () => domChannel.query(selector),
1952
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1953
- }).pipe(
1954
- Effect4.catch(
1955
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1956
- )
1957
- );
1958
- if (matches) {
1959
- const count2 = visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
1960
- lastCount = count2;
1961
- lastActualStr = String(count2);
1962
- if (negate ? count2 !== expectedCount : count2 === expectedCount) return;
1963
- if (Date.now() >= deadline) break;
1964
- yield* Effect4.sleep(
1965
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2083
+ cache.invalidate();
2084
+ if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
2085
+ const matches = yield* Effect4.tryPromise({
2086
+ try: () => domChannel.query(selector),
2087
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
2088
+ }).pipe(
2089
+ Effect4.catch(
2090
+ (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
2091
+ )
1966
2092
  );
1967
- continue;
2093
+ if (matches) {
2094
+ const count2 = visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
2095
+ lastCount = count2;
2096
+ lastActualStr = String(count2);
2097
+ if (negate ? count2 !== expectedCount : count2 === expectedCount) return;
2098
+ if (Date.now() >= deadline) break;
2099
+ yield* Effect4.sleep(
2100
+ Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2101
+ );
2102
+ continue;
2103
+ }
1968
2104
  }
2105
+ const raw = yield* driver.dumpHierarchy();
2106
+ const root = parse(raw);
2107
+ const matched = findElements(root, selector);
2108
+ const count = visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
2109
+ lastCount = count;
2110
+ lastActualStr = String(count);
2111
+ if (negate ? count !== expectedCount : count === expectedCount) return;
2112
+ if (Date.now() >= deadline) break;
2113
+ yield* Effect4.sleep(
2114
+ Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2115
+ );
1969
2116
  }
1970
- const raw = yield* driver.dumpHierarchy();
1971
- const root = parse(raw);
1972
- const matched = findElements(root, selector);
1973
- const count = visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
1974
- lastCount = count;
1975
- lastActualStr = String(count);
1976
- if (negate ? count !== expectedCount : count === expectedCount) return;
1977
- if (Date.now() >= deadline) break;
1978
- yield* Effect4.sleep(
1979
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1980
- );
1981
- }
1982
- const finalActual = lastActualStr ?? String(lastCount >= 0 ? lastCount : 0);
1983
- return yield* new TextMismatchError({
1984
- message: negate ? `Expected count NOT to be ${expectedCount} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected count ${expectedCount} but got ${finalActual} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1985
- expected: negate ? `not ${expectedCount}` : String(expectedCount),
1986
- actual: finalActual,
1987
- selector
1988
- });
1989
- }),
1990
- waitForURL: (expected, opts, negate = false) => Effect4.gen(function* () {
1991
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1992
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1993
- const start = Date.now();
1994
- const deadline = start + timeout;
1995
- let lastUrl = "";
1996
- const matchesUrl = (url) => expected instanceof RegExp ? expected.test(url) : url === expected || url.includes(expected);
1997
- const initialNavUrls = driver.getNavigationUrls ? driver.getNavigationUrls() : [];
1998
- const navMark = initialNavUrls.length;
1999
- const lastPreMarkUrl = navMark > 0 ? initialNavUrls[navMark - 1] : void 0;
2000
- const checkRecentNavUrls = () => {
2001
- if (negate || !driver.getNavigationUrls) return false;
2002
- const all = driver.getNavigationUrls();
2003
- const sinceMark = all.slice(Math.min(navMark, all.length));
2004
- if (sinceMark.some((u) => matchesUrl(u))) return true;
2005
- if (lastPreMarkUrl && matchesUrl(lastPreMarkUrl)) return true;
2006
- return false;
2007
- };
2008
- const readCurrentUrl = () => driver.getUrl ? driver.getUrl().pipe(Effect4.catch(() => Effect4.succeed(""))) : driver.evaluate(
2009
- "typeof window !== 'undefined' && window.location ? window.location.href : ''"
2010
- ).pipe(Effect4.catch(() => Effect4.succeed("")));
2011
- const initialUrl = yield* readCurrentUrl();
2012
- lastUrl = initialUrl;
2013
- if (negate ? !matchesUrl(initialUrl) : matchesUrl(initialUrl) || checkRecentNavUrls()) {
2014
- return;
2015
- }
2016
- while (Date.now() < deadline) {
2017
- if (checkRecentNavUrls()) return;
2018
- const domChannel = driver.domChannel;
2019
- if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
2020
- const remaining = Math.max(50, deadline - Date.now());
2021
- const reactive = yield* Effect4.tryPromise({
2022
- try: () => domChannel.waitForMatch("", {
2023
- kind: "url",
2024
- ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
2025
- ...negate ? { negate: true } : {},
2026
- timeoutMs: Math.min(remaining, 300)
2027
- }),
2028
- catch: () => null
2029
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
2030
- if (reactive?.matched) return;
2031
- if (reactive?.actual) lastUrl = reactive.actual;
2117
+ const finalActual = lastActualStr ?? String(lastCount >= 0 ? lastCount : 0);
2118
+ return yield* new TextMismatchError({
2119
+ message: negate ? `Expected count NOT to be ${expectedCount} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected count ${expectedCount} but got ${finalActual} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2120
+ expected: negate ? `not ${expectedCount}` : String(expectedCount),
2121
+ actual: finalActual,
2122
+ selector
2123
+ });
2124
+ }),
2125
+ waitForURL: (expected, opts, negate = false) => Effect4.gen(function* () {
2126
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2127
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2128
+ const start = Date.now();
2129
+ const deadline = start + timeout;
2130
+ let lastUrl = "";
2131
+ const matchesUrl = (url) => expected instanceof RegExp ? expected.test(url) : url === expected || url.includes(expected);
2132
+ const initialNavUrls = driver.getNavigationUrls ? driver.getNavigationUrls() : [];
2133
+ const navMark = initialNavUrls.length;
2134
+ const lastPreMarkUrl = navMark > 0 ? initialNavUrls[navMark - 1] : void 0;
2135
+ const checkRecentNavUrls = () => {
2136
+ if (negate || !driver.getNavigationUrls) return false;
2137
+ const all = driver.getNavigationUrls();
2138
+ const sinceMark = all.slice(Math.min(navMark, all.length));
2139
+ if (sinceMark.some((u) => matchesUrl(u))) return true;
2140
+ if (lastPreMarkUrl && matchesUrl(lastPreMarkUrl)) return true;
2141
+ return false;
2142
+ };
2143
+ const readCurrentUrl = () => driver.getUrl ? driver.getUrl().pipe(Effect4.catch(() => Effect4.succeed(""))) : driver.evaluate(
2144
+ "typeof window !== 'undefined' && window.location ? window.location.href : ''"
2145
+ ).pipe(Effect4.catch(() => Effect4.succeed("")));
2146
+ const initialUrl = yield* readCurrentUrl();
2147
+ lastUrl = initialUrl;
2148
+ if (negate ? !matchesUrl(initialUrl) : matchesUrl(initialUrl) || checkRecentNavUrls()) {
2149
+ return;
2150
+ }
2151
+ while (Date.now() < deadline) {
2032
2152
  if (checkRecentNavUrls()) return;
2153
+ const domChannel = driver.domChannel;
2154
+ if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
2155
+ const remaining = Math.max(50, deadline - Date.now());
2156
+ const reactive = yield* Effect4.tryPromise({
2157
+ try: () => domChannel.waitForMatch("", {
2158
+ kind: "url",
2159
+ ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
2160
+ ...negate ? { negate: true } : {},
2161
+ timeoutMs: Math.min(remaining, 300)
2162
+ }),
2163
+ catch: () => null
2164
+ }).pipe(Effect4.catch(() => Effect4.succeed(null)));
2165
+ if (reactive?.matched) return;
2166
+ if (reactive?.actual) lastUrl = reactive.actual;
2167
+ if (checkRecentNavUrls()) return;
2168
+ }
2169
+ const url = yield* readCurrentUrl();
2170
+ if (url) lastUrl = url;
2171
+ if (negate ? !matchesUrl(url) : matchesUrl(url) || checkRecentNavUrls()) return;
2172
+ if (Date.now() >= deadline) break;
2173
+ yield* Effect4.sleep(
2174
+ Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2175
+ );
2033
2176
  }
2034
- const url = yield* readCurrentUrl();
2035
- if (url) lastUrl = url;
2036
- if (negate ? !matchesUrl(url) : matchesUrl(url) || checkRecentNavUrls()) return;
2037
- if (Date.now() >= deadline) break;
2038
- yield* Effect4.sleep(
2039
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2177
+ return yield* new TextMismatchError({
2178
+ message: negate ? `Expected URL NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms` : `Expected URL ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms`,
2179
+ expected: negate ? `not ${String(expected)}` : String(expected),
2180
+ actual: lastUrl,
2181
+ selector: "url"
2182
+ });
2183
+ }),
2184
+ assertFocusable: (selector, platform, opts) => Effect4.gen(function* () {
2185
+ const { isFocusable } = yield* Effect4.promise(
2186
+ () => import("./accessibility-audit-IWTD2HPR.js")
2040
2187
  );
2041
- }
2042
- return yield* new TextMismatchError({
2043
- message: negate ? `Expected URL NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms` : `Expected URL ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms`,
2044
- expected: negate ? `not ${String(expected)}` : String(expected),
2045
- actual: lastUrl,
2046
- selector: "url"
2047
- });
2048
- }),
2049
- assertFocusable: (selector, platform, opts) => Effect4.gen(function* () {
2050
- const { isFocusable } = yield* Effect4.promise(
2051
- () => import("./accessibility-audit-F5KLUHLS.js")
2052
- );
2053
- yield* pollUntilMatch(
2188
+ yield* pollUntilMatch(
2189
+ selector,
2190
+ opts,
2191
+ (el) => {
2192
+ const focusable = isFocusable(el, {
2193
+ platform
2194
+ });
2195
+ return { matched: focusable, actual: focusable ? "focusable" : "not focusable" };
2196
+ },
2197
+ (actual, timeout) => ({
2198
+ message: `Expected element to be focusable but it was "${actual ?? "not focusable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2199
+ expected: "focusable"
2200
+ })
2201
+ );
2202
+ }),
2203
+ assertRole: (selector, expectedRole, platform, opts, negate = false) => Effect4.gen(function* () {
2204
+ const { normalizeRole } = yield* Effect4.promise(
2205
+ () => import("./accessibility-audit-IWTD2HPR.js")
2206
+ );
2207
+ yield* pollUntilMatch(
2208
+ selector,
2209
+ opts,
2210
+ (el) => {
2211
+ const actual = el.role ?? normalizeRole(
2212
+ platform,
2213
+ el.elementType ?? "",
2214
+ el.attributes ?? {}
2215
+ );
2216
+ return { matched: actual === expectedRole, actual };
2217
+ },
2218
+ (actual, timeout) => ({
2219
+ message: negate ? `Expected role NOT to be "${expectedRole}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected role "${expectedRole}" but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2220
+ expected: negate ? `not ${expectedRole}` : expectedRole
2221
+ }),
2222
+ { kind: "role", expected: expectedRole },
2223
+ negate
2224
+ );
2225
+ }),
2226
+ assertMinTouchTarget: (selector, minSize, opts) => pollUntilMatch(
2054
2227
  selector,
2055
2228
  opts,
2056
2229
  (el) => {
2057
- const focusable = isFocusable(el, {
2058
- platform
2059
- });
2060
- return { matched: focusable, actual: focusable ? "focusable" : "not focusable" };
2230
+ const { width, height } = el.bounds;
2231
+ const passed = width >= minSize && height >= minSize;
2232
+ const actual = `${width}x${height}`;
2233
+ return { matched: passed, actual };
2061
2234
  },
2062
2235
  (actual, timeout) => ({
2063
- message: `Expected element to be focusable but it was "${actual ?? "not focusable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2064
- expected: "focusable"
2236
+ message: `Expected touch target to be at least ${minSize}x${minSize}px but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2237
+ expected: `${minSize}x${minSize}`
2065
2238
  })
2066
- );
2067
- }),
2068
- assertRole: (selector, expectedRole, platform, opts, negate = false) => Effect4.gen(function* () {
2069
- const { normalizeRole } = yield* Effect4.promise(
2070
- () => import("./accessibility-audit-F5KLUHLS.js")
2071
- );
2072
- yield* pollUntilMatch(
2073
- selector,
2074
- opts,
2075
- (el) => {
2076
- const actual = el.role ?? normalizeRole(
2077
- platform,
2078
- el.elementType ?? "",
2079
- el.attributes ?? {}
2080
- );
2081
- return { matched: actual === expectedRole, actual };
2082
- },
2083
- (actual, timeout) => ({
2084
- message: negate ? `Expected role NOT to be "${expectedRole}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected role "${expectedRole}" but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2085
- expected: negate ? `not ${expectedRole}` : expectedRole
2086
- }),
2087
- { kind: "role", expected: expectedRole },
2088
- negate
2089
- );
2090
- }),
2091
- assertMinTouchTarget: (selector, minSize, opts) => pollUntilMatch(
2092
- selector,
2093
- opts,
2094
- (el) => {
2095
- const { width, height } = el.bounds;
2096
- const passed = width >= minSize && height >= minSize;
2097
- const actual = `${width}x${height}`;
2098
- return { matched: passed, actual };
2099
- },
2100
- (actual, timeout) => ({
2101
- message: `Expected touch target to be at least ${minSize}x${minSize}px but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2102
- expected: `${minSize}x${minSize}`
2239
+ ),
2240
+ runAccessibilityAudit: (platform, options = {}) => Effect4.gen(function* () {
2241
+ if (platform !== "web") {
2242
+ return yield* new DriverError({
2243
+ message: `accessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2244
+ });
2245
+ }
2246
+ const axeContext = {};
2247
+ const includes = [
2248
+ ...options.targetSelector ? [options.targetSelector] : [],
2249
+ ...options.includeSelectors ?? []
2250
+ ];
2251
+ if (includes.length > 0) {
2252
+ axeContext["include"] = includes.map((s) => [s]);
2253
+ }
2254
+ if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2255
+ axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2256
+ }
2257
+ const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2258
+ const axeOptions = {};
2259
+ const rulesConfig = {};
2260
+ for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2261
+ for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2262
+ if (Object.keys(rulesConfig).length > 0) {
2263
+ axeOptions["rules"] = rulesConfig;
2264
+ }
2265
+ if (options.tags && options.tags.length > 0) {
2266
+ axeOptions["runOnly"] = { type: "tag", values: options.tags };
2267
+ }
2268
+ const runExpr = `axe.run(${serializedContext}, ${JSON.stringify(axeOptions)})`;
2269
+ let rawResult;
2270
+ if (hasInjectedAxe) {
2271
+ const fastScript = `(function() { if (typeof axe === "undefined") return { __spanaNeedAxe: true }; return ${runExpr}; })()`;
2272
+ rawResult = yield* driver.evaluate(fastScript);
2273
+ } else {
2274
+ rawResult = { __spanaNeedAxe: true };
2275
+ }
2276
+ if (rawResult && typeof rawResult === "object" && "__spanaNeedAxe" in rawResult) {
2277
+ const axeSource = yield* Effect4.promise(() => loadCachedAxeSource());
2278
+ const injectAndRunScript = `(function() { if (typeof axe === "undefined") { ${axeSource} } return ${runExpr}; })()`;
2279
+ rawResult = yield* driver.evaluate(injectAndRunScript);
2280
+ hasInjectedAxe = true;
2281
+ }
2282
+ const axeResult = rawResult;
2283
+ const violations = (axeResult?.violations ?? []).map((v) => ({
2284
+ ruleId: v.id,
2285
+ severity: v.impact ?? "minor",
2286
+ description: v.description,
2287
+ helpUrl: v.helpUrl,
2288
+ wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2289
+ elements: v.nodes.map((n) => ({
2290
+ selector: n.target.join(", "),
2291
+ html: n.html,
2292
+ failureSummary: n.failureSummary
2293
+ }))
2294
+ }));
2295
+ return { violations };
2296
+ }),
2297
+ assertAccessibilityAudit: (platform, options = {}) => Effect4.gen(function* () {
2298
+ if (platform !== "web") {
2299
+ return yield* new DriverError({
2300
+ message: `assertAccessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2301
+ });
2302
+ }
2303
+ const axeContext = {};
2304
+ const includes = [
2305
+ ...options.targetSelector ? [options.targetSelector] : [],
2306
+ ...options.includeSelectors ?? []
2307
+ ];
2308
+ if (includes.length > 0) {
2309
+ axeContext["include"] = includes.map((s) => [s]);
2310
+ }
2311
+ if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2312
+ axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2313
+ }
2314
+ const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2315
+ const axeOptions = {};
2316
+ const rulesConfig = {};
2317
+ for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2318
+ for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2319
+ if (Object.keys(rulesConfig).length > 0) {
2320
+ axeOptions["rules"] = rulesConfig;
2321
+ }
2322
+ if (options.tags && options.tags.length > 0) {
2323
+ axeOptions["runOnly"] = { type: "tag", values: options.tags };
2324
+ }
2325
+ const runExpr = `axe.run(${serializedContext}, ${JSON.stringify(axeOptions)})`;
2326
+ let rawResult;
2327
+ if (hasInjectedAxe) {
2328
+ const fastScript = `(function() { if (typeof axe === "undefined") return { __spanaNeedAxe: true }; return ${runExpr}; })()`;
2329
+ rawResult = yield* driver.evaluate(fastScript);
2330
+ } else {
2331
+ rawResult = { __spanaNeedAxe: true };
2332
+ }
2333
+ if (rawResult && typeof rawResult === "object" && "__spanaNeedAxe" in rawResult) {
2334
+ const axeSource = yield* Effect4.promise(() => loadCachedAxeSource());
2335
+ const injectAndRunScript = `(function() { if (typeof axe === "undefined") { ${axeSource} } return ${runExpr}; })()`;
2336
+ rawResult = yield* driver.evaluate(injectAndRunScript);
2337
+ hasInjectedAxe = true;
2338
+ }
2339
+ const axeResult = rawResult;
2340
+ const violations = (axeResult?.violations ?? []).map((v) => ({
2341
+ ruleId: v.id,
2342
+ severity: v.impact ?? "minor",
2343
+ description: v.description,
2344
+ helpUrl: v.helpUrl,
2345
+ wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2346
+ elements: v.nodes.map((n) => ({
2347
+ selector: n.target.join(", "),
2348
+ html: n.html,
2349
+ failureSummary: n.failureSummary
2350
+ }))
2351
+ }));
2352
+ const minSeverity = options.severity ?? "serious";
2353
+ const filtered = filterViolations(violations, minSeverity);
2354
+ if (filtered.length > 0) {
2355
+ const summary = formatViolationSummary(filtered);
2356
+ return yield* new DriverError({ message: summary });
2357
+ }
2103
2358
  })
2104
- ),
2105
- runAccessibilityAudit: (platform, options = {}) => Effect4.gen(function* () {
2106
- if (platform !== "web") {
2107
- return yield* new DriverError({
2108
- message: `accessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2109
- });
2110
- }
2111
- const axeContext = {};
2112
- const includes = [
2113
- ...options.targetSelector ? [options.targetSelector] : [],
2114
- ...options.includeSelectors ?? []
2115
- ];
2116
- if (includes.length > 0) {
2117
- axeContext["include"] = includes.map((s) => [s]);
2118
- }
2119
- if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2120
- axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2121
- }
2122
- const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2123
- const axeOptions = {};
2124
- const rulesConfig = {};
2125
- for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2126
- for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2127
- if (Object.keys(rulesConfig).length > 0) {
2128
- axeOptions["rules"] = rulesConfig;
2129
- }
2130
- if (options.tags && options.tags.length > 0) {
2131
- axeOptions["runOnly"] = { type: "tag", values: options.tags };
2132
- }
2133
- const runExpr = `axe.run(${serializedContext}, ${JSON.stringify(axeOptions)})`;
2134
- const fastScript = `(function() { if (typeof axe === "undefined") return { __spanaNeedAxe: true }; return ${runExpr}; })()`;
2135
- let rawResult = yield* driver.evaluate(fastScript);
2136
- if (rawResult && typeof rawResult === "object" && "__spanaNeedAxe" in rawResult) {
2137
- const axeSource = yield* Effect4.promise(() => loadCachedAxeSource());
2138
- const injectAndRunScript = `(function() { if (typeof axe === "undefined") { ${axeSource} } return ${runExpr}; })()`;
2139
- rawResult = yield* driver.evaluate(injectAndRunScript);
2140
- }
2141
- const axeResult = rawResult;
2142
- const violations = (axeResult?.violations ?? []).map((v) => ({
2143
- ruleId: v.id,
2144
- severity: v.impact ?? "minor",
2145
- description: v.description,
2146
- helpUrl: v.helpUrl,
2147
- wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2148
- elements: v.nodes.map((n) => ({
2149
- selector: n.target.join(", "),
2150
- html: n.html,
2151
- failureSummary: n.failureSummary
2152
- }))
2153
- }));
2154
- return { violations };
2155
- }),
2156
- assertAccessibilityAudit: (platform, options = {}) => Effect4.gen(function* () {
2157
- if (platform !== "web") {
2158
- return yield* new DriverError({
2159
- message: `assertAccessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2160
- });
2161
- }
2162
- const { readFileSync: readFileSync2 } = yield* Effect4.promise(() => import("fs"));
2163
- const { createRequire } = yield* Effect4.promise(() => import("module"));
2164
- const require2 = createRequire(import.meta.url);
2165
- const axePath = require2.resolve("axe-core/axe.js");
2166
- const axeSource = readFileSync2(axePath, "utf-8");
2167
- const { filterViolations, formatViolationSummary } = yield* Effect4.promise(
2168
- () => import("./accessibility-audit-F5KLUHLS.js")
2169
- );
2170
- const axeContext = {};
2171
- const includes = [
2172
- ...options.targetSelector ? [options.targetSelector] : [],
2173
- ...options.includeSelectors ?? []
2174
- ];
2175
- if (includes.length > 0) {
2176
- axeContext["include"] = includes.map((s) => [s]);
2177
- }
2178
- if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2179
- axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2180
- }
2181
- const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2182
- const axeOptions = {};
2183
- const rulesConfig = {};
2184
- for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2185
- for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2186
- if (Object.keys(rulesConfig).length > 0) {
2187
- axeOptions["rules"] = rulesConfig;
2188
- }
2189
- if (options.tags && options.tags.length > 0) {
2190
- axeOptions["runOnly"] = { type: "tag", values: options.tags };
2191
- }
2192
- const script = `
2193
- (function() {
2194
- if (typeof axe === "undefined") {
2195
- ${axeSource}
2196
- }
2197
- return axe.run(${serializedContext}, ${JSON.stringify(axeOptions)});
2198
- })()
2199
- `;
2200
- const axeResult = yield* driver.evaluate(script);
2201
- const violations = (axeResult?.violations ?? []).map((v) => ({
2202
- ruleId: v.id,
2203
- severity: v.impact ?? "minor",
2204
- description: v.description,
2205
- helpUrl: v.helpUrl,
2206
- wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2207
- elements: v.nodes.map((n) => ({
2208
- selector: n.target.join(", "),
2209
- html: n.html,
2210
- failureSummary: n.failureSummary
2211
- }))
2212
- }));
2213
- const minSeverity = options.severity ?? "serious";
2214
- const filtered = filterViolations(violations, minSeverity);
2215
- if (filtered.length > 0) {
2216
- const summary = formatViolationSummary(filtered);
2217
- return yield* new DriverError({ message: summary });
2218
- }
2219
- })
2220
- });
2359
+ };
2360
+ };
2221
2361
  const assertions = createAssertions();
2222
2362
  const runGuardedPointerAction = (selector, opts, actionLabel, performPointer, options) => Effect4.gen(function* () {
2223
2363
  const effectiveTapMode = opts?.tapMode ?? config.tapMode ?? "native";
@@ -2265,7 +2405,7 @@ function createCoordinator(driver, config) {
2265
2405
  return true;
2266
2406
  }
2267
2407
  }
2268
- const { x, y } = centerOf(resolved.element);
2408
+ const { x, y } = resolved.domMatch?.clickPoint && (!resolved.webViewFrame || resolved.webViewFrame.x === 0 && resolved.webViewFrame.y === 0 && config.platform !== "ios" && config.platform !== "android") ? resolved.domMatch.clickPoint : centerOf(resolved.element);
2269
2409
  const guardActive = !opts?.force && resolved.channel === "dom" && !isRelativeSelectorLike2(selector) && !isSystemUISelector(selector) && !(typeof selector === "object" && selector !== null && "frame" in selector && selector.frame) && driver.domChannel?.isConnected();
2270
2410
  if (guardActive && canInlineTapGuard) {
2271
2411
  yield* performPointer(x, y, resolved);
@@ -2368,7 +2508,7 @@ function createCoordinator(driver, config) {
2368
2508
  selector,
2369
2509
  opts,
2370
2510
  "doubleTap",
2371
- (x, y) => Effect4.gen(function* () {
2511
+ (x, y) => driver.domChannel && driver.doubleTapAtCoordinate ? driver.doubleTapAtCoordinate(x, y) : Effect4.gen(function* () {
2372
2512
  yield* driver.tapAtCoordinate(x, y);
2373
2513
  yield* Effect4.promise(() => new Promise((r) => setTimeout(r, 200)));
2374
2514
  yield* driver.tapAtCoordinate(x, y);
@@ -2416,7 +2556,7 @@ function createCoordinator(driver, config) {
2416
2556
  mergedOpts,
2417
2557
  cache
2418
2558
  );
2419
- const { x, y } = centerOf(resolved.element);
2559
+ const { x, y } = resolved.domMatch?.clickPoint && (!resolved.webViewFrame || resolved.webViewFrame.x === 0 && resolved.webViewFrame.y === 0 && config.platform !== "ios" && config.platform !== "android") ? resolved.domMatch.clickPoint : centerOf(resolved.element);
2420
2560
  if (driver.hoverAtCoordinate) {
2421
2561
  yield* driver.hoverAtCoordinate(x, y);
2422
2562
  } else if (config.platform === "web") {
@@ -2583,6 +2723,28 @@ function createCoordinator(driver, config) {
2583
2723
  );
2584
2724
  }),
2585
2725
  blur: (selector, opts) => Effect4.gen(function* () {
2726
+ if (!isRelativeSelectorLike2(selector) && !isSystemUISelector(selector) && driver.domChannel?.isConnected()) {
2727
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2728
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2729
+ const deadline = Date.now() + timeout;
2730
+ const script = `(() => {
2731
+ const el = ${buildDomFindElementScript(selector)};
2732
+ if (el && typeof el.blur === "function") { el.blur(); return true; }
2733
+ return false;
2734
+ })()`;
2735
+ while (true) {
2736
+ const ok = yield* Effect4.tryPromise({
2737
+ try: () => driver.domChannel.evaluate(script),
2738
+ catch: () => false
2739
+ }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2740
+ if (ok) {
2741
+ yield* afterMutation();
2742
+ return;
2743
+ }
2744
+ if (Date.now() >= deadline) break;
2745
+ yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
2746
+ }
2747
+ }
2586
2748
  yield* waitForResolvedElementResult(
2587
2749
  driver,
2588
2750
  selector,
@@ -2601,14 +2763,7 @@ function createCoordinator(driver, config) {
2601
2763
  }
2602
2764
  return false;
2603
2765
  })()`;
2604
- if (driver.domChannel?.isConnected()) {
2605
- yield* Effect4.tryPromise({
2606
- try: () => driver.domChannel.evaluate(script),
2607
- catch: () => false
2608
- }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2609
- } else {
2610
- yield* driver.evaluate(script).pipe(Effect4.catch(() => Effect4.succeed(false)));
2611
- }
2766
+ yield* driver.evaluate(script).pipe(Effect4.catch(() => Effect4.succeed(false)));
2612
2767
  }
2613
2768
  yield* afterMutation();
2614
2769
  }),
@@ -2651,6 +2806,24 @@ function createCoordinator(driver, config) {
2651
2806
  return res.selected ?? [];
2652
2807
  }),
2653
2808
  focus: (selector, opts) => Effect4.gen(function* () {
2809
+ if (!isRelativeSelectorLike2(selector) && !isSystemUISelector(selector) && driver.domChannel?.isConnected()) {
2810
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2811
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2812
+ const deadline = Date.now() + timeout;
2813
+ const script = buildDomFocusScript(selector);
2814
+ while (true) {
2815
+ const ok = yield* Effect4.tryPromise({
2816
+ try: () => driver.domChannel.evaluate(script),
2817
+ catch: () => false
2818
+ }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2819
+ if (ok) {
2820
+ yield* afterMutation();
2821
+ return;
2822
+ }
2823
+ if (Date.now() >= deadline) break;
2824
+ yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
2825
+ }
2826
+ }
2654
2827
  const resolved = yield* waitForResolvedElementResult(
2655
2828
  driver,
2656
2829
  selector,
@@ -2661,16 +2834,13 @@ function createCoordinator(driver, config) {
2661
2834
  );
2662
2835
  if (!isRelativeSelectorLike2(selector) && !isSystemUISelector(selector)) {
2663
2836
  const script = buildDomFocusScript(selector);
2664
- const ok = driver.domChannel?.isConnected() ? yield* Effect4.tryPromise({
2665
- try: () => driver.domChannel.evaluate(script),
2666
- catch: () => false
2667
- }).pipe(Effect4.catch(() => Effect4.succeed(false))) : yield* driver.evaluate(script).pipe(Effect4.catch(() => Effect4.succeed(false)));
2837
+ const ok = yield* driver.evaluate(script).pipe(Effect4.catch(() => Effect4.succeed(false)));
2668
2838
  if (ok) {
2669
2839
  yield* afterMutation();
2670
2840
  return;
2671
2841
  }
2672
2842
  }
2673
- const { x, y } = centerOf(resolved.element);
2843
+ const { x, y } = resolved.domMatch?.clickPoint && (!resolved.webViewFrame || resolved.webViewFrame.x === 0 && resolved.webViewFrame.y === 0 && config.platform !== "ios" && config.platform !== "android") ? resolved.domMatch.clickPoint : centerOf(resolved.element);
2674
2844
  yield* driver.tapAtCoordinate(x, y);
2675
2845
  yield* afterMutation();
2676
2846
  }),
@@ -2728,8 +2898,45 @@ function createCoordinator(driver, config) {
2728
2898
  const totalTimeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2729
2899
  const deadline = Date.now() + totalTimeout;
2730
2900
  let scrollCount = 0;
2901
+ const domChannel = driver.domChannel;
2902
+ const isWebDom = (config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && Boolean(domChannel?.isConnected());
2903
+ const isRectInViewport = (m) => {
2904
+ const vpW = m.viewportWidth || 0;
2905
+ const vpH = m.viewportHeight || 0;
2906
+ if (vpW <= 0 || vpH <= 0) return true;
2907
+ const r = m.rect;
2908
+ return r.width > 0 && r.height > 0 && r.x + r.width > 0 && r.y + r.height > 0 && r.x < vpW && r.y < vpH;
2909
+ };
2910
+ const probeVisibleInViewport = () => Effect4.gen(function* () {
2911
+ if (isWebDom && domChannel) {
2912
+ const matches = yield* Effect4.tryPromise({
2913
+ try: () => domChannel.query(selector),
2914
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
2915
+ }).pipe(
2916
+ Effect4.catch(
2917
+ (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
2918
+ )
2919
+ );
2920
+ if (matches) {
2921
+ const visibleMatches = matches.filter((m) => m.visible);
2922
+ if (visibleMatches.length === 0) return false;
2923
+ if (visibleMatches.some(isRectInViewport)) return true;
2924
+ if (domChannel.scrollIntoView) {
2925
+ const scrolled = yield* Effect4.tryPromise({
2926
+ try: () => domChannel.scrollIntoView(selector),
2927
+ catch: () => null
2928
+ }).pipe(Effect4.catch(() => Effect4.succeed(null)));
2929
+ if (scrolled && scrolled.visible && isRectInViewport(scrolled)) {
2930
+ return true;
2931
+ }
2932
+ }
2933
+ return false;
2934
+ }
2935
+ }
2936
+ return yield* probeVisible(selector, opts);
2937
+ });
2731
2938
  while (scrollCount <= maxScrolls && Date.now() <= deadline) {
2732
- const found = yield* probeVisible(selector, opts);
2939
+ const found = yield* probeVisibleInViewport();
2733
2940
  if (found) {
2734
2941
  return;
2735
2942
  }
@@ -3257,6 +3464,11 @@ function createPromiseExpect(driver, config, recorder, flowContext, visualRegres
3257
3464
  (v) => v === void 0,
3258
3465
  (v) => negate ? `Expected polled value NOT to be undefined` : `Expected polled value to be undefined, received ${JSON.stringify(v)}`
3259
3466
  ),
3467
+ toBeNull: () => check(
3468
+ "toBeNull",
3469
+ (v) => v === null,
3470
+ (v) => negate ? `Expected polled value NOT to be null` : `Expected polled value to be null, received ${JSON.stringify(v)}`
3471
+ ),
3260
3472
  toHaveLength: (expected) => check(
3261
3473
  `toHaveLength(${expected})`,
3262
3474
  (v) => v !== null && v !== void 0 && typeof v.length === "number" && v.length === expected,
@@ -3605,7 +3817,8 @@ function parseSetCookieHeader(headerValue, originUrl) {
3605
3817
  const v = rest.join("=").trim();
3606
3818
  if (k === "path" && v) cookie.path = v;
3607
3819
  else if (k === "domain" && v) {
3608
- cookie.domain = v;
3820
+ const bare = v.replace(/^\.+/, "");
3821
+ cookie.domain = bare ? `.${bare}` : v;
3609
3822
  delete cookie.url;
3610
3823
  } else if (k === "httponly") cookie.httpOnly = true;
3611
3824
  else if (k === "secure") cookie.secure = true;
@@ -3678,7 +3891,10 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
3678
3891
  message: `${name}() is not supported on ${target} with the current driver`
3679
3892
  });
3680
3893
  };
3681
- const runStep = (command, action, opts) => recorder ? recorder.runStep(command, action, opts) : action();
3894
+ const runStep = (command, action, opts) => {
3895
+ options.onActiveDriver?.(driver);
3896
+ return recorder ? recorder.runStep(command, action, opts) : action();
3897
+ };
3682
3898
  const runDeviceStep = (name, method, ...args) => runStep(name, async () => {
3683
3899
  if (!method) {
3684
3900
  const target = platform ?? (await run(driver.getDeviceInfo())).platform;
@@ -4210,18 +4426,18 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4210
4426
  insertText: (text) => runStep("keyboard.insertText", () => run(coord.inputText(text)))
4211
4427
  };
4212
4428
  const mouseClient = {
4213
- move: (x, y) => runStep(
4429
+ move: (x, y, opts) => runStep(
4214
4430
  `mouse.move(${x},${y})`,
4215
- () => run(optionalMethod("mouse.move", driver.hoverAtCoordinate)(x, y))
4431
+ () => run(optionalMethod("mouse.move", driver.hoverAtCoordinate)(x, y, opts))
4216
4432
  ),
4217
- down: (x, y, opts) => runStep(
4218
- `mouse.down(${x},${y})`,
4433
+ down: ((x, y, opts) => runStep(
4434
+ typeof x === "number" ? `mouse.down(${x},${y})` : "mouse.down()",
4219
4435
  () => run(optionalMethod("mouse.down", driver.mouseDown)(x, y, opts))
4220
- ),
4221
- up: (x, y, opts) => runStep(
4222
- `mouse.up(${x},${y})`,
4436
+ )),
4437
+ up: ((x, y, opts) => runStep(
4438
+ typeof x === "number" ? `mouse.up(${x},${y})` : "mouse.up()",
4223
4439
  () => run(optionalMethod("mouse.up", driver.mouseUp)(x, y, opts))
4224
- ),
4440
+ )),
4225
4441
  click: (x, y) => runStep(`mouse.click(${x},${y})`, () => run(coord.tapXY(x, y))),
4226
4442
  wheel: (deltaX, deltaY, opts) => runStep(`mouse.wheel(${deltaX},${deltaY})`, async () => {
4227
4443
  const x = opts?.x ?? 0;
@@ -4444,6 +4660,7 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4444
4660
  captureScreenshot: true
4445
4661
  }
4446
4662
  ),
4663
+ lastNavigationStatus: () => driver.getLastNavigationStatus?.() ?? null,
4447
4664
  openStory: (storyId, opts) => runStep(
4448
4665
  `openStory(${storyId})`,
4449
4666
  async () => {
@@ -4522,12 +4739,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4522
4739
  const timeout = opts?.timeout ?? config.defaults?.timeout ?? 5e3;
4523
4740
  const pollInterval = opts?.pollInterval ?? 100;
4524
4741
  const deadline = Date.now() + timeout;
4742
+ let lastTransientErr;
4525
4743
  while (Date.now() < deadline) {
4526
- const val = arg === void 0 ? await run(driver.evaluate(fn)) : await run(driver.evaluate(fn, arg));
4527
- if (val) return val;
4528
- await new Promise((r) => setTimeout(r, pollInterval));
4744
+ try {
4745
+ const val = arg === void 0 ? await run(driver.evaluate(fn)) : await run(driver.evaluate(fn, arg));
4746
+ if (val) return val;
4747
+ lastTransientErr = void 0;
4748
+ } catch (err) {
4749
+ const msg = err instanceof Error ? err.message : String(err);
4750
+ const isNavContextDestroyed = /Execution context was destroyed|Cannot find context with specified id|Inspected target navigated or closed/i.test(
4751
+ msg
4752
+ );
4753
+ if (!isNavContextDestroyed) throw err;
4754
+ lastTransientErr = err;
4755
+ }
4756
+ await new Promise(
4757
+ (r) => setTimeout(r, Math.min(pollInterval, Math.max(10, deadline - Date.now())))
4758
+ );
4529
4759
  }
4530
- throw new DriverError({ message: `waitForFunction() timed out after ${timeout}ms` });
4760
+ const detail = lastTransientErr instanceof Error ? ` (${lastTransientErr.message})` : "";
4761
+ throw new DriverError({
4762
+ message: `waitForFunction() timed out after ${timeout}ms${detail}`
4763
+ });
4531
4764
  })),
4532
4765
  waitForPopup: (triggerFn, opts) => runStep(
4533
4766
  "waitForPopup",
@@ -4546,6 +4779,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4546
4779
  () => run(driver.takeScreenshot()),
4547
4780
  { name }
4548
4781
  ),
4782
+ boundingBox: (selector, opts) => runStep(
4783
+ "boundingBox",
4784
+ async () => {
4785
+ try {
4786
+ const el = await run(
4787
+ coord.assertVisible(selector, {
4788
+ timeout: opts?.timeout ?? 5e3,
4789
+ platform: config.platform
4790
+ })
4791
+ );
4792
+ return {
4793
+ x: el.bounds.x,
4794
+ y: el.bounds.y,
4795
+ width: el.bounds.width,
4796
+ height: el.bounds.height
4797
+ };
4798
+ } catch {
4799
+ return null;
4800
+ }
4801
+ },
4802
+ { selector }
4803
+ ),
4549
4804
  evaluate: ((fn, ...args) => runStep(
4550
4805
  formatEvaluateCommand(fn),
4551
4806
  () => run(driver.evaluate(fn, ...args))
@@ -4555,6 +4810,11 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4555
4810
  () => driver.route ? run(driver.route(matcher, handler)) : unsupportedNetworkFeature("route"),
4556
4811
  { selector: { matcher: describeMatcher(matcher) } }
4557
4812
  ),
4813
+ unroute: (matcher, handler) => runStep(
4814
+ "unroute",
4815
+ () => driver.unroute ? run(driver.unroute(matcher, handler)) : unsupportedNetworkFeature("unroute"),
4816
+ { selector: { matcher: describeMatcher(matcher) } }
4817
+ ),
4558
4818
  mockNetwork: (matcher, response) => runStep(
4559
4819
  "mockNetwork",
4560
4820
  () => driver.mockNetwork ? run(driver.mockNetwork(matcher, response)) : unsupportedNetworkFeature("mockNetwork"),
@@ -4741,7 +5001,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4741
5001
  getAttribute: (sel, name, opts) => appObj.getAttribute(scoped(sel), name, opts),
4742
5002
  isVisible: (sel, opts) => appObj.isVisible(scoped(sel), opts),
4743
5003
  isEnabled: (sel, opts) => appObj.isEnabled(scoped(sel), opts),
5004
+ isChecked: (sel, opts) => appObj.isChecked(scoped(sel), opts),
4744
5005
  count: (sel, opts) => appObj.count(scoped(sel), opts),
5006
+ evaluate: (fn, ...args) => runStep(
5007
+ "frame.evaluate",
5008
+ async () => {
5009
+ const ch = driver.domChannel;
5010
+ if (ch?.isConnected() && ch.evaluateInFrame) {
5011
+ return ch.evaluateInFrame(frameSelector, fn, ...args);
5012
+ }
5013
+ const expr = buildDomFrameEvaluateScript(frameSelector, fn, args);
5014
+ const res = await appObj.evaluate(
5015
+ expr
5016
+ );
5017
+ if (res?.__spanaFrameEvalOk) {
5018
+ return res.value;
5019
+ }
5020
+ throw new DriverError({
5021
+ message: `Iframe matching ${JSON.stringify(frameSelector)} not found`
5022
+ });
5023
+ },
5024
+ { selector: frameSelector }
5025
+ ),
4745
5026
  expect: (sel) => appExpect(scoped(sel))
4746
5027
  };
4747
5028
  },
@@ -4826,15 +5107,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4826
5107
  selector
4827
5108
  }),
4828
5109
  isVisible: (selector, opts) => {
4829
- const timeout = opts?.timeout ?? 1e3;
5110
+ const timeout = opts?.timeout ?? 0;
4830
5111
  return run(
4831
5112
  Effect6.gen(function* () {
5113
+ if (timeout <= 0) {
5114
+ const resolved = yield* Effect6.result(
5115
+ resolveElementAcrossChannels(driver, selector, config.parse, void 0, {
5116
+ forAction: false,
5117
+ platform: config.platform
5118
+ })
5119
+ );
5120
+ return resolved._tag === "Success" && resolved.success !== void 0;
5121
+ }
4832
5122
  const result = yield* Effect6.result(
4833
5123
  waitForElement(
4834
5124
  driver,
4835
5125
  selector,
4836
5126
  config.parse,
4837
- { timeout, pollInterval: 100 },
5127
+ {
5128
+ timeout,
5129
+ pollInterval: Math.min(100, timeout),
5130
+ platform: config.platform
5131
+ },
4838
5132
  void 0
4839
5133
  )
4840
5134
  );
@@ -4843,6 +5137,7 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4843
5137
  );
4844
5138
  },
4845
5139
  isEnabled: (selector, opts) => runStep("isEnabled", () => run(coord.isElementEnabled(selector, opts)), { selector }),
5140
+ isChecked: (selector, opts) => runStep("isChecked", () => run(coord.isChecked(selector, opts)), { selector }),
4846
5141
  count: (selector, opts) => runStep("count", () => run(coord.count(selector, opts)), { selector }),
4847
5142
  // Web-first bridge & fast state helpers
4848
5143
  waitForIdle: (opts) => runStep("waitForIdle", async () => {
@@ -5157,11 +5452,13 @@ export {
5157
5452
  domRectToScreenBounds,
5158
5453
  isOffscreenInViewport,
5159
5454
  resolveElementAcrossChannels,
5455
+ loadCachedAxeSource,
5160
5456
  createCoordinator,
5161
5457
  buildStorybookUrl,
5162
5458
  matchDataSnapshot,
5163
5459
  assertDataSnapshot,
5164
5460
  createPromiseExpect,
5461
+ parseSetCookieHeader,
5165
5462
  createPromiseApp
5166
5463
  };
5167
- //# sourceMappingURL=chunk-ZCSH3QKX.js.map
5464
+ //# sourceMappingURL=chunk-L5EVAGCV.js.map