@datadog/datadog-ci 2.48.0 → 3.0.1

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 (399) hide show
  1. package/README.md +9 -2
  2. package/dist/__tests__/cli.test.d.ts +1 -0
  3. package/dist/__tests__/cli.test.js +92 -0
  4. package/dist/__tests__/cli.test.js.map +1 -0
  5. package/dist/cli.js +1 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/cloud-run/__tests__/fixtures.d.ts +2 -0
  8. package/dist/commands/cloud-run/__tests__/fixtures.js +12 -0
  9. package/dist/commands/cloud-run/__tests__/fixtures.js.map +1 -0
  10. package/dist/commands/cloud-run/__tests__/flare.test.d.ts +1 -0
  11. package/dist/commands/cloud-run/__tests__/flare.test.js +557 -0
  12. package/dist/commands/cloud-run/__tests__/flare.test.js.map +1 -0
  13. package/dist/commands/coverage/__tests__/upload.test.d.ts +1 -0
  14. package/dist/commands/coverage/__tests__/upload.test.js +323 -0
  15. package/dist/commands/coverage/__tests__/upload.test.js.map +1 -0
  16. package/dist/commands/coverage/__tests__/utils.test.d.ts +1 -0
  17. package/dist/commands/coverage/__tests__/utils.test.js +57 -0
  18. package/dist/commands/coverage/__tests__/utils.test.js.map +1 -0
  19. package/dist/commands/coverage/api.d.ts +9 -0
  20. package/dist/commands/coverage/api.js +52 -0
  21. package/dist/commands/coverage/api.js.map +1 -0
  22. package/dist/commands/coverage/cli.d.ts +1 -0
  23. package/dist/commands/coverage/cli.js +5 -0
  24. package/dist/commands/coverage/cli.js.map +1 -0
  25. package/dist/commands/coverage/interfaces.d.ts +13 -0
  26. package/dist/commands/coverage/interfaces.js +3 -0
  27. package/dist/commands/coverage/interfaces.js.map +1 -0
  28. package/dist/commands/coverage/renderer.d.ts +12 -0
  29. package/dist/commands/coverage/renderer.js +83 -0
  30. package/dist/commands/coverage/renderer.js.map +1 -0
  31. package/dist/commands/coverage/upload.d.ts +27 -0
  32. package/dist/commands/coverage/upload.js +329 -0
  33. package/dist/commands/coverage/upload.js.map +1 -0
  34. package/dist/commands/coverage/utils.d.ts +3 -0
  35. package/dist/commands/coverage/utils.js +83 -0
  36. package/dist/commands/coverage/utils.js.map +1 -0
  37. package/dist/commands/deployment/__tests__/correlate.test.d.ts +1 -0
  38. package/dist/commands/deployment/__tests__/correlate.test.js +106 -0
  39. package/dist/commands/deployment/__tests__/correlate.test.js.map +1 -0
  40. package/dist/commands/deployment/__tests__/mark.test.d.ts +1 -0
  41. package/dist/commands/deployment/__tests__/mark.test.js +97 -0
  42. package/dist/commands/deployment/__tests__/mark.test.js.map +1 -0
  43. package/dist/commands/dora/__tests__/deployment.test.d.ts +1 -0
  44. package/dist/commands/dora/__tests__/deployment.test.js +201 -0
  45. package/dist/commands/dora/__tests__/deployment.test.js.map +1 -0
  46. package/dist/commands/dsyms/__tests__/upload.test.d.ts +1 -0
  47. package/dist/commands/dsyms/__tests__/upload.test.js +346 -0
  48. package/dist/commands/dsyms/__tests__/upload.test.js.map +1 -0
  49. package/dist/commands/dsyms/__tests__/utils.test.d.ts +1 -0
  50. package/dist/commands/dsyms/__tests__/utils.test.js +100 -0
  51. package/dist/commands/dsyms/__tests__/utils.test.js.map +1 -0
  52. package/dist/commands/dsyms/upload.js +3 -3
  53. package/dist/commands/dsyms/upload.js.map +1 -1
  54. package/dist/commands/dsyms/utils.js +7 -6
  55. package/dist/commands/dsyms/utils.js.map +1 -1
  56. package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +1 -0
  57. package/dist/commands/elf-symbols/__tests__/elf.test.js +819 -0
  58. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +1 -0
  59. package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +1 -0
  60. package/dist/commands/elf-symbols/__tests__/upload.test.js +224 -0
  61. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +1 -0
  62. package/dist/commands/elf-symbols/elf.d.ts +1 -0
  63. package/dist/commands/elf-symbols/upload.js +2 -3
  64. package/dist/commands/elf-symbols/upload.js.map +1 -1
  65. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +1 -0
  66. package/dist/commands/flutter-symbols/__tests__/upload.test.js +617 -0
  67. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +1 -0
  68. package/dist/commands/flutter-symbols/upload.js +2 -2
  69. package/dist/commands/flutter-symbols/upload.js.map +1 -1
  70. package/dist/commands/gate/__tests__/evaluate.test.d.ts +1 -0
  71. package/dist/commands/gate/__tests__/evaluate.test.js +398 -0
  72. package/dist/commands/gate/__tests__/evaluate.test.js.map +1 -0
  73. package/dist/commands/gate/__tests__/scope.test.d.ts +1 -0
  74. package/dist/commands/gate/__tests__/scope.test.js +29 -0
  75. package/dist/commands/gate/__tests__/scope.test.js.map +1 -0
  76. package/dist/commands/git-metadata/__tests__/git.test.d.ts +1 -0
  77. package/dist/commands/git-metadata/__tests__/git.test.js +132 -0
  78. package/dist/commands/git-metadata/__tests__/git.test.js.map +1 -0
  79. package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +1 -0
  80. package/dist/commands/git-metadata/__tests__/gitdb.test.js +1386 -0
  81. package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +1 -0
  82. package/dist/commands/git-metadata/__tests__/library.test.d.ts +1 -0
  83. package/dist/commands/git-metadata/__tests__/library.test.js +118 -0
  84. package/dist/commands/git-metadata/__tests__/library.test.js.map +1 -0
  85. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +1 -0
  86. package/dist/commands/git-metadata/__tests__/upload.test.js +52 -0
  87. package/dist/commands/git-metadata/__tests__/upload.test.js.map +1 -0
  88. package/dist/commands/git-metadata/upload.d.ts +0 -1
  89. package/dist/commands/git-metadata/upload.js +0 -6
  90. package/dist/commands/git-metadata/upload.js.map +1 -1
  91. package/dist/commands/junit/__tests__/upload.test.d.ts +1 -0
  92. package/dist/commands/junit/__tests__/upload.test.js +446 -0
  93. package/dist/commands/junit/__tests__/upload.test.js.map +1 -0
  94. package/dist/commands/junit/renderer.d.ts +0 -1
  95. package/dist/commands/junit/renderer.js +1 -5
  96. package/dist/commands/junit/renderer.js.map +1 -1
  97. package/dist/commands/junit/upload.d.ts +0 -2
  98. package/dist/commands/junit/upload.js +8 -21
  99. package/dist/commands/junit/upload.js.map +1 -1
  100. package/dist/commands/lambda/__tests__/fixtures.d.ts +51 -0
  101. package/dist/commands/lambda/__tests__/fixtures.js +146 -0
  102. package/dist/commands/lambda/__tests__/fixtures.js.map +1 -0
  103. package/dist/commands/lambda/__tests__/flare.test.d.ts +1 -0
  104. package/dist/commands/lambda/__tests__/flare.test.js +730 -0
  105. package/dist/commands/lambda/__tests__/flare.test.js.map +1 -0
  106. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +1 -0
  107. package/dist/commands/lambda/__tests__/functions/commons.test.js +791 -0
  108. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +1 -0
  109. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +1 -0
  110. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +386 -0
  111. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +1 -0
  112. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +1 -0
  113. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +721 -0
  114. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +1 -0
  115. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
  116. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +513 -0
  117. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +1 -0
  118. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +1 -0
  119. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +33 -0
  120. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +1 -0
  121. package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
  122. package/dist/commands/lambda/__tests__/instrument.test.js +1537 -0
  123. package/dist/commands/lambda/__tests__/instrument.test.js.map +1 -0
  124. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
  125. package/dist/commands/lambda/__tests__/loggroup.test.js +340 -0
  126. package/dist/commands/lambda/__tests__/loggroup.test.js.map +1 -0
  127. package/dist/commands/lambda/__tests__/prompt.test.d.ts +1 -0
  128. package/dist/commands/lambda/__tests__/prompt.test.js +206 -0
  129. package/dist/commands/lambda/__tests__/prompt.test.js.map +1 -0
  130. package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
  131. package/dist/commands/lambda/__tests__/tags.test.js +305 -0
  132. package/dist/commands/lambda/__tests__/tags.test.js.map +1 -0
  133. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
  134. package/dist/commands/lambda/__tests__/uninstrument.test.js +722 -0
  135. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +1 -0
  136. package/dist/commands/lambda/constants.d.ts +2 -0
  137. package/dist/commands/lambda/constants.js +4 -0
  138. package/dist/commands/lambda/constants.js.map +1 -1
  139. package/dist/commands/lambda/functions/commons.d.ts +1 -1
  140. package/dist/commands/measure/__tests__/measure.test.d.ts +1 -0
  141. package/dist/commands/measure/__tests__/measure.test.js +102 -0
  142. package/dist/commands/measure/__tests__/measure.test.js.map +1 -0
  143. package/dist/commands/measure/measure.d.ts +0 -1
  144. package/dist/commands/measure/measure.js +2 -9
  145. package/dist/commands/measure/measure.js.map +1 -1
  146. package/dist/commands/react-native/__tests__/codepush.test.d.ts +1 -0
  147. package/dist/commands/react-native/__tests__/codepush.test.js +161 -0
  148. package/dist/commands/react-native/__tests__/codepush.test.js.map +1 -0
  149. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +1 -0
  150. package/dist/commands/react-native/__tests__/interfaces.test.js +33 -0
  151. package/dist/commands/react-native/__tests__/interfaces.test.js.map +1 -0
  152. package/dist/commands/react-native/__tests__/upload.test.d.ts +1 -0
  153. package/dist/commands/react-native/__tests__/upload.test.js +238 -0
  154. package/dist/commands/react-native/__tests__/upload.test.js.map +1 -0
  155. package/dist/commands/react-native/__tests__/utils.test.d.ts +1 -0
  156. package/dist/commands/react-native/__tests__/utils.test.js +27 -0
  157. package/dist/commands/react-native/__tests__/utils.test.js.map +1 -0
  158. package/dist/commands/react-native/__tests__/xcode.test.d.ts +1 -0
  159. package/dist/commands/react-native/__tests__/xcode.test.js +465 -0
  160. package/dist/commands/react-native/__tests__/xcode.test.js.map +1 -0
  161. package/dist/commands/sarif/__tests__/upload.test.d.ts +1 -0
  162. package/dist/commands/sarif/__tests__/upload.test.js +218 -0
  163. package/dist/commands/sarif/__tests__/upload.test.js.map +1 -0
  164. package/dist/commands/sarif/__tests__/validation.test.d.ts +1 -0
  165. package/dist/commands/sarif/__tests__/validation.test.js +19 -0
  166. package/dist/commands/sarif/__tests__/validation.test.js.map +1 -0
  167. package/dist/commands/sarif/api.js +1 -1
  168. package/dist/commands/sarif/api.js.map +1 -1
  169. package/dist/commands/sarif/interfaces.d.ts +0 -1
  170. package/dist/commands/sarif/renderer.d.ts +2 -2
  171. package/dist/commands/sarif/renderer.js +5 -5
  172. package/dist/commands/sarif/renderer.js.map +1 -1
  173. package/dist/commands/sarif/upload.d.ts +1 -1
  174. package/dist/commands/sarif/upload.js +15 -10
  175. package/dist/commands/sarif/upload.js.map +1 -1
  176. package/dist/commands/sbom/__tests__/payload.test.d.ts +1 -0
  177. package/dist/commands/sbom/__tests__/payload.test.js +306 -0
  178. package/dist/commands/sbom/__tests__/payload.test.js.map +1 -0
  179. package/dist/commands/sbom/__tests__/validation.test.d.ts +1 -0
  180. package/dist/commands/sbom/__tests__/validation.test.js +141 -0
  181. package/dist/commands/sbom/__tests__/validation.test.js.map +1 -0
  182. package/dist/commands/sbom/upload.d.ts +1 -1
  183. package/dist/commands/sbom/upload.js +9 -3
  184. package/dist/commands/sbom/upload.js.map +1 -1
  185. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
  186. package/dist/commands/sourcemaps/__tests__/upload.test.js +270 -0
  187. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +1 -0
  188. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
  189. package/dist/commands/sourcemaps/__tests__/utils.test.js +31 -0
  190. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +1 -0
  191. package/dist/commands/sourcemaps/upload.d.ts +1 -0
  192. package/dist/commands/sourcemaps/upload.js +6 -2
  193. package/dist/commands/sourcemaps/upload.js.map +1 -1
  194. package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +1 -0
  195. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +210 -0
  196. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +1 -0
  197. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +6 -0
  198. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +45 -0
  199. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +1 -0
  200. package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +5 -0
  201. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +19 -0
  202. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +1 -0
  203. package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +1 -0
  204. package/dist/commands/stepfunctions/__tests__/helpers.test.js +501 -0
  205. package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +1 -0
  206. package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +1 -0
  207. package/dist/commands/stepfunctions/__tests__/instrument.test.js +431 -0
  208. package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +1 -0
  209. package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +1 -0
  210. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +166 -0
  211. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +1 -0
  212. package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
  213. package/dist/commands/synthetics/__tests__/api.test.js +416 -0
  214. package/dist/commands/synthetics/__tests__/api.test.js.map +1 -0
  215. package/dist/commands/synthetics/__tests__/batch.test.d.ts +1 -0
  216. package/dist/commands/synthetics/__tests__/batch.test.js +906 -0
  217. package/dist/commands/synthetics/__tests__/batch.test.js.map +1 -0
  218. package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
  219. package/dist/commands/synthetics/__tests__/cli.test.js +1371 -0
  220. package/dist/commands/synthetics/__tests__/cli.test.js.map +1 -0
  221. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.d.ts +1 -0
  222. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js +112 -0
  223. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js.map +1 -0
  224. package/dist/commands/synthetics/__tests__/fixtures.d.ts +123 -0
  225. package/dist/commands/synthetics/__tests__/fixtures.js +493 -0
  226. package/dist/commands/synthetics/__tests__/fixtures.js.map +1 -0
  227. package/dist/commands/synthetics/__tests__/import-tests-lib.test.d.ts +1 -0
  228. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js +186 -0
  229. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js.map +1 -0
  230. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +1 -0
  231. package/dist/commands/synthetics/__tests__/mobile.test.js +376 -0
  232. package/dist/commands/synthetics/__tests__/mobile.test.js.map +1 -0
  233. package/dist/commands/synthetics/__tests__/multilocator.test.d.ts +1 -0
  234. package/dist/commands/synthetics/__tests__/multilocator.test.js +132 -0
  235. package/dist/commands/synthetics/__tests__/multilocator.test.js.map +1 -0
  236. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
  237. package/dist/commands/synthetics/__tests__/reporters/default.test.js +410 -0
  238. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +1 -0
  239. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
  240. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +354 -0
  241. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +1 -0
  242. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +1 -0
  243. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +232 -0
  244. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +1 -0
  245. package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +1 -0
  246. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +698 -0
  247. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +1 -0
  248. package/dist/commands/synthetics/__tests__/test.test.d.ts +1 -0
  249. package/dist/commands/synthetics/__tests__/test.test.js +269 -0
  250. package/dist/commands/synthetics/__tests__/test.test.js.map +1 -0
  251. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +1 -0
  252. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +21 -0
  253. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +1 -0
  254. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +1 -0
  255. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +80 -0
  256. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +1 -0
  257. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +1 -0
  258. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +109 -0
  259. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +1 -0
  260. package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +1 -0
  261. package/dist/commands/synthetics/__tests__/utils/internal.test.js +161 -0
  262. package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +1 -0
  263. package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +1 -0
  264. package/dist/commands/synthetics/__tests__/utils/public.test.js +575 -0
  265. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +1 -0
  266. package/dist/commands/synthetics/api.d.ts +4 -2
  267. package/dist/commands/synthetics/api.js +20 -1
  268. package/dist/commands/synthetics/api.js.map +1 -1
  269. package/dist/commands/synthetics/batch.d.ts +4 -2
  270. package/dist/commands/synthetics/batch.js +65 -7
  271. package/dist/commands/synthetics/batch.js.map +1 -1
  272. package/dist/commands/synthetics/cli.js +3 -1
  273. package/dist/commands/synthetics/cli.js.map +1 -1
  274. package/dist/commands/synthetics/deploy-tests-command.d.ts +22 -0
  275. package/dist/commands/synthetics/deploy-tests-command.js +150 -0
  276. package/dist/commands/synthetics/deploy-tests-command.js.map +1 -0
  277. package/dist/commands/synthetics/deploy-tests-lib.d.ts +2 -0
  278. package/dist/commands/synthetics/deploy-tests-lib.js +72 -0
  279. package/dist/commands/synthetics/deploy-tests-lib.js.map +1 -0
  280. package/dist/commands/synthetics/errors.d.ts +1 -1
  281. package/dist/commands/synthetics/errors.js +1 -0
  282. package/dist/commands/synthetics/errors.js.map +1 -1
  283. package/dist/commands/synthetics/import-tests-command.d.ts +22 -0
  284. package/dist/commands/synthetics/import-tests-command.js +142 -0
  285. package/dist/commands/synthetics/import-tests-command.js.map +1 -0
  286. package/dist/commands/synthetics/import-tests-lib.d.ts +2 -0
  287. package/dist/commands/synthetics/import-tests-lib.js +71 -0
  288. package/dist/commands/synthetics/import-tests-lib.js.map +1 -0
  289. package/dist/commands/synthetics/interfaces.d.ts +74 -28
  290. package/dist/commands/synthetics/interfaces.js.map +1 -1
  291. package/dist/commands/synthetics/local-test-definition.d.ts +2 -0
  292. package/dist/commands/synthetics/local-test-definition.js +16 -0
  293. package/dist/commands/synthetics/local-test-definition.js.map +1 -0
  294. package/dist/commands/synthetics/mobile.js +2 -2
  295. package/dist/commands/synthetics/mobile.js.map +1 -1
  296. package/dist/commands/synthetics/multilocator.d.ts +3 -0
  297. package/dist/commands/synthetics/multilocator.js +98 -0
  298. package/dist/commands/synthetics/multilocator.js.map +1 -0
  299. package/dist/commands/synthetics/reporters/junit.d.ts +1 -2
  300. package/dist/commands/synthetics/reporters/junit.js +5 -6
  301. package/dist/commands/synthetics/reporters/junit.js.map +1 -1
  302. package/dist/commands/synthetics/run-tests-command.d.ts +0 -9
  303. package/dist/commands/synthetics/run-tests-command.js +22 -64
  304. package/dist/commands/synthetics/run-tests-command.js.map +1 -1
  305. package/dist/commands/synthetics/run-tests-lib.js +24 -12
  306. package/dist/commands/synthetics/run-tests-lib.js.map +1 -1
  307. package/dist/commands/synthetics/test.d.ts +10 -19
  308. package/dist/commands/synthetics/test.js +93 -13
  309. package/dist/commands/synthetics/test.js.map +1 -1
  310. package/dist/commands/synthetics/tunnel/tunnel.js +2 -2
  311. package/dist/commands/synthetics/tunnel/tunnel.js.map +1 -1
  312. package/dist/commands/synthetics/utils/internal.d.ts +3 -1
  313. package/dist/commands/synthetics/utils/internal.js +18 -8
  314. package/dist/commands/synthetics/utils/internal.js.map +1 -1
  315. package/dist/commands/synthetics/utils/public.d.ts +5 -26
  316. package/dist/commands/synthetics/utils/public.js +13 -248
  317. package/dist/commands/synthetics/utils/public.js.map +1 -1
  318. package/dist/commands/tag/__tests__/tag.test.d.ts +1 -0
  319. package/dist/commands/tag/__tests__/tag.test.js +85 -0
  320. package/dist/commands/tag/__tests__/tag.test.js.map +1 -0
  321. package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
  322. package/dist/commands/trace/__tests__/trace.test.js +145 -0
  323. package/dist/commands/trace/__tests__/trace.test.js.map +1 -0
  324. package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +1 -0
  325. package/dist/commands/unity-symbols/__tests__/upload.test.js +369 -0
  326. package/dist/commands/unity-symbols/__tests__/upload.test.js.map +1 -0
  327. package/dist/commands/unity-symbols/upload.js +2 -2
  328. package/dist/commands/unity-symbols/upload.js.map +1 -1
  329. package/dist/helpers/__tests__/app.test.d.ts +1 -0
  330. package/dist/helpers/__tests__/app.test.js +31 -0
  331. package/dist/helpers/__tests__/app.test.js.map +1 -0
  332. package/dist/helpers/__tests__/ci.test.d.ts +1 -0
  333. package/dist/helpers/__tests__/ci.test.js +295 -0
  334. package/dist/helpers/__tests__/ci.test.js.map +1 -0
  335. package/dist/helpers/__tests__/env.test.d.ts +1 -0
  336. package/dist/helpers/__tests__/env.test.js +74 -0
  337. package/dist/helpers/__tests__/env.test.js.map +1 -0
  338. package/dist/helpers/__tests__/fips.test.d.ts +1 -0
  339. package/dist/helpers/__tests__/fips.test.js +30 -0
  340. package/dist/helpers/__tests__/fips.test.js.map +1 -0
  341. package/dist/helpers/__tests__/fixtures.d.ts +41 -0
  342. package/dist/helpers/__tests__/fixtures.js +80 -0
  343. package/dist/helpers/__tests__/fixtures.js.map +1 -0
  344. package/dist/helpers/__tests__/flare.test.d.ts +1 -0
  345. package/dist/helpers/__tests__/flare.test.js +226 -0
  346. package/dist/helpers/__tests__/flare.test.js.map +1 -0
  347. package/dist/helpers/__tests__/fs.test.d.ts +1 -0
  348. package/dist/helpers/__tests__/fs.test.js +189 -0
  349. package/dist/helpers/__tests__/fs.test.js.map +1 -0
  350. package/dist/helpers/__tests__/id.test.d.ts +1 -0
  351. package/dist/helpers/__tests__/id.test.js +24 -0
  352. package/dist/helpers/__tests__/id.test.js.map +1 -0
  353. package/dist/helpers/__tests__/plist.test.d.ts +1 -0
  354. package/dist/helpers/__tests__/plist.test.js +43 -0
  355. package/dist/helpers/__tests__/plist.test.js.map +1 -0
  356. package/dist/helpers/__tests__/prompt.test.d.ts +1 -0
  357. package/dist/helpers/__tests__/prompt.test.js +71 -0
  358. package/dist/helpers/__tests__/prompt.test.js.map +1 -0
  359. package/dist/helpers/__tests__/retry.test.d.ts +1 -0
  360. package/dist/helpers/__tests__/retry.test.js +99 -0
  361. package/dist/helpers/__tests__/retry.test.js.map +1 -0
  362. package/dist/helpers/__tests__/tags.test.d.ts +1 -0
  363. package/dist/helpers/__tests__/tags.test.js +303 -0
  364. package/dist/helpers/__tests__/tags.test.js.map +1 -0
  365. package/dist/helpers/__tests__/upload.test.d.ts +1 -0
  366. package/dist/helpers/__tests__/upload.test.js +231 -0
  367. package/dist/helpers/__tests__/upload.test.js.map +1 -0
  368. package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
  369. package/dist/helpers/__tests__/user-provided-git.test.js +119 -0
  370. package/dist/helpers/__tests__/user-provided-git.test.js.map +1 -0
  371. package/dist/helpers/__tests__/utils.test.d.ts +1 -0
  372. package/dist/helpers/__tests__/utils.test.js +429 -0
  373. package/dist/helpers/__tests__/utils.test.js.map +1 -0
  374. package/dist/helpers/__tests__/validation.test.d.ts +1 -0
  375. package/dist/helpers/__tests__/validation.test.js +25 -0
  376. package/dist/helpers/__tests__/validation.test.js.map +1 -0
  377. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +1 -0
  378. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +103 -0
  379. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +1 -0
  380. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +1 -0
  381. package/dist/helpers/git/__tests__/format-git-span-data.test.js +121 -0
  382. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +1 -0
  383. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +1 -0
  384. package/dist/helpers/git/__tests__/get-git-data.test.js +72 -0
  385. package/dist/helpers/git/__tests__/get-git-data.test.js.map +1 -0
  386. package/dist/helpers/id.js.map +1 -0
  387. package/dist/helpers/tags.d.ts +1 -4
  388. package/dist/helpers/tags.js +2 -6
  389. package/dist/helpers/tags.js.map +1 -1
  390. package/dist/helpers/utils.d.ts +0 -4
  391. package/dist/helpers/utils.js +1 -21
  392. package/dist/helpers/utils.js.map +1 -1
  393. package/package.json +16 -17
  394. package/dist/commands/junit/id.js.map +0 -1
  395. package/dist/commands/synthetics/compatibility.d.ts +0 -7
  396. package/dist/commands/synthetics/compatibility.js +0 -83
  397. package/dist/commands/synthetics/compatibility.js.map +0 -1
  398. /package/dist/{commands/junit → helpers}/id.d.ts +0 -0
  399. /package/dist/{commands/junit → helpers}/id.js +0 -0
