@hubspot/ui-extensions 0.11.3 → 0.11.5

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 (110) hide show
  1. package/dist/hooks/useExtensionActions.d.ts +4 -0
  2. package/dist/hooks/useExtensionActions.js +6 -0
  3. package/dist/hooks/useExtensionContext.d.ts +4 -0
  4. package/dist/hooks/useExtensionContext.js +6 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +2 -0
  7. package/dist/internal/global-utils.js +4 -0
  8. package/dist/internal/hook-utils.d.ts +10 -3
  9. package/dist/internal/hook-utils.js +10 -1
  10. package/dist/shared/types/worker-globals.d.ts +15 -0
  11. package/dist/{experimental/testing → testing}/__tests__/debug.spec.js +1 -1
  12. package/dist/{experimental/testing → testing}/__tests__/find.spec.js +1 -1
  13. package/dist/{experimental/testing → testing}/__tests__/findAll.spec.js +1 -1
  14. package/dist/{experimental/testing → testing}/__tests__/findAllChildren.spec.js +1 -1
  15. package/dist/{experimental/testing → testing}/__tests__/findByTestId.spec.js +1 -1
  16. package/dist/{experimental/testing → testing}/__tests__/findChild.spec.js +1 -1
  17. package/dist/{experimental/testing → testing}/__tests__/fragments.spec.js +1 -1
  18. package/dist/{experimental/testing → testing}/__tests__/invalid-components.spec.js +1 -1
  19. package/dist/{experimental/testing → testing}/__tests__/isMatch.spec.js +1 -1
  20. package/dist/{experimental/testing → testing}/__tests__/logger.spec.js +1 -1
  21. package/dist/{experimental/testing → testing}/__tests__/maybeFind.spec.js +1 -1
  22. package/dist/{experimental/testing → testing}/__tests__/maybeFindByTestId.spec.js +1 -1
  23. package/dist/{experimental/testing → testing}/__tests__/maybeFindChild.spec.js +1 -1
  24. package/dist/{experimental/testing → testing}/__tests__/mocks.runServerlessFunction.spec.js +1 -1
  25. package/dist/{experimental/testing → testing}/__tests__/mocks.useAssociations.spec.js +2 -2
  26. package/dist/{experimental/testing → testing}/__tests__/mocks.useCrmProperties.spec.js +2 -2
  27. package/dist/testing/__tests__/mocks.useExtensionActions.spec.js +32 -0
  28. package/dist/testing/__tests__/mocks.useExtensionContext.spec.js +46 -0
  29. package/dist/{experimental/testing → testing}/__tests__/props.spec.js +1 -1
  30. package/dist/{experimental/testing → testing}/__tests__/testId.spec.js +1 -1
  31. package/dist/{experimental/testing → testing}/__tests__/trigger.spec.js +1 -1
  32. package/dist/{experimental/testing → testing}/__tests__/type-utils.spec.js +1 -1
  33. package/dist/testing/__tests__/waitFor.spec.d.ts +1 -0
  34. package/dist/{experimental/testing → testing}/__tests__/waitFor.spec.js +1 -1
  35. package/dist/{experimental/testing → testing}/internal/convert.js +1 -1
  36. package/dist/{experimental/testing → testing}/internal/element.d.ts +1 -1
  37. package/dist/{experimental/testing → testing}/internal/errors.js +1 -1
  38. package/dist/{experimental/testing → testing}/internal/match.d.ts +1 -1
  39. package/dist/{experimental/testing → testing}/internal/mocks/index.d.ts +1 -1
  40. package/dist/{experimental/testing → testing}/internal/mocks/mock-extension-point-api.d.ts +1 -1
  41. package/dist/{experimental/testing → testing}/internal/mocks/mock-extension-point-api.js +1 -1
  42. package/dist/testing/internal/mocks/mock-hooks.d.ts +3 -0
  43. package/dist/{experimental/testing → testing}/internal/mocks/mock-hooks.js +10 -0
  44. package/dist/{experimental/testing → testing}/internal/print.js +1 -1
  45. package/dist/{experimental/testing → testing}/internal/query.d.ts +1 -1
  46. package/dist/{experimental/testing → testing}/internal/query.js +1 -1
  47. package/dist/{experimental/testing → testing}/internal/types-internal.d.ts +7 -3
  48. package/dist/testing/internal/types-internal.js +1 -0
  49. package/dist/{experimental/testing → testing}/render.d.ts +1 -1
  50. package/dist/{experimental/testing → testing}/render.js +7 -7
  51. package/dist/{experimental/testing → testing}/types.d.ts +25 -5
  52. package/dist/{experimental/testing → testing}/utils.d.ts +1 -1
  53. package/dist/{experimental/testing → testing}/utils.js +1 -1
  54. package/package.json +4 -3
  55. package/dist/experimental/testing/internal/mocks/mock-hooks.d.ts +0 -2
  56. /package/dist/{experimental/testing → testing}/__tests__/createRenderer.spec.d.ts +0 -0
  57. /package/dist/{experimental/testing → testing}/__tests__/createRenderer.spec.js +0 -0
  58. /package/dist/{experimental/testing → testing}/__tests__/debug.spec.d.ts +0 -0
  59. /package/dist/{experimental/testing → testing}/__tests__/find.spec.d.ts +0 -0
  60. /package/dist/{experimental/testing → testing}/__tests__/findAll.spec.d.ts +0 -0
  61. /package/dist/{experimental/testing → testing}/__tests__/findAllChildren.spec.d.ts +0 -0
  62. /package/dist/{experimental/testing → testing}/__tests__/findByTestId.spec.d.ts +0 -0
  63. /package/dist/{experimental/testing → testing}/__tests__/findChild.spec.d.ts +0 -0
  64. /package/dist/{experimental/testing → testing}/__tests__/fragments.spec.d.ts +0 -0
  65. /package/dist/{experimental/testing → testing}/__tests__/invalid-components.spec.d.ts +0 -0
  66. /package/dist/{experimental/testing → testing}/__tests__/isMatch.spec.d.ts +0 -0
  67. /package/dist/{experimental/testing → testing}/__tests__/logger.spec.d.ts +0 -0
  68. /package/dist/{experimental/testing → testing}/__tests__/maybeFind.spec.d.ts +0 -0
  69. /package/dist/{experimental/testing → testing}/__tests__/maybeFindByTestId.spec.d.ts +0 -0
  70. /package/dist/{experimental/testing → testing}/__tests__/maybeFindChild.spec.d.ts +0 -0
  71. /package/dist/{experimental/testing → testing}/__tests__/mocks.actions.spec.d.ts +0 -0
  72. /package/dist/{experimental/testing → testing}/__tests__/mocks.actions.spec.js +0 -0
  73. /package/dist/{experimental/testing → testing}/__tests__/mocks.context.spec.d.ts +0 -0
  74. /package/dist/{experimental/testing → testing}/__tests__/mocks.context.spec.js +0 -0
  75. /package/dist/{experimental/testing → testing}/__tests__/mocks.runServerlessFunction.spec.d.ts +0 -0
  76. /package/dist/{experimental/testing → testing}/__tests__/mocks.useAssociations.spec.d.ts +0 -0
  77. /package/dist/{experimental/testing → testing}/__tests__/mocks.useCrmProperties.spec.d.ts +0 -0
  78. /package/dist/{experimental/testing/__tests__/props.spec.d.ts → testing/__tests__/mocks.useExtensionActions.spec.d.ts} +0 -0
  79. /package/dist/{experimental/testing/__tests__/testId.spec.d.ts → testing/__tests__/mocks.useExtensionContext.spec.d.ts} +0 -0
  80. /package/dist/{experimental/testing/__tests__/trigger.spec.d.ts → testing/__tests__/props.spec.d.ts} +0 -0
  81. /package/dist/{experimental/testing/__tests__/type-utils.spec.d.ts → testing/__tests__/testId.spec.d.ts} +0 -0
  82. /package/dist/{experimental/testing/__tests__/waitFor.spec.d.ts → testing/__tests__/trigger.spec.d.ts} +0 -0
  83. /package/dist/{experimental/testing/internal/types-internal.js → testing/__tests__/type-utils.spec.d.ts} +0 -0
  84. /package/dist/{experimental/testing → testing}/index.d.ts +0 -0
  85. /package/dist/{experimental/testing → testing}/index.js +0 -0
  86. /package/dist/{experimental/testing → testing}/internal/constants.d.ts +0 -0
  87. /package/dist/{experimental/testing → testing}/internal/constants.js +0 -0
  88. /package/dist/{experimental/testing → testing}/internal/convert.d.ts +0 -0
  89. /package/dist/{experimental/testing → testing}/internal/debug.d.ts +0 -0
  90. /package/dist/{experimental/testing → testing}/internal/debug.js +0 -0
  91. /package/dist/{experimental/testing → testing}/internal/document.d.ts +0 -0
  92. /package/dist/{experimental/testing → testing}/internal/document.js +0 -0
  93. /package/dist/{experimental/testing → testing}/internal/element.js +0 -0
  94. /package/dist/{experimental/testing → testing}/internal/errors.d.ts +0 -0
  95. /package/dist/{experimental/testing → testing}/internal/fragment.d.ts +0 -0
  96. /package/dist/{experimental/testing → testing}/internal/fragment.js +0 -0
  97. /package/dist/{experimental/testing → testing}/internal/match.js +0 -0
  98. /package/dist/{experimental/testing → testing}/internal/mocks/index.js +0 -0
  99. /package/dist/{experimental/testing → testing}/internal/print.d.ts +0 -0
  100. /package/dist/{experimental/testing → testing}/internal/root.d.ts +0 -0
  101. /package/dist/{experimental/testing → testing}/internal/root.js +0 -0
  102. /package/dist/{experimental/testing → testing}/internal/text.d.ts +0 -0
  103. /package/dist/{experimental/testing → testing}/internal/text.js +0 -0
  104. /package/dist/{experimental/testing → testing}/internal/type-utils-internal.d.ts +0 -0
  105. /package/dist/{experimental/testing → testing}/internal/type-utils-internal.js +0 -0
  106. /package/dist/{experimental/testing → testing}/internal/utils/promise-utils.d.ts +0 -0
  107. /package/dist/{experimental/testing → testing}/internal/utils/promise-utils.js +0 -0
  108. /package/dist/{experimental/testing → testing}/type-utils.d.ts +0 -0
  109. /package/dist/{experimental/testing → testing}/type-utils.js +0 -0
  110. /package/dist/{experimental/testing → testing}/types.js +0 -0
