@hubspot/ui-extensions 0.11.1 → 0.11.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 (236) hide show
  1. package/dist/__tests__/crm/hooks/useAssociations.spec.js +36 -32
  2. package/dist/__tests__/crm/hooks/useCrmProperties.spec.js +20 -19
  3. package/dist/__tests__/crm/utils/fetchAssociations.spec.js +13 -12
  4. package/dist/__tests__/crm/utils/fetchCrmProperties.spec.js +38 -37
  5. package/dist/clientTypes.d.ts +1 -0
  6. package/dist/clientTypes.js +1 -1
  7. package/dist/crm/hooks/useAssociations.d.ts +5 -3
  8. package/dist/crm/hooks/useAssociations.js +4 -2
  9. package/dist/crm/hooks/useCrmProperties.d.ts +4 -2
  10. package/dist/crm/hooks/useCrmProperties.js +4 -2
  11. package/dist/crm/index.d.ts +4 -4
  12. package/dist/crm/index.js +3 -3
  13. package/dist/crm/utils/fetchAssociations.d.ts +1 -1
  14. package/dist/experimental/index.d.ts +4 -4
  15. package/dist/experimental/index.js +3 -3
  16. package/dist/experimental/testing/__tests__/createRenderer.spec.js +23 -0
  17. package/dist/experimental/testing/__tests__/debug.spec.js +57 -0
  18. package/dist/experimental/testing/__tests__/find.spec.js +48 -0
  19. package/dist/experimental/testing/__tests__/findAll.spec.js +13 -0
  20. package/dist/experimental/testing/__tests__/findAllChildren.spec.js +54 -0
  21. package/dist/experimental/testing/__tests__/findByTestId.spec.js +126 -0
  22. package/dist/experimental/testing/__tests__/findChild.spec.js +33 -0
  23. package/dist/experimental/testing/__tests__/fragments.spec.js +66 -0
  24. package/dist/experimental/testing/__tests__/invalid-components.spec.js +96 -0
  25. package/dist/experimental/testing/__tests__/isMatch.spec.js +113 -0
  26. package/dist/experimental/testing/__tests__/logger.spec.js +10 -0
  27. package/dist/experimental/testing/__tests__/maybeFind.spec.js +67 -0
  28. package/dist/experimental/testing/__tests__/maybeFindByTestId.spec.js +65 -0
  29. package/dist/experimental/testing/__tests__/maybeFindChild.spec.js +75 -0
  30. package/dist/experimental/testing/__tests__/mocks.actions.spec.js +19 -0
  31. package/dist/experimental/testing/__tests__/mocks.context.spec.js +24 -0
  32. package/dist/experimental/testing/__tests__/mocks.runServerlessFunction.spec.js +35 -0
  33. package/dist/experimental/testing/__tests__/mocks.useAssociations.spec.js +47 -0
  34. package/dist/experimental/testing/__tests__/mocks.useCrmProperties.spec.js +58 -0
  35. package/dist/experimental/testing/__tests__/props.spec.js +13 -0
  36. package/dist/experimental/testing/__tests__/testId.spec.js +18 -0
  37. package/dist/experimental/testing/__tests__/trigger.spec.js +43 -0
  38. package/dist/experimental/testing/__tests__/type-utils.spec.js +165 -0
  39. package/dist/experimental/testing/__tests__/waitFor.spec.js +57 -0
  40. package/dist/experimental/testing/index.d.ts +4 -0
  41. package/dist/experimental/testing/index.js +4 -0
  42. package/dist/experimental/testing/internal/constants.d.ts +2 -2
  43. package/dist/experimental/testing/internal/constants.js +1 -1
  44. package/dist/experimental/testing/internal/convert.d.ts +10 -0
  45. package/dist/experimental/testing/internal/convert.js +149 -0
  46. package/dist/experimental/testing/internal/debug.d.ts +3 -3
  47. package/dist/experimental/testing/internal/debug.js +12 -4
  48. package/dist/experimental/testing/internal/document.d.ts +14 -0
  49. package/dist/experimental/testing/internal/document.js +40 -0
  50. package/dist/experimental/testing/internal/element.d.ts +4 -3
  51. package/dist/experimental/testing/internal/element.js +15 -10
  52. package/dist/experimental/testing/internal/errors.d.ts +57 -2
  53. package/dist/experimental/testing/internal/errors.js +62 -2
  54. package/dist/experimental/testing/internal/fragment.d.ts +3 -2
  55. package/dist/experimental/testing/internal/fragment.js +13 -9
  56. package/dist/experimental/testing/internal/match.d.ts +10 -0
  57. package/dist/experimental/testing/internal/match.js +19 -0
  58. package/dist/experimental/testing/internal/mocks/index.d.ts +17 -0
  59. package/dist/experimental/testing/internal/mocks/index.js +46 -0
  60. package/dist/experimental/testing/internal/mocks/mock-extension-point-api.d.ts +2 -0
  61. package/dist/experimental/testing/internal/mocks/mock-extension-point-api.js +166 -0
  62. package/dist/experimental/testing/internal/mocks/mock-hooks.d.ts +2 -0
  63. package/dist/experimental/testing/internal/mocks/mock-hooks.js +59 -0
  64. package/dist/experimental/testing/internal/print.d.ts +2 -2
  65. package/dist/experimental/testing/internal/print.js +17 -11
  66. package/dist/experimental/testing/internal/query.d.ts +19 -9
  67. package/dist/experimental/testing/internal/query.js +91 -46
  68. package/dist/experimental/testing/internal/root.d.ts +1 -1
  69. package/dist/experimental/testing/internal/root.js +12 -8
  70. package/dist/experimental/testing/internal/text.d.ts +3 -2
  71. package/dist/experimental/testing/internal/text.js +12 -3
  72. package/dist/experimental/testing/internal/type-utils-internal.d.ts +44 -0
  73. package/dist/experimental/testing/internal/type-utils-internal.js +54 -0
  74. package/dist/experimental/testing/internal/types-internal.d.ts +20 -2
  75. package/dist/experimental/testing/internal/utils/promise-utils.d.ts +14 -0
  76. package/dist/experimental/testing/internal/utils/promise-utils.js +14 -0
  77. package/dist/experimental/testing/render.d.ts +35 -0
  78. package/dist/experimental/testing/render.js +219 -0
  79. package/dist/experimental/testing/type-utils.d.ts +2 -2
  80. package/dist/experimental/testing/type-utils.js +1 -1
  81. package/dist/experimental/testing/types.d.ts +127 -9
  82. package/dist/experimental/testing/utils.d.ts +11 -0
  83. package/dist/experimental/testing/utils.js +24 -0
  84. package/dist/hubspot.d.ts +2 -4
  85. package/dist/hubspot.js +3 -3
  86. package/dist/index.d.ts +5 -5
  87. package/dist/index.js +5 -5
  88. package/dist/internal/global-utils.d.ts +6 -0
  89. package/dist/internal/global-utils.js +37 -0
  90. package/dist/internal/hook-utils.d.ts +19 -0
  91. package/dist/internal/hook-utils.js +34 -0
  92. package/dist/logger.d.ts +1 -8
  93. package/dist/logger.js +3 -2
  94. package/dist/pages/home/index.d.ts +1 -1
  95. package/dist/pages/home/index.js +1 -1
  96. package/dist/{__synced__/remoteComponents.synced.d.ts → shared/remoteComponents.d.ts} +159 -77
  97. package/dist/{__synced__/remoteComponents.synced.js → shared/remoteComponents.js} +99 -1
  98. package/dist/{__synced__/types/components/accordion.synced.d.ts → shared/types/components/accordion.d.ts} +2 -2
  99. package/dist/{__synced__/types/components/alert.synced.d.ts → shared/types/components/alert.d.ts} +2 -1
  100. package/dist/{__synced__/types/components/app-home-header-actions.synced.d.ts → shared/types/components/app-home-header-actions.d.ts} +4 -4
  101. package/dist/{__synced__/types/components/button-row.synced.d.ts → shared/types/components/button-row.d.ts} +2 -2
  102. package/dist/{__synced__/types/components/button.synced.d.ts → shared/types/components/button.d.ts} +9 -3
  103. package/dist/{__synced__/types/components/card.synced.d.ts → shared/types/components/card.d.ts} +2 -1
  104. package/dist/{__synced__/types/components/chart.synced.d.ts → shared/types/components/chart.d.ts} +2 -1
  105. package/dist/{__synced__/types/components/description-list.synced.d.ts → shared/types/components/description-list.d.ts} +3 -2
  106. package/dist/{__synced__/types/components/divider.synced.d.ts → shared/types/components/divider.d.ts} +2 -2
  107. package/dist/{__synced__/types/components/dropdown.synced.d.ts → shared/types/components/dropdown.d.ts} +5 -5
  108. package/dist/{__synced__/types/components/empty-state.synced.d.ts → shared/types/components/empty-state.d.ts} +2 -1
  109. package/dist/{__synced__/types/components/error-state.synced.d.ts → shared/types/components/error-state.d.ts} +2 -1
  110. package/dist/{__synced__/types/components/form.synced.d.ts → shared/types/components/form.d.ts} +3 -3
  111. package/dist/{__synced__/types/components/heading.synced.d.ts → shared/types/components/heading.d.ts} +2 -1
  112. package/dist/{__synced__/types/components/icon.synced.d.ts → shared/types/components/icon.d.ts} +2 -2
  113. package/dist/{__synced__/types/components/iframe.synced.d.ts → shared/types/components/iframe.d.ts} +2 -2
  114. package/dist/{__synced__/types/components/illustration.synced.d.ts → shared/types/components/illustration.d.ts} +2 -1
  115. package/dist/{__synced__/types/components/image.synced.d.ts → shared/types/components/image.d.ts} +3 -3
  116. package/dist/shared/types/components/index.d.ts +38 -0
  117. package/dist/shared/types/components/index.js +1 -0
  118. package/dist/{__synced__/types/components/inputs.synced.d.ts → shared/types/components/inputs.d.ts} +2 -1
  119. package/dist/shared/types/components/inputs.js +1 -0
  120. package/dist/{__synced__/types/components/layouts.synced.d.ts → shared/types/components/layouts.d.ts} +6 -6
  121. package/dist/shared/types/components/layouts.js +1 -0
  122. package/dist/{__synced__/types/components/link.synced.d.ts → shared/types/components/link.d.ts} +3 -3
  123. package/dist/shared/types/components/link.js +1 -0
  124. package/dist/{__synced__/types/components/list.synced.d.ts → shared/types/components/list.d.ts} +2 -1
  125. package/dist/shared/types/components/list.js +1 -0
  126. package/dist/{__synced__/types/components/loading-spinner.synced.d.ts → shared/types/components/loading-spinner.d.ts} +2 -2
  127. package/dist/shared/types/components/loading-spinner.js +1 -0
  128. package/dist/{__synced__/types/components/modal.synced.d.ts → shared/types/components/modal.d.ts} +4 -4
  129. package/dist/shared/types/components/modal.js +1 -0
  130. package/dist/{__synced__/types/components/panel.synced.d.ts → shared/types/components/panel.d.ts} +5 -5
  131. package/dist/shared/types/components/panel.js +1 -0
  132. package/dist/{__synced__/types/components/progress-bar.synced.d.ts → shared/types/components/progress-bar.d.ts} +2 -1
  133. package/dist/shared/types/components/progress-bar.js +1 -0
  134. package/dist/{__synced__/types/components/selects.synced.d.ts → shared/types/components/selects.d.ts} +2 -1
  135. package/dist/shared/types/components/selects.js +1 -0
  136. package/dist/{__synced__/types/components/statistics.synced.d.ts → shared/types/components/statistics.d.ts} +4 -3
  137. package/dist/shared/types/components/statistics.js +1 -0
  138. package/dist/{__synced__/types/components/status-tag.synced.d.ts → shared/types/components/status-tag.d.ts} +2 -1
  139. package/dist/shared/types/components/status-tag.js +1 -0
  140. package/dist/{__synced__/types/components/step-indicator.synced.d.ts → shared/types/components/step-indicator.d.ts} +2 -2
  141. package/dist/shared/types/components/step-indicator.js +1 -0
  142. package/dist/{__synced__/types/components/table.synced.d.ts → shared/types/components/table.d.ts} +5 -4
  143. package/dist/shared/types/components/table.js +1 -0
  144. package/dist/{__synced__/types/components/tabs.synced.d.ts → shared/types/components/tabs.d.ts} +3 -2
  145. package/dist/shared/types/components/tabs.js +1 -0
  146. package/dist/{__synced__/types/components/tag.synced.d.ts → shared/types/components/tag.d.ts} +3 -3
  147. package/dist/shared/types/components/tag.js +1 -0
  148. package/dist/{__synced__/types/components/text.synced.d.ts → shared/types/components/text.d.ts} +2 -1
  149. package/dist/shared/types/components/text.js +1 -0
  150. package/dist/{__synced__/types/components/tile.synced.d.ts → shared/types/components/tile.d.ts} +2 -1
  151. package/dist/shared/types/components/tile.js +1 -0
  152. package/dist/{__synced__/types/components/toggle.synced.d.ts → shared/types/components/toggle.d.ts} +2 -2
  153. package/dist/shared/types/components/toggle.js +1 -0
  154. package/dist/{__synced__/types/components/toggleInputs.synced.d.ts → shared/types/components/toggleInputs.d.ts} +4 -4
  155. package/dist/shared/types/components/toggleInputs.js +1 -0
  156. package/dist/{__synced__/types/components/tooltip.synced.d.ts → shared/types/components/tooltip.d.ts} +2 -1
  157. package/dist/shared/types/components/tooltip.js +1 -0
  158. package/dist/{__synced__/types/context.synced.d.ts → shared/types/context.d.ts} +1 -1
  159. package/dist/shared/types/context.js +1 -0
  160. package/dist/{__synced__/types/crm.synced.d.ts → shared/types/crm.d.ts} +13 -13
  161. package/dist/shared/types/crm.js +1 -0
  162. package/dist/{__synced__/experimental/types.synced.d.ts → shared/types/experimental.d.ts} +12 -17
  163. package/dist/shared/types/experimental.js +1 -0
  164. package/dist/shared/types/extend.d.ts +4 -0
  165. package/dist/shared/types/extend.js +1 -0
  166. package/dist/{__synced__/types/extension-points.synced.d.ts → shared/types/extension-points.d.ts} +18 -10
  167. package/dist/{__synced__/types/http-requests.synced.d.ts → shared/types/http-requests.d.ts} +1 -1
  168. package/dist/shared/types/index.d.ts +8 -0
  169. package/dist/shared/types/index.js +1 -0
  170. package/dist/shared/types/logger.d.ts +7 -0
  171. package/dist/shared/types/logger.js +1 -0
  172. package/dist/shared/types/reactions.js +1 -0
  173. package/dist/{__synced__/types/shared.synced.d.ts → shared/types/shared.d.ts} +3 -0
  174. package/dist/shared/types/worker-globals.d.ts +17 -0
  175. package/dist/shared/types/worker-globals.js +1 -0
  176. package/dist/{__synced__/utils/remote-component-registry.synced.d.ts → shared/utils/remote-component-registry.d.ts} +1 -1
  177. package/dist/{__synced__/utils/remote-component-registry.synced.js → shared/utils/remote-component-registry.js} +0 -1
  178. package/package.json +13 -14
  179. package/dist/__synced__/appHomeRemoteComponents.synced.d.ts +0 -28
  180. package/dist/__synced__/appHomeRemoteComponents.synced.js +0 -21
  181. package/dist/__synced__/crmRemoteComponents.synced.d.ts +0 -66
  182. package/dist/__synced__/crmRemoteComponents.synced.js +0 -15
  183. package/dist/__synced__/experimental/types.synced.js +0 -5
  184. package/dist/__synced__/experimentalRemoteComponents.synced.d.ts +0 -94
  185. package/dist/__synced__/experimentalRemoteComponents.synced.js +0 -56
  186. package/dist/__synced__/types/components/index.synced.d.ts +0 -38
  187. package/dist/__synced__/types/index.synced.d.ts +0 -8
  188. package/dist/__synced__/types/index.synced.js +0 -1
  189. /package/dist/{__synced__/types/actions.synced.js → experimental/testing/__tests__/createRenderer.spec.d.ts} +0 -0
  190. /package/dist/{__synced__/types/components/accordion.synced.js → experimental/testing/__tests__/debug.spec.d.ts} +0 -0
  191. /package/dist/{__synced__/types/components/alert.synced.js → experimental/testing/__tests__/find.spec.d.ts} +0 -0
  192. /package/dist/{__synced__/types/components/app-home-header-actions.synced.js → experimental/testing/__tests__/findAll.spec.d.ts} +0 -0
  193. /package/dist/{__synced__/types/components/button-row.synced.js → experimental/testing/__tests__/findAllChildren.spec.d.ts} +0 -0
  194. /package/dist/{__synced__/types/components/button.synced.js → experimental/testing/__tests__/findByTestId.spec.d.ts} +0 -0
  195. /package/dist/{__synced__/types/components/card.synced.js → experimental/testing/__tests__/findChild.spec.d.ts} +0 -0
  196. /package/dist/{__synced__/types/components/description-list.synced.js → experimental/testing/__tests__/fragments.spec.d.ts} +0 -0
  197. /package/dist/{__synced__/types/components/divider.synced.js → experimental/testing/__tests__/invalid-components.spec.d.ts} +0 -0
  198. /package/dist/{__synced__/types/components/dropdown.synced.js → experimental/testing/__tests__/isMatch.spec.d.ts} +0 -0
  199. /package/dist/{__synced__/types/components/empty-state.synced.js → experimental/testing/__tests__/logger.spec.d.ts} +0 -0
  200. /package/dist/{__synced__/types/components/error-state.synced.js → experimental/testing/__tests__/maybeFind.spec.d.ts} +0 -0
  201. /package/dist/{__synced__/types/components/form.synced.js → experimental/testing/__tests__/maybeFindByTestId.spec.d.ts} +0 -0
  202. /package/dist/{__synced__/types/components/heading.synced.js → experimental/testing/__tests__/maybeFindChild.spec.d.ts} +0 -0
  203. /package/dist/{__synced__/types/components/icon.synced.js → experimental/testing/__tests__/mocks.actions.spec.d.ts} +0 -0
  204. /package/dist/{__synced__/types/components/iframe.synced.js → experimental/testing/__tests__/mocks.context.spec.d.ts} +0 -0
  205. /package/dist/{__synced__/types/components/image.synced.js → experimental/testing/__tests__/mocks.runServerlessFunction.spec.d.ts} +0 -0
  206. /package/dist/{__synced__/types/components/index.synced.js → experimental/testing/__tests__/mocks.useAssociations.spec.d.ts} +0 -0
  207. /package/dist/{__synced__/types/components/inputs.synced.js → experimental/testing/__tests__/mocks.useCrmProperties.spec.d.ts} +0 -0
  208. /package/dist/{__synced__/types/components/layouts.synced.js → experimental/testing/__tests__/props.spec.d.ts} +0 -0
  209. /package/dist/{__synced__/types/components/link.synced.js → experimental/testing/__tests__/testId.spec.d.ts} +0 -0
  210. /package/dist/{__synced__/types/components/list.synced.js → experimental/testing/__tests__/trigger.spec.d.ts} +0 -0
  211. /package/dist/{__synced__/types/components/loading-spinner.synced.js → experimental/testing/__tests__/type-utils.spec.d.ts} +0 -0
  212. /package/dist/{__synced__/types/components/modal.synced.js → experimental/testing/__tests__/waitFor.spec.d.ts} +0 -0
  213. /package/dist/{__synced__/types/actions.synced.d.ts → shared/types/actions.d.ts} +0 -0
  214. /package/dist/{__synced__/types/components/panel.synced.js → shared/types/actions.js} +0 -0
  215. /package/dist/{__synced__/types/components/progress-bar.synced.js → shared/types/components/accordion.js} +0 -0
  216. /package/dist/{__synced__/types/components/selects.synced.js → shared/types/components/alert.js} +0 -0
  217. /package/dist/{__synced__/types/components/statistics.synced.js → shared/types/components/app-home-header-actions.js} +0 -0
  218. /package/dist/{__synced__/types/components/status-tag.synced.js → shared/types/components/button-row.js} +0 -0
  219. /package/dist/{__synced__/types/components/step-indicator.synced.js → shared/types/components/button.js} +0 -0
  220. /package/dist/{__synced__/types/components/table.synced.js → shared/types/components/card.js} +0 -0
  221. /package/dist/{__synced__/types/components/chart.synced.js → shared/types/components/chart.js} +0 -0
  222. /package/dist/{__synced__/types/components/tabs.synced.js → shared/types/components/description-list.js} +0 -0
  223. /package/dist/{__synced__/types/components/tag.synced.js → shared/types/components/divider.js} +0 -0
  224. /package/dist/{__synced__/types/components/text.synced.js → shared/types/components/dropdown.js} +0 -0
  225. /package/dist/{__synced__/types/components/tile.synced.js → shared/types/components/empty-state.js} +0 -0
  226. /package/dist/{__synced__/types/components/toggle.synced.js → shared/types/components/error-state.js} +0 -0
  227. /package/dist/{__synced__/types/components/toggleInputs.synced.js → shared/types/components/form.js} +0 -0
  228. /package/dist/{__synced__/types/components/tooltip.synced.js → shared/types/components/heading.js} +0 -0
  229. /package/dist/{__synced__/types/context.synced.js → shared/types/components/icon.js} +0 -0
  230. /package/dist/{__synced__/types/crm.synced.js → shared/types/components/iframe.js} +0 -0
  231. /package/dist/{__synced__/types/components/illustration.synced.js → shared/types/components/illustration.js} +0 -0
  232. /package/dist/{__synced__/types/reactions.synced.js → shared/types/components/image.js} +0 -0
  233. /package/dist/{__synced__/types/extension-points.synced.js → shared/types/extension-points.js} +0 -0
  234. /package/dist/{__synced__/types/http-requests.synced.js → shared/types/http-requests.js} +0 -0
  235. /package/dist/{__synced__/types/reactions.synced.d.ts → shared/types/reactions.d.ts} +0 -0
  236. /package/dist/{__synced__/types/shared.synced.js → shared/types/shared.js} +0 -0
