@thoughtspot/visual-embed-sdk 1.20.2 → 1.20.3

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 (368) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +171 -0
  3. package/cjs/src/auth.d.ts +183 -0
  4. package/cjs/src/auth.d.ts.map +1 -0
  5. package/cjs/src/auth.js +457 -0
  6. package/cjs/src/auth.js.map +1 -0
  7. package/cjs/src/auth.spec.d.ts +13 -0
  8. package/cjs/src/auth.spec.d.ts.map +1 -0
  9. package/cjs/src/auth.spec.js +397 -0
  10. package/cjs/src/auth.spec.js.map +1 -0
  11. package/cjs/src/config.d.ts +22 -0
  12. package/cjs/src/config.d.ts.map +1 -0
  13. package/cjs/src/config.js +70 -0
  14. package/cjs/src/config.js.map +1 -0
  15. package/cjs/src/config.spec.d.ts +5 -0
  16. package/cjs/src/config.spec.d.ts.map +1 -0
  17. package/cjs/src/config.spec.js +65 -0
  18. package/cjs/src/config.spec.js.map +1 -0
  19. package/cjs/src/embed/app.d.ts +168 -0
  20. package/cjs/src/embed/app.d.ts.map +1 -0
  21. package/cjs/src/embed/app.js +215 -0
  22. package/cjs/src/embed/app.js.map +1 -0
  23. package/cjs/src/embed/app.spec.d.ts +2 -0
  24. package/cjs/src/embed/app.spec.d.ts.map +1 -0
  25. package/cjs/src/embed/app.spec.js +239 -0
  26. package/cjs/src/embed/app.spec.js.map +1 -0
  27. package/cjs/src/embed/base.d.ts +79 -0
  28. package/cjs/src/embed/base.d.ts.map +1 -0
  29. package/cjs/src/embed/base.js +229 -0
  30. package/cjs/src/embed/base.js.map +1 -0
  31. package/cjs/src/embed/base.spec.d.ts +2 -0
  32. package/cjs/src/embed/base.spec.d.ts.map +1 -0
  33. package/cjs/src/embed/base.spec.js +198 -0
  34. package/cjs/src/embed/base.spec.js.map +1 -0
  35. package/cjs/src/embed/embed.spec.d.ts +2 -0
  36. package/cjs/src/embed/embed.spec.d.ts.map +1 -0
  37. package/cjs/src/embed/embed.spec.js +74 -0
  38. package/cjs/src/embed/embed.spec.js.map +1 -0
  39. package/cjs/src/embed/events.spec.d.ts +2 -0
  40. package/cjs/src/embed/events.spec.d.ts.map +1 -0
  41. package/cjs/src/embed/events.spec.js +238 -0
  42. package/cjs/src/embed/events.spec.js.map +1 -0
  43. package/cjs/src/embed/liveboard.d.ts +150 -0
  44. package/cjs/src/embed/liveboard.d.ts.map +1 -0
  45. package/cjs/src/embed/liveboard.js +168 -0
  46. package/cjs/src/embed/liveboard.js.map +1 -0
  47. package/cjs/src/embed/liveboard.spec.d.ts +2 -0
  48. package/cjs/src/embed/liveboard.spec.d.ts.map +1 -0
  49. package/cjs/src/embed/liveboard.spec.js +229 -0
  50. package/cjs/src/embed/liveboard.spec.js.map +1 -0
  51. package/cjs/src/embed/pinboard.spec.d.ts +2 -0
  52. package/cjs/src/embed/pinboard.spec.d.ts.map +1 -0
  53. package/cjs/src/embed/pinboard.spec.js +148 -0
  54. package/cjs/src/embed/pinboard.spec.js.map +1 -0
  55. package/cjs/src/embed/search-bar.d.ts +50 -0
  56. package/cjs/src/embed/search-bar.d.ts.map +1 -0
  57. package/cjs/src/embed/search-bar.js +63 -0
  58. package/cjs/src/embed/search-bar.js.map +1 -0
  59. package/cjs/src/embed/search.d.ts +129 -0
  60. package/cjs/src/embed/search.d.ts.map +1 -0
  61. package/cjs/src/embed/search.js +121 -0
  62. package/cjs/src/embed/search.js.map +1 -0
  63. package/cjs/src/embed/search.spec.d.ts +2 -0
  64. package/cjs/src/embed/search.spec.d.ts.map +1 -0
  65. package/cjs/src/embed/search.spec.js +238 -0
  66. package/cjs/src/embed/search.spec.js.map +1 -0
  67. package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
  68. package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
  69. package/cjs/src/embed/searchEmbed-basic-auth.spec.js +103 -0
  70. package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
  71. package/cjs/src/embed/ts-embed.d.ts +323 -0
  72. package/cjs/src/embed/ts-embed.d.ts.map +1 -0
  73. package/cjs/src/embed/ts-embed.js +719 -0
  74. package/cjs/src/embed/ts-embed.js.map +1 -0
  75. package/cjs/src/embed/ts-embed.spec.d.ts +2 -0
  76. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -0
  77. package/cjs/src/embed/ts-embed.spec.js +771 -0
  78. package/cjs/src/embed/ts-embed.spec.js.map +1 -0
  79. package/cjs/src/errors.d.ts +7 -0
  80. package/cjs/src/errors.d.ts.map +1 -0
  81. package/cjs/src/errors.js +10 -0
  82. package/cjs/src/errors.js.map +1 -0
  83. package/cjs/src/index.d.ts +18 -0
  84. package/cjs/src/index.d.ts.map +1 -0
  85. package/cjs/src/index.js +42 -0
  86. package/cjs/src/index.js.map +1 -0
  87. package/cjs/src/mixpanel-service.d.ts +29 -0
  88. package/cjs/src/mixpanel-service.d.ts.map +1 -0
  89. package/cjs/src/mixpanel-service.js +76 -0
  90. package/cjs/src/mixpanel-service.js.map +1 -0
  91. package/cjs/src/mixpanel-service.spec.d.ts +2 -0
  92. package/cjs/src/mixpanel-service.spec.d.ts.map +1 -0
  93. package/cjs/src/mixpanel-service.spec.js +63 -0
  94. package/cjs/src/mixpanel-service.spec.js.map +1 -0
  95. package/cjs/src/react/all-types-export.d.ts +3 -0
  96. package/cjs/src/react/all-types-export.d.ts.map +1 -0
  97. package/cjs/src/react/all-types-export.js +29 -0
  98. package/cjs/src/react/all-types-export.js.map +1 -0
  99. package/cjs/src/react/all-types-export.spec.d.ts +2 -0
  100. package/cjs/src/react/all-types-export.spec.d.ts.map +1 -0
  101. package/cjs/src/react/all-types-export.spec.js +13 -0
  102. package/cjs/src/react/all-types-export.spec.js.map +1 -0
  103. package/cjs/src/react/index.d.ts +95 -0
  104. package/cjs/src/react/index.d.ts.map +1 -0
  105. package/cjs/src/react/index.js +121 -0
  106. package/cjs/src/react/index.js.map +1 -0
  107. package/cjs/src/react/index.spec.d.ts +3 -0
  108. package/cjs/src/react/index.spec.d.ts.map +1 -0
  109. package/cjs/src/react/index.spec.js +138 -0
  110. package/cjs/src/react/index.spec.js.map +1 -0
  111. package/cjs/src/react/util.d.ts +19 -0
  112. package/cjs/src/react/util.d.ts.map +1 -0
  113. package/cjs/src/react/util.js +25 -0
  114. package/cjs/src/react/util.js.map +1 -0
  115. package/cjs/src/test/test-utils.d.ts +48 -0
  116. package/cjs/src/test/test-utils.d.ts.map +1 -0
  117. package/cjs/src/test/test-utils.js +108 -0
  118. package/cjs/src/test/test-utils.js.map +1 -0
  119. package/cjs/src/types.d.ts +2020 -0
  120. package/cjs/src/types.d.ts.map +1 -0
  121. package/cjs/src/types.js +1543 -0
  122. package/cjs/src/types.js.map +1 -0
  123. package/cjs/src/utils/answerService.d.ts +10 -0
  124. package/cjs/src/utils/answerService.d.ts.map +1 -0
  125. package/cjs/src/utils/answerService.js +61 -0
  126. package/cjs/src/utils/answerService.js.map +1 -0
  127. package/cjs/src/utils/answerService.spec.d.ts +2 -0
  128. package/cjs/src/utils/answerService.spec.d.ts.map +1 -0
  129. package/cjs/src/utils/answerService.spec.js +31 -0
  130. package/cjs/src/utils/answerService.spec.js.map +1 -0
  131. package/cjs/src/utils/authService.d.ts +37 -0
  132. package/cjs/src/utils/authService.d.ts.map +1 -0
  133. package/cjs/src/utils/authService.js +106 -0
  134. package/cjs/src/utils/authService.js.map +1 -0
  135. package/cjs/src/utils/authService.spec.d.ts +2 -0
  136. package/cjs/src/utils/authService.spec.d.ts.map +1 -0
  137. package/cjs/src/utils/authService.spec.js +72 -0
  138. package/cjs/src/utils/authService.spec.js.map +1 -0
  139. package/cjs/src/utils/processData.d.ts +16 -0
  140. package/cjs/src/utils/processData.d.ts.map +1 -0
  141. package/cjs/src/utils/processData.js +110 -0
  142. package/cjs/src/utils/processData.js.map +1 -0
  143. package/cjs/src/utils/processData.spec.d.ts +2 -0
  144. package/cjs/src/utils/processData.spec.d.ts.map +1 -0
  145. package/cjs/src/utils/processData.spec.js +142 -0
  146. package/cjs/src/utils/processData.spec.js.map +1 -0
  147. package/cjs/src/utils/processTrigger.d.ts +10 -0
  148. package/cjs/src/utils/processTrigger.d.ts.map +1 -0
  149. package/cjs/src/utils/processTrigger.js +63 -0
  150. package/cjs/src/utils/processTrigger.js.map +1 -0
  151. package/cjs/src/utils/processTrigger.spec.d.ts +2 -0
  152. package/cjs/src/utils/processTrigger.spec.d.ts.map +1 -0
  153. package/cjs/src/utils/processTrigger.spec.js +58 -0
  154. package/cjs/src/utils/processTrigger.spec.js.map +1 -0
  155. package/cjs/src/utils.d.ts +68 -0
  156. package/cjs/src/utils.d.ts.map +1 -0
  157. package/cjs/src/utils.js +196 -0
  158. package/cjs/src/utils.js.map +1 -0
  159. package/cjs/src/utils.spec.d.ts +5 -0
  160. package/cjs/src/utils.spec.d.ts.map +1 -0
  161. package/cjs/src/utils.spec.js +98 -0
  162. package/cjs/src/utils.spec.js.map +1 -0
  163. package/dist/src/auth.d.ts +54 -5
  164. package/dist/src/auth.d.ts.map +1 -1
  165. package/dist/src/auth.spec.d.ts +3 -0
  166. package/dist/src/auth.spec.d.ts.map +1 -1
  167. package/dist/src/config.d.ts +1 -0
  168. package/dist/src/config.d.ts.map +1 -1
  169. package/dist/src/embed/app.d.ts +35 -6
  170. package/dist/src/embed/app.d.ts.map +1 -1
  171. package/dist/src/embed/base.d.ts +20 -9
  172. package/dist/src/embed/base.d.ts.map +1 -1
  173. package/dist/src/embed/liveboard.d.ts +17 -5
  174. package/dist/src/embed/liveboard.d.ts.map +1 -1
  175. package/dist/src/embed/search-bar.d.ts +3 -0
  176. package/dist/src/embed/search-bar.d.ts.map +1 -1
  177. package/dist/src/embed/search.d.ts +9 -1
  178. package/dist/src/embed/search.d.ts.map +1 -1
  179. package/dist/src/embed/ts-embed.d.ts +65 -7
  180. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  181. package/dist/src/errors.d.ts.map +1 -1
  182. package/dist/src/index.d.ts +2 -2
  183. package/dist/src/index.d.ts.map +1 -1
  184. package/dist/src/mixpanel-service.d.ts +8 -0
  185. package/dist/src/mixpanel-service.d.ts.map +1 -1
  186. package/dist/src/react/all-types-export.d.ts +3 -0
  187. package/dist/src/react/all-types-export.d.ts.map +1 -0
  188. package/dist/src/react/all-types-export.spec.d.ts +2 -0
  189. package/dist/src/react/all-types-export.spec.d.ts.map +1 -0
  190. package/dist/src/react/index.d.ts +72 -0
  191. package/dist/src/react/index.d.ts.map +1 -1
  192. package/dist/src/react/util.d.ts +4 -0
  193. package/dist/src/react/util.d.ts.map +1 -1
  194. package/dist/src/test/test-utils.d.ts +11 -2
  195. package/dist/src/test/test-utils.d.ts.map +1 -1
  196. package/dist/src/types.d.ts +499 -96
  197. package/dist/src/types.d.ts.map +1 -1
  198. package/dist/src/utils/answerService.d.ts +7 -0
  199. package/dist/src/utils/answerService.d.ts.map +1 -1
  200. package/dist/src/utils/authService.d.ts +30 -0
  201. package/dist/src/utils/authService.d.ts.map +1 -1
  202. package/dist/src/utils/processData.d.ts +12 -0
  203. package/dist/src/utils/processData.d.ts.map +1 -1
  204. package/dist/src/utils/processTrigger.d.ts +7 -0
  205. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  206. package/dist/src/utils.d.ts +12 -0
  207. package/dist/src/utils.d.ts.map +1 -1
  208. package/dist/tsembed-react.es.js +28024 -0
  209. package/dist/tsembed-react.js +27966 -0
  210. package/dist/tsembed.es.js +18114 -305
  211. package/dist/tsembed.js +18088 -327
  212. package/dist/visual-embed-sdk-react-full.d.ts +3092 -0
  213. package/dist/visual-embed-sdk-react.d.ts +2781 -0
  214. package/dist/visual-embed-sdk.d.ts +2944 -0
  215. package/lib/package.json +15 -14
  216. package/lib/src/auth.d.ts +54 -5
  217. package/lib/src/auth.d.ts.map +1 -1
  218. package/lib/src/auth.js +91 -31
  219. package/lib/src/auth.js.map +1 -1
  220. package/lib/src/auth.spec.d.ts +3 -0
  221. package/lib/src/auth.spec.d.ts.map +1 -1
  222. package/lib/src/auth.spec.js +37 -6
  223. package/lib/src/auth.spec.js.map +1 -1
  224. package/lib/src/config.d.ts +1 -0
  225. package/lib/src/config.d.ts.map +1 -1
  226. package/lib/src/config.js +5 -3
  227. package/lib/src/config.js.map +1 -1
  228. package/lib/src/config.spec.js.map +1 -1
  229. package/lib/src/embed/app.d.ts +35 -6
  230. package/lib/src/embed/app.d.ts.map +1 -1
  231. package/lib/src/embed/app.js +55 -16
  232. package/lib/src/embed/app.js.map +1 -1
  233. package/lib/src/embed/app.spec.js +41 -12
  234. package/lib/src/embed/app.spec.js.map +1 -1
  235. package/lib/src/embed/base.d.ts +20 -9
  236. package/lib/src/embed/base.d.ts.map +1 -1
  237. package/lib/src/embed/base.js +31 -15
  238. package/lib/src/embed/base.js.map +1 -1
  239. package/lib/src/embed/base.spec.js.map +1 -1
  240. package/lib/src/embed/embed.spec.js +1 -1
  241. package/lib/src/embed/embed.spec.js.map +1 -1
  242. package/lib/src/embed/liveboard.d.ts +17 -5
  243. package/lib/src/embed/liveboard.d.ts.map +1 -1
  244. package/lib/src/embed/liveboard.js +49 -37
  245. package/lib/src/embed/liveboard.js.map +1 -1
  246. package/lib/src/embed/liveboard.spec.js +37 -30
  247. package/lib/src/embed/liveboard.spec.js.map +1 -1
  248. package/lib/src/embed/pinboard.spec.js +14 -26
  249. package/lib/src/embed/pinboard.spec.js.map +1 -1
  250. package/lib/src/embed/search-bar.d.ts +3 -0
  251. package/lib/src/embed/search-bar.d.ts.map +1 -1
  252. package/lib/src/embed/search-bar.js +5 -6
  253. package/lib/src/embed/search-bar.js.map +1 -1
  254. package/lib/src/embed/search.d.ts +9 -1
  255. package/lib/src/embed/search.d.ts.map +1 -1
  256. package/lib/src/embed/search.js +18 -14
  257. package/lib/src/embed/search.js.map +1 -1
  258. package/lib/src/embed/search.spec.js +16 -19
  259. package/lib/src/embed/search.spec.js.map +1 -1
  260. package/lib/src/embed/searchEmbed-basic-auth.spec.js +4 -0
  261. package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
  262. package/lib/src/embed/ts-embed.d.ts +65 -7
  263. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  264. package/lib/src/embed/ts-embed.js +154 -77
  265. package/lib/src/embed/ts-embed.js.map +1 -1
  266. package/lib/src/embed/ts-embed.spec.js +46 -24
  267. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  268. package/lib/src/errors.d.ts.map +1 -1
  269. package/lib/src/errors.js.map +1 -1
  270. package/lib/src/index.d.ts +2 -2
  271. package/lib/src/index.d.ts.map +1 -1
  272. package/lib/src/index.js +4 -4
  273. package/lib/src/index.js.map +1 -1
  274. package/lib/src/mixpanel-service.d.ts +8 -0
  275. package/lib/src/mixpanel-service.d.ts.map +1 -1
  276. package/lib/src/mixpanel-service.js +13 -1
  277. package/lib/src/mixpanel-service.js.map +1 -1
  278. package/lib/src/mixpanel-service.spec.js.map +1 -1
  279. package/lib/src/react/all-types-export.d.ts +3 -0
  280. package/lib/src/react/all-types-export.d.ts.map +1 -0
  281. package/lib/src/react/all-types-export.js +5 -0
  282. package/lib/src/react/all-types-export.js.map +1 -0
  283. package/lib/src/react/all-types-export.spec.d.ts +2 -0
  284. package/lib/src/react/all-types-export.spec.d.ts.map +1 -0
  285. package/lib/src/react/all-types-export.spec.js +10 -0
  286. package/lib/src/react/all-types-export.spec.js.map +1 -0
  287. package/lib/src/react/index.d.ts +72 -0
  288. package/lib/src/react/index.d.ts.map +1 -1
  289. package/lib/src/react/index.js +79 -7
  290. package/lib/src/react/index.js.map +1 -1
  291. package/lib/src/react/index.spec.js +27 -6
  292. package/lib/src/react/index.spec.js.map +1 -1
  293. package/lib/src/react/util.d.ts +4 -0
  294. package/lib/src/react/util.d.ts.map +1 -1
  295. package/lib/src/react/util.js +4 -0
  296. package/lib/src/react/util.js.map +1 -1
  297. package/lib/src/test/test-utils.d.ts +11 -2
  298. package/lib/src/test/test-utils.d.ts.map +1 -1
  299. package/lib/src/test/test-utils.js +36 -25
  300. package/lib/src/test/test-utils.js.map +1 -1
  301. package/lib/src/types.d.ts +499 -96
  302. package/lib/src/types.d.ts.map +1 -1
  303. package/lib/src/types.js +374 -68
  304. package/lib/src/types.js.map +1 -1
  305. package/lib/src/utils/answerService.d.ts +7 -0
  306. package/lib/src/utils/answerService.d.ts.map +1 -1
  307. package/lib/src/utils/answerService.js +7 -0
  308. package/lib/src/utils/answerService.js.map +1 -1
  309. package/lib/src/utils/answerService.spec.js.map +1 -1
  310. package/lib/src/utils/authService.d.ts +30 -0
  311. package/lib/src/utils/authService.d.ts.map +1 -1
  312. package/lib/src/utils/authService.js +39 -2
  313. package/lib/src/utils/authService.js.map +1 -1
  314. package/lib/src/utils/authService.spec.js.map +1 -1
  315. package/lib/src/utils/processData.d.ts +12 -0
  316. package/lib/src/utils/processData.d.ts.map +1 -1
  317. package/lib/src/utils/processData.js +33 -5
  318. package/lib/src/utils/processData.js.map +1 -1
  319. package/lib/src/utils/processData.spec.js.map +1 -1
  320. package/lib/src/utils/processTrigger.d.ts +7 -0
  321. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  322. package/lib/src/utils/processTrigger.js +17 -3
  323. package/lib/src/utils/processTrigger.js.map +1 -1
  324. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  325. package/lib/src/utils.d.ts +12 -0
  326. package/lib/src/utils.d.ts.map +1 -1
  327. package/lib/src/utils.js +24 -19
  328. package/lib/src/utils.js.map +1 -1
  329. package/lib/src/utils.spec.js.map +1 -1
  330. package/package.json +15 -14
  331. package/src/auth.spec.ts +83 -133
  332. package/src/auth.ts +148 -115
  333. package/src/config.spec.ts +2 -4
  334. package/src/config.ts +5 -3
  335. package/src/embed/app.spec.ts +57 -14
  336. package/src/embed/app.ts +91 -36
  337. package/src/embed/base.spec.ts +3 -9
  338. package/src/embed/base.ts +51 -53
  339. package/src/embed/embed.spec.ts +5 -6
  340. package/src/embed/liveboard.spec.ts +56 -37
  341. package/src/embed/liveboard.ts +66 -64
  342. package/src/embed/pinboard.spec.ts +26 -29
  343. package/src/embed/search-bar.tsx +10 -8
  344. package/src/embed/search.spec.ts +31 -21
  345. package/src/embed/search.ts +26 -20
  346. package/src/embed/searchEmbed-basic-auth.spec.ts +22 -28
  347. package/src/embed/ts-embed.spec.ts +99 -144
  348. package/src/embed/ts-embed.ts +188 -162
  349. package/src/errors.ts +3 -6
  350. package/src/index.ts +6 -10
  351. package/src/mixpanel-service.spec.ts +1 -3
  352. package/src/mixpanel-service.ts +13 -1
  353. package/src/react/index.spec.tsx +66 -13
  354. package/src/react/index.tsx +111 -62
  355. package/src/react/util.ts +8 -4
  356. package/src/test/test-utils.ts +43 -39
  357. package/src/types.ts +498 -98
  358. package/src/utils/answerService.spec.ts +3 -5
  359. package/src/utils/answerService.ts +21 -17
  360. package/src/utils/authService.spec.ts +26 -41
  361. package/src/utils/authService.ts +47 -21
  362. package/src/utils/processData.spec.ts +26 -59
  363. package/src/utils/processData.ts +36 -14
  364. package/src/utils/processTrigger.spec.ts +1 -6
  365. package/src/utils/processTrigger.ts +18 -9
  366. package/src/utils.spec.ts +8 -12
  367. package/src/utils.ts +25 -26
  368. package/lib/src/visual-embed-sdk.d.ts +0 -2419