@@ -0,0 +1,4 @@
1
+ import type { ExtensionPoints } from '../shared/types/extension-points.ts';
2
+ declare function useExtensionActionsInternal<ExtensionPoint extends keyof ExtensionPoints>(): import("../shared/types/extension-points.ts").ExtensionPointApiActions<ExtensionPoint>;
3
+ export declare const useExtensionActions: typeof useExtensionActionsInternal;
4
+ export {};
@@ -0,0 +1,6 @@
1
+ import { getWorkerGlobals } from "../internal/global-utils.js";
2
+ import { createMockAwareHook } from "../internal/hook-utils.js";
3
+ function useExtensionActionsInternal() {
4
+ return getWorkerGlobals().hsWorkerAPI.useExtensionActions();
5
+ }
6
+ export const useExtensionActions = createMockAwareHook('useExtensionActions', useExtensionActionsInternal);
@@ -0,0 +1,4 @@
1
+ import type { ExtensionPoints } from '../shared/types/extension-points.ts';
2
+ declare function useExtensionContextInternal<ExtensionPoint extends keyof ExtensionPoints>(): import("../shared/types/extension-points.ts").ExtensionPointApiContext<ExtensionPoint>;
3
+ export declare const useExtensionContext: typeof useExtensionContextInternal;
4
+ export {};
@@ -0,0 +1,6 @@
1
+ import { getWorkerGlobals } from "../internal/global-utils.js";
2
+ import { createMockAwareHook } from "../internal/hook-utils.js";
3
+ function useExtensionContextInternal() {
4
+ return getWorkerGlobals().hsWorkerAPI.useExtensionContext();
5
+ }
6
+ export const useExtensionContext = createMockAwareHook('useExtensionContext', useExtensionContextInternal);
package/dist/index.d.ts CHANGED
@@ -3,3 +3,5 @@ export { hubspot } from './hubspot.ts';
3
3
  export { logger } from './logger.ts';
