@intuned/runtime 1.3.17 → 1.3.18-interface.6

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 (300) hide show
  1. package/bin/intuned +0 -0
  2. package/bin/intuned-interface +7 -0
  3. package/dist/chunk-6ZRJOUQS.mjs +16 -0
  4. package/dist/chunk-6ZRJOUQS.mjs.map +1 -0
  5. package/dist/chunk-7YL2JUTE.mjs +146 -0
  6. package/dist/chunk-7YL2JUTE.mjs.map +1 -0
  7. package/dist/chunk-B3T6RXPC.mjs +794 -0
  8. package/dist/chunk-B3T6RXPC.mjs.map +1 -0
  9. package/dist/chunk-FGV5T6SI.mjs +27 -0
  10. package/dist/chunk-FGV5T6SI.mjs.map +1 -0
  11. package/dist/chunk-G4PO5RIV.mjs +85 -0
  12. package/dist/chunk-G4PO5RIV.mjs.map +1 -0
  13. package/dist/chunk-LZOMFHX3.mjs +38 -0
  14. package/dist/chunk-LZOMFHX3.mjs.map +1 -0
  15. package/dist/{common/formatZodError.js → chunk-NDMVGENG.mjs} +9 -9
  16. package/dist/chunk-NDMVGENG.mjs.map +1 -0
  17. package/dist/chunk-W4UX6G4X.mjs +17 -0
  18. package/dist/chunk-W4UX6G4X.mjs.map +1 -0
  19. package/dist/chunk-XC75QGFG.mjs +1106 -0
  20. package/dist/chunk-XC75QGFG.mjs.map +1 -0
  21. package/dist/chunk-XOAZ2MGA.mjs +59 -0
  22. package/dist/chunk-XOAZ2MGA.mjs.map +1 -0
  23. package/dist/commands/interface/run.d.mts +3 -0
  24. package/dist/commands/interface/run.d.ts +3 -1
  25. package/dist/commands/interface/run.js +2060 -178
  26. package/dist/commands/interface/run.js.map +1 -0
  27. package/dist/commands/interface/run.mjs +255 -0
  28. package/dist/commands/interface/run.mjs.map +1 -0
  29. package/dist/common/asyncLocalStorage/index.d.mts +17 -0
  30. package/dist/common/asyncLocalStorage/index.d.ts +9 -8
  31. package/dist/common/asyncLocalStorage/index.js +34 -9
  32. package/dist/common/asyncLocalStorage/index.js.map +1 -0
  33. package/dist/common/asyncLocalStorage/index.mjs +12 -0
  34. package/dist/common/asyncLocalStorage/index.mjs.map +1 -0
  35. package/dist/common/binStartupScript.d.mts +2 -0
  36. package/dist/common/binStartupScript.d.ts +2 -1
  37. package/dist/common/binStartupScript.js +127 -11
  38. package/dist/common/binStartupScript.js.map +1 -0
  39. package/dist/common/binStartupScript.mjs +135 -0
  40. package/dist/common/binStartupScript.mjs.map +1 -0
  41. package/dist/common/cleanEnvironmentVariables.d.mts +3 -0
  42. package/dist/common/cleanEnvironmentVariables.d.ts +3 -1
  43. package/dist/common/cleanEnvironmentVariables.js +30 -7
  44. package/dist/common/cleanEnvironmentVariables.js.map +1 -0
  45. package/dist/common/cleanEnvironmentVariables.mjs +8 -0
  46. package/dist/common/cleanEnvironmentVariables.mjs.map +1 -0
  47. package/dist/common/constants.d.mts +13 -0
  48. package/dist/common/constants.d.ts +13 -10
  49. package/dist/common/constants.js +58 -14
  50. package/dist/common/constants.js.map +1 -0
  51. package/dist/common/constants.mjs +28 -0
  52. package/dist/common/constants.mjs.map +1 -0
  53. package/dist/common/contextStorageStateHelpers.d.mts +24 -0
  54. package/dist/common/contextStorageStateHelpers.d.ts +8 -5
  55. package/dist/common/contextStorageStateHelpers.js +51 -23
  56. package/dist/common/contextStorageStateHelpers.js.map +1 -0
  57. package/dist/common/contextStorageStateHelpers.mjs +10 -0
  58. package/dist/common/contextStorageStateHelpers.mjs.map +1 -0
  59. package/dist/common/jwtTokenManager.d.mts +19 -0
  60. package/dist/common/jwtTokenManager.d.ts +6 -4
  61. package/dist/common/jwtTokenManager.js +112 -40
  62. package/dist/common/jwtTokenManager.js.map +1 -0
  63. package/dist/common/jwtTokenManager.mjs +11 -0
  64. package/dist/common/jwtTokenManager.mjs.map +1 -0
  65. package/dist/common/runApi/index.d.mts +11 -0
  66. package/dist/common/runApi/index.d.ts +10 -10
  67. package/dist/common/runApi/index.js +1776 -93
  68. package/dist/common/runApi/index.js.map +1 -0
  69. package/dist/common/runApi/index.mjs +18 -0
  70. package/dist/common/runApi/index.mjs.map +1 -0
  71. package/dist/common/settingsSchema.d.mts +536 -0
  72. package/dist/common/settingsSchema.d.ts +9 -6
  73. package/dist/common/settingsSchema.js +55 -20
  74. package/dist/common/settingsSchema.js.map +1 -0
  75. package/dist/common/settingsSchema.mjs +10 -0
  76. package/dist/common/settingsSchema.mjs.map +1 -0
  77. package/dist/common/telemetry.d.mts +6 -0
  78. package/dist/common/telemetry.d.ts +6 -3
  79. package/dist/common/telemetry.js +41 -9
  80. package/dist/common/telemetry.js.map +1 -0
  81. package/dist/common/telemetry.mjs +31 -0
  82. package/dist/common/telemetry.mjs.map +1 -0
  83. package/dist/export.d-BAUMB-lG.d.mts +140 -0
  84. package/dist/export.d-BAUMB-lG.d.ts +140 -0
  85. package/dist/index.d.mts +6 -0
  86. package/dist/index.d.ts +6 -5
  87. package/dist/index.js +783 -98
  88. package/dist/index.js.map +1 -0
  89. package/dist/index.mjs +47 -0
  90. package/dist/index.mjs.map +1 -0
  91. package/dist/runtime/index.d.mts +163 -0
  92. package/dist/runtime/index.d.ts +163 -10
  93. package/dist/runtime/index.js +779 -88
  94. package/dist/runtime/index.js.map +1 -0
  95. package/dist/runtime/index.mjs +42 -0
  96. package/dist/runtime/index.mjs.map +1 -0
  97. package/package.json +78 -23
  98. package/.babelrc +0 -21
  99. package/.eslintignore +0 -10
  100. package/.eslintrc.js +0 -39
  101. package/InterfaceTemplate/__utils.ts +0 -61
  102. package/InterfaceTemplate/index.playwright.ts +0 -6
  103. package/WebTemplate.zip +0 -0
  104. package/dist/commands/api/run.d.ts +0 -6
  105. package/dist/commands/api/run.js +0 -119
  106. package/dist/commands/auth-sessions/load.d.ts +0 -2
  107. package/dist/commands/auth-sessions/load.js +0 -35
  108. package/dist/commands/auth-sessions/run-check.d.ts +0 -2
  109. package/dist/commands/auth-sessions/run-check.js +0 -74
  110. package/dist/commands/auth-sessions/run-create.d.ts +0 -2
  111. package/dist/commands/auth-sessions/run-create.js +0 -78
  112. package/dist/commands/browser/save-state.d.ts +0 -2
  113. package/dist/commands/browser/save-state.js +0 -17
  114. package/dist/commands/browser/start-browser.d.ts +0 -2
  115. package/dist/commands/browser/start-browser.js +0 -14
  116. package/dist/commands/build.d.ts +0 -1
  117. package/dist/commands/build.js +0 -84
  118. package/dist/commands/common/browserUtils.d.ts +0 -14
  119. package/dist/commands/common/browserUtils.js +0 -58
  120. package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
  121. package/dist/commands/common/getFirstLineNumber.js +0 -101
  122. package/dist/commands/common/getFirstLineNumber.test.js +0 -228
  123. package/dist/commands/common/projectExclusions.d.ts +0 -2
  124. package/dist/commands/common/projectExclusions.js +0 -8
  125. package/dist/commands/common/sendMessageToClient.d.ts +0 -1
  126. package/dist/commands/common/sendMessageToClient.js +0 -10
  127. package/dist/commands/common/tsNodeImport.d.ts +0 -2
  128. package/dist/commands/common/tsNodeImport.js +0 -43
  129. package/dist/commands/common/utils/fileUtils.d.ts +0 -6
  130. package/dist/commands/common/utils/fileUtils.js +0 -33
  131. package/dist/commands/common/utils/settings.d.ts +0 -2
  132. package/dist/commands/common/utils/settings.js +0 -31
  133. package/dist/commands/common/utils/template.d.ts +0 -2
  134. package/dist/commands/common/utils/template.js +0 -31
  135. package/dist/commands/common/utils/unixSocket.d.ts +0 -23
  136. package/dist/commands/common/utils/unixSocket.js +0 -87
  137. package/dist/commands/get-headless-user-agent.d.ts +0 -1
  138. package/dist/commands/get-headless-user-agent.js +0 -18
  139. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  140. package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  141. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  142. package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  143. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  144. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  145. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  146. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  147. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  148. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  149. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  150. package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  151. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  152. package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
  153. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +0 -1
  154. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +0 -16
  155. package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  156. package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  157. package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  158. package/dist/commands/intuned-cli/commands/command.js +0 -9
  159. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  160. package/dist/commands/intuned-cli/commands/deploy.command.js +0 -42
  161. package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  162. package/dist/commands/intuned-cli/commands/index.js +0 -203
  163. package/dist/commands/intuned-cli/commands/provision.command.d.ts +0 -13
  164. package/dist/commands/intuned-cli/commands/provision.command.js +0 -50
  165. package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  166. package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  167. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  168. package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  169. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -31
  170. package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  171. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  172. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  173. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  174. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  175. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  176. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  177. package/dist/commands/intuned-cli/commands/types.d.ts +0 -35
  178. package/dist/commands/intuned-cli/commands/types.js +0 -31
  179. package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  180. package/dist/commands/intuned-cli/constants/index.js +0 -25
  181. package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -398
  182. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1060
  183. package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  184. package/dist/commands/intuned-cli/controller/api.js +0 -194
  185. package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  186. package/dist/commands/intuned-cli/controller/authSession.js +0 -424
  187. package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  188. package/dist/commands/intuned-cli/controller/build.js +0 -36
  189. package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
  190. package/dist/commands/intuned-cli/controller/deploy.js +0 -318
  191. package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  192. package/dist/commands/intuned-cli/controller/index.js +0 -46
  193. package/dist/commands/intuned-cli/controller/provision.d.ts +0 -21
  194. package/dist/commands/intuned-cli/controller/provision.js +0 -300
  195. package/dist/commands/intuned-cli/controller/scaffold.d.ts +0 -1
  196. package/dist/commands/intuned-cli/controller/scaffold.js +0 -77
  197. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -115
  198. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -41
  199. package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  200. package/dist/commands/intuned-cli/helpers/api.js +0 -16
  201. package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  202. package/dist/commands/intuned-cli/helpers/auth.js +0 -147
  203. package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  204. package/dist/commands/intuned-cli/helpers/backend.js +0 -35
  205. package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -15
  206. package/dist/commands/intuned-cli/helpers/browser.js +0 -64
  207. package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  208. package/dist/commands/intuned-cli/helpers/context.js +0 -33
  209. package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
  210. package/dist/commands/intuned-cli/helpers/errors.js +0 -44
  211. package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  212. package/dist/commands/intuned-cli/helpers/index.js +0 -137
  213. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -39
  214. package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
  215. package/dist/commands/intuned-cli/helpers/prompts.d.ts +0 -3
  216. package/dist/commands/intuned-cli/helpers/prompts.js +0 -71
  217. package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  218. package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  219. package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  220. package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  221. package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  222. package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  223. package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  224. package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  225. package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  226. package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  227. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  228. package/dist/commands/intuned-cli/helpers/wrapper.js +0 -76
  229. package/dist/commands/intuned-cli/index.d.ts +0 -1
  230. package/dist/commands/intuned-cli/index.js +0 -16
  231. package/dist/commands/intuned-cli/main.d.ts +0 -1
  232. package/dist/commands/intuned-cli/main.js +0 -36
  233. package/dist/commands/intuned-cli/types.d.ts +0 -70
  234. package/dist/commands/intuned-cli/types.js +0 -22
  235. package/dist/commands/ts-check.d.ts +0 -2
  236. package/dist/commands/ts-check.js +0 -56
  237. package/dist/common/Logger/Logger/index.d.ts +0 -12
  238. package/dist/common/Logger/Logger/index.js +0 -60
  239. package/dist/common/Logger/Logger/types.d.ts +0 -8
  240. package/dist/common/Logger/Logger/types.js +0 -5
  241. package/dist/common/Logger/index.d.ts +0 -12
  242. package/dist/common/Logger/index.js +0 -60
  243. package/dist/common/Logger/types.d.ts +0 -8
  244. package/dist/common/Logger/types.js +0 -5
  245. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
  246. package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
  247. package/dist/common/extension/extensionsHelpers.d.ts +0 -11
  248. package/dist/common/extension/extensionsHelpers.js +0 -147
  249. package/dist/common/extension/intunedExtensionServer.d.ts +0 -24
  250. package/dist/common/extension/intunedExtensionServer.js +0 -178
  251. package/dist/common/extension/types.d.ts +0 -212
  252. package/dist/common/extension/types.js +0 -51
  253. package/dist/common/formatZodError.d.ts +0 -2
  254. package/dist/common/intunedJson.d.ts +0 -229
  255. package/dist/common/intunedJson.js +0 -133
  256. package/dist/common/launchBrowser.d.ts +0 -33
  257. package/dist/common/launchBrowser.js +0 -235
  258. package/dist/common/playwrightContext.d.ts +0 -31
  259. package/dist/common/playwrightContext.js +0 -150
  260. package/dist/common/runApi/errors.d.ts +0 -72
  261. package/dist/common/runApi/errors.js +0 -169
  262. package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
  263. package/dist/common/runApi/importUsingImportFunction.js +0 -46
  264. package/dist/common/runApi/types.d.ts +0 -830
  265. package/dist/common/runApi/types.js +0 -73
  266. package/dist/common/setupContextHook.d.ts +0 -17
  267. package/dist/common/setupContextHook.js +0 -22
  268. package/dist/runtime/RunError.d.ts +0 -5
  269. package/dist/runtime/RunError.js +0 -19
  270. package/dist/runtime/attemptStore.d.ts +0 -2
  271. package/dist/runtime/attemptStore.js +0 -23
  272. package/dist/runtime/captcha.d.ts +0 -15
  273. package/dist/runtime/captcha.js +0 -191
  274. package/dist/runtime/captcha.test.js +0 -821
  275. package/dist/runtime/downloadDirectory.d.ts +0 -1
  276. package/dist/runtime/downloadDirectory.js +0 -19
  277. package/dist/runtime/enums.d.js +0 -5
  278. package/dist/runtime/enums.d.ts +0 -11
  279. package/dist/runtime/enums.js +0 -18
  280. package/dist/runtime/executionHelpers.test.js +0 -52
  281. package/dist/runtime/export.d.js +0 -5
  282. package/dist/runtime/export.d.ts +0 -284
  283. package/dist/runtime/extendPayload.d.ts +0 -2
  284. package/dist/runtime/extendPayload.js +0 -21
  285. package/dist/runtime/extendTimeout.d.ts +0 -1
  286. package/dist/runtime/extendTimeout.js +0 -23
  287. package/dist/runtime/getAiGatewayConfig.d.ts +0 -10
  288. package/dist/runtime/getAiGatewayConfig.js +0 -16
  289. package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
  290. package/dist/runtime/getAuthSessionParameters.js +0 -20
  291. package/dist/runtime/persistentStore.d.ts +0 -2
  292. package/dist/runtime/persistentStore.js +0 -37
  293. package/dist/runtime/persistentStore.test.js +0 -101
  294. package/dist/runtime/runInfo.d.ts +0 -2
  295. package/dist/runtime/runInfo.js +0 -21
  296. package/template.tsconfig.json +0 -11
  297. package/tsconfig.eslint.json +0 -5
  298. package/tsconfig.json +0 -25
  299. package/typedoc.json +0 -49
  300. /package/dist/common/assets/{browser_scripts.js → assets/browser_scripts.js} +0 -0