@@ -0,0 +1,771 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /* eslint-disable dot-notation */
5
+ const index_1 = require("../index");
6
+ const types_1 = require("../types");
7
+ const test_utils_1 = require("../test/test-utils");
8
+ const config = tslib_1.__importStar(require("../config"));
9
+ const tsEmbedInstance = tslib_1.__importStar(require("./ts-embed"));
10
+ const mixpanelInstance = tslib_1.__importStar(require("../mixpanel-service"));
11
+ const authInstance = tslib_1.__importStar(require("../auth"));
12
+ const baseInstance = tslib_1.__importStar(require("./base"));
13
+ const mixpanel_service_1 = require("../mixpanel-service");
14
+ const defaultViewConfig = {
15
+ frameParams: {
16
+ width: 1280,
17
+ height: 720,
18
+ },
19
+ };
20
+ const pinboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
21
+ const liveboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
22
+ const thoughtSpotHost = 'tshost';
23
+ const defaultParamsPost = '';
24
+ beforeAll(() => {
25
+ spyOn(window, 'alert');
26
+ });
27
+ const customisations = {
28
+ style: {
29
+ customCSS: {},
30
+ customCSSUrl: 'http://localhost:3000',
31
+ },
32
+ content: {},
33
+ };
34
+ const customisationsView = {
35
+ style: {
36
+ customCSS: {},
37
+ customCSSUrl: 'http://localhost:8000',
38
+ },
39
+ content: {
40
+ strings: {
41
+ DATA: 'data',
42
+ },
43
+ },
44
+ };
45
+ describe('Unit test case for ts embed', () => {
46
+ const mockMixPanelEvent = jest.spyOn(mixpanelInstance, 'uploadMixpanelEvent');
47
+ beforeEach(() => {
48
+ document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
49
+ });
50
+ afterEach(() => {
51
+ jest.clearAllMocks();
52
+ });
53
+ describe('Called Embed event status for start and end', () => {
54
+ beforeAll(() => {
55
+ (0, index_1.init)({
56
+ thoughtSpotHost: 'tshost',
57
+ authType: index_1.AuthType.None,
58
+ customizations: customisations,
59
+ customCssUrl: 'http://localhost:5000',
60
+ });
61
+ });
62
+ test('verify Customisations', async () => {
63
+ const mockEmbedEventPayload = {
64
+ type: index_1.EmbedEvent.APP_INIT,
65
+ data: {},
66
+ };
67
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
68
+ searchEmbed.render();
69
+ const mockPort = {
70
+ postMessage: jest.fn(),
71
+ };
72
+ await (0, test_utils_1.executeAfterWait)(() => {
73
+ const iframe = (0, test_utils_1.getIFrameEl)();
74
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload, mockPort);
75
+ });
76
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
77
+ type: index_1.EmbedEvent.APP_INIT,
78
+ data: { customisations, authToken: '' },
79
+ });
80
+ });
81
+ test('verify Customisations from viewConfig', async () => {
82
+ const mockEmbedEventPayload = {
83
+ type: index_1.EmbedEvent.APP_INIT,
84
+ data: {},
85
+ };
86
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), {
87
+ ...defaultViewConfig,
88
+ customizations: customisationsView,
89
+ });
90
+ searchEmbed.render();
91
+ const mockPort = {
92
+ postMessage: jest.fn(),
93
+ };
94
+ await (0, test_utils_1.executeAfterWait)(() => {
95
+ const iframe = (0, test_utils_1.getIFrameEl)();
96
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload, mockPort);
97
+ });
98
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
99
+ type: index_1.EmbedEvent.APP_INIT,
100
+ data: { customisations: customisationsView, authToken: '' },
101
+ });
102
+ expect((0, test_utils_1.getIFrameSrc)()).toContain(`customCssUrl=${customisationsView.style.customCSSUrl}`);
103
+ });
104
+ test('when Embed event status have start status', (done) => {
105
+ const mockEmbedEventPayload = {
106
+ type: index_1.EmbedEvent.Save,
107
+ data: { answerId: '123' },
108
+ status: 'start',
109
+ };
110
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
111
+ searchEmbed
112
+ .on(index_1.EmbedEvent.Save, (payload) => {
113
+ expect(payload).toEqual(mockEmbedEventPayload);
114
+ done();
115
+ }, { start: true })
116
+ .render();
117
+ (0, test_utils_1.executeAfterWait)(() => {
118
+ const iframe = (0, test_utils_1.getIFrameEl)();
119
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
120
+ });
121
+ });
122
+ test('should not called post message, when Embed event status have start and start option as false', () => {
123
+ const mockEmbedEventPayload = {
124
+ type: index_1.EmbedEvent.Save,
125
+ data: { answerId: '123' },
126
+ status: 'start',
127
+ };
128
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
129
+ searchEmbed
130
+ .on(index_1.EmbedEvent.Save, () => {
131
+ console.log('non callable');
132
+ })
133
+ .render();
134
+ (0, test_utils_1.executeAfterWait)(() => {
135
+ const iframe = (0, test_utils_1.getIFrameEl)();
136
+ iframe.contentWindow.postMessage = jest.fn();
137
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
138
+ expect(iframe.contentWindow.postMessage).toHaveBeenCalledTimes(0);
139
+ });
140
+ });
141
+ test('when Embed event status have end status', (done) => {
142
+ const mockEmbedEventPayload = {
143
+ type: index_1.EmbedEvent.Save,
144
+ data: { answerId: '123' },
145
+ status: 'end',
146
+ };
147
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
148
+ searchEmbed
149
+ .on(index_1.EmbedEvent.Save, (payload) => {
150
+ expect(payload).toEqual(mockEmbedEventPayload);
151
+ done();
152
+ })
153
+ .render();
154
+ (0, test_utils_1.executeAfterWait)(() => {
155
+ const iframe = (0, test_utils_1.getIFrameEl)();
156
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
157
+ }, 1000);
158
+ });
159
+ test('should not called post message, when Embed event status have end status and start is true', () => {
160
+ const mockEmbedEventPayload = {
161
+ type: index_1.EmbedEvent.Save,
162
+ data: { answerId: '123' },
163
+ status: 'end',
164
+ };
165
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
166
+ searchEmbed
167
+ .on(index_1.EmbedEvent.Save, () => {
168
+ console.log('non callable');
169
+ }, { start: true })
170
+ .render();
171
+ (0, test_utils_1.executeAfterWait)(() => {
172
+ const iframe = (0, test_utils_1.getIFrameEl)();
173
+ iframe.contentWindow.postMessage = jest.fn();
174
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
175
+ expect(iframe.contentWindow.postMessage).toHaveBeenCalledTimes(0);
176
+ }, 1000);
177
+ });
178
+ test('should remove event listener when called off method', async (done) => {
179
+ const mockEmbedEventPayload = {
180
+ type: index_1.EmbedEvent.Save,
181
+ data: { answerId: '123' },
182
+ status: 'end',
183
+ };
184
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
185
+ const mockFn = jest.fn();
186
+ searchEmbed.on(index_1.EmbedEvent.Save, mockFn).render();
187
+ await (0, test_utils_1.executeAfterWait)(() => {
188
+ const iframe = (0, test_utils_1.getIFrameEl)();
189
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
190
+ });
191
+ searchEmbed.off(index_1.EmbedEvent.Save, mockFn);
192
+ await (0, test_utils_1.executeAfterWait)(() => {
193
+ const iframe = (0, test_utils_1.getIFrameEl)();
194
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
195
+ });
196
+ await (0, test_utils_1.executeAfterWait)(() => {
197
+ expect(mockFn).toHaveBeenCalledTimes(1);
198
+ done();
199
+ }, 100);
200
+ });
201
+ });
202
+ describe('Appinit embedEvent in cookieless authentication authType', () => {
203
+ beforeAll(() => {
204
+ (0, index_1.init)({
205
+ thoughtSpotHost: 'tshost',
206
+ customizations: customisations,
207
+ customCssUrl: 'http://localhost:5000',
208
+ authType: index_1.AuthType.TrustedAuthTokenCookieless,
209
+ getAuthToken: () => Promise.resolve('test_auth_token1'),
210
+ });
211
+ });
212
+ test('check for authToken based on getAuthToken function', async () => {
213
+ const mockEmbedEventPayload = {
214
+ type: index_1.EmbedEvent.APP_INIT,
215
+ data: {},
216
+ };
217
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
218
+ searchEmbed.render();
219
+ const mockPort = {
220
+ postMessage: jest.fn(),
221
+ };
222
+ await (0, test_utils_1.executeAfterWait)(() => {
223
+ const iframe = (0, test_utils_1.getIFrameEl)();
224
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload, mockPort);
225
+ });
226
+ await (0, test_utils_1.executeAfterWait)(() => {
227
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
228
+ type: index_1.EmbedEvent.APP_INIT,
229
+ data: { customisations, authToken: 'test_auth_token1' },
230
+ });
231
+ });
232
+ });
233
+ });
234
+ describe('AuthExpire embedEvent in cookieless authentication authType', () => {
235
+ beforeAll(() => {
236
+ (0, index_1.init)({
237
+ thoughtSpotHost: 'tshost',
238
+ customizations: customisations,
239
+ customCssUrl: 'http://localhost:5000',
240
+ authType: index_1.AuthType.TrustedAuthTokenCookieless,
241
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
242
+ });
243
+ });
244
+ test('check for new authToken based on getAuthToken function', async () => {
245
+ const mockEmbedEventPayload = {
246
+ type: index_1.EmbedEvent.AuthExpire,
247
+ data: {},
248
+ };
249
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
250
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
251
+ jest.spyOn(baseInstance, 'handleAuth');
252
+ searchEmbed.render();
253
+ const mockPort = {
254
+ postMessage: jest.fn(),
255
+ };
256
+ await (0, test_utils_1.executeAfterWait)(() => {
257
+ const iframe = (0, test_utils_1.getIFrameEl)();
258
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload, mockPort);
259
+ });
260
+ await (0, test_utils_1.executeAfterWait)(() => {
261
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.EXPIRY);
262
+ expect(baseInstance.handleAuth).not.toHaveBeenCalled();
263
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
264
+ type: index_1.EmbedEvent.AuthExpire,
265
+ data: { authToken: 'test_auth_token2' },
266
+ });
267
+ });
268
+ });
269
+ });
270
+ xdescribe('AuthExpire embedEvent in TrustedAuthToken authType', () => {
271
+ test('AutoLogin true scenario', async () => {
272
+ (0, index_1.init)({
273
+ thoughtSpotHost: 'tshost',
274
+ customizations: customisations,
275
+ customCssUrl: 'http://localhost:5000',
276
+ authType: index_1.AuthType.TrustedAuthToken,
277
+ username: 'tsadmin',
278
+ getAuthToken: () => Promise.resolve('test_auth_token3'),
279
+ autoLogin: true,
280
+ });
281
+ const mockEmbedEventPayload = {
282
+ type: index_1.EmbedEvent.AuthExpire,
283
+ data: {},
284
+ };
285
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
286
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
287
+ jest.spyOn(baseInstance, 'handleAuth');
288
+ searchEmbed.render();
289
+ await (0, test_utils_1.executeAfterWait)(() => {
290
+ const iframe = (0, test_utils_1.getIFrameEl)();
291
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
292
+ });
293
+ await (0, test_utils_1.executeAfterWait)(() => {
294
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.EXPIRY);
295
+ expect(baseInstance.handleAuth).toHaveBeenCalled();
296
+ });
297
+ });
298
+ test('AutoLogin false scenario', async () => {
299
+ (0, index_1.init)({
300
+ thoughtSpotHost: 'tshost',
301
+ customizations: customisations,
302
+ customCssUrl: 'http://localhost:5000',
303
+ authType: index_1.AuthType.TrustedAuthToken,
304
+ username: 'tsadmin',
305
+ getAuthToken: () => Promise.resolve('test_auth_token4'),
306
+ });
307
+ const mockEmbedEventPayload = {
308
+ type: index_1.EmbedEvent.AuthExpire,
309
+ data: {},
310
+ };
311
+ const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
312
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
313
+ jest.spyOn(baseInstance, 'handleAuth');
314
+ searchEmbed.render();
315
+ await (0, test_utils_1.executeAfterWait)(() => {
316
+ const iframe = (0, test_utils_1.getIFrameEl)();
317
+ (0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload);
318
+ });
319
+ await (0, test_utils_1.executeAfterWait)(() => {
320
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.EXPIRY);
321
+ expect(baseInstance.handleAuth).not.toHaveBeenCalled();
322
+ });
323
+ });
324
+ });
325
+ describe('when thoughtSpotHost have value and authPromise return response true/false', () => {
326
+ beforeAll(() => {
327
+ (0, index_1.init)({
328
+ thoughtSpotHost,
329
+ authType: index_1.AuthType.None,
330
+ loginFailedMessage: 'Failed to Login',
331
+ });
332
+ });
333
+ const setup = async (isLoggedIn = false) => {
334
+ jest.spyOn(window, 'addEventListener').mockImplementationOnce((event, handler, options) => {
335
+ handler({
336
+ data: {
337
+ type: 'xyz',
338
+ },
339
+ ports: [3000],
340
+ source: null,
341
+ });
342
+ });
343
+ const iFrame = document.createElement('div');
344
+ jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(isLoggedIn);
345
+ const tsEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
346
+ iFrame.contentWindow = null;
347
+ tsEmbed.on(index_1.EmbedEvent.CustomAction, jest.fn());
348
+ jest.spyOn(iFrame, 'addEventListener').mockImplementationOnce((event, handler, options) => {
349
+ handler({});
350
+ });
351
+ jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
352
+ await tsEmbed.render();
353
+ };
354
+ test('mixpanel should call with VISUAL_SDK_RENDER_COMPLETE', async () => {
355
+ await setup(true);
356
+ expect(mockMixPanelEvent).toBeCalledWith(mixpanel_service_1.MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
357
+ expect(mockMixPanelEvent).toBeCalledWith(mixpanel_service_1.MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
358
+ });
359
+ test('Should remove prefetch iframe', async () => {
360
+ await setup(true);
361
+ const prefetchIframe = document.querySelectorAll('.prefetchIframe');
362
+ expect(prefetchIframe.length).toBe(0);
363
+ });
364
+ test('Should render failure when login fails', async (done) => {
365
+ setup(false);
366
+ (0, test_utils_1.executeAfterWait)(() => {
367
+ expect((0, test_utils_1.getRootEl)().innerHTML).toContain('Failed to Login');
368
+ done();
369
+ });
370
+ });
371
+ });
372
+ describe('when thoughtSpotHost have value and authPromise return error', () => {
373
+ beforeAll(() => {
374
+ (0, index_1.init)({
375
+ thoughtSpotHost: 'tshost',
376
+ authType: index_1.AuthType.None,
377
+ });
378
+ });
379
+ beforeEach(() => {
380
+ jest.spyOn(baseInstance, 'getAuthPromise').mockRejectedValueOnce(false);
381
+ const tsEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
382
+ const iFrame = document.createElement('div');
383
+ iFrame.contentWindow = null;
384
+ jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
385
+ spyOn(console, 'error');
386
+ tsEmbed.render();
387
+ });
388
+ test('mixpanel should call with VISUAL_SDK_RENDER_FAILED', () => {
389
+ expect(mockMixPanelEvent).toBeCalledWith(mixpanel_service_1.MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
390
+ expect(mockMixPanelEvent).toBeCalledWith(mixpanel_service_1.MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, {
391
+ error: 'false',
392
+ });
393
+ });
394
+ });
395
+ describe('when visible actions are set', () => {
396
+ test('should throw error when there are both visible and hidden actions - pinboard', async () => {
397
+ spyOn(console, 'error');
398
+ const pinboardEmbed = new index_1.PinboardEmbed((0, test_utils_1.getRootEl)(), {
399
+ hiddenActions: [types_1.Action.DownloadAsCsv],
400
+ visibleActions: [types_1.Action.DownloadAsCsv],
401
+ ...defaultViewConfig,
402
+ pinboardId,
403
+ });
404
+ await pinboardEmbed.render();
405
+ expect(pinboardEmbed['isError']).toBe(true);
406
+ expect(console.error).toHaveBeenCalledWith('You cannot have both hidden actions and visible actions');
407
+ });
408
+ test('should not throw error when there are only visible or hidden actions - pinboard', async () => {
409
+ const pinboardEmbed = new index_1.PinboardEmbed((0, test_utils_1.getRootEl)(), {
410
+ hiddenActions: [types_1.Action.DownloadAsCsv],
411
+ ...defaultViewConfig,
412
+ pinboardId,
413
+ });
414
+ pinboardEmbed.render();
415
+ expect(pinboardEmbed['isError']).toBe(false);
416
+ });
417
+ /**
418
+ *
419
+ * @param hiddenActions
420
+ * @param visibleActions
421
+ */
422
+ async function testActionsForLiveboards(hiddenActions, visibleActions) {
423
+ spyOn(console, 'error');
424
+ const liveboardEmbed = new index_1.LiveboardEmbed((0, test_utils_1.getRootEl)(), {
425
+ hiddenActions,
426
+ visibleActions,
427
+ ...defaultViewConfig,
428
+ liveboardId,
429
+ });
430
+ await liveboardEmbed.render();
431
+ expect(liveboardEmbed['isError']).toBe(true);
432
+ expect(console.error).toHaveBeenCalledWith('You cannot have both hidden actions and visible actions');
433
+ }
434
+ test('should throw error when there are both visible and hidden action arrays', async () => {
435
+ await testActionsForLiveboards([types_1.Action.DownloadAsCsv], [types_1.Action.DownloadAsCsv]);
436
+ });
437
+ test('should throw error when there are both visible and hidden actions arrays as empty', async () => {
438
+ await testActionsForLiveboards([], []);
439
+ });
440
+ test('should throw error when there are both visible and hidden actions - one of them is an empty array', async () => {
441
+ await testActionsForLiveboards([], [types_1.Action.DownloadAsCsv]);
442
+ });
443
+ test('should not throw error when there are only visible or hidden actions', async () => {
444
+ const liveboardEmbed = new index_1.LiveboardEmbed((0, test_utils_1.getRootEl)(), {
445
+ hiddenActions: [types_1.Action.DownloadAsCsv],
446
+ ...defaultViewConfig,
447
+ liveboardId,
448
+ });
449
+ liveboardEmbed.render();
450
+ expect(liveboardEmbed['isError']).toBe(false);
451
+ });
452
+ test('should not throw error when there are only visible or hidden actions', async () => {
453
+ const liveboardEmbed = new index_1.LiveboardEmbed((0, test_utils_1.getRootEl)(), {
454
+ visibleActions: [types_1.Action.DownloadAsCsv],
455
+ ...defaultViewConfig,
456
+ liveboardId,
457
+ });
458
+ liveboardEmbed.render();
459
+ expect(liveboardEmbed['isError']).toBe(false);
460
+ });
461
+ });
462
+ describe('when thoughtSpotHost is empty', () => {
463
+ beforeAll(() => {
464
+ jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => '');
465
+ (0, index_1.init)({
466
+ thoughtSpotHost: '',
467
+ authType: index_1.AuthType.None,
468
+ });
469
+ });
470
+ test('Error should be true', async () => {
471
+ spyOn(console, 'error');
472
+ const tsEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
473
+ tsEmbed.render();
474
+ expect(tsEmbed['isError']).toBe(true);
475
+ expect(console.error).toHaveBeenCalledWith('You need to init the ThoughtSpot SDK module first');
476
+ });
477
+ });
478
+ describe('V1Embed ', () => {
479
+ test('when isRendered is true than isError will be true', () => {
480
+ spyOn(console, 'error');
481
+ const viEmbedIns = new tsEmbedInstance.V1Embed((0, test_utils_1.getRootEl)(), defaultViewConfig);
482
+ expect(viEmbedIns['isError']).toBe(false);
483
+ viEmbedIns.render();
484
+ viEmbedIns.on(index_1.EmbedEvent.CustomAction, jest.fn()).render();
485
+ expect(viEmbedIns['isError']).toBe(true);
486
+ expect(console.error).toHaveBeenCalledWith('Please register event handlers before calling render');
487
+ });
488
+ });
489
+ describe('Navigate to Page API', () => {
490
+ const path = 'viz/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
491
+ beforeEach(() => {
492
+ jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
493
+ });
494
+ test('when app is PinboardEmbed after navigateToPage function call, new path should be set to iframe', async () => {
495
+ const pinboardEmbed = new index_1.PinboardEmbed((0, test_utils_1.getRootEl)(), {
496
+ pinboardId: 'e0836cad-4fdf-42d4-bd97-567a6b2a6058',
497
+ });
498
+ await pinboardEmbed.render();
499
+ // pinboardEmbed.navigateToPage(path);
500
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&${test_utils_1.defaultParamsForPinboardEmbed}&isLiveboardEmbed=true${defaultParamsPost}#/embed/${path}`);
501
+ });
502
+ test('when app is AppEmbed after navigateToPage function call, new path should be set to iframe', async () => {
503
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
504
+ frameParams: {
505
+ width: '100%',
506
+ height: '100%',
507
+ },
508
+ });
509
+ await appEmbed.render();
510
+ appEmbed.navigateToPage(path, false);
511
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${test_utils_1.defaultParamsForPinboardEmbed}${defaultParamsPost}#/${path}`);
512
+ });
513
+ test('navigateToPage function use before render', async () => {
514
+ spyOn(console, 'log');
515
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
516
+ frameParams: {
517
+ width: '100%',
518
+ height: '100%',
519
+ },
520
+ });
521
+ appEmbed.navigateToPage(path, false);
522
+ await appEmbed.render();
523
+ expect(console.log).toHaveBeenCalledWith('Please call render before invoking this method');
524
+ });
525
+ });
526
+ describe('Navigate to Page API - Pinboard', () => {
527
+ const path = 'pinboard/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
528
+ beforeEach(() => {
529
+ jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
530
+ });
531
+ test('when app is AppEmbed after navigateToPage function call, new path should be set to iframe', async () => {
532
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
533
+ frameParams: {
534
+ width: '100%',
535
+ height: '100%',
536
+ },
537
+ });
538
+ await appEmbed.render();
539
+ appEmbed.navigateToPage(path, false);
540
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${test_utils_1.defaultParamsForPinboardEmbed}${defaultParamsPost}#/${path}`);
541
+ });
542
+ });
543
+ describe('get Encoded query param string', () => {
544
+ beforeAll(() => {
545
+ (0, index_1.init)({
546
+ thoughtSpotHost: 'tshost',
547
+ authType: index_1.AuthType.None,
548
+ shouldEncodeUrlQueryParams: true,
549
+ });
550
+ });
551
+ afterAll(() => {
552
+ (0, index_1.init)({
553
+ thoughtSpotHost: 'tshost',
554
+ authType: index_1.AuthType.None,
555
+ shouldEncodeUrlQueryParams: false,
556
+ });
557
+ });
558
+ it('should return the correct encoded query params string', async () => {
559
+ const tsEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), {
560
+ frameParams: {
561
+ width: '100%',
562
+ height: '100%',
563
+ },
564
+ });
565
+ tsEmbed.render();
566
+ (0, test_utils_1.waitFor)(() => !!(0, test_utils_1.getIFrameEl)()).then(() => {
567
+ expect((0, test_utils_1.getIFrameSrc)()).toContain('?base64UrlEncodedFlags');
568
+ });
569
+ });
570
+ it('should return the correct encoded query params string when app is embeded', async () => {
571
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
572
+ frameParams: {
573
+ width: '100%',
574
+ height: '100%',
575
+ },
576
+ });
577
+ appEmbed.render();
578
+ (0, test_utils_1.waitFor)(() => !!(0, test_utils_1.getIFrameEl)()).then(() => {
579
+ expect((0, test_utils_1.getIFrameSrc)()).toContain('?base64UrlEncodedFlags');
580
+ });
581
+ });
582
+ });
583
+ describe('Iframe flags', () => {
584
+ beforeEach(() => {
585
+ jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
586
+ });
587
+ test('Set Frame params to the iframe as attributes', async () => {
588
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
589
+ frameParams: {
590
+ width: '100%',
591
+ height: '100%',
592
+ allowtransparency: true,
593
+ },
594
+ });
595
+ await appEmbed.render();
596
+ const iframe = (0, test_utils_1.getIFrameEl)();
597
+ expect(iframe.getAttribute('allowtransparency')).toBe('true');
598
+ });
599
+ it('should set the additional flags correctly on the iframe src', async () => {
600
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
601
+ frameParams: {
602
+ width: '100%',
603
+ height: '100%',
604
+ },
605
+ additionalFlags: {
606
+ foo: 'bar',
607
+ baz: 1,
608
+ bool: true,
609
+ },
610
+ });
611
+ await appEmbed.render();
612
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${test_utils_1.defaultParamsForPinboardEmbed}`
613
+ + `&foo=bar&baz=1&bool=true${defaultParamsPost}#/home`);
614
+ });
615
+ it('Sets the showAlerts param', async () => {
616
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
617
+ frameParams: {
618
+ width: '100%',
619
+ height: '100%',
620
+ },
621
+ showAlerts: true,
622
+ });
623
+ await appEmbed.render();
624
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${test_utils_1.defaultParamsForPinboardEmbed}`
625
+ + `&showAlerts=true${defaultParamsPost}#/home`);
626
+ });
627
+ it('Sets the locale param', async () => {
628
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
629
+ frameParams: {
630
+ width: '100%',
631
+ height: '100%',
632
+ },
633
+ locale: 'ja-JP',
634
+ });
635
+ await appEmbed.render();
636
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${test_utils_1.defaultParamsForPinboardEmbed}`
637
+ + `&locale=ja-JP${defaultParamsPost}#/home`);
638
+ });
639
+ it('Sets the iconSprite url', async () => {
640
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
641
+ frameParams: {
642
+ width: '100%',
643
+ height: '100%',
644
+ },
645
+ customizations: {
646
+ iconSpriteUrl: 'https://iconSprite.com',
647
+ },
648
+ });
649
+ await appEmbed.render();
650
+ (0, test_utils_1.expectUrlMatchesWithParams)((0, test_utils_1.getIFrameSrc)(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${test_utils_1.defaultParamsForPinboardEmbed}`
651
+ + `&iconSprite=iconSprite.com${defaultParamsPost}#/home`);
652
+ });
653
+ it('inserts as sibling of root node if configured', async () => {
654
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
655
+ frameParams: {
656
+ width: '100%',
657
+ height: '100%',
658
+ },
659
+ insertAsSibling: true,
660
+ });
661
+ await appEmbed.render();
662
+ expect((0, test_utils_1.getRootEl)().nextSibling).toBe((0, test_utils_1.getIFrameEl)());
663
+ });
664
+ it('Should remove existing embed when rerendering', async () => {
665
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
666
+ frameParams: {
667
+ width: '100%',
668
+ height: '100%',
669
+ },
670
+ insertAsSibling: true,
671
+ });
672
+ await appEmbed.render();
673
+ expect((0, test_utils_1.getRootEl)().nextSibling).toBe((0, test_utils_1.getIFrameEl)());
674
+ await appEmbed.render();
675
+ expect((0, test_utils_1.getRootEl)().nextSibling.nextSibling).not.toBe((0, test_utils_1.getIFrameEl)());
676
+ });
677
+ xit('Sets the forceSAMLAutoRedirect param', async (done) => {
678
+ jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValue(true);
679
+ (0, index_1.init)({
680
+ thoughtSpotHost: 'tshost',
681
+ authType: index_1.AuthType.EmbeddedSSO,
682
+ });
683
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
684
+ frameParams: {
685
+ width: '100%',
686
+ height: '100%',
687
+ },
688
+ });
689
+ appEmbed.render();
690
+ (0, test_utils_1.waitFor)(() => !!(0, test_utils_1.getIFrameEl)()).then(() => {
691
+ expect((0, test_utils_1.getIFrameSrc)()).toContain('authType=EmbeddedSSO');
692
+ expect((0, test_utils_1.getIFrameSrc)()).toContain('forceSAMLAutoRedirect=true');
693
+ done();
694
+ });
695
+ });
696
+ });
697
+ describe('When destroyed', () => {
698
+ it('should remove the iframe', async () => {
699
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
700
+ frameParams: {
701
+ width: '100%',
702
+ height: '100%',
703
+ },
704
+ });
705
+ await appEmbed.render();
706
+ expect((0, test_utils_1.getIFrameEl)()).toBeTruthy();
707
+ appEmbed.destroy();
708
+ expect((0, test_utils_1.getIFrameEl)()).toBeFalsy();
709
+ });
710
+ it('should remove the iframe when insertAsSibling is true', async () => {
711
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
712
+ frameParams: {
713
+ width: '100%',
714
+ height: '100%',
715
+ },
716
+ insertAsSibling: true,
717
+ });
718
+ await appEmbed.render();
719
+ expect((0, test_utils_1.getIFrameEl)()).toBeTruthy();
720
+ appEmbed.destroy();
721
+ expect((0, test_utils_1.getIFrameEl)()).toBeFalsy();
722
+ });
723
+ it("Should remove the error message on destroy if it's present", async () => {
724
+ jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(false);
725
+ const appEmbed = new index_1.AppEmbed((0, test_utils_1.getRootEl)(), {
726
+ frameParams: {
727
+ width: '100%',
728
+ height: '100%',
729
+ },
730
+ insertAsSibling: true,
731
+ });
732
+ await appEmbed.render();
733
+ expect((0, test_utils_1.getRootEl)().nextElementSibling.innerHTML).toContain('Not logged in');
734
+ appEmbed.destroy();
735
+ expect((0, test_utils_1.getRootEl)().nextElementSibling.innerHTML).toBe('');
736
+ });
737
+ });
738
+ describe('validate getThoughtSpotPostUrlParams', () => {
739
+ const { location } = window;
740
+ beforeAll(() => {
741
+ delete window.location;
742
+ window.location = {
743
+ hash: '',
744
+ search: '',
745
+ };
746
+ });
747
+ beforeEach(() => {
748
+ jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
749
+ });
750
+ afterAll(() => {
751
+ window.location = location;
752
+ });
753
+ it('get url params for TS', () => {
754
+ const tsEmbed = new tsEmbedInstance.TsEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
755
+ const urlHash = '#/analyze?ts-app=thoughtspot&ts-id=123&title=embed-sdk';
756
+ window.location.hash = urlHash;
757
+ const postHashParams = '?ts-app=thoughtspot&ts-id=123';
758
+ expect(tsEmbed.getThoughtSpotPostUrlParams()).toBe(postHashParams);
759
+ });
760
+ it('validate query params and postHash params for TS', () => {
761
+ const tsEmbed = new tsEmbedInstance.TsEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
762
+ const urlHash = '#/analyze?ts-app=thoughtspot&ts-id=123&title=embed-sdk';
763
+ window.location.hash = urlHash;
764
+ const urlSearch = '?ts-type=subscribe&search-title=abc';
765
+ window.location.search = urlSearch;
766
+ const postHashParams = '?ts-type=subscribe&ts-app=thoughtspot&ts-id=123';
767
+ expect(tsEmbed.getThoughtSpotPostUrlParams()).toBe(postHashParams);
768
+ });
769
+ });
770
+ });
771
+ //# sourceMappingURL=ts-embed.spec.js.map