4
4
  export * from './shared/types/index.ts';
5
5
  export { Accordion, Alert, AutoGrid, BarChart, Box, Button, ButtonRow, Card, Checkbox, CurrencyInput, DateInput, DescriptionList, DescriptionListItem, Divider, Dropdown, EmptyState, ErrorState, Flex, Form, Heading, Icon, Illustration, Image, Inline, Input, LineChart, Link, List, LoadingButton, LoadingSpinner, Modal, ModalBody, ModalFooter, MultiSelect, NumberInput, Panel, PanelBody, PanelFooter, PanelSection, ProgressBar, RadioButton, SearchInput, Select, Stack, Statistics, StatisticsItem, StatisticsTrend, StatusTag, StepIndicator, StepperInput, Tab, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, Tag, Text, TextArea, Textarea, Tile, TimeInput, Toggle, ToggleGroup, Tooltip, } from './shared/remoteComponents.tsx';
6
+ export { useExtensionContext } from './hooks/useExtensionContext.tsx';
7
+ export { useExtensionActions } from './hooks/useExtensionActions.tsx';
package/dist/index.js CHANGED
@@ -4,3 +4,5 @@ export { hubspot } from "./hubspot.js";
4
4
  export { logger } from "./logger.js";
5
5
  export * from "./shared/types/index.js";
6
6
  export { Accordion, Alert, AutoGrid, BarChart, Box, Button, ButtonRow, Card, Checkbox, CurrencyInput, DateInput, DescriptionList, DescriptionListItem, Divider, Dropdown, EmptyState, ErrorState, Flex, Form, Heading, Icon, Illustration, Image, Inline, Input, LineChart, Link, List, LoadingButton, LoadingSpinner, Modal, ModalBody, ModalFooter, MultiSelect, NumberInput, Panel, PanelBody, PanelFooter, PanelSection, ProgressBar, RadioButton, SearchInput, Select, Stack, Statistics, StatisticsItem, StatisticsTrend, StatusTag, StepIndicator, StepperInput, Tab, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, Tag, Text, TextArea, Textarea, Tile, TimeInput, Toggle, ToggleGroup, Tooltip, } from "./shared/remoteComponents.js";
7
+ export { useExtensionContext } from "./hooks/useExtensionContext.js";
8
+ export { useExtensionActions } from "./hooks/useExtensionActions.js";
@@ -25,6 +25,10 @@ const fakeWorkerGlobals = {
25
25
  extend_V2: () => {
26
26
  // No-op in test environment
27
27
  },
28
+ // @ts-expect-error we are not using the worker endpoint in tests env.
29
+ __useExtensionContext: () => {
30
+ // No-op in test environment
31
+ },
28
32
  };
29
33
  /**
30
34
  * Gets the worker globals object for the current environment.
@@ -1,4 +1,4 @@
1
- import { RendererMocksInternal } from '../experimental/testing/internal/types-internal.ts';
1
+ import { RendererSpies } from '../testing/types.ts';
2
2
  type AnyFunction = (...args: any[]) => any;
3
3
  /**
4
4
  * Creates a mock-aware hook function that can be used to mock the original hook function.
@@ -8,12 +8,19 @@ type AnyFunction = (...args: any[]) => any;
8
8
  * @param originalHookFunction The original hook function to call if no mock is found
9
9
  * @returns The mocked hook function or the original hook function if no mock is found
10
10
  */
11
- export declare const createMockAwareHook: <THookName extends keyof RendererMocksInternal, THookFunction extends AnyFunction>(hookName: THookName, originalHookFunction: THookFunction) => THookFunction;
11
+ export declare const createMockAwareHook: <THookName extends keyof RendererSpies, THookFunction extends AnyFunction>(hookName: THookName, originalHookFunction: THookFunction) => THookFunction;
12
+ /**
13
+ * A hook that provides access to the Mocks context.
14
+ * Returns the mocks object if inside a MocksContextProvider, otherwise returns null.
15
+ *
16
+ * @returns The mocks object or null if not in a test environment.
17
+ */
18
+ export declare function useMocksContext(): RendererSpies<"home" | "settings" | "crm.record.tab" | "crm.record.sidebar" | "crm.preview" | "helpdesk.sidebar" | "uie.playground.middle"> | null;
12
19
  /**
13
20
  * A React component that provides the Mocks context that can be used to provide mocks to the mock-aware hook functions.
14
21
  *
15
22
  * @param children The children to render.
16
23
  * @returns The children wrapped in the Mocks context provider.
17
24
  */