@@ -1,6 +1,6 @@
1
- import type { HubSpotReactComponent, UnknownComponentProps } from '../../../__synced__/types/shared.synced';
2
- import type { ElementMatcher, RenderedElementNode } from '../types';
3
- import type { RenderedParentNodeInternal } from './types-internal';
1
+ import type { HubSpotReactComponent, UnknownComponentProps } from '../../../shared/types/shared.ts';
2
+ import type { ElementMatcher, RenderedElementNode } from '../types.ts';
3
+ import type { RenderedDocumentInternal, RenderedParentNodeInternal } from './types-internal.ts';
4
4
  /**
5
5
  * Finds the first descendant element node that matches the given component.
6
6
  *
@@ -9,7 +9,7 @@ import type { RenderedParentNodeInternal } from './types-internal';
9
9
  * @param matcher An optional matcher to filter the elements.
10
10
  * @returns The first element node that matches the given component or `null` if no match is found.
11
11
  */
12
- export declare const maybeFind: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps> | undefined) => RenderedElementNode<TProps> | null;
12
+ export declare const maybeFind: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps>) => RenderedElementNode<TProps> | null;
13
13
  /**
14
14
  * Finds the first descendant element node that matches the given component.
15
15
  *
@@ -18,7 +18,7 @@ export declare const maybeFind: <TProps extends UnknownComponentProps>(parentNod
18
18
  * @param matcher An optional matcher to filter the elements.
19
19
  * @returns The first element node that matches the given component.
20
20
  */