@@ -1,1060 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _authSession = require("../authSession");
5
- var _helpers = require("../../helpers");
6
- var _neverthrow = require("neverthrow");
7
- var _runApi = require("../../../../common/runApi");
8
- var _browser = require("../../helpers/browser");
9
- var _launchBrowser = require("../../../../common/launchBrowser");
10
- var _promises = require("timers/promises");
11
- const _checkPassedResult = (0, _neverthrow.ok)({
12
- result: true
13
- });
14
- const _checkFailedResult = (0, _neverthrow.ok)({
15
- result: false
16
- });
17
- const _errorResult = (0, _neverthrow.err)(new _runApi.AutomationError("failed"));
18
- function _createSuccessResult(session) {
19
- return (0, _neverthrow.ok)({
20
- session
21
- });
22
- }
23
- function getTerminal() {
24
- return new Proxy(() => ({}), {
25
- get: () => getTerminal(),
26
- apply: () => ({})
27
- });
28
- }
29
- function getMockTimeout() {
30
- let resolveTimeout = () => undefined;
31
- _vitest.vi.mocked(_promises.setTimeout).mockImplementation(() => new Promise(r => {
32
- resolveTimeout = r;
33
- }));
34
- return {
35
- async resolve() {
36
- await Promise.resolve();
37
- resolveTimeout();
38
- }
39
- };
40
- }
41
- _vitest.vi.mock("fs-extra", () => ({
42
- ensureDir: _vitest.vi.fn(),
43
- writeJSON: _vitest.vi.fn(),
44
- exists: _vitest.vi.fn().mockResolvedValue(true)
45
- }));
46
- _vitest.vi.mock("timers/promises", () => ({
47
- setTimeout: _vitest.vi.fn().mockResolvedValue(undefined)
48
- }));
49
- _vitest.vi.mock("../../../../common/contextStorageStateHelpers", () => ({
50
- getStorageState: _vitest.vi.fn()
51
- }));
52
- _vitest.vi.mock("../../../../common/launchBrowser", () => ({
53
- launchChromium: _vitest.vi.fn()
54
- }));
55
- _vitest.vi.mock("../../../../common/runApi", async importOriginal => {
56
- const original = await importOriginal();
57
- return {
58
- ...original,
59
- runApi: _vitest.vi.fn().mockImplementation(() => (0, _neverthrow.ok)({}))
60
- };
61
- });
62
- _vitest.vi.mock("../../helpers/terminal", () => ({
63
- terminal: getTerminal()
64
- }));
65
- _vitest.vi.mock("../../helpers/proxy", () => {
66
- return {
67
- parseUrlProxy: _vitest.vi.fn(v => v)
68
- };
69
- });
70
- _vitest.vi.mock("../../helpers/browser", async importOriginal => {
71
- const original = await importOriginal();
72
- return {
73
- getCLIRunOptions: _vitest.vi.fn(({
74
- keepBrowserOpen: _,
75
- ...rest
76
- }) => original.getCLIRunOptions({
77
- keepBrowserOpen: false,
78
- ...rest
79
- }))
80
- };
81
- });
82
- _vitest.vi.mock("../../helpers", async importOriginal => {
83
- const original = await importOriginal();
84
- return {
85
- ...original,
86
- terminal: getTerminal(),
87
- assertApiFileExists: _vitest.vi.fn(),
88
- withTimeout: _vitest.vi.fn(fn => fn()),
89
- keepBrowserOpen: false,
90
- withCLITrace: _vitest.vi.fn(original.withCLITrace),
91
- loadAuthSessionInstance: _vitest.vi.fn(),
92
- storeAuthSessionInstance: _vitest.vi.fn().mockResolvedValue("authSessionInstancePath"),
93
- registerGetAuthSessionParameters: _vitest.vi.fn()
94
- };
95
- });
96
- (0, _vitest.describe)("AuthSession controller", () => {
97
- (0, _vitest.beforeEach)(() => {
98
- _vitest.vi.clearAllMocks();
99
- });
100
- (0, _vitest.describe)("runCheck", () => {
101
- (0, _vitest.it)("calls timeout middleware with timeout", async () => {
102
- await (0, _authSession._runCheck)({
103
- auth: "session",
104
- headless: false,
105
- timeout: 6000,
106
- keepBrowserOpen: false
107
- });
108
- (0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
109
- });
110
- (0, _vitest.it)("uses tracing wrapper and calls with correct parameters", async () => {
111
- await (0, _authSession._runCheck)({
112
- auth: "session",
113
- headless: false,
114
- timeout: 6000,
115
- keepBrowserOpen: false
116
- });
117
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
118
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
119
- _vitest.vi.mocked(_runApi.runApi).mockClear();
120
- await (0, _authSession._runCheck)({
121
- auth: "session",
122
- headless: false,
123
- timeout: 6000,
124
- keepBrowserOpen: false,
125
- traceId: "trace-id"
126
- });
127
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), "trace-id");
128
- });
129
- (0, _vitest.it)("uses cli browser helper", async () => {
130
- await (0, _authSession._runCheck)({
131
- auth: "session",
132
- headless: false,
133
- timeout: 6000,
134
- keepBrowserOpen: false
135
- });
136
- (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
137
- headless: false,
138
- keepBrowserOpen: false
139
- }));
140
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
141
- _vitest.vi.mocked(_runApi.runApi).mockClear();
142
- await (0, _authSession._runCheck)({
143
- auth: "session",
144
- headless: true,
145
- timeout: 6000,
146
- keepBrowserOpen: true
147
- });
148
- (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
149
- headless: true,
150
- keepBrowserOpen: true
151
- }));
152
- });
153
- (0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
154
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
155
- await (0, _authSession._runCheck)({
156
- auth: "session",
157
- headless: "headless",
158
- timeout: 999999999,
159
- keepBrowserOpen: false,
160
- proxy: "proxy"
161
- });
162
- (0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
163
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
164
- automationFunction: {
165
- name: "auth-sessions/check"
166
- },
167
- runOptions: {
168
- headless: "headless",
169
- environment: "standalone",
170
- proxy: "parsed-proxy"
171
- },
172
- auth: _vitest.expect.objectContaining({
173
- session: {
174
- type: "state",
175
- state: "session"
176
- }
177
- })
178
- }));
179
- });
180
- (0, _vitest.it)("returns if check returns", async () => {
181
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
182
- const resultTrue = await (0, _authSession._runCheck)({
183
- auth: "session",
184
- headless: "headless",
185
- timeout: 999999999,
186
- keepBrowserOpen: false
187
- });
188
- (0, _vitest.expect)(resultTrue).toEqual(true);
189
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
190
- const resultFalse = await (0, _authSession._runCheck)({
191
- auth: "session",
192
- headless: "headless",
193
- timeout: 999999999,
194
- keepBrowserOpen: false
195
- });
196
- (0, _vitest.expect)(resultFalse).toEqual(false);
197
- });
198
- (0, _vitest.it)("throws the error check fails with an error", async () => {
199
- const error = new Error("runApi failed");
200
- _vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
201
- await (0, _vitest.expect)((0, _authSession._runCheck)({
202
- auth: "session",
203
- headless: "headless",
204
- timeout: 999999999,
205
- keepBrowserOpen: false
206
- })).rejects.toThrow(error);
207
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult);
208
- await (0, _vitest.expect)((0, _authSession._runCheck)({
209
- auth: "session",
210
- headless: "headless",
211
- timeout: 999999999,
212
- keepBrowserOpen: false
213
- })).rejects.toThrow("failed");
214
- });
215
- });
216
- (0, _vitest.describe)("runCheckWithRetries", () => {
217
- (0, _vitest.it)("enables tracing on runCheck if trace is true", async () => {
218
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
219
- await (0, _authSession._runCheckWithRetries)({
220
- auth: "session",
221
- retries: 1,
222
- headless: "headless",
223
- timeout: 999999999,
224
- keepBrowserOpen: false,
225
- trace: false
226
- });
227
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
228
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
229
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
230
- await (0, _authSession._runCheckWithRetries)({
231
- auth: "session",
232
- retries: 1,
233
- headless: "headless",
234
- timeout: 999999999,
235
- keepBrowserOpen: false,
236
- trace: true
237
- });
238
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), _vitest.expect.any(String));
239
- });
240
- (0, _vitest.it)("retries the check if it fails", async () => {
241
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult).mockResolvedValueOnce(_checkPassedResult);
242
- const result = await (0, _authSession._runCheckWithRetries)({
243
- auth: "session",
244
- retries: 10,
245
- headless: "headless",
246
- timeout: 999999999,
247
- keepBrowserOpen: false,
248
- trace: false
249
- });
250
- (0, _vitest.expect)(result).toEqual(true);
251
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
252
- });
253
- (0, _vitest.it)("returns false if all retries fail", async () => {
254
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
255
- result: false
256
- }));
257
- const result = await (0, _authSession._runCheckWithRetries)({
258
- auth: "session",
259
- retries: 10,
260
- headless: "headless",
261
- timeout: 999999999,
262
- keepBrowserOpen: false,
263
- trace: false
264
- });
265
- (0, _vitest.expect)(result).toEqual(false);
266
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(10);
267
- });
268
- (0, _vitest.it)("continues retrying if check fails due to an automation error", async () => {
269
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult).mockResolvedValueOnce(_checkPassedResult);
270
- const result = await (0, _authSession._runCheckWithRetries)({
271
- auth: "session",
272
- retries: 10,
273
- headless: "headless",
274
- timeout: 999999999,
275
- keepBrowserOpen: false,
276
- trace: false
277
- });
278
- (0, _vitest.expect)(result).toEqual(true);
279
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
280
- });
281
- (0, _vitest.it)("throws the error if check fails with a non-automation error", async () => {
282
- const error = new Error("runCheck failed");
283
- _vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
284
- await (0, _vitest.expect)((0, _authSession._runCheckWithRetries)({
285
- auth: "session",
286
- retries: 10,
287
- headless: "headless",
288
- timeout: 999999999,
289
- keepBrowserOpen: false,
290
- trace: false
291
- })).rejects.toThrow(error);
292
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
293
- });
294
- });
295
- (0, _vitest.describe)("runCreate", () => {
296
- (0, _vitest.it)("calls timeout middleware with timeout", async () => {
297
- await (0, _authSession._runCreate)({
298
- authSessionInput: {},
299
- headless: false,
300
- timeout: 6000,
301
- keepBrowserOpen: false
302
- });
303
- (0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
304
- });
305
- (0, _vitest.it)("uses tracing wrapper and calls with correct parameters", async () => {
306
- await (0, _authSession._runCreate)({
307
- authSessionInput: {},
308
- headless: false,
309
- timeout: 6000,
310
- keepBrowserOpen: false
311
- });
312
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
313
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
314
- _vitest.vi.mocked(_runApi.runApi).mockClear();
315
- await (0, _authSession._runCreate)({
316
- authSessionInput: {},
317
- headless: false,
318
- timeout: 6000,
319
- keepBrowserOpen: false,
320
- traceId: "trace-id"
321
- });
322
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), "trace-id");
323
- });
324
- (0, _vitest.it)("uses cli browser helper", async () => {
325
- await (0, _authSession._runCreate)({
326
- authSessionInput: {},
327
- headless: false,
328
- timeout: 6000,
329
- keepBrowserOpen: false
330
- });
331
- (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
332
- headless: false,
333
- keepBrowserOpen: false
334
- }));
335
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
336
- _vitest.vi.mocked(_runApi.runApi).mockClear();
337
- await (0, _authSession._runCreate)({
338
- authSessionInput: {},
339
- headless: true,
340
- timeout: 6000,
341
- keepBrowserOpen: true
342
- });
343
- (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
344
- headless: true,
345
- keepBrowserOpen: true
346
- }));
347
- });
348
- (0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
349
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
350
- await (0, _authSession._runCreate)({
351
- authSessionInput: "authSessionInput",
352
- headless: "headless",
353
- timeout: 999999999,
354
- keepBrowserOpen: false,
355
- proxy: "proxy"
356
- });
357
- (0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
358
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
359
- automationFunction: {
360
- name: "auth-sessions/create",
361
- params: "authSessionInput"
362
- },
363
- runOptions: {
364
- headless: "headless",
365
- environment: "standalone",
366
- proxy: "parsed-proxy"
367
- },
368
- retrieveSession: true
369
- }));
370
- });
371
- (0, _vitest.it)("returns if create returns", async () => {
372
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
373
- const storageState = await (0, _authSession._runCreate)({
374
- authSessionInput: {},
375
- headless: "headless",
376
- timeout: 999999999,
377
- keepBrowserOpen: false
378
- });
379
- (0, _vitest.expect)(storageState).toEqual("session");
380
- });
381
- (0, _vitest.it)("throws the error create fails with an error", async () => {
382
- const error = new Error("runApi failed");
383
- _vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
384
- await (0, _vitest.expect)((0, _authSession._runCreate)({
385
- authSessionInput: {},
386
- headless: "headless",
387
- timeout: 999999999,
388
- keepBrowserOpen: false
389
- })).rejects.toThrow(error);
390
- });
391
- });
392
- (0, _vitest.describe)("runCreateWithRetries", () => {
393
- (0, _vitest.it)("enables tracing on runCreate if trace is true", async () => {
394
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
395
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
396
- await (0, _authSession._runCreateWithRetries)({
397
- authSessionId: "authSessionId",
398
- authSessionInput: "authSessionInput",
399
- retries: 10,
400
- headless: "headless",
401
- proxy: "proxy",
402
- timeout: 999999999,
403
- keepBrowserOpen: false,
404
- trace: false
405
- });
406
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
407
- _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
408
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
409
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
410
- await (0, _authSession._runCreateWithRetries)({
411
- authSessionId: "authSessionId",
412
- authSessionInput: "authSessionInput",
413
- retries: 10,
414
- headless: "headless",
415
- proxy: "proxy",
416
- timeout: 999999999,
417
- keepBrowserOpen: false,
418
- trace: true
419
- });
420
- (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), _vitest.expect.any(String));
421
- });
422
- (0, _vitest.it)("saves the AuthSession instance", async () => {
423
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
424
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
425
- await (0, _authSession._runCreateWithRetries)({
426
- authSessionId: "authSessionId",
427
- authSessionInput: "authSessionInput",
428
- retries: 10,
429
- headless: "headless",
430
- proxy: "proxy",
431
- timeout: 999999999,
432
- keepBrowserOpen: false,
433
- trace: false
434
- });
435
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith({
436
- state: "session",
437
- id: "authSessionId",
438
- input: "authSessionInput",
439
- proxy: "proxy"
440
- });
441
- });
442
- (0, _vitest.it)("retries the create if it fails with automation error", async () => {
443
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult).mockResolvedValueOnce(_createSuccessResult("session"));
444
- await (0, _authSession._runCreateWithRetries)({
445
- authSessionId: "authSessionId",
446
- authSessionInput: "authSessionInput",
447
- retries: 10,
448
- headless: "headless",
449
- timeout: 999999999,
450
- keepBrowserOpen: false,
451
- trace: false
452
- });
453
- });
454
- (0, _vitest.it)("throws if all retries fail", async () => {
455
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue(_errorResult);
456
- await (0, _vitest.expect)((0, _authSession._runCreateWithRetries)({
457
- authSessionId: "authSessionId",
458
- authSessionInput: {},
459
- retries: 10,
460
- headless: "headless",
461
- timeout: 999999999,
462
- keepBrowserOpen: false,
463
- trace: false
464
- })).rejects.toThrow(_helpers.CLIError);
465
- });
466
- (0, _vitest.it)("continues retrying if create fails due to an automation error", async () => {
467
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult).mockResolvedValueOnce(_createSuccessResult("session"));
468
- const result = await (0, _authSession._runCreateWithRetries)({
469
- authSessionId: "authSessionId",
470
- authSessionInput: {},
471
- retries: 10,
472
- headless: "headless",
473
- timeout: 999999999,
474
- keepBrowserOpen: false,
475
- trace: false
476
- });
477
- (0, _vitest.expect)(result).toEqual("session");
478
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
479
- });
480
- (0, _vitest.it)("throws the error if create fails with a non-automation error", async () => {
481
- const error = new Error("runCheck failed");
482
- _vitest.vi.mocked(_runApi.runApi).mockRejectedValueOnce(error);
483
- await (0, _vitest.expect)((0, _authSession._runCreateWithRetries)({
484
- authSessionId: "authSessionId",
485
- authSessionInput: {},
486
- retries: 10,
487
- headless: "headless",
488
- timeout: 999999999,
489
- keepBrowserOpen: false,
490
- trace: false
491
- })).rejects.toThrow(error);
492
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
493
- });
494
- });
495
- (0, _vitest.describe)("executeRunValidateAuthSessionCLI", () => {
496
- (0, _vitest.beforeEach)(() => {
497
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
498
- storageState: {},
499
- metadata: {
500
- authSessionId: "authSessionId",
501
- authSessionType: "API",
502
- authSessionInput: {},
503
- createdAt: "",
504
- updatedAt: ""
505
- }
506
- });
507
- });
508
- (0, _vitest.it)("asserts check API file exists", async () => {
509
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
510
- await (0, _authSession.executeRunValidateAuthSessionCLI)({
511
- id: "authSessionId",
512
- checkRetries: 1,
513
- createRetries: 1,
514
- autoRecreate: false,
515
- headless: false,
516
- timeout: 999999999,
517
- keepBrowserOpen: false,
518
- trace: false
519
- });
520
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
521
- });
522
- (0, _vitest.it)("succeeds if check succeeds", async () => {
523
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
524
- await (0, _authSession.executeRunValidateAuthSessionCLI)({
525
- id: "authSessionId",
526
- checkRetries: 1,
527
- createRetries: 1,
528
- autoRecreate: false,
529
- headless: false,
530
- timeout: 999999999,
531
- keepBrowserOpen: false,
532
- trace: false
533
- });
534
- });
535
- (0, _vitest.it)("throws if check fails with auto recreate disabled", async () => {
536
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
537
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
538
- storageState: {},
539
- metadata: {
540
- authSessionId: "authSessionId",
541
- authSessionType: "API",
542
- authSessionInput: {},
543
- createdAt: "1970-01-01T00:00:00Z",
544
- updatedAt: "1970-01-01T00:00:00Z"
545
- }
546
- });
547
- await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
548
- id: "authSessionId",
549
- checkRetries: 1,
550
- createRetries: 1,
551
- autoRecreate: false,
552
- headless: false,
553
- timeout: 999999999,
554
- keepBrowserOpen: false,
555
- trace: false
556
- })).rejects.toThrow(_helpers.CLIError);
557
- });
558
- (0, _vitest.describe)("check failed with auto recreate enabled", () => {
559
- (0, _vitest.beforeEach)(() => {
560
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
561
- });
562
- afterEach(() => {
563
- _vitest.vi.mocked(_runApi.runApi).mockReset();
564
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
565
- });
566
- (0, _vitest.it)("asserts create API file exists", async () => {
567
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
568
- await (0, _authSession.executeRunValidateAuthSessionCLI)({
569
- id: "authSessionId",
570
- checkRetries: 1,
571
- createRetries: 1,
572
- autoRecreate: true,
573
- headless: false,
574
- timeout: 999999999,
575
- keepBrowserOpen: false,
576
- trace: false
577
- });
578
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
579
- });
580
- (0, _vitest.it)("throws if AuthSession is manual", async () => {
581
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
582
- storageState: {},
583
- metadata: {
584
- authSessionId: "authSessionId",
585
- authSessionType: "MANUAL",
586
- authSessionInput: {},
587
- createdAt: "",
588
- updatedAt: ""
589
- }
590
- });
591
- await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
592
- id: "authSessionId",
593
- checkRetries: 1,
594
- createRetries: 1,
595
- autoRecreate: true,
596
- headless: false,
597
- timeout: 999999999,
598
- keepBrowserOpen: false,
599
- trace: false
600
- })).rejects.toThrow(_helpers.CLIError);
601
- });
602
- (0, _vitest.it)("throws if create fails", async () => {
603
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_errorResult);
604
- await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
605
- id: "authSessionId",
606
- checkRetries: 1,
607
- createRetries: 1,
608
- autoRecreate: true,
609
- headless: false,
610
- timeout: 999999999,
611
- keepBrowserOpen: false,
612
- trace: false
613
- })).rejects.toThrow(_helpers.CLIError);
614
- });
615
- (0, _vitest.it)("throws if create succeeds then check fails", async () => {
616
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkFailedResult);
617
- await (0, _vitest.expect)((0, _authSession.executeRunValidateAuthSessionCLI)({
618
- id: "authSessionId",
619
- checkRetries: 1,
620
- createRetries: 1,
621
- autoRecreate: true,
622
- headless: false,
623
- timeout: 999999999,
624
- keepBrowserOpen: false,
625
- trace: false
626
- })).rejects.toThrow(_helpers.CLIError);
627
- });
628
- (0, _vitest.it)("succeeds if create succeeds then check succeeds", async () => {
629
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
630
- await (0, _authSession.executeRunValidateAuthSessionCLI)({
631
- id: "authSessionId",
632
- checkRetries: 1,
633
- createRetries: 1,
634
- autoRecreate: true,
635
- headless: false,
636
- timeout: 999999999,
637
- keepBrowserOpen: false,
638
- trace: false
639
- });
640
- });
641
- });
642
- });
643
- (0, _vitest.describe)("executeRunCreateAuthSessionCLI", () => {
644
- (0, _vitest.beforeEach)(() => {
645
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
646
- });
647
- (0, _vitest.it)("asserts create check API file exists", async () => {
648
- await (0, _authSession.executeRunCreateAuthSessionCLI)({
649
- input: {},
650
- checkRetries: 1,
651
- createRetries: 1,
652
- headless: false,
653
- timeout: 999999999,
654
- keepBrowserOpen: false,
655
- trace: false
656
- });
657
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
658
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
659
- });
660
- (0, _vitest.it)("throws if create fails", async () => {
661
- _vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_errorResult);
662
- await (0, _vitest.expect)((0, _authSession.executeRunCreateAuthSessionCLI)({
663
- input: {},
664
- checkRetries: 1,
665
- createRetries: 1,
666
- headless: false,
667
- timeout: 999999999,
668
- keepBrowserOpen: false,
669
- trace: false
670
- })).rejects.toThrow(_helpers.CLIError);
671
- });
672
- (0, _vitest.it)("throws if check fails after create succeeds", async () => {
673
- _vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkFailedResult);
674
- await (0, _vitest.expect)((0, _authSession.executeRunCreateAuthSessionCLI)({
675
- input: {},
676
- checkRetries: 1,
677
- createRetries: 1,
678
- headless: false,
679
- timeout: 999999999,
680
- keepBrowserOpen: false,
681
- trace: false
682
- })).rejects.toThrow(_helpers.CLIError);
683
- });
684
- (0, _vitest.it)("saves to AuthSession instance path if create and check succeed", async () => {
685
- await (0, _authSession.executeRunCreateAuthSessionCLI)({
686
- input: "authSessionInput",
687
- checkRetries: 1,
688
- createRetries: 1,
689
- headless: false,
690
- timeout: 999999999,
691
- keepBrowserOpen: false,
692
- trace: false
693
- });
694
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
695
- id: _vitest.expect.any(String)
696
- }));
697
- });
698
- (0, _vitest.it)("uses AuthSession id to save if provided", async () => {
699
- const result = await (0, _authSession.executeRunCreateAuthSessionCLI)({
700
- id: "authSessionId",
701
- input: "authSessionInput",
702
- checkRetries: 1,
703
- createRetries: 1,
704
- headless: false,
705
- timeout: 999999999,
706
- keepBrowserOpen: false,
707
- trace: false
708
- });
709
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
710
- id: "authSessionId"
711
- }));
712
- });
713
- });
714
- (0, _vitest.describe)("executeRunUpdateAuthSessionCLI", () => {
715
- (0, _vitest.beforeEach)(() => {
716
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session")).mockResolvedValueOnce(_checkPassedResult);
717
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
718
- storageState: {},
719
- metadata: {
720
- authSessionId: "authSessionId",
721
- authSessionType: "API",
722
- authSessionInput: {},
723
- createdAt: "",
724
- updatedAt: ""
725
- }
726
- });
727
- });
728
- afterEach(() => {
729
- _vitest.vi.mocked(_runApi.runApi).mockReset();
730
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
731
- });
732
- (0, _vitest.it)("throws if AuthSession is manual", async () => {
733
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
734
- storageState: {},
735
- metadata: {
736
- authSessionId: "authSessionId",
737
- authSessionType: "MANUAL",
738
- authSessionInput: {},
739
- createdAt: "",
740
- updatedAt: ""
741
- }
742
- });
743
- await (0, _vitest.expect)((0, _authSession.executeRunUpdateAuthSessionCLI)({
744
- id: "authSessionId",
745
- checkRetries: 1,
746
- createRetries: 1,
747
- headless: false,
748
- timeout: 999999999,
749
- keepBrowserOpen: false,
750
- trace: false
751
- })).rejects.toThrow(_helpers.CLIError);
752
- });
753
- (0, _vitest.it)("calls create with existing input if no input provided", async () => {
754
- await (0, _authSession.executeRunUpdateAuthSessionCLI)({
755
- id: "authSessionId",
756
- checkRetries: 1,
757
- createRetries: 1,
758
- headless: false,
759
- timeout: 999999999,
760
- keepBrowserOpen: false,
761
- trace: false
762
- });
763
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
764
- automationFunction: {
765
- name: "auth-sessions/create",
766
- params: {}
767
- },
768
- runOptions: {
769
- headless: false,
770
- environment: "standalone",
771
- proxy: undefined
772
- },
773
- retrieveSession: true
774
- }));
775
- });
776
- (0, _vitest.it)("calls create with new input if provided", async () => {
777
- _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("newProxy");
778
- await (0, _authSession.executeRunUpdateAuthSessionCLI)({
779
- id: "authSessionId",
780
- input: "newAuthSessionInput",
781
- proxy: "newProxyUrl",
782
- checkRetries: 1,
783
- createRetries: 1,
784
- headless: false,
785
- timeout: 999999999,
786
- keepBrowserOpen: false,
787
- trace: false
788
- });
789
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
790
- automationFunction: {
791
- name: "auth-sessions/create",
792
- params: "newAuthSessionInput"
793
- },
794
- runOptions: {
795
- headless: false,
796
- environment: "standalone",
797
- proxy: "newProxy"
798
- },
799
- retrieveSession: true
800
- }));
801
- });
802
- (0, _vitest.it)("saves the AuthSession with existing input if create and check succeed without providing input", async () => {
803
- const result = await (0, _authSession.executeRunUpdateAuthSessionCLI)({
804
- id: "authSessionId",
805
- checkRetries: 1,
806
- createRetries: 1,
807
- headless: false,
808
- timeout: 999999999,
809
- keepBrowserOpen: false,
810
- trace: false
811
- });
812
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
813
- id: "authSessionId",
814
- input: {},
815
- proxy: undefined
816
- }));
817
- });
818
- (0, _vitest.it)("saves the AuthSession with new input if create and check succeed with new input", async () => {
819
- const result = await (0, _authSession.executeRunUpdateAuthSessionCLI)({
820
- id: "authSessionId",
821
- input: "newAuthSessionInput",
822
- proxy: "newProxyUrl",
823
- checkRetries: 1,
824
- createRetries: 1,
825
- headless: false,
826
- timeout: 999999999,
827
- keepBrowserOpen: false,
828
- trace: false
829
- });
830
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
831
- id: "authSessionId",
832
- input: "newAuthSessionInput",
833
- proxy: "newProxyUrl"
834
- }));
835
- });
836
- });
837
- (0, _vitest.describe)("executeAttemptCheckAuthSessionCLI", () => {
838
- (0, _vitest.beforeEach)(() => {
839
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
840
- storageState: {},
841
- metadata: {
842
- authSessionId: "authSessionId",
843
- authSessionType: "API",
844
- authSessionInput: {},
845
- createdAt: "",
846
- updatedAt: ""
847
- }
848
- });
849
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
850
- });
851
- afterEach(() => {
852
- _vitest.vi.mocked(_runApi.runApi).mockReset();
853
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
854
- });
855
- (0, _vitest.it)("asserts check API file exists", async () => {
856
- await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
857
- id: "authSessionId",
858
- headless: false,
859
- timeout: 999999999,
860
- keepBrowserOpen: false,
861
- trace: false
862
- });
863
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "check");
864
- });
865
- (0, _vitest.it)("succeeds if check succeeds", async () => {
866
- await (0, _authSession.executeAttemptCheckAuthSessionCLI)({
867
- id: "authSessionId",
868
- headless: false,
869
- timeout: 999999999,
870
- keepBrowserOpen: false,
871
- trace: false
872
- });
873
- });
874
- (0, _vitest.it)("throws if check fails", async () => {
875
- _vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_checkFailedResult);
876
- await (0, _vitest.expect)((0, _authSession.executeAttemptCheckAuthSessionCLI)({
877
- id: "authSessionId",
878
- headless: false,
879
- timeout: 999999999,
880
- keepBrowserOpen: false,
881
- trace: false
882
- })).rejects.toThrow(_helpers.CLIError);
883
- });
884
- });
885
- (0, _vitest.describe)("executeAttemptCreateAuthSessionCLI", () => {
886
- (0, _vitest.beforeEach)(() => {
887
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_createSuccessResult("session"));
888
- });
889
- (0, _vitest.it)("asserts create API file exists", async () => {
890
- await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
891
- input: {},
892
- headless: false,
893
- timeout: 999999999,
894
- keepBrowserOpen: false,
895
- trace: false
896
- });
897
- (0, _vitest.expect)(_helpers.assertApiFileExists).toHaveBeenCalledWith("auth-sessions", "create");
898
- });
899
- (0, _vitest.it)("throws if create fails", async () => {
900
- _vitest.vi.mocked(_runApi.runApi).mockReset().mockResolvedValueOnce(_errorResult);
901
- await (0, _vitest.expect)((0, _authSession.executeAttemptCreateAuthSessionCLI)({
902
- input: {},
903
- headless: false,
904
- timeout: 999999999,
905
- keepBrowserOpen: false,
906
- trace: false
907
- })).rejects.toThrow(_helpers.CLIError);
908
- });
909
- (0, _vitest.it)("saves to AuthSession instance path if create and check succeed", async () => {
910
- await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
911
- input: "authSessionInput",
912
- headless: false,
913
- timeout: 999999999,
914
- keepBrowserOpen: false,
915
- trace: false
916
- });
917
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
918
- id: _vitest.expect.any(String)
919
- }));
920
- });
921
- (0, _vitest.it)("uses AuthSession id to save if provided", async () => {
922
- await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
923
- id: "authSessionId",
924
- input: "authSessionInput",
925
- headless: false,
926
- timeout: 999999999,
927
- keepBrowserOpen: false,
928
- trace: false
929
- });
930
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
931
- id: "authSessionId"
932
- }));
933
- });
934
- });
935
- (0, _vitest.describe)("executeRecordAuthSessionCLI", () => {
936
- let mockPage;
937
- let mockContext;
938
- (0, _vitest.beforeEach)(() => {
939
- _vitest.vi.useFakeTimers();
940
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
941
- mockPage = {
942
- url: _vitest.vi.fn().mockReturnValue(""),
943
- close: _vitest.vi.fn(),
944
- goto: _vitest.vi.fn(),
945
- waitForLoadState: _vitest.vi.fn()
946
- };
947
- mockContext = {
948
- pages: _vitest.vi.fn().mockReturnValue([mockPage]),
949
- close: _vitest.vi.fn()
950
- };
951
- _vitest.vi.mocked(_launchBrowser.launchChromium).mockResolvedValue({
952
- context: mockContext,
953
- page: mockPage
954
- });
955
- _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockResolvedValue({
956
- storageState: {},
957
- metadata: {
958
- authSessionId: "authSessionId",
959
- authSessionType: "MANUAL",
960
- authSessionInput: {},
961
- createdAt: "",
962
- updatedAt: ""
963
- }
964
- });
965
- });
966
- afterEach(() => {
967
- _vitest.vi.mocked(_runApi.runApi).mockReset();
968
- _vitest.vi.mocked(_launchBrowser.launchChromium).mockReset();
969
- _vitest.vi.useRealTimers();
970
- });
971
- (0, _vitest.it)("launches browser with app mode", async () => {
972
- mockPage.url.mockReturnValue("finishUrl");
973
- await (0, _authSession.executeRecordAuthSessionCLI)({
974
- checkRetries: 1,
975
- startUrl: "startUrl",
976
- finishUrl: "finishUrl",
977
- headless: false,
978
- keepBrowserOpen: false
979
- });
980
- (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledWith(_vitest.expect.objectContaining({
981
- appModeInitialUrl: "startUrl"
982
- }));
983
- });
984
- (0, _vitest.it)("navigates to the start url if the page doesn't load with it", async () => {
985
- mockPage.url.mockReturnValue("finishUrl");
986
- await (0, _authSession.executeRecordAuthSessionCLI)({
987
- checkRetries: 1,
988
- startUrl: "startUrl",
989
- finishUrl: "finishUrl",
990
- headless: false,
991
- keepBrowserOpen: false
992
- });
993
- (0, _vitest.expect)(mockPage.goto).toHaveBeenCalledWith("startUrl");
994
- });
995
- (0, _vitest.it)("waits for the finish url", async () => {
996
- mockPage.url.mockReturnValueOnce("startUrl");
997
- const mockTimeout = getMockTimeout();
998
- let pending = true;
999
- const p = (0, _authSession.executeRecordAuthSessionCLI)({
1000
- checkRetries: 1,
1001
- startUrl: "startUrl",
1002
- finishUrl: "finishUrl",
1003
- headless: false,
1004
- keepBrowserOpen: false
1005
- }).finally(() => pending = false);
1006
- await mockTimeout.resolve();
1007
- await mockTimeout.resolve();
1008
- await mockTimeout.resolve();
1009
- (0, _vitest.expect)(pending).toEqual(true);
1010
- mockPage.url.mockClear();
1011
- mockPage.url.mockReturnValueOnce("finishUrl");
1012
- await mockTimeout.resolve();
1013
- await p;
1014
- });
1015
- (0, _vitest.it)("throws if timeout is reached", async () => {
1016
- mockPage.url.mockReturnValueOnce("startUrl");
1017
- const mockTimeout = getMockTimeout();
1018
- _vitest.vi.setSystemTime(new Date(0));
1019
- let pending = true;
1020
- const p = (0, _authSession.executeRecordAuthSessionCLI)({
1021
- checkRetries: 1,
1022
- startUrl: "startUrl",
1023
- finishUrl: "finishUrl",
1024
- headless: false,
1025
- keepBrowserOpen: false,
1026
- timeout: 1000
1027
- }).finally(() => pending = false);
1028
- await mockTimeout.resolve();
1029
- await mockTimeout.resolve();
1030
- await mockTimeout.resolve();
1031
- (0, _vitest.expect)(pending).toEqual(true);
1032
- _vitest.vi.setSystemTime(new Date(2000));
1033
- await mockTimeout.resolve();
1034
- await (0, _vitest.expect)(p).rejects.toThrow(_helpers.CLIError);
1035
- });
1036
- (0, _vitest.it)("stores AuthSession and validates it if successful", async () => {
1037
- mockPage.url.mockReturnValue("finishUrl");
1038
- await (0, _authSession.executeRecordAuthSessionCLI)({
1039
- checkRetries: 1,
1040
- startUrl: "startUrl",
1041
- finishUrl: "finishUrl",
1042
- headless: false,
1043
- keepBrowserOpen: false
1044
- });
1045
- (0, _vitest.expect)(_helpers.storeAuthSessionInstance).toHaveBeenCalledWith(_vitest.expect.objectContaining({
1046
- id: _vitest.expect.any(String),
1047
- metadata: _vitest.expect.objectContaining({
1048
- authSessionType: "MANUAL",
1049
- recorderStartUrl: "startUrl",
1050
- recorderEndUrl: "finishUrl"
1051
- })
1052
- }));
1053
- (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
1054
- automationFunction: _vitest.expect.objectContaining({
1055
- name: "auth-sessions/check"
1056
- })
1057
- }));
1058
- });
1059
- });
1060
- });