18
- export declare const MocksContextProvider: import("react").Provider<RendererMocksInternal | null>;
25
+ export declare const MocksContextProvider: import("react").Provider<RendererSpies<"home" | "settings" | "crm.record.tab" | "crm.record.sidebar" | "crm.preview" | "helpdesk.sidebar" | "uie.playground.middle"> | null>;
19
26
  export {};
@@ -10,7 +10,7 @@ const MocksContext = createContext(null);
10
10
  */
11
11
  export const createMockAwareHook = (hookName, originalHookFunction) => {
12
12
  const useWrapper = (...args) => {
13
- const mocks = useContext(MocksContext);
13
+ const mocks = useMocksContext();
14
14
  if (!mocks) {
15
15
  // If no mocks are provided, call the original hook function
16
16
  return originalHookFunction(...args);
@@ -25,6 +25,15 @@ export const createMockAwareHook = (hookName, originalHookFunction) => {
25
25
  };
26
26
  return useWrapper;
27
27
  };
28
+ /**
29
+ * A hook that provides access to the Mocks context.
30
+ * Returns the mocks object if inside a MocksContextProvider, otherwise returns null.
31
+ *
32
+ * @returns The mocks object or null if not in a test environment.
33
+ */
34
+ export function useMocksContext() {
35
+ return useContext(MocksContext);
36
+ }
28
37
  /**
29
38
  * A React component that provides the Mocks context that can be used to provide mocks to the mock-aware hook functions.
30
39
  *
@@ -1,5 +1,6 @@
1
1
  import { Logger } from './logger.ts';
2
2
  import { HubspotExtendFunction } from './extend.ts';
3
+ import type { ExtensionPoints, ExtensionPointApiContext, ExtensionPointApiActions } from './extension-points.ts';
3
4
  export interface WorkerGlobalsInternal {
4
5
  /**
5
6
  * A marker that the current global is a HubSpot extension worker.
@@ -14,4 +15,18 @@ export interface WorkerGlobalsInternal {
14
15
  * NOTE: `extend_V2` is used internally by `hubspot.extend` (where `hubspot` is imported from `@hubspot/ui-extensions`).
15
16
  */
16
17
  extend_V2: HubspotExtendFunction;
18
+ /**
19
+ * Namespace where all HubSpot APIs that go on the worker should live.
20
+ * This avoids polluting the global and reduces the possibility of customer code having collisions with our code.
21
+ */
22
+ hsWorkerAPI: {
23
+ /**
24
+ * Hook added to worker globals so customer code can access extension context at runtime.
25
+ */
26
+ useExtensionContext: <ExtensionPoint extends keyof ExtensionPoints>() => ExtensionPointApiContext<ExtensionPoint>;
27
+ /**
28
+ * Hook added to worker globals so customer code can access extension actions at runtime.
29
+ */
30
+ useExtensionActions: <ExtensionPoint extends keyof ExtensionPoints>() => ExtensionPointApiActions<ExtensionPoint>;
31
+ };
17
32
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, List, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, List, Text } from "../../index.js";
4
4
  import { createRenderer, isRenderedTextNode } from "../index.js";
5
5
  function MyComponent() {
6
6
  return (_jsxs(_Fragment, { children: [_jsx(ButtonRow, { children: _jsx(Button, { variant: "primary", overlay: _jsx(List, { children: _jsx(Text, { children: "Item 1" }) }), children: "Click me!" }) }), _jsx(Alert, { title: "My Alert" })] }));
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  import { ComponentNotFoundError, FindInvalidComponentError, } from "../internal/errors.js";
6
6
  describe('find()', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  describe('findAll()', () => {
6
6
  it('should allow finding all matching components', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  describe('findAllChildren()', () => {
6
6
  it('should allow finding all direct children from the root node', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  import { ComponentMismatchedByTestIdError, ComponentNotFoundByTestIdError, FindInvalidComponentError, } from "../internal/errors.js";
6
6
  describe('findByTestId()', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  import { ComponentNotFoundError, FindInvalidComponentError, } from "../internal/errors.js";
6
6
  describe('findChild()', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, List, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, List, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  import { InvalidFragmentPropArrayError } from "../internal/errors.js";
6
6
  describe('fragments', () => {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { describe, expect, it } from 'vitest';
4
- import { Alert, Button, ButtonRow, Text } from "../../../index.js";
4
+ import { Alert, Button, ButtonRow, Text } from "../../index.js";
5
5
  import { createRenderer } from "../index.js";
6
6
  import { InvalidComponentsError } from "../internal/errors.js";
7
7
  import { createDeferred } from "../internal/utils/promise-utils.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button } from "../../../index.js";
3
+ import { Alert, Button } from "../../index.js";
4
4
  import { createRenderer, isMatch, isRenderedFragmentNode, } from "../index.js";
5
5
  describe('isMatch()', () => {
6
6
  describe('isMatch() utility function', () => {
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { logger } from "../../../logger.js";
2
+ import { logger } from "../../logger.js";
3
3
  describe('logger in test environment', () => {
4
4
  it('should be available', () => {
5
5
  expect(logger.debug).toBeInstanceOf(Function);
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  describe('maybeFind()', () => {
6
6
  it('should return the element when found', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  import { ComponentMismatchedByTestIdError, FindInvalidComponentError, } from "../internal/errors.js";
6
6
  describe('maybeFindByTestId()', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Alert, Button, ButtonRow, Text } from "../../../index.js";
3
+ import { Alert, Button, ButtonRow, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  describe('maybeFindChild()', () => {
6
6
  it('should return direct child from the root node', () => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from 'vitest';
2
2
  import { createRenderer } from "../index.js";
3
- import { ServerlessExecutionStatus, } from "../../../shared/types/http-requests.js";
3
+ import { ServerlessExecutionStatus, } from "../../shared/types/http-requests.js";
4
4
  describe('mock runServerlessFunction', () => {
5
5
  it('should provide the ability to spy on the runServerlessFunction function', async () => {
6
6
  const { mocks } = createRenderer('crm.record.tab');
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Text } from "../../../index.js";
3
+ import { Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
- import { useAssociations } from "../../../crm/index.js";
5
+ import { useAssociations } from "../../crm/index.js";
6
6
  function MyComponent() {
7
7
  const { results, isLoading, error } = useAssociations({
8
8
  toObjectType: '0-1',
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Text } from "../../../index.js";
3
+ import { Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
- import { useCrmProperties } from "../../../crm/index.js";
5
+ import { useCrmProperties } from "../../crm/index.js";
6
6
  function MyComponent() {
7
7
  const { properties, isLoading, error } = useCrmProperties([
8
8
  'firstname',
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createRenderer } from "../index.js";
3
+ import { useExtensionActions } from "../../hooks/useExtensionActions.js";
4
+ import { Button } from "../../index.js";
5
+ function MyActionsCrmComponent() {
6
+ const actions = useExtensionActions();
7
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { testId: "reloadButton", onClick: () => actions.reloadPage(), children: "Reload Page" }), _jsx(Button, { testId: "fetchButton", onClick: () => {
8
+ actions.fetchCrmObjectProperties(['firstname', 'lastname']);
9
+ }, children: "Fetch Properties" })] }));
10
+ }
11
+ function MyActionsHomeComponent() {
12
+ const actions = useExtensionActions();
13
+ return (_jsx(_Fragment, { children: _jsx(Button, { testId: "copyButton", onClick: () => actions.copyTextToClipboard('Hello world'), children: "Copy Text" }) }));
14
+ }
15
+ describe('mock actions', () => {
16
+ it('should provide the ability to spy on the actions for the "crm.record.tab" extension point', () => {
17
+ const { mocks, render, findByTestId } = createRenderer('crm.record.tab');
18
+ const { actions } = mocks;
19
+ render(_jsx(MyActionsCrmComponent, {}));
20
+ findByTestId(Button, 'reloadButton').trigger('onClick');
21
+ expect(actions.reloadPage.callCount).toBe(1);
22
+ findByTestId(Button, 'fetchButton').trigger('onClick');
23
+ expect(actions.fetchCrmObjectProperties.callCount).toBe(1);
24
+ });
25
+ it('should provide the ability to spy on the actions for the "home" extension point', () => {
26
+ const { mocks, render, findByTestId } = createRenderer('home');
27
+ const { actions } = mocks;
28
+ render(_jsx(MyActionsHomeComponent, {}));
29
+ findByTestId(Button, 'copyButton').trigger('onClick');
30
+ expect(actions.copyTextToClipboard.callCount).toBe(1);
31
+ });
32
+ });
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { describe, expect, it } from 'vitest';
3
+ import { Text } from "../../index.js";
4
+ import { createRenderer } from "../index.js";
5
+ import { useExtensionContext } from "../../hooks/useExtensionContext.js";
6
+ function MyComponent() {
7
+ const context = useExtensionContext();
8
+ return (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "location-text", children: context.location }), _jsx(Text, { testId: "user-email", children: context.user.email }), _jsx(Text, { testId: "user-firstName", children: context.user.firstName }), _jsx(Text, { testId: "user-lastName", children: context.user.lastName }), _jsx(Text, { testId: "portal-id", children: context.portal.id }), _jsx(Text, { testId: "portal-timezone", children: context.portal.timezone }), 'crm' in context && (_jsxs(_Fragment, { children: [_jsx(Text, { testId: "crm-objectId", children: context.crm.objectId }), _jsx(Text, { testId: "crm-objectTypeId", children: context.crm.objectTypeId })] }))] }));
9
+ }
10
+ describe('mock useExtensionContext', () => {
11
+ it('should provide a CRM mock implementation', () => {
12
+ const { render, findByTestId } = createRenderer('crm.record.tab');
13
+ render(_jsx(MyComponent, {}));
14
+ expect(findByTestId(Text, 'location-text').text).toEqual('crm.record.tab');
15
+ expect(findByTestId(Text, 'user-email').text).toEqual('fake_email@example.com');
16
+ expect(findByTestId(Text, 'user-firstName').text).toEqual('fake_firstName');
17
+ expect(findByTestId(Text, 'user-lastName').text).toEqual('fake_lastName');
18
+ expect(findByTestId(Text, 'portal-id').text).toEqual('123');
19
+ expect(findByTestId(Text, 'portal-timezone').text).toEqual('America/New_York');
20
+ expect(findByTestId(Text, 'crm-objectId').text).toEqual('123');
21
+ expect(findByTestId(Text, 'crm-objectTypeId').text).toEqual('0-1');
22
+ });
23
+ it('should provide a generic mock implementation without CRM properties', () => {
24
+ const { render, findByTestId, maybeFindByTestId } = createRenderer('settings');
25
+ render(_jsx(MyComponent, {}));
26
+ expect(findByTestId(Text, 'location-text').text).toEqual('settings');
27
+ expect(findByTestId(Text, 'user-email').text).toEqual('fake_email@example.com');
28
+ expect(findByTestId(Text, 'user-firstName').text).toEqual('fake_firstName');
29
+ expect(findByTestId(Text, 'user-lastName').text).toEqual('fake_lastName');
30
+ expect(findByTestId(Text, 'portal-id').text).toEqual('123');
31
+ expect(findByTestId(Text, 'portal-timezone').text).toEqual('America/New_York');
32
+ // doesn't have the CRM properties
33
+ expect(maybeFindByTestId(Text, 'crm-objectId')).toBeNull();
34
+ expect(maybeFindByTestId(Text, 'crm-objectTypeId')).toBeNull();
35
+ });
36
+ it('should use the mutated context', () => {
37
+ const newName = 'Gracie';
38
+ const { render, findByTestId, mocks } = createRenderer('settings');
39
+ mocks.context.user.firstName = newName;
40
+ render(_jsx(MyComponent, {}));
41
+ // no longer has the default context value, it has the mutate context
42
+ expect(findByTestId(Text, 'user-firstName').text).toEqual(newName);
43
+ // other properties stay the same
44
+ expect(findByTestId(Text, 'location-text').text).toEqual('settings');
45
+ });
46
+ });
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Button, ButtonRow } from "../../../index.js";
3
+ import { Button, ButtonRow } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  describe('props', () => {
6
6
  it('should remove the children prop from the props object', () => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button } from "../../../index.js";
2
+ import { Button } from "../../index.js";
3
3
  import { createRenderer } from "../index.js";
4
4
  import { DuplicateTestIdError } from "../internal/errors.js";
5
5
  describe('testId', () => {
@@ -1,7 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { describe, expect, it } from 'vitest';
4
- import { Button } from "../../../index.js";
4
+ import { Button } from "../../index.js";
5
5
  import { createRenderer } from "../index.js";
6
6
  import { InvalidEventFunctionError, MissingEventFunctionError, } from "../internal/errors.js";
7
7
  describe('trigger()', () => {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { describe, expect, it } from 'vitest';
3
- import { Button, ButtonRow, Text } from "../../../index.js";
3
+ import { Button, ButtonRow, Text } from "../../index.js";
4
4
  import { createRenderer } from "../index.js";
5
5
  import { isRenderedElementNode, isRenderedFragmentNode, isRenderedRootNode, isRenderedTextNode, } from "../type-utils.js";
6
6
  import { RenderedNodeType } from "../types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
- import { Button } from "../../../index.js";
4
+ import { Button } from "../../index.js";
5
5
  import { createRenderer } from "../index.js";
6
6
  import { WaitForTimeoutError } from "../internal/errors.js";
7
7
  describe('waitFor()', () => {
@@ -3,7 +3,7 @@ import { createElementNode } from "./element.js";
3
3
  import { DuplicateTestIdError, InvalidFragmentPropArrayError, } from "./errors.js";
4
4
  import { createFragmentNode } from "./fragment.js";
5
5
  import { createTextNode } from "./text.js";
6
- import { __hubSpotComponentRegistry } from "../../../shared/remoteComponents.js";
6
+ import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
7
7
  import { isRenderedTextNode } from "../type-utils.js";
8
8
  import { EMPTY_RENDERED_CHILD_NODES } from "./constants.js";
9
9
  import { asRenderedParentNode } from "./type-utils-internal.js";
@@ -1,4 +1,4 @@
1
- import type { UnknownComponentProps } from '../../../shared/types/shared.ts';
1
+ import type { UnknownComponentProps } from '../../shared/types/shared.ts';
2
2
  import { RenderedElementNode } from '../types.ts';
3
3
  import type { RenderedDocumentInternal } from './types-internal.ts';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { EXTENSION_POINT_LOCATIONS } from "../../../shared/types/extension-points.js";
1
+ import { EXTENSION_POINT_LOCATIONS } from "../../shared/types/extension-points.js";
2
2
  import { printNode } from "./print.js";
3
3
  import { asRenderedNode } from "./type-utils-internal.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { UnknownComponentProps } from '../../../shared/types/shared.ts';
1
+ import { UnknownComponentProps } from '../../shared/types/shared.ts';
2
2
  import { ElementMatcher, RenderedElementNode } from '../types.ts';
3
3
  /**
4
4
  * Checks if the element matches the matcher.
@@ -1,6 +1,6 @@
1
1
  import { RendererSpies } from '../../types.ts';
2
2
  import { RendererMocksInternal } from '../types-internal.ts';
3
- import { ExtensionPointLocation } from '../../../../shared/types/extension-points.ts';
3
+ import { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
4
4
  /**
5
5
  * An object containing the mocks and spies.
6
6
  */
@@ -1,2 +1,2 @@
1
- import { ExtensionPointApi, type ExtensionPointLocation } from '../../../../shared/types/extension-points.ts';
1
+ import { ExtensionPointApi, type ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
2
2
  export declare const createMockExtensionPointApi: (extensionPointLocation: ExtensionPointLocation) => ExtensionPointApi<ExtensionPointLocation>;
@@ -1,4 +1,4 @@
1
- import { ServerlessExecutionStatus, } from "../../../../shared/types/http-requests.js";
1
+ import { ServerlessExecutionStatus, } from "../../../shared/types/http-requests.js";
2
2
  const fakePrefix = 'fake_';
3
3
  const createMockServerlessFuncRunner = () => {
4
4
  return () => Promise.resolve({
@@ -0,0 +1,3 @@
1
+ import { RendererMockHooksInternal } from '../types-internal.ts';
2
+ import type { ExtensionPointLocation } from '../../../shared/types/extension-points.ts';
3
+ export declare const createMockHooks: <TExtensionPointLocation extends ExtensionPointLocation>() => RendererMockHooksInternal;
@@ -1,3 +1,4 @@
1
+ import { useMocksContext } from "../../../internal/hook-utils.js";
1
2
  /**
2
3
  * Creates a record of property names and their fake values.
3
4
  *
@@ -55,5 +56,14 @@ export const createMockHooks = () => {
55
56
  },
56
57
  };
57
58
  },
59
+ useExtensionContext: () => {
60
+ const mocks = useMocksContext();
61
+ return mocks.context;
62
+ },
63
+ useExtensionActions: () => {
64
+ const mocks = useMocksContext();
65
+ return mocks
66
+ .actions;
67
+ },
58
68
  };
59
69
  };
@@ -1,4 +1,4 @@
1
- import { __hubSpotComponentRegistry } from "../../../shared/remoteComponents.js";
1
+ import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
2
2
  import { isRenderedElementNode, isRenderedFragmentNode, isRenderedRootNode, isRenderedTextNode, } from "../type-utils.js";
3
3
  const INDENT_STRING = ' ';
4
4
  const printTextNode = (node, indent, printContext) => {
@@ -1,4 +1,4 @@
1
- import type { HubSpotReactComponent, UnknownComponentProps } from '../../../shared/types/shared.ts';
1
+ import type { HubSpotReactComponent, UnknownComponentProps } from '../../shared/types/shared.ts';
2
2
  import type { ElementMatcher, RenderedElementNode } from '../types.ts';
3
3
  import type { RenderedDocumentInternal, RenderedParentNodeInternal } from './types-internal.ts';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { __hubSpotComponentRegistry } from "../../../shared/remoteComponents.js";
1
+ import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
2
2
  import { isRenderedElementNode } from "../type-utils.js";
3
3
  import { ComponentMismatchedByTestIdError, ComponentNotFoundByTestIdError, ComponentNotFoundError, FindInvalidComponentError, InvalidComponentsError, } from "./errors.js";
4
4
  import { checkElementMatches } from "./match.js";
@@ -1,7 +1,9 @@
1
1
  import type { RemoteComponent, RemoteFragment, RemoteRoot, RemoteText } from '@remote-ui/core';
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';
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 { useExtensionContext } from '../../hooks/useExtensionContext.tsx';
6
+ import { useExtensionActions } from '../../hooks/useExtensionActions.tsx';
5
7
  import type { ElementMatcher, RenderedElementNode, RenderedFragmentNode, RenderedNode, RenderedParentNode, RenderedRootNode, RenderedTextNode } from '../types.ts';
6
8
  export type RemoteChildNode = RemoteComponent<any, RemoteRoot> | RemoteText<RemoteRoot>;
7
9
  export type RemoteParentNode = RemoteRoot | RemoteComponent<any, RemoteRoot> | RemoteFragment;
@@ -59,6 +61,8 @@ export type RenderedNodeInternal = RenderedElementNodeInternal | RenderedTextNod
59
61
  export interface RendererMockHooksInternal {
60
62
  useCrmProperties: typeof useCrmProperties;
61
63
  useAssociations: typeof useAssociations;
64
+ useExtensionContext: typeof useExtensionContext;
65
+ useExtensionActions: typeof useExtensionActions;
62
66
  }
63
67
  export type RendererMocksInternal<TExtensionPointLocationName extends ExtensionPointLocation = ExtensionPointLocation> = RendererMockHooksInternal & ExtensionPointApi<TExtensionPointLocationName>;
64
68
  export type AnyFunction = (...args: any[]) => any;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { ExtensionPointLocation } from '../../shared/types/extension-points.ts';
1
+ import { ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
2
  import { Renderer } from './types.ts';
3
3
  /**
4
4
  * Creates a renderer object with methods for rendering and testing UI extension components.
@@ -4,8 +4,8 @@ import { createRoot as createReactRoot } from '@remote-ui/react';
4
4
  import { convertRemoteRoot } from "./internal/convert.js";
5
5
  import { createDocument } from "./internal/document.js";
6
6
  import { InvalidComponentsError, InvalidExtensionPointLocationError, WaitForTimeoutError, } from "./internal/errors.js";
7
- import { EXTENSION_POINT_LOCATIONS, } from "../../shared/types/extension-points.js";
8
- import { MocksContextProvider } from "../../internal/hook-utils.js";
7
+ import { EXTENSION_POINT_LOCATIONS, } from "../shared/types/extension-points.js";
8
+ import { MocksContextProvider } from "../internal/hook-utils.js";
9
9
  import { createMocksWithSpies } from "./internal/mocks/index.js";
10
10
  import { find, findAll, findAllChildren, findByTestId, findChild, maybeFind, maybeFindByTestId, maybeFindChild, } from "./internal/query.js";
11
11
  import { createRootNode } from "./internal/root.js";
@@ -21,7 +21,7 @@ const DEFAULT_WAIT_FOR_OPTIONS = {
21
21
  * @param node The React node to render.
22
22
  * @returns A render result object
23
23
  */
24
- const render = (node, mocks) => {
24
+ const render = (node, mocksWithSpies) => {
25
25
  let dirty = true;
26
26
  let waitForChecksQueued = false;
27
27
  let waitForList = [];
@@ -75,7 +75,7 @@ const render = (node, mocks) => {
75
75
  };
76
76
  const remoteRoot = createRemoteRoot(remoteChannel);
77
77
  const reactRoot = createReactRoot(remoteRoot);
78
- reactRoot.render(_jsx(MocksContextProvider, { value: mocks, children: node }));
78
+ reactRoot.render(_jsx(MocksContextProvider, { value: mocksWithSpies, children: node }));
79
79
  remoteRoot.mount();
80
80
  let maybeRenderedRootNode;
81
81
  /**
@@ -175,13 +175,13 @@ export const createRenderer = (extensionPointLocation) => {
175
175
  return renderResult;
176
176
  };
177
177
  const getLatestRootNode = () => getRenderResult().getLatestRootNode();
178
- const { mocks, spies } = createMocksWithSpies(extensionPointLocation);
178
+ const { spies: mocksWithSpies } = createMocksWithSpies(extensionPointLocation);
179
179
  return {
180
180
  render: (node) => {
181
- renderResult = render(node, mocks);
181
+ renderResult = render(node, mocksWithSpies);
182
182
  return asRenderedRootNode(renderResult.getLatestRootNode());
183
183
  },
184
- mocks: spies,
184
+ mocks: mocksWithSpies,
185
185
  find: (component, matcher) => {
186
186
  return find(getLatestRootNode(), component, matcher);
187
187
  },
@@ -1,9 +1,11 @@
1
- import { ExtensionPointApi, ExtensionPointApiActions, ExtensionPointLocation } from '../../shared/types/extension-points.ts';
2
- import { ServerlessFuncRunner } from '../../shared/types/http-requests.ts';
1
+ import { ExtensionPointApi, ExtensionPointApiActions, ExtensionPointLocation } from '../shared/types/extension-points.ts';
2
+ import { ServerlessFuncRunner } from '../shared/types/http-requests.ts';
3
3
  import { SpyImpl } from 'tinyspy';
4
- import { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../../shared/types/shared.ts';
5
- import { useAssociations, useCrmProperties } from '../../crm/index.ts';
4
+ import { HubSpotReactComponent, HubSpotReactFragmentProp, UnknownComponentProps } from '../shared/types/shared.ts';
5
+ import { useAssociations, useCrmProperties } from '../crm/index.ts';
6
+ import { useExtensionContext } from '../hooks/useExtensionContext.tsx';
6
7
  import { AnyFunction } from './internal/types-internal.ts';
8
+ import { useExtensionActions } from '../hooks/useExtensionActions.tsx';
7
9
  /**
8
10
  * The type of a rendered node.
9
11
  */
@@ -258,7 +260,7 @@ export type ExtensionPointApiActionSpies<TExtensionPointLocation extends Extensi
258
260
  /**
259
261
  * An object containing the spies for the various functions.
260
262
  */
261
- export interface RendererSpies<TExtensionPointLocation extends ExtensionPointLocation> {
263
+ export interface RendererSpies<TExtensionPointLocation extends ExtensionPointLocation = ExtensionPointLocation> {
262
264
  /**
263
265
  * A spy for the `useCrmProperties` hook function.
264
266
  * The spy can be used to track the calls to the hook function and also control the
@@ -277,6 +279,24 @@ export interface RendererSpies<TExtensionPointLocation extends ExtensionPointLoc
277
279
  * information about spies and the supported API.
278
280
  */
279
281
  useAssociations: FunctionSpy<typeof useAssociations>;
282
+ /**
283
+ * A spy for the `useExtensionContext` hook function.
284
+ * The spy can be used to track the calls to the hook function and also control the
285
+ * return result of the hook function.
286
+ *
287
+ * See the [tinyspy](https://github.com/tiny-spy/tinyspy) library for more
288
+ * information about spies and the supported API.
289
+ */
290
+ useExtensionContext: FunctionSpy<typeof useExtensionContext>;
291
+ /**
292
+ * A spy for the `useExtensionActions` hook function.
293
+ * The spy can be used to track the calls to the hook function and also control the
294
+ * return result of the hook function.
295
+ *
296
+ * See the [tinyspy](https://github.com/tiny-spy/tinyspy) library for more
297
+ * information about spies and the supported API.
298
+ */
299
+ useExtensionActions: FunctionSpy<typeof useExtensionActions>;
280
300
  /**
281
301
  * Mock context object that contains fake context data for the extension point API.
282
302
  */
@@ -1,4 +1,4 @@
1
- import { type HubSpotReactComponent, type UnknownComponentProps } from '../../shared/types/shared.ts';
1
+ import { type HubSpotReactComponent, type UnknownComponentProps } from '../shared/types/shared.ts';
2
2
  import { type ElementMatcher, type RenderedElementNode, type RenderedNode } from './types.ts';
3
3
  /**
4
4
  * Checks if the node matches the component and matcher.
@@ -1,5 +1,5 @@
1
1
  import { RenderedNodeType, } from "./types.js";
2
- import { __hubSpotComponentRegistry } from "../../shared/remoteComponents.js";
2
+ import { __hubSpotComponentRegistry } from "../shared/remoteComponents.js";
3
3
  import { checkElementMatches } from "./internal/match.js";
4
4
  /**
5
5
  * Checks if the node matches the component and matcher.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/ui-extensions",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,13 +28,14 @@
28
28
  "./crm": "./dist/crm/index.js",
29
29
  "./pages/home": "./dist/pages/home/index.js",
30
30
  "./experimental": "./dist/experimental/index.js",
31
- "./experimental/testing": "./dist/experimental/testing/index.js"
31
+ "./testing": "./dist/testing/index.js"
32
32
  },
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
35
  "@remote-ui/core": "2.2.7",
36
36
  "@remote-ui/react": "5.0.2",
37
37
  "react": "18.3.1",
38
+ "react-reconciler": "0.29.2",
38
39
  "tinyspy": "4.0.4"
39
40
  },
40
41
  "engines": {
@@ -73,5 +74,5 @@
73
74
  "tsd": {
74
75
  "directory": "src/__tests__/test-d"
75
76
  },
76
- "gitHead": "c97841ad97f7ebb9689a9cde03d179e1c98d7207"
77
+ "gitHead": "e262c2b6780bb1f65bd09b1df4a2e724cd627c19"
77
78
  }
@@ -1,2 +0,0 @@
1
- import { RendererMockHooksInternal } from '../types-internal.ts';
2
- export declare const createMockHooks: () => RendererMockHooksInternal;
File without changes
File without changes