21
- export declare const find: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps> | undefined) => RenderedElementNode<TProps>;
21
+ export declare const find: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps>) => RenderedElementNode<TProps>;
22
22
  /**
23
23
  * Finds all descendant element nodes that match the given component.
24
24
  *
@@ -27,7 +27,7 @@ export declare const find: <TProps extends UnknownComponentProps>(parentNode: Re
27
27
  * @param matcher An optional matcher to filter the elements.
28
28
  * @returns An array of element nodes that match the given component.
29
29
  */
30
- export declare const findAll: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps> | undefined) => RenderedElementNode<TProps>[];
30
+ export declare const findAll: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps>) => RenderedElementNode<TProps>[];
31
31
  /**
32
32
  * Finds the first direct child element node that matches the given component.
33
33
  *
@@ -36,7 +36,7 @@ export declare const findAll: <TProps extends UnknownComponentProps>(parentNode:
36
36
  * @param matcher An optional matcher to filter the elements.
37
37
  * @returns The first child element node that matches the given component.
38
38
  */
39
- export declare const findChild: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps> | undefined) => RenderedElementNode<TProps>;
39
+ export declare const findChild: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps>) => RenderedElementNode<TProps>;
40
40
  /**
41
41
  * Finds the first direct child element node that matches the given component.
42
42
  *
@@ -45,7 +45,7 @@ export declare const findChild: <TProps extends UnknownComponentProps>(parentNod
45
45
  * @param matcher An optional matcher to filter the elements.
46
46
  * @returns The first child element node that matches the given component.
47
47
  */