@@ -0,0 +1,906 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const axios_1 = __importDefault(require("axios"));
39
+ const deep_extend_1 = __importDefault(require("deep-extend"));
40
+ const fixtures_1 = require("../../../helpers/__tests__/fixtures");
41
+ const ciHelpers = __importStar(require("../../../helpers/ci"));
42
+ process.env.DATADOG_SYNTHETICS_CI_TRIGGER_APP = 'env_default';
43
+ const api_1 = require("../api");
44
+ const batch_1 = require("../batch");
45
+ const errors_1 = require("../errors");
46
+ const interfaces_1 = require("../interfaces");
47
+ const run_tests_command_1 = require("../run-tests-command");
48
+ const internalUtils = __importStar(require("../utils/internal"));
49
+ const utils = __importStar(require("../utils/public"));
50
+ const fixtures_2 = require("./fixtures");
51
+ const apiConfiguration = {
52
+ apiKey: '123',
53
+ appKey: '123',
54
+ baseIntakeUrl: 'baseintake',
55
+ baseUnstableUrl: 'baseUnstable',
56
+ baseUrl: 'base',
57
+ proxyOpts: { protocol: 'http' },
58
+ };
59
+ const api = (0, api_1.apiConstructor)(apiConfiguration);
60
+ describe('runTests', () => {
61
+ beforeEach(() => {
62
+ jest.restoreAllMocks();
63
+ });
64
+ const fakeId = '123-456-789';
65
+ const fakeTrigger = {
66
+ batch_id: 'bid',
67
+ locations: [],
68
+ };
69
+ test('should run test', () => __awaiter(void 0, void 0, void 0, function* () {
70
+ jest.spyOn(api, 'triggerTests').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return fakeTrigger; }));
71
+ const output = yield (0, batch_1.runTests)(api, [{ public_id: fakeId, executionRule: interfaces_1.ExecutionRule.NON_BLOCKING }]);
72
+ expect(output).toEqual(fakeTrigger);
73
+ }));
74
+ test('runTests sends batch metadata', () => __awaiter(void 0, void 0, void 0, function* () {
75
+ jest.spyOn(ciHelpers, 'getCIMetadata').mockImplementation(() => undefined);
76
+ const payloadMetadataSpy = jest.fn();
77
+ jest.spyOn(axios_1.default, 'create').mockImplementation((() => (request) => {
78
+ payloadMetadataSpy(request.data.metadata);
79
+ if (request.url === '/synthetics/tests/trigger/ci') {
80
+ return { data: fakeTrigger };
81
+ }
82
+ }));
83
+ yield (0, batch_1.runTests)(api, [{ public_id: fakeId, executionRule: interfaces_1.ExecutionRule.NON_BLOCKING }]);
84
+ expect(payloadMetadataSpy).toHaveBeenCalledWith(undefined);
85
+ const metadata = {
86
+ ci: { job: { name: 'job' }, pipeline: {}, provider: { name: 'jest' }, stage: {} },
87
+ git: { commit: { author: {}, committer: {}, message: 'test' } },
88
+ };
89
+ jest.spyOn(ciHelpers, 'getCIMetadata').mockImplementation(() => metadata);
90
+ yield (0, batch_1.runTests)(api, [{ public_id: fakeId, executionRule: interfaces_1.ExecutionRule.NON_BLOCKING }]);
91
+ expect(payloadMetadataSpy).toHaveBeenCalledWith(metadata);
92
+ }));
93
+ test('runTests api call has the right payload and trigger app header', () => __awaiter(void 0, void 0, void 0, function* () {
94
+ jest.spyOn(ciHelpers, 'getCIMetadata').mockImplementation(() => undefined);
95
+ const testsPayloadSpy = jest.fn();
96
+ const headersMetadataSpy = jest.fn();
97
+ jest.spyOn(axios_1.default, 'create').mockImplementation((() => (request) => {
98
+ testsPayloadSpy(request.data.tests);
99
+ headersMetadataSpy(request.headers);
100
+ if (request.url === '/synthetics/tests/trigger/ci') {
101
+ return { data: fakeTrigger };
102
+ }
103
+ }));
104
+ yield (0, batch_1.runTests)(api, [{ public_id: fakeId, executionRule: interfaces_1.ExecutionRule.NON_BLOCKING }]);
105
+ expect(headersMetadataSpy).toHaveBeenCalledWith(expect.objectContaining({ 'X-Trigger-App': 'env_default' }));
106
+ expect(testsPayloadSpy).toHaveBeenCalledWith([
107
+ {
108
+ public_id: fakeId,
109
+ executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
110
+ },
111
+ ]);
112
+ utils.setCiTriggerApp('unit_test');
113
+ yield (0, batch_1.runTests)(api, [{ public_id: fakeId, executionRule: interfaces_1.ExecutionRule.NON_BLOCKING }]);
114
+ expect(headersMetadataSpy).toHaveBeenCalledWith(expect.objectContaining({ 'X-Trigger-App': 'unit_test' }));
115
+ expect(testsPayloadSpy).toHaveBeenCalledWith([
116
+ {
117
+ public_id: fakeId,
118
+ executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
119
+ },
120
+ ]);
121
+ }));
122
+ test('should run test with publicId from url', () => __awaiter(void 0, void 0, void 0, function* () {
123
+ jest.spyOn(api, 'triggerTests').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return fakeTrigger; }));
124
+ const output = yield (0, batch_1.runTests)(api, [
125
+ {
126
+ executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
127
+ public_id: `http://localhost/synthetics/tests/details/${fakeId}`,
128
+ },
129
+ ]);
130
+ expect(output).toEqual(fakeTrigger);
131
+ }));
132
+ test('triggerTests throws', () => __awaiter(void 0, void 0, void 0, function* () {
133
+ jest.spyOn(api, 'triggerTests').mockImplementation(() => {
134
+ throw (0, fixtures_1.getAxiosError)(502, { message: 'Server Error' });
135
+ });
136
+ yield expect((0, batch_1.runTests)(api, [{ public_id: fakeId, executionRule: interfaces_1.ExecutionRule.NON_BLOCKING }])).rejects.toThrow(/Failed to trigger tests:/);
137
+ }));
138
+ });
139
+ describe('waitForResults', () => {
140
+ beforeEach(() => {
141
+ jest.useFakeTimers({ now: 123 });
142
+ jest.spyOn(internalUtils, 'wait').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return jest.advanceTimersByTime(5000); }));
143
+ });
144
+ afterEach(() => {
145
+ jest.useRealTimers();
146
+ jest.restoreAllMocks();
147
+ });
148
+ const batch = (0, fixtures_2.getBatch)();
149
+ const apiTest = (0, fixtures_2.getApiTest)('pid');
150
+ const result = {
151
+ duration: 1000,
152
+ executionRule: interfaces_1.ExecutionRule.BLOCKING,
153
+ initialResultId: undefined,
154
+ isNonFinal: false,
155
+ location: fixtures_2.mockLocation.display_name,
156
+ passed: true,
157
+ result: (0, fixtures_2.getBrowserServerResult)({ passed: true }),
158
+ resultId: 'rid',
159
+ retries: 0,
160
+ maxRetries: 0,
161
+ selectiveRerun: undefined,
162
+ test: apiTest,
163
+ timedOut: false,
164
+ timestamp: 0,
165
+ };
166
+ const pollResult = {
167
+ check: result.test,
168
+ result: result.result,
169
+ resultID: result.resultId,
170
+ timestamp: result.timestamp,
171
+ };
172
+ const trigger = { batch_id: 'bid', locations: [fixtures_2.mockLocation] };
173
+ const mockApi = ({ getBatchImplementation, pollResultsImplementation, } = {}) => {
174
+ const getBatchMock = jest
175
+ .spyOn(api, 'getBatch')
176
+ .mockImplementation(getBatchImplementation || (() => __awaiter(void 0, void 0, void 0, function* () { return (0, deep_extend_1.default)({}, batch); })));
177
+ const pollResultsMock = jest
178
+ .spyOn(api, 'pollResults')
179
+ .mockImplementation(pollResultsImplementation || (() => __awaiter(void 0, void 0, void 0, function* () { return [(0, deep_extend_1.default)({}, pollResult)]; })));
180
+ return { getBatchMock, pollResultsMock };
181
+ };
182
+ const waiter = {
183
+ promise: Promise.resolve(),
184
+ resolve: () => { },
185
+ start() {
186
+ this.promise = new Promise((resolve) => (this.resolve = resolve));
187
+ },
188
+ };
189
+ test('should poll result ids', () => __awaiter(void 0, void 0, void 0, function* () {
190
+ mockApi();
191
+ expect(yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
192
+ batchTimeout: 120000,
193
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
194
+ failOnCriticalErrors: false,
195
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
196
+ }, fixtures_2.mockReporter)).toEqual([result]);
197
+ }));
198
+ test('should show results as they arrive', () => __awaiter(void 0, void 0, void 0, function* () {
199
+ jest.spyOn(internalUtils, 'wait').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return waiter.resolve(); }));
200
+ const tests = [result.test, Object.assign(Object.assign({}, result.test), { public_id: 'other-public-id' })];
201
+ // === STEP 1 === (batch 'in_progress')
202
+ waiter.start();
203
+ mockApi({
204
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
205
+ return ({
206
+ status: 'in_progress',
207
+ results: [
208
+ Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()),
209
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { result_id: 'rid-2' }),
210
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-3' }),
211
+ ],
212
+ });
213
+ }),
214
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return [(0, deep_extend_1.default)({}, pollResult)]; }),
215
+ });
216
+ const resultsPromise = (0, batch_1.waitForResults)(api, trigger, tests, {
217
+ batchTimeout: 120000,
218
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
219
+ failOnCriticalErrors: false,
220
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
221
+ }, fixtures_2.mockReporter);
222
+ // Wait for the 2 tests (initial)
223
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(1, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id);
224
+ yield waiter.promise;
225
+ // No results received
226
+ expect(fixtures_2.mockReporter.resultReceived).not.toHaveBeenCalled();
227
+ expect(fixtures_2.mockReporter.resultEnd).not.toHaveBeenCalled();
228
+ // Still waiting for the 2 tests
229
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(2, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
230
+ // === STEP 2 === (batch 'in_progress')
231
+ waiter.start();
232
+ mockApi({
233
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
234
+ return ({
235
+ status: 'in_progress',
236
+ results: [
237
+ Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()),
238
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
239
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-3' }),
240
+ ],
241
+ });
242
+ }),
243
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
244
+ return [
245
+ (0, deep_extend_1.default)({}, pollResult),
246
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' }),
247
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-3' }),
248
+ ];
249
+ }),
250
+ });
251
+ yield waiter.promise;
252
+ // One result received
253
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(1, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed', result_id: 'rid-2' }));
254
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(1, Object.assign(Object.assign({}, result), { resultId: 'rid-2' }), fixtures_1.MOCK_BASE_URL, 'bid');
255
+ // Still waiting for 2 tests
256
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(3, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
257
+ // === STEP 3 === (batch 'in_progress')
258
+ waiter.start();
259
+ mockApi({
260
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
261
+ return ({
262
+ status: 'in_progress',
263
+ results: [
264
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
265
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
266
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-3' }),
267
+ ],
268
+ });
269
+ }),
270
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
271
+ return [
272
+ (0, deep_extend_1.default)({}, pollResult),
273
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' }),
274
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-3' }),
275
+ ];
276
+ }),
277
+ });
278
+ yield waiter.promise;
279
+ // One result received
280
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed' }));
281
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(2, result, fixtures_1.MOCK_BASE_URL, 'bid');
282
+ // Now waiting for 1 test
283
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(4, [tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
284
+ // === STEP 4 === (batch 'in_progress')
285
+ waiter.start();
286
+ mockApi({
287
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
288
+ return ({
289
+ status: 'in_progress',
290
+ results: [
291
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
292
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
293
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { duration: 1000, retries: 0, test_public_id: 'other-public-id', timed_out: false, result_id: 'rid-3' }),
294
+ ],
295
+ });
296
+ }),
297
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
298
+ return [
299
+ (0, deep_extend_1.default)({}, pollResult),
300
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' }),
301
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-3' }),
302
+ ];
303
+ }),
304
+ });
305
+ yield waiter.promise;
306
+ // One result received
307
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(3, Object.assign(Object.assign({}, batch.results[0]), { duration: 1000, status: 'in_progress', test_public_id: 'other-public-id', result_id: 'rid-3' }));
308
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(3, Object.assign(Object.assign({}, result), { isNonFinal: true, resultId: 'rid-3', passed: false }), // the first attempt failed, so it's being retried
309
+ fixtures_1.MOCK_BASE_URL, 'bid');
310
+ // Now waiting for 1 test
311
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(5, [tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
312
+ // === STEP 5 === (batch 'passed')
313
+ mockApi({
314
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
315
+ return ({
316
+ status: 'passed',
317
+ results: [
318
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
319
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
320
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { retries: 1, test_public_id: 'other-public-id', result_id: 'rid-3-final' }),
321
+ ],
322
+ });
323
+ }),
324
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
325
+ return [
326
+ (0, deep_extend_1.default)({}, pollResult),
327
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' }),
328
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-3-final' }),
329
+ ];
330
+ }),
331
+ });
332
+ expect(yield resultsPromise).toEqual([
333
+ result,
334
+ Object.assign(Object.assign({}, result), { resultId: 'rid-2' }),
335
+ Object.assign(Object.assign({}, result), { resultId: 'rid-3-final', retries: 1 }),
336
+ ]);
337
+ // One result received
338
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(4, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed', test_public_id: 'other-public-id', result_id: 'rid-3-final', retries: 1 }));
339
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(4, Object.assign(Object.assign({}, result), { resultId: 'rid-3-final', retries: 1 }), fixtures_1.MOCK_BASE_URL, 'bid');
340
+ // Do not report when there are no tests to wait anymore
341
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenCalledTimes(5);
342
+ }));
343
+ test('skipped results are reported as received', () => __awaiter(void 0, void 0, void 0, function* () {
344
+ jest.spyOn(internalUtils, 'wait').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return waiter.resolve(); }));
345
+ const tests = [result.test, Object.assign(Object.assign({}, result.test), { public_id: 'other-public-id' })];
346
+ // === STEP 1 === (batch 'in_progress')
347
+ waiter.start();
348
+ mockApi({
349
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
350
+ return ({
351
+ status: 'in_progress',
352
+ results: [
353
+ Object.assign({}, (0, fixtures_2.getSkippedResultInBatch)()),
354
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-2' }),
355
+ ],
356
+ });
357
+ }),
358
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return [Object.assign(Object.assign({}, pollResult), { resultID: 'rid-2' })]; }),
359
+ });
360
+ const resultsPromise = (0, batch_1.waitForResults)(api, trigger, tests, {
361
+ batchTimeout: 120000,
362
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
363
+ failOnCriticalErrors: false,
364
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
365
+ }, fixtures_2.mockReporter);
366
+ // Wait for the 2 tests (initial)
367
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(1, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id);
368
+ yield waiter.promise;
369
+ // The skipped result is received
370
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(1, Object.assign({}, (0, fixtures_2.getSkippedResultInBatch)()));
371
+ // And marked as passed because it's selective rerun
372
+ const skippedResult = {
373
+ executionRule: interfaces_1.ExecutionRule.SKIPPED,
374
+ passed: true,
375
+ resultId: '123',
376
+ selectiveRerun: { decision: 'skip', reason: 'passed', linked_result_id: '123' },
377
+ test: result.test,
378
+ timedOut: false,
379
+ };
380
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(1, skippedResult, fixtures_1.MOCK_BASE_URL, 'bid');
381
+ // Now waiting for the remaining test
382
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(2, [tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 1);
383
+ // === STEP 2 === (batch 'passed')
384
+ mockApi({
385
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
386
+ return ({
387
+ status: 'passed',
388
+ results: [
389
+ Object.assign({}, (0, fixtures_2.getSkippedResultInBatch)()),
390
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-2' }),
391
+ ],
392
+ });
393
+ }),
394
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return [(0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' })]; }),
395
+ });
396
+ expect(yield resultsPromise).toEqual([Object.assign({}, skippedResult), Object.assign(Object.assign({}, result), { resultId: 'rid-2' })]);
397
+ // One result received
398
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed', test_public_id: 'other-public-id', result_id: 'rid-2' }));
399
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, result), { resultId: 'rid-2' }), fixtures_1.MOCK_BASE_URL, 'bid');
400
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenCalledTimes(2);
401
+ }));
402
+ test('should wait for incomplete results', () => __awaiter(void 0, void 0, void 0, function* () {
403
+ jest.spyOn(internalUtils, 'wait').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return waiter.resolve(); }));
404
+ const tests = [result.test, Object.assign(Object.assign({}, result.test), { public_id: 'other-public-id' })];
405
+ // === STEP 1 === (batch 'in_progress')
406
+ waiter.start();
407
+ mockApi({
408
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
409
+ return ({
410
+ status: 'in_progress',
411
+ results: [
412
+ Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()),
413
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
414
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-3' }),
415
+ ],
416
+ });
417
+ }),
418
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return [Object.assign(Object.assign({}, pollResult), { resultID: 'rid-2', result: (0, fixtures_2.getIncompleteServerResult)() })]; }),
419
+ });
420
+ const resultsPromise = (0, batch_1.waitForResults)(api, trigger, tests, {
421
+ batchTimeout: 120000,
422
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
423
+ failOnCriticalErrors: false,
424
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
425
+ }, fixtures_2.mockReporter);
426
+ // Wait for the 2 tests (initial)
427
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(1, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id);
428
+ yield waiter.promise;
429
+ // One result received
430
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(1, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed', result_id: 'rid-2' }));
431
+ // But the data from `/poll_results` data is not available yet, so we should wait more before reporting
432
+ expect(fixtures_2.mockReporter.resultEnd).not.toHaveBeenCalled();
433
+ // Still waiting for 2 tests
434
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(2, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
435
+ // === STEP 2 === (batch 'in_progress')
436
+ waiter.start();
437
+ mockApi({
438
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
439
+ return ({
440
+ status: 'in_progress',
441
+ results: [
442
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
443
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
444
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-3' }),
445
+ ],
446
+ });
447
+ }),
448
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
449
+ return [
450
+ Object.assign(Object.assign({}, pollResult), { result: (0, fixtures_2.getIncompleteServerResult)() }),
451
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' }), // just became available
452
+ ];
453
+ }),
454
+ });
455
+ yield waiter.promise;
456
+ // One result received
457
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed' }));
458
+ // Result 2 just became available, so it should be reported
459
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(1, Object.assign(Object.assign({}, result), { resultId: 'rid-2' }), fixtures_1.MOCK_BASE_URL, 'bid');
460
+ // Now waiting for 1 test
461
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(3, [tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
462
+ // === STEP 3 === (batch 'failed')
463
+ mockApi({
464
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
465
+ return ({
466
+ status: 'failed',
467
+ results: [
468
+ Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()),
469
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: 'rid-2' }),
470
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-3' }),
471
+ ],
472
+ });
473
+ }),
474
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
475
+ return [
476
+ Object.assign(Object.assign({}, pollResult), { result: (0, fixtures_2.getIncompleteServerResult)() }),
477
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-2' }),
478
+ (0, deep_extend_1.default)({}, pollResult, { resultID: 'rid-3' }),
479
+ ];
480
+ }),
481
+ });
482
+ expect(yield resultsPromise).toEqual([
483
+ Object.assign(Object.assign({}, result), { resultId: 'rid', passed: false, result: undefined }),
484
+ Object.assign(Object.assign({}, result), { resultId: 'rid-2' }),
485
+ Object.assign(Object.assign({}, result), { resultId: 'rid-3' }),
486
+ ]);
487
+ // One result received
488
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(3, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed', test_public_id: 'other-public-id', result_id: 'rid-3' }));
489
+ // Result 3 was available instantly
490
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, result), { resultId: 'rid-3' }), fixtures_1.MOCK_BASE_URL, 'bid');
491
+ // Result 1 never became available (but the batch says it did not pass)
492
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(3, Object.assign(Object.assign({}, result), { passed: false, resultId: 'rid', result: undefined }), fixtures_1.MOCK_BASE_URL, 'bid');
493
+ expect(fixtures_2.mockReporter.error).toHaveBeenCalledWith('The information for result rid of test pid was incomplete at the end of the batch.\n\n');
494
+ // Do not report when there are no tests to wait anymore
495
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenCalledTimes(3);
496
+ }));
497
+ test('should wait for incomplete results caused by 404', () => __awaiter(void 0, void 0, void 0, function* () {
498
+ jest.spyOn(internalUtils, 'wait').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return waiter.resolve(); }));
499
+ const tests = [result.test, Object.assign(Object.assign({}, result.test), { public_id: 'other-public-id' })];
500
+ // === STEP 1 === (batch 'in_progress')
501
+ waiter.start();
502
+ mockApi({
503
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
504
+ return ({
505
+ status: 'in_progress',
506
+ results: [
507
+ Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()),
508
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-2' }),
509
+ ],
510
+ });
511
+ }),
512
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
513
+ });
514
+ const resultsPromise = (0, batch_1.waitForResults)(api, trigger, tests, {
515
+ batchTimeout: 120000,
516
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
517
+ failOnCriticalErrors: false,
518
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
519
+ }, fixtures_2.mockReporter);
520
+ // Wait for the 2 tests (initial)
521
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(1, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id);
522
+ yield waiter.promise;
523
+ // Still waiting for 2 tests
524
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(2, [tests[0], tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
525
+ // === STEP 2 === (batch 'in_progress')
526
+ waiter.start();
527
+ mockApi({
528
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
529
+ return ({
530
+ status: 'in_progress',
531
+ results: [
532
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
533
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-2' }),
534
+ ],
535
+ });
536
+ }),
537
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
538
+ throw (0, fixtures_1.getAxiosError)(404, { message: 'Test results not found' });
539
+ }),
540
+ });
541
+ yield waiter.promise;
542
+ // One result received
543
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(1, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed' }));
544
+ // But not available
545
+ expect(fixtures_2.mockReporter.resultEnd).not.toHaveBeenCalled();
546
+ // Now waiting for 1 test
547
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(3, [tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
548
+ // === STEP 3 === (batch 'in_progress')
549
+ waiter.start();
550
+ mockApi({
551
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
552
+ return ({
553
+ status: 'in_progress',
554
+ results: [
555
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
556
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-2' }),
557
+ ],
558
+ });
559
+ }),
560
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
561
+ return [
562
+ (0, deep_extend_1.default)({}, pollResult), // became available
563
+ ];
564
+ }),
565
+ });
566
+ yield waiter.promise;
567
+ // Result 1 just became available, so it should be reported
568
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(1, result, fixtures_1.MOCK_BASE_URL, 'bid');
569
+ // Still waiting for 1 test
570
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenNthCalledWith(3, [tests[1]], fixtures_1.MOCK_BASE_URL, trigger.batch_id, 0);
571
+ mockApi({
572
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
573
+ return ({
574
+ status: 'passed',
575
+ results: [
576
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
577
+ Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { test_public_id: 'other-public-id', result_id: 'rid-2' }),
578
+ ],
579
+ });
580
+ }),
581
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
582
+ throw (0, fixtures_1.getAxiosError)(404, { message: 'Test results not found' });
583
+ }),
584
+ });
585
+ expect(yield resultsPromise).toEqual([
586
+ result,
587
+ Object.assign(Object.assign({}, result), { resultId: 'rid-2', result: undefined, timestamp: 123, test: tests[1] }),
588
+ ]);
589
+ // One result received
590
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, batch.results[0]), { status: 'passed', test_public_id: 'other-public-id', result_id: 'rid-2' }));
591
+ // Last result is reported without a poll result
592
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(2, Object.assign(Object.assign({}, result), { resultId: 'rid-2', result: undefined, test: tests[1], timestamp: 123 }), fixtures_1.MOCK_BASE_URL, 'bid');
593
+ expect(fixtures_2.mockReporter.error).toHaveBeenCalledWith('The information for result rid-2 of test other-public-id was incomplete at the end of the batch.\n\n');
594
+ // Do not report when there are no tests to wait anymore
595
+ expect(fixtures_2.mockReporter.testsWait).toHaveBeenCalledTimes(4);
596
+ }));
597
+ test('object in each result should be different even if they share the same public ID (config overrides)', () => __awaiter(void 0, void 0, void 0, function* () {
598
+ mockApi({
599
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
600
+ return ({
601
+ results: [(0, fixtures_2.getPassedResultInBatch)(), Object.assign(Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), { result_id: '3' })],
602
+ status: 'passed',
603
+ });
604
+ }),
605
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
606
+ return [
607
+ (0, deep_extend_1.default)({}, pollResult),
608
+ // The test object from the second result has an overridden start URL
609
+ (0, deep_extend_1.default)({}, pollResult, { check: { config: { request: { url: 'https://reddit.com/' } } }, resultID: '3' }),
610
+ ];
611
+ }),
612
+ });
613
+ const results = yield (0, batch_1.waitForResults)(api, trigger, [result.test, result.test], {
614
+ batchTimeout: 0,
615
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
616
+ failOnCriticalErrors: false,
617
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
618
+ }, fixtures_2.mockReporter);
619
+ expect(results.map(({ test }) => test.config.request.url)).toEqual(['http://fake.url', 'https://reddit.com/']);
620
+ }));
621
+ test('results should be timed out if the backend says so', () => __awaiter(void 0, void 0, void 0, function* () {
622
+ mockApi({
623
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
624
+ return ({
625
+ status: 'failed',
626
+ results: [Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()), Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { result_id: '3', timed_out: true })],
627
+ });
628
+ }),
629
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
630
+ return [
631
+ Object.assign(Object.assign({}, pollResult), { result: Object.assign({}, pollResult.result) }),
632
+ Object.assign(Object.assign({}, pollResult), { result: Object.assign({}, pollResult.result), resultID: '3' }),
633
+ ];
634
+ }),
635
+ });
636
+ const expectedTimeoutResult = Object.assign(Object.assign({}, result), { result: Object.assign(Object.assign({}, result.result), { failure: { code: 'TIMEOUT', message: 'The batch timed out before receiving the result.' }, passed: false }), resultId: '3', timedOut: true });
637
+ expect(yield (0, batch_1.waitForResults)(api, trigger, [result.test, result.test], {
638
+ batchTimeout: 3000,
639
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
640
+ failOnCriticalErrors: false,
641
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
642
+ }, fixtures_2.mockReporter)).toEqual([result, expectedTimeoutResult]);
643
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledTimes(2);
644
+ // `resultEnd` should return the same data as `waitForResults`
645
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(1, result, fixtures_1.MOCK_BASE_URL, 'bid');
646
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(2, expectedTimeoutResult, fixtures_1.MOCK_BASE_URL, 'bid');
647
+ // Failed directly.
648
+ expect(internalUtils.wait).toHaveBeenCalledTimes(0);
649
+ }));
650
+ test('results should be timed out with a different error if the backend did not say so', () => __awaiter(void 0, void 0, void 0, function* () {
651
+ mockApi({
652
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
653
+ return ({
654
+ status: 'in_progress',
655
+ results: [
656
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
657
+ Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { result_id: '3' }),
658
+ ],
659
+ });
660
+ }),
661
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
662
+ return [
663
+ Object.assign(Object.assign({}, pollResult), { result: Object.assign({}, pollResult.result) }),
664
+ Object.assign(Object.assign({}, pollResult), { result: Object.assign({}, pollResult.result), resultID: '3' }),
665
+ ];
666
+ }),
667
+ });
668
+ const expectedDeadlineResult = Object.assign(Object.assign({}, result), { duration: 0, result: Object.assign(Object.assign({}, result.result), { failure: {
669
+ code: 'BATCH_TIMEOUT_RUNAWAY',
670
+ message: "The batch didn't timeout after the expected timeout period.",
671
+ }, passed: false }), resultId: '3', timedOut: true });
672
+ yield expect((0, batch_1.waitForResults)(api, trigger, [result.test, result.test], {
673
+ batchTimeout: 3000,
674
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
675
+ failOnCriticalErrors: false,
676
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
677
+ }, fixtures_2.mockReporter)).rejects.toThrow(new errors_1.BatchTimeoutRunawayError());
678
+ // Residual results are never 'received': we force-end them.
679
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledTimes(1);
680
+ // `resultEnd` should return the same data as `waitForResults`
681
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(1, result, fixtures_1.MOCK_BASE_URL, 'bid');
682
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenNthCalledWith(2, expectedDeadlineResult, fixtures_1.MOCK_BASE_URL, 'bid');
683
+ // Initial wait + 3 polling cycles.
684
+ expect(internalUtils.wait).toHaveBeenCalledTimes(4);
685
+ }));
686
+ test('results failure should be ignored if timed out', () => __awaiter(void 0, void 0, void 0, function* () {
687
+ // The original failure of a result received between timing out in batch poll
688
+ // and retrieving it should be ignored in favor of timeout.
689
+ mockApi({
690
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
691
+ return ({
692
+ status: 'failed',
693
+ results: [Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { timed_out: true })],
694
+ });
695
+ }),
696
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
697
+ return [
698
+ Object.assign(Object.assign({}, pollResult), { passed: false, result: Object.assign(Object.assign({}, pollResult.result), { failure: { code: 'FAILURE', message: 'Original failure, should be ignored' }, passed: false }) }),
699
+ ];
700
+ }),
701
+ });
702
+ expect(yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
703
+ batchTimeout: 0,
704
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
705
+ failOnCriticalErrors: false,
706
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
707
+ }, fixtures_2.mockReporter)).toStrictEqual([
708
+ Object.assign(Object.assign({}, result), { result: Object.assign(Object.assign({}, result.result), { failure: { code: 'TIMEOUT', message: 'The batch timed out before receiving the result.' }, passed: false }), timedOut: true }),
709
+ ]);
710
+ }));
711
+ test('results should be timed out if batch result is timed out', () => __awaiter(void 0, void 0, void 0, function* () {
712
+ const batchWithTimeoutResult = Object.assign(Object.assign({}, batch), { results: [Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { timed_out: true })] });
713
+ mockApi({ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return batchWithTimeoutResult; }) });
714
+ expect(yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
715
+ batchTimeout: 120000,
716
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
717
+ failOnCriticalErrors: false,
718
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
719
+ }, fixtures_2.mockReporter)).toEqual([
720
+ Object.assign(Object.assign({}, result), { result: Object.assign(Object.assign({}, result.result), { failure: { code: 'TIMEOUT', message: 'The batch timed out before receiving the result.' }, passed: false }), timedOut: true }),
721
+ ]);
722
+ }));
723
+ test('wait between batch polling', () => __awaiter(void 0, void 0, void 0, function* () {
724
+ const { getBatchMock } = mockApi({
725
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () {
726
+ return getBatchMock.mock.calls.length === 3 ? batch : Object.assign(Object.assign({}, batch), { status: 'in_progress' });
727
+ }),
728
+ });
729
+ expect(yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
730
+ batchTimeout: 120000,
731
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
732
+ failOnCriticalErrors: false,
733
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
734
+ }, fixtures_2.mockReporter)).toEqual([result]);
735
+ expect(getBatchMock).toHaveBeenCalledTimes(3);
736
+ expect(internalUtils.wait).toHaveBeenCalledTimes(2);
737
+ }));
738
+ test('correct number of passed and timed out results', () => __awaiter(void 0, void 0, void 0, function* () {
739
+ const pollTimeoutResult = Object.assign(Object.assign({}, (0, deep_extend_1.default)({}, pollResult)), { resultID: 'another-id' });
740
+ const batchWithTimeoutResult = Object.assign(Object.assign({}, batch), { results: [
741
+ Object.assign({}, (0, fixtures_2.getPassedResultInBatch)()),
742
+ Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { timed_out: true, result_id: pollTimeoutResult.resultID }),
743
+ ] });
744
+ mockApi({
745
+ getBatchImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return batchWithTimeoutResult; }),
746
+ pollResultsImplementation: () => __awaiter(void 0, void 0, void 0, function* () { return [pollResult, pollTimeoutResult]; }),
747
+ });
748
+ expect(yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
749
+ batchTimeout: 2000,
750
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
751
+ failOnCriticalErrors: false,
752
+ failOnTimeout: false,
753
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
754
+ }, fixtures_2.mockReporter)).toEqual([
755
+ Object.assign(Object.assign({}, result), { passed: true, timedOut: false }),
756
+ Object.assign(Object.assign({}, result), { passed: true, timedOut: true, resultId: pollTimeoutResult.resultID, result: Object.assign(Object.assign({}, result.result), { failure: {
757
+ code: 'TIMEOUT',
758
+ message: 'The batch timed out before receiving the result.',
759
+ }, passed: false }) }),
760
+ ]);
761
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledTimes(2);
762
+ expect(fixtures_2.mockReporter.resultEnd).toHaveBeenCalledTimes(2);
763
+ }));
764
+ test('tunnel failure', () => __awaiter(void 0, void 0, void 0, function* () {
765
+ mockApi();
766
+ const mockTunnel = {
767
+ keepAlive: () => __awaiter(void 0, void 0, void 0, function* () {
768
+ throw new Error('keepAlive failed');
769
+ }),
770
+ };
771
+ yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
772
+ batchTimeout: 2000,
773
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
774
+ failOnCriticalErrors: true,
775
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
776
+ }, fixtures_2.mockReporter, mockTunnel);
777
+ expect(fixtures_2.mockReporter.error).toHaveBeenCalledWith('The tunnel has stopped working, this may have affected the results.');
778
+ }));
779
+ test('location when tunnel', () => __awaiter(void 0, void 0, void 0, function* () {
780
+ mockApi();
781
+ const mockTunnel = { keepAlive: () => __awaiter(void 0, void 0, void 0, function* () { return true; }) };
782
+ let results = yield (0, batch_1.waitForResults)(api, trigger, [result.test], {
783
+ batchTimeout: 2000,
784
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
785
+ failOnCriticalErrors: true,
786
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
787
+ }, fixtures_2.mockReporter, mockTunnel);
788
+ expect(results[0].location).toBe('Tunneled');
789
+ const newTest = Object.assign({}, result.test);
790
+ newTest.type = 'api';
791
+ newTest.subtype = 'http';
792
+ results = yield (0, batch_1.waitForResults)(api, trigger, [newTest], {
793
+ batchTimeout: 2000,
794
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
795
+ failOnCriticalErrors: true,
796
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
797
+ }, fixtures_2.mockReporter, mockTunnel);
798
+ expect(results[0].location).toBe('Tunneled');
799
+ newTest.type = 'api';
800
+ newTest.subtype = 'ssl';
801
+ results = yield (0, batch_1.waitForResults)(api, trigger, [newTest], {
802
+ batchTimeout: 2000,
803
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
804
+ failOnCriticalErrors: true,
805
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
806
+ }, fixtures_2.mockReporter, mockTunnel);
807
+ expect(results[0].location).toBe('Frankfurt (AWS)');
808
+ }));
809
+ test('pollResults throws', () => __awaiter(void 0, void 0, void 0, function* () {
810
+ const { pollResultsMock } = mockApi({
811
+ pollResultsImplementation: () => {
812
+ throw (0, fixtures_1.getAxiosError)(502, { message: 'Poll results server error' });
813
+ },
814
+ });
815
+ yield expect((0, batch_1.waitForResults)(api, trigger, [result.test], {
816
+ batchTimeout: 2000,
817
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
818
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
819
+ }, fixtures_2.mockReporter)).rejects.toThrow('Failed to poll results: could not query https://app.datadoghq.com/example\nPoll results server error\n');
820
+ expect(pollResultsMock).toHaveBeenCalledWith([result.resultId]);
821
+ }));
822
+ test('getBatch throws', () => __awaiter(void 0, void 0, void 0, function* () {
823
+ const { getBatchMock } = mockApi({
824
+ getBatchImplementation: () => {
825
+ throw (0, fixtures_1.getAxiosError)(502, { message: 'Get batch server error' });
826
+ },
827
+ });
828
+ yield expect((0, batch_1.waitForResults)(api, trigger, [result.test], {
829
+ batchTimeout: 2000,
830
+ datadogSite: run_tests_command_1.DEFAULT_COMMAND_CONFIG.datadogSite,
831
+ subdomain: run_tests_command_1.DEFAULT_COMMAND_CONFIG.subdomain,
832
+ }, fixtures_2.mockReporter)).rejects.toThrow('Failed to get batch: could not query https://app.datadoghq.com/example\nGet batch server error\n');
833
+ expect(getBatchMock).toHaveBeenCalledWith(trigger.batch_id);
834
+ }));
835
+ });
836
+ describe('getResultsToReport', () => {
837
+ test.each([false])('timed out retry - shouldContinuePolling=%s', (shouldContinuePolling) => {
838
+ const timedOutRetry = Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { retries: 0, max_retries: 1, timed_out: true });
839
+ const batch = {
840
+ status: 'failed',
841
+ results: [timedOutRetry],
842
+ };
843
+ const resultsToReport = (0, batch_1.getResultsToReport)(shouldContinuePolling, batch, [], new Set(['rid']), new Set(), new Set(), fixtures_2.mockReporter);
844
+ expect(resultsToReport).toStrictEqual([timedOutRetry]);
845
+ });
846
+ test.each([false])('timed out retry never emitted before - shouldContinuePolling=%s', (shouldContinuePolling) => {
847
+ const timedOutRetry = Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { retries: 0, max_retries: 1, timed_out: true });
848
+ const batch = {
849
+ status: 'failed',
850
+ results: [timedOutRetry],
851
+ };
852
+ const resultsToReport = (0, batch_1.getResultsToReport)(shouldContinuePolling, batch, [timedOutRetry], new Set(), new Set(), new Set(), fixtures_2.mockReporter);
853
+ expect(resultsToReport).toStrictEqual([timedOutRetry]);
854
+ });
855
+ });
856
+ describe('reportReceivedResults', () => {
857
+ test('skipped', () => {
858
+ const skippedResult = (0, fixtures_2.getSkippedResultInBatch)();
859
+ const batch = {
860
+ status: 'failed',
861
+ results: [skippedResult],
862
+ };
863
+ const emittedResultIds = new Set();
864
+ const receivedResults = (0, batch_1.reportReceivedResults)(batch, emittedResultIds, fixtures_2.mockReporter);
865
+ expect(receivedResults).toStrictEqual([skippedResult]);
866
+ expect(emittedResultIds).toContain('skipped-0');
867
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledWith(skippedResult);
868
+ });
869
+ test('final', () => {
870
+ const result = (0, fixtures_2.getPassedResultInBatch)();
871
+ const batch = {
872
+ status: 'passed',
873
+ results: [result],
874
+ };
875
+ const emittedResultIds = new Set();
876
+ const receivedResults = (0, batch_1.reportReceivedResults)(batch, emittedResultIds, fixtures_2.mockReporter);
877
+ expect(receivedResults).toStrictEqual([result]);
878
+ expect(emittedResultIds).toContain('rid');
879
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledWith(result);
880
+ });
881
+ test('non final', () => {
882
+ const result = Object.assign(Object.assign({}, (0, fixtures_2.getInProgressResultInBatch)()), { retries: 0, max_retries: 1 });
883
+ const batch = {
884
+ status: 'in_progress',
885
+ results: [result],
886
+ };
887
+ const emittedResultIds = new Set();
888
+ const receivedResults = (0, batch_1.reportReceivedResults)(batch, emittedResultIds, fixtures_2.mockReporter);
889
+ expect(receivedResults).toStrictEqual([result]);
890
+ expect(emittedResultIds).toContain('rid');
891
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledWith(result);
892
+ });
893
+ test('timed out', () => {
894
+ const timedOut = Object.assign(Object.assign({}, (0, fixtures_2.getFailedResultInBatch)()), { timed_out: true });
895
+ const batch = {
896
+ status: 'failed',
897
+ results: [timedOut],
898
+ };
899
+ const emittedResultIds = new Set();
900
+ const receivedResults = (0, batch_1.reportReceivedResults)(batch, emittedResultIds, fixtures_2.mockReporter);
901
+ expect(receivedResults).toStrictEqual([timedOut]);
902
+ expect(emittedResultIds).toContain('rid');
903
+ expect(fixtures_2.mockReporter.resultReceived).toHaveBeenCalledWith(timedOut);
904
+ });
905
+ });
906
+ //# sourceMappingURL=batch.test.js.map