48
- export declare const maybeFindChild: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps> | undefined) => RenderedElementNode<TProps> | null;
48
+ export declare const maybeFindChild: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps>) => RenderedElementNode<TProps> | null;
49
49
  /**
50
50
  * Finds all direct child element nodes that match the given component.
51
51
  *
@@ -54,4 +54,14 @@ export declare const maybeFindChild: <TProps extends UnknownComponentProps>(pare
54
54
  * @param matcher An optional matcher to filter the elements.
55
55
  * @returns An array of child element nodes that match the given component.
56
56
  */
57
- export declare const findAllChildren: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps> | undefined) => RenderedElementNode<TProps>[];
57
+ export declare const findAllChildren: <TProps extends UnknownComponentProps>(parentNode: RenderedParentNodeInternal, targetComponent: HubSpotReactComponent<TProps>, matcher?: ElementMatcher<TProps>) => RenderedElementNode<TProps>[];
58
+ /**
59
+ * Finds the first descendant element node that matches the given component and test ID.
60
+ *
61
+ * @param parentNode The parent node to search in.
62
+ * @param targetComponent The component to find.
63
+ * @param testId The test ID to find.
64
+ * @returns The first element node that matches the given component and test ID.
65
+ */
66
+ export declare const maybeFindByTestId: <TProps extends UnknownComponentProps>(document: RenderedDocumentInternal, targetComponent: HubSpotReactComponent<TProps>, testId: string) => RenderedElementNode<TProps> | null;
67
+ export declare const findByTestId: <TProps extends UnknownComponentProps>(document: RenderedDocumentInternal, targetComponent: HubSpotReactComponent<TProps>, testId: string) => RenderedElementNode<TProps>;
@@ -1,25 +1,8 @@
1
- import { __hubSpotComponentRegistry } from '../../../__synced__/remoteComponents.synced';
2
- import { isRenderedElementNode, isRenderedFragmentNode } from '../type-utils';
3
- import { ComponentNotFoundError, FindInvalidComponentError, InvalidComponentsError, } from './errors';
4
- /**
5
- * Checks if the element matches the matcher.
6
- *
7
- * @param element The element to check.
8
- * @param matcher An optional matcher to filter the elements.
9
- * @returns `true` if the element matches the matcher, `false` otherwise.
10
- */
11
- const checkElementMatches = (element, matcher) => {
12
- // If no matcher is provided, the element matches
13
- if (!matcher) {
14
- return true;
15
- }
16
- // Check if the matcher is a predicate function
17
- if (typeof matcher === 'function') {
18
- return matcher(element);
19
- }
20
- // Check if all the props in the matcher match the props in the element
21
- return Object.keys(matcher).every((key) => element.props[key] === matcher[key]);
22
- };
1
+ import { __hubSpotComponentRegistry } from "../../../shared/remoteComponents.js";
2
+ import { isRenderedElementNode } from "../type-utils.js";
3
+ import { ComponentMismatchedByTestIdError, ComponentNotFoundByTestIdError, ComponentNotFoundError, FindInvalidComponentError, InvalidComponentsError, } from "./errors.js";
4
+ import { checkElementMatches } from "./match.js";
5
+ import { asRenderedParentNode } from "./type-utils-internal.js";
23
6
  const addMatchToFindResult = (findResult, match, options) => {
24
7
  if (options.findFirstOnly) {
25
8
  findResult.match = match;
@@ -37,32 +20,32 @@ const addMatchToFindResult = (findResult, match, options) => {
37
20
  * @param findResult The find result to mutate.
38
21
  */
39
22
  const findInternalHelper = (parentNode, options, findResult) => {
40
- const { children } = parentNode;
23
+ const { childNodes } = parentNode;
41
24
  const { targetComponent, matcher, findFirstOnly, findDirectChildrenOnly } = options;
42
25
  const targetComponentName = __hubSpotComponentRegistry.getComponentName(targetComponent);
43
- for (const child of children) {
44
- if (!isRenderedElementNode(child)) {
26
+ for (const childNode of childNodes) {
27
+ if (!isRenderedElementNode(childNode)) {
45
28
  // Skip over non-element child nodes (just text nodes)
46
29
  continue;
47
30
  }
48
- if (child.name === targetComponentName &&
49
- checkElementMatches(child, matcher)) {
31
+ if (childNode.name === targetComponentName &&
32
+ checkElementMatches(childNode, matcher)) {
50
33
  // We found a match, so add it to the find result
51
- addMatchToFindResult(findResult, child, options);
34
+ addMatchToFindResult(findResult, childNode, options);
52
35
  if (findFirstOnly) {
53
36
  return;
54
37
  }
55
38
  }
56
- // We only search in nested children and fragment props if we're not only looking for children
39
+ // We only search in nested child nodes and fragment props if we're not only looking for children
57
40
  if (!findDirectChildrenOnly) {
58
41
  // Search for the component in the fragment props
59
- const { props } = child;
60
- const fragmentProps = __hubSpotComponentRegistry.getComponentFragmentPropNames(child.name);
42
+ const { props } = childNode;
43
+ const fragmentProps = __hubSpotComponentRegistry.getComponentFragmentPropNames(childNode.name);
61
44
  for (const fragmentPropName of fragmentProps) {
62
45
  const maybeFragment = props[fragmentPropName];
63
46
  // NOTE: As part of the conversion process of converting remote nodes to rendered nodes, we
64
47
  // create a RenderedFragmentNode for each fragment prop and put that into the props object.
65
- if (isRenderedFragmentNode(maybeFragment)) {
48
+ if (maybeFragment) {
66
49
  findInternalHelper(maybeFragment, options, findResult);
67
50
  if (findFirstOnly && findResult.match) {
68
51
  return;
@@ -70,7 +53,7 @@ const findInternalHelper = (parentNode, options, findResult) => {
70
53
  }
71
54
  }
72
55
  // Search for the component in the child
73
- findInternalHelper(child, options, findResult);
56
+ findInternalHelper(childNode, options, findResult);
74
57
  if (findFirstOnly && findResult.match) {
75
58
  return;
76
59
  }
@@ -78,6 +61,22 @@ const findInternalHelper = (parentNode, options, findResult) => {
78
61
  }
79
62
  return;
80
63
  };
64
+ const validateComponent = (targetComponent, findMethodName) => {
65
+ const targetComponentName = __hubSpotComponentRegistry.getComponentName(targetComponent);
66
+ if (!targetComponentName) {
67
+ throw new FindInvalidComponentError({
68
+ findMethodName,
69
+ });
70
+ }
71
+ return {
72
+ targetComponentName,
73
+ };
74
+ };
75
+ const validateRenderedDocument = (document) => {
76
+ if (document.hasInvalidComponentNames()) {
77
+ throw new InvalidComponentsError(document.rootNode);
78
+ }
79
+ };
81
80
  /**
82
81
  * Internal utility that centralizes finding elements in the rendered tree (including error handling).
83
82
  *
@@ -88,28 +87,19 @@ const findInternalHelper = (parentNode, options, findResult) => {
88
87
  const findInternal = (parentNode, options) => {
89
88
  const { document } = parentNode;
90
89
  const { targetComponent, findMethodName, shouldThrowErrorIfNotFound } = options;
91
- const targetComponentName = __hubSpotComponentRegistry.getComponentName(targetComponent);
92
- if (!targetComponentName) {
93
- throw new FindInvalidComponentError({
94
- findMethodName,
95
- });
96
- }
97
- // We always validate the document before running the find operation since the document may
98
- // have been updated asynchronously in the background.
99
- if (document.hasInvalidComponentNames()) {
100
- throw new InvalidComponentsError(document.rootNode);
101
- }
90
+ const { targetComponentName } = validateComponent(targetComponent, findMethodName);
91
+ validateRenderedDocument(document);
102
92
  // Initialize the find result that will be mutated in place
103
93
  const findResult = {
104
94
  match: null,
105
95
  allMatches: [],
106
96
  };
107
97
  // Run the internal find helper to recursively search the rendered tree
108
- findInternalHelper(parentNode, options, findResult);
98
+ findInternalHelper(asRenderedParentNode(parentNode), options, findResult);
109
99
  if (findResult.match === null && shouldThrowErrorIfNotFound) {
110
100
  throw new ComponentNotFoundError({
111
101
  findMethodName: options.findMethodName,
112
- parentNode,
102
+ parentNode: asRenderedParentNode(parentNode),
113
103
  componentName: targetComponentName,
114
104
  });
115
105
  }
@@ -229,3 +219,58 @@ export const findAllChildren = (parentNode, targetComponent, matcher) => {
229
219
  });
230
220
  return allMatches;
231
221
  };
222
+ const findByTestIdHelper = (options) => {
223
+ const { document, targetComponent, testId, findMethodName, shouldThrowErrorIfNotFound, } = options;
224
+ const { targetComponentName } = validateComponent(targetComponent, findMethodName);
225
+ validateRenderedDocument(document);
226
+ const matchingElement = document.testIdToElementMap.get(testId);
227
+ if (!matchingElement) {
228
+ if (shouldThrowErrorIfNotFound) {
229
+ throw new ComponentNotFoundByTestIdError({
230
+ findMethodName,
231
+ componentName: targetComponentName,
232
+ testId,
233
+ rootNode: document.rootNode,
234
+ });
235
+ }
236
+ return null;
237
+ }
238
+ if (!matchingElement.isMatch(targetComponent)) {
239
+ throw new ComponentMismatchedByTestIdError({
240
+ findMethodName,
241
+ actualComponentName: matchingElement.name,
242
+ expectedComponentName: targetComponentName,
243
+ testId,
244
+ rootNode: document.rootNode,
245
+ });
246
+ }
247
+ return matchingElement;
248
+ };
249
+ /**
250
+ * Finds the first descendant element node that matches the given component and test ID.
251
+ *
252
+ * @param parentNode The parent node to search in.
253
+ * @param targetComponent The component to find.
254
+ * @param testId The test ID to find.
255
+ * @returns The first element node that matches the given component and test ID.
256
+ */
257
+ export const maybeFindByTestId = (document, targetComponent, testId) => {
258
+ const maybeMatchingElement = findByTestIdHelper({
259
+ document,
260
+ targetComponent,
261
+ testId,
262
+ findMethodName: 'maybeFindByTestId',
263
+ shouldThrowErrorIfNotFound: false,
264
+ });
265
+ return maybeMatchingElement;
266
+ };
267
+ export const findByTestId = (document, targetComponent, testId) => {
268
+ const matchingElement = findByTestIdHelper({
269
+ document,
270
+ targetComponent,
271
+ testId,
272
+ findMethodName: 'findByTestId',
273
+ shouldThrowErrorIfNotFound: true,
274
+ });
275
+ return matchingElement;
276
+ };
@@ -1,4 +1,4 @@
1
- import type { RenderedDocumentInternal, RenderedRootNodeInternal } from './types-internal';
1
+ import type { RenderedDocumentInternal, RenderedRootNodeInternal } from './types-internal.ts';
2
2
  /**
3
3
  * Creates a rendered root node.
4
4
  *
@@ -1,8 +1,9 @@
1
- import { RenderedNodeType } from '../types';
2
- import { EMPTY_CHILDREN } from './constants';
3
- import { debugLog } from './debug';
4
- import { printNode } from './print';
5
- import { find, findAll, findAllChildren, findChild, maybeFind, maybeFindChild, } from './query';
1
+ import { RenderedNodeType } from "../types.js";
2
+ import { EMPTY_RENDERED_CHILD_NODES } from "./constants.js";
3
+ import { debugLog } from "./debug.js";
4
+ import { printNode } from "./print.js";
5
+ import { find, findAll, findAllChildren, findChild, maybeFind, maybeFindChild, } from "./query.js";
6
+ import { asRenderedNode } from "./type-utils-internal.js";
6
7
  /**
7
8
  * Creates a rendered root node.
8
9
  *
@@ -13,10 +14,10 @@ export const createRootNode = (document) => {
13
14
  const rootNode = {
14
15
  nodeType: RenderedNodeType.Root,
15
16
  text: null,
16
- children: EMPTY_CHILDREN,
17
+ childNodes: EMPTY_RENDERED_CHILD_NODES,
17
18
  document,
18
19
  debugLog: (label) => {
19
- debugLog(rootNode, label);
20
+ debugLog(asRenderedNode(rootNode), label);
20
21
  },
21
22
  find: (targetComponent, matcher) => {
22
23
  return find(rootNode, targetComponent, matcher);
@@ -37,7 +38,10 @@ export const createRootNode = (document) => {
37
38
  return maybeFindChild(rootNode, targetComponent, matcher);
38
39
  },
39
40
  toString: () => {
40
- return printNode(rootNode);
41
+ return printNode(asRenderedNode(rootNode));
42
+ },
43
+ isMatch(__component, __matcher) {
44
+ return false;
41
45
  },
42
46
  };
43
47
  return rootNode;
@@ -1,9 +1,10 @@
1
1
  import { type RemoteRoot, type RemoteText } from '@remote-ui/core';
2
- import { type RenderedTextNode } from '../types';
2
+ import { RenderedTextNode } from '../types.ts';
3
+ import { RenderedDocumentInternal } from './types-internal.ts';
3
4
  /**
4
5
  * Creates a rendered text node.
5
6
  *
6
7
  * @param remoteText The remote text node or string to create a text node from.
7
8
  * @returns A rendered text node.
8
9
  */
9
- export declare const createTextNode: (remoteText: RemoteText<RemoteRoot> | string) => RenderedTextNode;
10
+ export declare const createTextNode: (document: RenderedDocumentInternal, remoteText: RemoteText<RemoteRoot> | string) => RenderedTextNode;
@@ -1,16 +1,25 @@
1
- import { RenderedNodeType } from '../types';
1
+ import { RenderedNodeType } from "../types.js";
2
+ import { debugLog } from "./debug.js";
3
+ import { asRenderedNode, asRenderedTextNode } from "./type-utils-internal.js";
2
4
  /**
3
5
  * Creates a rendered text node.
4
6
  *
5
7
  * @param remoteText The remote text node or string to create a text node from.
6
8
  * @returns A rendered text node.
7
9
  */
8
- export const createTextNode = (remoteText) => {
10
+ export const createTextNode = (document, remoteText) => {
9
11
  const text = typeof remoteText === 'string' ? remoteText : remoteText.text;
10
12
  const textNode = {
13
+ document,
11
14
  nodeType: RenderedNodeType.Text,
12
15
  text,
13
16
  toString: () => text,
17
+ debugLog: (label) => {
18
+ debugLog(asRenderedNode(textNode), label);
19
+ },
20
+ isMatch(__component, __matcher) {
21
+ return false;
22
+ },
14
23
  };
15
- return textNode;
24
+ return asRenderedTextNode(textNode);
16
25
  };
@@ -0,0 +1,44 @@
1
+ import { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
2
+ import { RenderedElementNodeInternal, RenderedFragmentNodeInternal, RenderedNodeInternal, RenderedRootNodeInternal, RenderedParentNodeInternal, RenderedTextNodeInternal } from './types-internal.ts';
3
+ /**
4
+ * Converts an internal rendered node to a public rendered node using a type assertion.
5
+ *
6
+ * @param node The node to convert.
7
+ * @returns The converted node.
8
+ */
9
+ export declare const asRenderedNode: (node: RenderedNodeInternal) => RenderedNode;
10
+ /**
11
+ * Converts an internal rendered element node to a public rendered element node using a type assertion.
12
+ *
13
+ * @param node The node to convert.
14
+ * @returns The converted node.
15
+ */
16
+ export declare const asRenderedElementNode: (node: RenderedElementNodeInternal) => RenderedElementNode;
17
+ /**
18
+ * Converts an internal rendered fragment node to a public rendered fragment node using a type assertion.
19
+ *
20
+ * @param node The node to convert.
21
+ * @returns The converted node.
22
+ */
23
+ export declare const asRenderedFragmentNode: (node: RenderedFragmentNodeInternal) => RenderedFragmentNode;
24
+ /**
25
+ * Converts an internal rendered text node to a public rendered text node using a type assertion.
26
+ *
27
+ * @param node The node to convert.
28
+ * @returns The converted node.
29
+ */
30
+ export declare const asRenderedTextNode: (node: RenderedTextNodeInternal) => RenderedTextNode;
31
+ /**
32
+ * Converts an internal rendered root node to a public rendered root node using a type assertion.
33
+ *
34
+ * @param node The node to convert.
35
+ * @returns The converted node.
36
+ */
37
+ export declare const asRenderedRootNode: (node: RenderedRootNodeInternal) => RenderedRootNode;
38
+ /**
39
+ * Converts an internal rendered parent node to a public rendered parent node using a type assertion.
40
+ *
41
+ * @param node The node to convert.
42
+ * @returns The converted node.
43
+ */
44
+ export declare const asRenderedParentNode: (node: RenderedParentNodeInternal) => RenderedParentNode;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Converts an internal rendered node to a public rendered node using a type assertion.
3
+ *
4
+ * @param node The node to convert.
5
+ * @returns The converted node.
6
+ */
7
+ export const asRenderedNode = (node) => {
8
+ return node;
9
+ };
10
+ /**
11
+ * Converts an internal rendered element node to a public rendered element node using a type assertion.
12
+ *
13
+ * @param node The node to convert.
14
+ * @returns The converted node.
15
+ */
16
+ export const asRenderedElementNode = (node) => {
17
+ return node;
18
+ };
19
+ /**
20
+ * Converts an internal rendered fragment node to a public rendered fragment node using a type assertion.
21
+ *
22
+ * @param node The node to convert.
23
+ * @returns The converted node.
24
+ */
25
+ export const asRenderedFragmentNode = (node) => {
26
+ return node;
27
+ };
28
+ /**
29
+ * Converts an internal rendered text node to a public rendered text node using a type assertion.
30
+ *
31
+ * @param node The node to convert.
32
+ * @returns The converted node.
33
+ */
34
+ export const asRenderedTextNode = (node) => {
35
+ return node;
36
+ };
37
+ /**
38
+ * Converts an internal rendered root node to a public rendered root node using a type assertion.
39
+ *
40
+ * @param node The node to convert.
41
+ * @returns The converted node.
42
+ */
43
+ export const asRenderedRootNode = (node) => {
44
+ return node;
45
+ };
46
+ /**
47
+ * Converts an internal rendered parent node to a public rendered parent node using a type assertion.
48
+ *
49
+ * @param node The node to convert.
50
+ * @returns The converted node.
51
+ */
52
+ export const asRenderedParentNode = (node) => {
53
+ return node;
54
+ };
@@ -1,5 +1,8 @@
1
1
  import type { RemoteComponent, RemoteFragment, RemoteRoot, RemoteText } from '@remote-ui/core';
2
- import type { RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types';
2
+ import { ExtensionPointApi, ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
3
+ import { HubSpotReactComponent, UnknownComponentProps } from '../../../shared/types/shared.ts';
4
+ import { useAssociations, useCrmProperties } from '../../../crm/index.ts';
5
+ import type { ElementMatcher, RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
3
6
  export type RemoteChildNode = RemoteComponent<any, RemoteRoot> | RemoteText<RemoteRoot>;
4
7
  export type RemoteParentNode = RemoteRoot | RemoteComponent<any, RemoteRoot> | RemoteFragment;
5
8
  /**
@@ -31,17 +34,32 @@ export interface RenderedDocumentInternal {
31
34
  * @param run The function to execute.
32
35
  */
33
36
  batchUpdate: (run: () => void) => void;
37
+ /**
38
+ * A lookup map of test IDs to elements.
39
+ */
40
+ testIdToElementMap: Map<string, RenderedElementNode<UnknownComponentProps>>;
34
41
  }
35
42
  /**
36
43
  * Adds the `document` property to the rendered node. We do not include this in the public types because it is not
37
44
  * part of the public API, but we need it for internal use.
38
45
  */
39
- type MakeRenderedNodeInternal<TRenderedNode extends RenderedNode> = TRenderedNode & {
46
+ type MakeRenderedNodeInternal<TRenderedNode extends RenderedNode> = Omit<TRenderedNode, 'isMatch'> & {
40
47
  document: RenderedDocumentInternal;
48
+ isMatch(component: HubSpotReactComponent, matcher?: ElementMatcher<UnknownComponentProps>): boolean;
41
49
  };
42
50
  export type RenderedElementNodeInternal = MakeRenderedNodeInternal<RenderedElementNode>;
43
51
  export type RenderedTextNodeInternal = MakeRenderedNodeInternal<RenderedTextNode>;
44
52
  export type RenderedRootNodeInternal = MakeRenderedNodeInternal<RenderedRootNode>;
45
53
  export type RenderedFragmentNodeInternal = MakeRenderedNodeInternal<RenderedFragmentNode>;
46
54
  export type RenderedParentNodeInternal = MakeRenderedNodeInternal<RenderedParentNode>;
55
+ export type RenderedNodeInternal = RenderedElementNodeInternal | RenderedTextNodeInternal | RenderedRootNodeInternal | RenderedFragmentNodeInternal;
56
+ /**
57
+ * An object containing the mocks for the various functions that can be mocked.
58
+ */
59
+ export interface RendererMockHooksInternal {
60
+ useCrmProperties: typeof useCrmProperties;
61
+ useAssociations: typeof useAssociations;
62
+ }
63
+ export type RendererMocksInternal<TExtensionPointLocationName extends ExtensionPointLocation = ExtensionPointLocation> = RendererMockHooksInternal & ExtensionPointApi<TExtensionPointLocationName>;
64
+ export type AnyFunction = (...args: any[]) => any;
47
65
  export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A deferred promise that can be resolved or rejected externally.
3
+ */
4
+ export interface Deferred<T = unknown> {
5
+ promise: Promise<T>;
6
+ resolve: (value: T) => void;
7
+ reject: (error: unknown) => void;
8
+ }
9
+ /**
10
+ * Creates a deferred promise that can be resolved or rejected externally.
11
+ *
12
+ * @returns A deferred promise object.
13
+ */
14
+ export declare const createDeferred: <T = unknown>() => Deferred<T>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Creates a deferred promise that can be resolved or rejected externally.
3
+ *
4
+ * @returns A deferred promise object.
5
+ */
6
+ export const createDeferred = () => {
7
+ let resolve;
8
+ let reject;
9
+ const promise = new Promise((_resolve, _reject) => {
10
+ resolve = _resolve;
11
+ reject = _reject;
12
+ });
13
+ return { promise, resolve: resolve, reject: reject };
14
+ };
@@ -0,0 +1,35 @@
1
+ import { ExtensionPointLocation } from '../../shared/types/extension-points.ts';
2
+ import { Renderer } from './types.ts';
3
+ /**
4
+ * Creates a renderer object with methods for rendering and testing UI extension components.
5
+ * Mocks for supported React hooks and the Extension Point API are automatically provided based on the extension point location.
6
+ *
7
+ * Example usage:
8
+ *
9
+ * ```tsx
10
+ * import { createRenderer } from '@hubspot/ui-extensions/testing';
11
+ * import { Alert, Button, ButtonRow } from '@hubspot/ui-extensions';
12
+ *
13
+ * const { render, find } = createRenderer('crm.record.tab');
14
+ * render(
15
+ * <>
16
+ * <ButtonRow>
17
+ * <Button variant="secondary">Button 1</Button>
18
+ * <Button variant="primary">Button 2</Button>
19
+ * </ButtonRow>
20
+ * <Alert title="My Alert" />
21
+ * </>
22
+ * );
23
+ *
24
+ * // Find any button
25
+ * const button = find(Button);
26
+ *
27
+ * // Assertions
28
+ * expect(button.props.variant).toEqual('primary');
29
+ * expect(button.text).toEqual('Button 2');
30
+ * ```
31
+ *
32
+ * @param extensionPointLocation The extension point location.
33
+ * @returns A renderer object with methods for rendering and testing UI extension components.
34
+ */
35
+ export declare const createRenderer: <TExtensionPointLocation extends ExtensionPointLocation>(extensionPointLocation: TExtensionPointLocation) => Renderer<TExtensionPointLocation>;