@tambo-ai/react 0.66.1 → 0.67.0
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.
- package/dist/context-helpers/current-interactables-context-helper.d.ts +2 -2
- package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.js +17 -23
- package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/dist/hoc/with-tambo-interactable.js +0 -1
- package/dist/hoc/with-tambo-interactable.js.map +1 -1
- package/dist/hooks/use-component-state.d.ts +16 -1
- package/dist/hooks/use-component-state.d.ts.map +1 -1
- package/dist/hooks/use-component-state.js +72 -12
- package/dist/hooks/use-component-state.js.map +1 -1
- package/dist/hooks/use-component-state.test.js +42 -0
- package/dist/hooks/use-component-state.test.js.map +1 -1
- package/dist/hooks/use-current-message.d.ts +3 -0
- package/dist/hooks/use-current-message.d.ts.map +1 -1
- package/dist/hooks/use-current-message.js +6 -5
- package/dist/hooks/use-current-message.js.map +1 -1
- package/dist/hooks/use-current-message.test.js +5 -0
- package/dist/hooks/use-current-message.test.js.map +1 -1
- package/dist/model/component-metadata.d.ts +2 -2
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/tambo-interactable.d.ts +6 -0
- package/dist/model/tambo-interactable.d.ts.map +1 -1
- package/dist/model/tambo-interactable.js.map +1 -1
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js +87 -87
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +1 -0
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +83 -47
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.test.d.ts +2 -0
- package/dist/providers/tambo-interactable-provider.test.d.ts.map +1 -0
- package/dist/providers/tambo-interactable-provider.test.js +62 -0
- package/dist/providers/tambo-interactable-provider.test.js.map +1 -0
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +8 -8
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context.test.js +10 -10
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +28 -18
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +57 -28
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.js +21 -19
- package/dist/providers/tambo-thread-provider.test.js.map +1 -1
- package/dist/schema/alias.d.ts +3 -0
- package/dist/schema/alias.d.ts.map +1 -0
- package/dist/schema/alias.js +6 -0
- package/dist/schema/alias.js.map +1 -0
- package/dist/schema/json-schema.js +29 -29
- package/dist/schema/json-schema.js.map +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +20 -9
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/schema.test.js +291 -3
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/schema/standard-schema.js +8 -8
- package/dist/schema/standard-schema.js.map +1 -1
- package/dist/schema/validate.test.js +31 -31
- package/dist/schema/validate.test.js.map +1 -1
- package/dist/schema/zod.d.ts +1 -1
- package/dist/schema/zod.d.ts.map +1 -1
- package/dist/schema/zod.js +27 -26
- package/dist/schema/zod.js.map +1 -1
- package/dist/schema/zod.test.d.ts +2 -0
- package/dist/schema/zod.test.d.ts.map +1 -0
- package/dist/schema/zod.test.js +551 -0
- package/dist/schema/zod.test.js.map +1 -0
- package/dist/util/registry-validators.d.ts.map +1 -1
- package/dist/util/registry-validators.js +40 -0
- package/dist/util/registry-validators.js.map +1 -1
- package/dist/util/registry-validators.test.js +69 -0
- package/dist/util/registry-validators.test.js.map +1 -1
- package/dist/util/registry.d.ts +1 -5
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +1 -5
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.js +80 -67
- package/dist/util/registry.test.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.d.ts +2 -2
- package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.js +17 -23
- package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/esm/hoc/with-tambo-interactable.js +0 -1
- package/esm/hoc/with-tambo-interactable.js.map +1 -1
- package/esm/hooks/use-component-state.d.ts +16 -1
- package/esm/hooks/use-component-state.d.ts.map +1 -1
- package/esm/hooks/use-component-state.js +74 -14
- package/esm/hooks/use-component-state.js.map +1 -1
- package/esm/hooks/use-component-state.test.js +40 -1
- package/esm/hooks/use-component-state.test.js.map +1 -1
- package/esm/hooks/use-current-message.d.ts +3 -0
- package/esm/hooks/use-current-message.d.ts.map +1 -1
- package/esm/hooks/use-current-message.js +2 -1
- package/esm/hooks/use-current-message.js.map +1 -1
- package/esm/hooks/use-current-message.test.js +5 -0
- package/esm/hooks/use-current-message.test.js.map +1 -1
- package/esm/model/component-metadata.d.ts +2 -2
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/tambo-interactable.d.ts +6 -0
- package/esm/model/tambo-interactable.d.ts.map +1 -1
- package/esm/model/tambo-interactable.js.map +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +1 -0
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +55 -19
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.test.d.ts +2 -0
- package/esm/providers/tambo-interactable-provider.test.d.ts.map +1 -0
- package/esm/providers/tambo-interactable-provider.test.js +57 -0
- package/esm/providers/tambo-interactable-provider.test.js.map +1 -0
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +16 -6
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +57 -28
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.js +8 -6
- package/esm/providers/tambo-thread-provider.test.js.map +1 -1
- package/esm/schema/alias.d.ts +3 -0
- package/esm/schema/alias.d.ts.map +1 -0
- package/esm/schema/alias.js +13 -0
- package/esm/schema/alias.js.map +1 -0
- package/esm/schema/json-schema.js +1 -1
- package/esm/schema/json-schema.js.map +1 -1
- package/esm/schema/schema.d.ts.map +1 -1
- package/esm/schema/schema.js +20 -9
- package/esm/schema/schema.js.map +1 -1
- package/esm/schema/schema.test.js +258 -3
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/schema/standard-schema.js +1 -1
- package/esm/schema/standard-schema.js.map +1 -1
- package/esm/schema/validate.test.js +1 -1
- package/esm/schema/validate.test.js.map +1 -1
- package/esm/schema/zod.d.ts +1 -1
- package/esm/schema/zod.d.ts.map +1 -1
- package/esm/schema/zod.js +27 -26
- package/esm/schema/zod.js.map +1 -1
- package/esm/schema/zod.test.d.ts +2 -0
- package/esm/schema/zod.test.d.ts.map +1 -0
- package/esm/schema/zod.test.js +516 -0
- package/esm/schema/zod.test.js.map +1 -0
- package/esm/util/registry-validators.d.ts.map +1 -1
- package/esm/util/registry-validators.js +40 -0
- package/esm/util/registry-validators.js.map +1 -1
- package/esm/util/registry-validators.test.js +69 -0
- package/esm/util/registry-validators.test.js.map +1 -1
- package/esm/util/registry.d.ts +1 -5
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +1 -5
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.js +80 -67
- package/esm/util/registry.test.js.map +1 -1
- package/package.json +2 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACN,CAAC;IAET,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC,EACvB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC,EAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;QAE5B,oBAAC,2BAA2B,QAAE,QAAQ,CAA+B,CACnD,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E;oBACV,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC;YACJ,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAE3B,OAAO,4CAAiB,OAAO,YAAY,CAAC;QAC9C,CAAC,CAAC;QAEF,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAC5B,oBAAoB,CAClB,oBAAC,yBAAyB;YACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,MAAM,GAAG;YACjC,oBAAC,aAAa,OAAG,CACS,CAC7B,CACF,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,gEAAgE;YAChE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YAE5B,oDAAoD;YACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CACrC,CAAC;YACF,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zodInternalAlias\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext - Edge Cases & Advanced Scenarios\", () => {\n test(\"handles components without propsSchema gracefully\", async () => {\n const SimpleComponent: React.FC<{ text: string }> = ({ text }) => (\n <div>{text}</div>\n );\n\n const InteractableSimpleComponent = withTamboInteractable(SimpleComponent, {\n componentName: \"SimpleComponent\",\n description: \"A component without schema\",\n // No propsSchema provided\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableSimpleComponent text=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n const component = entry!.context.components[0];\n expect(component.propsSchema).toBe(\"Not specified\");\n });\n });\n\n test(\"handles component unmounting and remounting correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showNote, setShowNote] = React.useState(true);\n\n React.useEffect(() => {\n // Toggle the note on/off to test unmounting\n const timeout = setTimeout(() => setShowNote(false), 100);\n const timeout2 = setTimeout(() => setShowNote(true), 200);\n return () => {\n clearTimeout(timeout);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n {showNote && <InteractableNote title=\"dynamic note\" />}\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(\n () => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n },\n { timeout: 1000 },\n );\n\n // Eventually should show the note again\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(1);\n },\n { timeout: 1000 },\n );\n });\n\n test(\"context helper updates when props change from parent\", async () => {\n const Counter: React.FC<{ count: number; label?: string }> = ({\n count,\n label = \"Count\",\n }) => (\n <div>\n {label}: {count}\n </div>\n );\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter component\",\n propsSchema: z.object({\n count: z.number(),\n label: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [count, setCount] = React.useState(0);\n const [label, setLabel] = React.useState(\"Items\");\n\n React.useEffect(() => {\n const timeout1 = setTimeout(() => setCount(5), 100);\n const timeout2 = setTimeout(() => setLabel(\"Updated Items\"), 200);\n return () => {\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n <InteractableCounter count={count} label={label} />\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n });\n\n // Wait for updates to propagate\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n if (entry?.context?.components?.[0]) {\n const props = entry.context.components[0].props;\n expect(props.count).toBe(5);\n expect(props.label).toBe(\"Updated Items\");\n }\n },\n { timeout: 1000 },\n );\n });\n\n test(\"multiple providers with nested context helpers work correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let outerContexts: any[] = [];\n let innerContexts: any[] = [];\n\n const OuterTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n outerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"outer-ready\">outer ready</div>;\n };\n\n const InnerTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n innerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"inner-ready\">inner ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"outer note\" />\n <OuterTestComponent />\n <TamboContextHelpersProvider\n contextHelpers={{\n customContext: () => ({ custom: \"inner\" }),\n }}\n >\n <TamboInteractableProvider>\n <InteractableNote title=\"inner note\" />\n <InnerTestComponent />\n </TamboInteractableProvider>\n </TamboContextHelpersProvider>\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"outer-ready\")).toBeInTheDocument();\n expect(getByTestId(\"inner-ready\")).toBeInTheDocument();\n });\n\n await waitFor(() => {\n // Outer context should have outer note\n const outerEntry = outerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(outerEntry?.context?.components).toHaveLength(1);\n expect(outerEntry?.context?.components[0]?.props?.title).toBe(\n \"outer note\",\n );\n\n // Inner context should have inner note and custom context\n const innerEntry = innerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(innerEntry?.context?.components).toHaveLength(1);\n expect(innerEntry?.context?.components[0]?.props?.title).toBe(\n \"inner note\",\n );\n\n const customEntry = innerContexts.find(\n (c: any) => c.name === \"customContext\",\n );\n expect(customEntry?.context).toEqual({ custom: \"inner\" });\n });\n });\n\n test(\"provider cleanup removes helper when last provider unmounts\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showProvider, setShowProvider] = React.useState(true);\n\n React.useEffect(() => {\n const timeout = setTimeout(() => setShowProvider(false), 200);\n return () => clearTimeout(timeout);\n }, []);\n\n return (\n <>\n {showProvider && (\n <TamboInteractableProvider>\n <InteractableNote title=\"will disappear\" />\n </TamboInteractableProvider>\n )}\n <TestComponent />\n </>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n // Initially should have the context\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n });\n\n // After provider unmounts, context should be gone\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined();\n },\n { timeout: 1000 },\n );\n });\n\n test(\"helper error handling doesn't crash the system\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Mock console.error to capture error logs\n const consoleSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext, addContextHelper } =\n useTamboContextHelpers();\n\n React.useEffect(() => {\n // Add a helper that throws an error\n addContextHelper(\"errorHelper\", () => {\n throw new Error(\"Test error in helper\");\n });\n }, [addContextHelper]);\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext()\n .then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n })\n .catch(() => {\n // Should not reach here - errors should be handled gracefully\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n // Should still have the interactables context despite the error\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n\n // Error helper should not be present (filtered out)\n const errorEntry = capturedContexts.find(\n (c: any) => c.name === \"errorHelper\",\n );\n expect(errorEntry).toBeUndefined();\n });\n\n consoleSpy.mockRestore();\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACN,CAAC;IAET,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC,EACvB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC,EAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;QAE5B,oBAAC,2BAA2B,QAAE,QAAQ,CAA+B,CACnD,CACrB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,mEAAmE,EA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ACJ,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAE3B,OAAO,4CAAiB,OAAO,YAAY,CAAC;QAC9C,CAAC,CAAC;QAEF,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAC5B,oBAAoB,CAClB,oBAAC,yBAAyB;YACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,MAAM,GAAG;YACjC,oBAAC,aAAa,OAAG,CACS,CAC7B,CACF,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,gEAAgE;YAChE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YAE5B,oDAAoD;YACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CACrC,CAAC;YACF,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext - Edge Cases & Advanced Scenarios\", () => {\n test(\"handles components without propsSchema gracefully\", async () => {\n const SimpleComponent: React.FC<{ text: string }> = ({ text }) => (\n <div>{text}</div>\n );\n\n const InteractableSimpleComponent = withTamboInteractable(SimpleComponent, {\n componentName: \"SimpleComponent\",\n description: \"A component without schema\",\n // No propsSchema provided\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableSimpleComponent text=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n const component = entry!.context.components[0];\n expect(component.propsSchema).toBe(\"Not specified\");\n });\n });\n\n test(\"handles component unmounting and remounting correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showNote, setShowNote] = React.useState(true);\n\n React.useEffect(() => {\n // Toggle the note on/off to test unmounting\n const timeout = setTimeout(() => setShowNote(false), 100);\n const timeout2 = setTimeout(() => setShowNote(true), 200);\n return () => {\n clearTimeout(timeout);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n {showNote && <InteractableNote title=\"dynamic note\" />}\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(\n () => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n },\n { timeout: 1000 },\n );\n\n // Eventually should show the note again\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(1);\n },\n { timeout: 1000 },\n );\n });\n\n test(\"context helper updates when props change from parent\", async () => {\n const Counter: React.FC<{ count: number; label?: string }> = ({\n count,\n label = \"Count\",\n }) => (\n <div>\n {label}: {count}\n </div>\n );\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter component\",\n propsSchema: z.object({\n count: z.number(),\n label: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [count, setCount] = React.useState(0);\n const [label, setLabel] = React.useState(\"Items\");\n\n React.useEffect(() => {\n const timeout1 = setTimeout(() => setCount(5), 100);\n const timeout2 = setTimeout(() => setLabel(\"Updated Items\"), 200);\n return () => {\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n <InteractableCounter count={count} label={label} />\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n });\n\n // Wait for updates to propagate\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n if (entry?.context?.components?.[0]) {\n const props = entry.context.components[0].props;\n expect(props.count).toBe(5);\n expect(props.label).toBe(\"Updated Items\");\n }\n },\n { timeout: 1000 },\n );\n });\n\n test(\"multiple providers with nested context helpers work correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let outerContexts: any[] = [];\n let innerContexts: any[] = [];\n\n const OuterTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n outerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"outer-ready\">outer ready</div>;\n };\n\n const InnerTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n innerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"inner-ready\">inner ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"outer note\" />\n <OuterTestComponent />\n <TamboContextHelpersProvider\n contextHelpers={{\n customContext: () => ({ custom: \"inner\" }),\n }}\n >\n <TamboInteractableProvider>\n <InteractableNote title=\"inner note\" />\n <InnerTestComponent />\n </TamboInteractableProvider>\n </TamboContextHelpersProvider>\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"outer-ready\")).toBeInTheDocument();\n expect(getByTestId(\"inner-ready\")).toBeInTheDocument();\n });\n\n await waitFor(() => {\n // Outer context should have outer note\n const outerEntry = outerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(outerEntry?.context?.components).toHaveLength(1);\n expect(outerEntry?.context?.components[0]?.props?.title).toBe(\n \"outer note\",\n );\n\n // Inner context should have inner note and custom context\n const innerEntry = innerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(innerEntry?.context?.components).toHaveLength(1);\n expect(innerEntry?.context?.components[0]?.props?.title).toBe(\n \"inner note\",\n );\n\n const customEntry = innerContexts.find(\n (c: any) => c.name === \"customContext\",\n );\n expect(customEntry?.context).toEqual({ custom: \"inner\" });\n });\n });\n\n test(\"provider cleanup removes helper when last provider unmounts\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showProvider, setShowProvider] = React.useState(true);\n\n React.useEffect(() => {\n const timeout = setTimeout(() => setShowProvider(false), 200);\n return () => clearTimeout(timeout);\n }, []);\n\n return (\n <>\n {showProvider && (\n <TamboInteractableProvider>\n <InteractableNote title=\"will disappear\" />\n </TamboInteractableProvider>\n )}\n <TestComponent />\n </>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n // Initially should have the context\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n });\n\n // After provider unmounts, context should be gone\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined();\n },\n { timeout: 1000 },\n );\n });\n\n test(\"helper error handling doesn't crash the system\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Mock console.error to capture error logs\n const consoleSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext, addContextHelper } =\n useTamboContextHelpers();\n\n React.useEffect(() => {\n // Add a helper that throws an error\n addContextHelper(\"errorHelper\", () => {\n throw new Error(\"Test error in helper\");\n });\n }, [addContextHelper]);\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext()\n .then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n })\n .catch(() => {\n // Should not reach here - errors should be handled gracefully\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n // Should still have the interactables context despite the error\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n\n // Error helper should not be present (filtered out)\n const errorEntry = capturedContexts.find(\n (c: any) => c.name === \"errorHelper\",\n );\n expect(errorEntry).toBeUndefined();\n });\n\n consoleSpy.mockRestore();\n });\n});\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, waitFor } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { z } from "
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
4
|
import { withTamboInteractable } from "../hoc/with-tambo-interactable";
|
|
5
5
|
import { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
|
|
6
6
|
import { TamboInteractableProvider, useCurrentInteractablesSnapshot, } from "./tambo-interactable-provider";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactables-additional-context.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACN,CAAC;IAET,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd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K;YACT,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,EAAE;SACN,CAAC;QAET,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAC5B,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC,EACvB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC,EAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;YAE5B,oBAAC,sBAAsB;gBACrB,oBAAC,yBAAyB;oBACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,mBAAmB,GAAG;oBAC9C,oBAAC,aAAa,OAAG,CACS,CACL,CACP,CACrB,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,kDAAkD;QACnF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zodInternalAlias\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useCurrentInteractablesSnapshot,\n} from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext (provider-based)\", () => {\n test(\"registers default helper and returns payload with description and components\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"hello\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(entry?.context?.description).toMatch(/interactable components/i);\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n const comp = entry!.context.components[0];\n expect(comp.componentName).toBe(\"Note\");\n expect(comp.props).toEqual({ title: \"hello\" });\n });\n });\n\n test(\"returns null when no interactable components are present\", async () => {\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <div>No interactables here</div>\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n\n test(\"context includes proper AI prompt with clear instructions\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A simple note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.description).toContain(\"interactable components\");\n expect(entry?.context?.description).toContain(\"visible on the page\");\n expect(entry?.context?.description).toContain(\"you can read and modify\");\n expect(entry?.context?.description).toContain(\"tools to update\");\n });\n });\n\n test(\"includes component metadata in expected format\", async () => {\n const Note: React.FC<{ title: string; color?: string }> = ({\n title,\n color = \"white\",\n }) => <div className={`note-${color}`}>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A colorful note component\",\n propsSchema: z.object({\n title: z.string(),\n color: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test note\" color=\"blue\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n const component = entry!.context.components[0];\n\n expect(component).toMatchObject({\n id: expect.any(String),\n componentName: \"Note\",\n description: \"A colorful note component\",\n props: { title: \"test note\", color: \"blue\" },\n propsSchema: \"Available - use component-specific update tools\",\n });\n });\n });\n\n test(\"snapshot hook returns immutable copies\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const TestComponent = () => {\n const snapshot = useCurrentInteractablesSnapshot();\n const [testResult, setTestResult] = React.useState<string>(\"pending\");\n\n React.useEffect(() => {\n if (snapshot.length > 0) {\n const originalLength = snapshot.length;\n\n // Try to mutate the returned array and props\n snapshot.push({\n id: \"fake\",\n name: \"Fake\",\n description: \"\",\n component: () => null,\n props: {},\n } as any);\n (snapshot[0].props as any).title = \"MUTATED\";\n\n // The mutations should succeed on the returned copy, proving it's a separate object\n if (\n snapshot.length === originalLength + 1 &&\n snapshot[0].props.title === \"MUTATED\"\n ) {\n setTestResult(\"mutation-successful-but-isolated\");\n } else {\n setTestResult(\"mutation-failed\");\n }\n }\n }, [snapshot]);\n\n return <div data-testid=\"test-result\">{testResult}</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"immutable test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n const result = getByTestId(\"test-result\").textContent;\n expect(result).toBe(\"mutation-successful-but-isolated\");\n });\n });\n\n test(\"multiple interactables from same provider appear in context\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const Counter: React.FC<{ count: number }> = ({ count }) => (\n <div>{count}</div>\n );\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter\",\n propsSchema: z.object({ count: z.number() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"first\" />\n <InteractableCounter count={42} />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(2);\n\n const components = entry!.context.components;\n expect(components[0].componentName).toBe(\"Note\");\n expect(components[0].props).toEqual({ title: \"first\" });\n expect(components[1].componentName).toBe(\"Counter\");\n expect(components[1].props).toEqual({ count: 42 });\n });\n });\n\n test(\"can be disabled by returning null\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Create a context helpers provider with a disabled interactables helper\n const DisabledContextHelpers = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboContextHelpersProvider\n contextHelpers={{\n [\"interactables\"]: () => null,\n }}\n >\n {children}\n </TamboContextHelpersProvider>\n );\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n const { getByTestId } = render(\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <DisabledContextHelpers>\n <TamboInteractableProvider>\n <InteractableNote title=\"should not appear\" />\n <TestComponent />\n </TamboInteractableProvider>\n </DisabledContextHelpers>\n </TamboStubProvider>,\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactables-additional-context.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,qBAAqB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C,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,kDAAkD;QACnF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useCurrentInteractablesSnapshot,\n} from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext (provider-based)\", () => {\n test(\"registers default helper and returns payload with description and components\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"hello\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(entry?.context?.description).toMatch(/interactable components/i);\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n const comp = entry!.context.components[0];\n expect(comp.componentName).toBe(\"Note\");\n expect(comp.props).toEqual({ title: \"hello\" });\n });\n });\n\n test(\"returns null when no interactable components are present\", async () => {\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <div>No interactables here</div>\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n\n test(\"context includes proper AI prompt with clear instructions\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A simple note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.description).toContain(\"interactable components\");\n expect(entry?.context?.description).toContain(\"visible on the page\");\n expect(entry?.context?.description).toContain(\"you can read and modify\");\n expect(entry?.context?.description).toContain(\"tools to update\");\n });\n });\n\n test(\"includes component metadata in expected format\", async () => {\n const Note: React.FC<{ title: string; color?: string }> = ({\n title,\n color = \"white\",\n }) => <div className={`note-${color}`}>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A colorful note component\",\n propsSchema: z.object({\n title: z.string(),\n color: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test note\" color=\"blue\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n const component = entry!.context.components[0];\n\n expect(component).toMatchObject({\n id: expect.any(String),\n componentName: \"Note\",\n description: \"A colorful note component\",\n props: { title: \"test note\", color: \"blue\" },\n propsSchema: \"Available - use component-specific update tools\",\n });\n });\n });\n\n test(\"snapshot hook returns immutable copies\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const TestComponent = () => {\n const snapshot = useCurrentInteractablesSnapshot();\n const [testResult, setTestResult] = React.useState<string>(\"pending\");\n\n React.useEffect(() => {\n if (snapshot.length > 0) {\n const originalLength = snapshot.length;\n\n // Try to mutate the returned array and props\n snapshot.push({\n id: \"fake\",\n name: \"Fake\",\n description: \"\",\n component: () => null,\n props: {},\n } as any);\n (snapshot[0].props as any).title = \"MUTATED\";\n\n // The mutations should succeed on the returned copy, proving it's a separate object\n if (\n snapshot.length === originalLength + 1 &&\n snapshot[0].props.title === \"MUTATED\"\n ) {\n setTestResult(\"mutation-successful-but-isolated\");\n } else {\n setTestResult(\"mutation-failed\");\n }\n }\n }, [snapshot]);\n\n return <div data-testid=\"test-result\">{testResult}</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"immutable test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n const result = getByTestId(\"test-result\").textContent;\n expect(result).toBe(\"mutation-successful-but-isolated\");\n });\n });\n\n test(\"multiple interactables from same provider appear in context\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const Counter: React.FC<{ count: number }> = ({ count }) => (\n <div>{count}</div>\n );\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter\",\n propsSchema: z.object({ count: z.number() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"first\" />\n <InteractableCounter count={42} />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(2);\n\n const components = entry!.context.components;\n expect(components[0].componentName).toBe(\"Note\");\n expect(components[0].props).toEqual({ title: \"first\" });\n expect(components[1].componentName).toBe(\"Counter\");\n expect(components[1].props).toEqual({ count: 42 });\n });\n });\n\n test(\"can be disabled by returning null\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Create a context helpers provider with a disabled interactables helper\n const DisabledContextHelpers = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboContextHelpersProvider\n contextHelpers={{\n [\"interactables\"]: () => null,\n }}\n >\n {children}\n </TamboContextHelpersProvider>\n );\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n const { getByTestId } = render(\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <DisabledContextHelpers>\n <TamboInteractableProvider>\n <InteractableNote title=\"should not appear\" />\n <TestComponent />\n </TamboInteractableProvider>\n </DisabledContextHelpers>\n </TamboStubProvider>,\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n});\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { act, renderHook } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { z } from "
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
4
|
import { defineTool } from "../util/registry";
|
|
5
5
|
import { TamboRegistryProvider, useTamboRegistry, } from "./tambo-registry-provider";
|
|
6
6
|
// Shared tool registry for all tests
|
|
@@ -9,14 +9,18 @@ const createMockTools = () => [
|
|
|
9
9
|
name: "test-tool-1",
|
|
10
10
|
description: "First test tool",
|
|
11
11
|
tool: jest.fn().mockResolvedValue("test-tool-1-result"),
|
|
12
|
-
inputSchema: z.
|
|
12
|
+
inputSchema: z.object({
|
|
13
|
+
input: z.string().describe("input parameter"),
|
|
14
|
+
}),
|
|
13
15
|
outputSchema: z.string(),
|
|
14
16
|
}),
|
|
15
17
|
defineTool({
|
|
16
18
|
name: "test-tool-2",
|
|
17
19
|
description: "Second test tool",
|
|
18
20
|
tool: jest.fn().mockResolvedValue("test-tool-2-result"),
|
|
19
|
-
inputSchema: z.
|
|
21
|
+
inputSchema: z.object({
|
|
22
|
+
value: z.number().describe("number parameter"),
|
|
23
|
+
}),
|
|
20
24
|
outputSchema: z.string(),
|
|
21
25
|
}),
|
|
22
26
|
];
|
|
@@ -94,7 +98,9 @@ describe("TamboRegistryProvider", () => {
|
|
|
94
98
|
name: "new-tool",
|
|
95
99
|
description: "New tool",
|
|
96
100
|
tool: jest.fn().mockResolvedValue("new-tool-result"),
|
|
97
|
-
inputSchema: z.
|
|
101
|
+
inputSchema: z.object({
|
|
102
|
+
input: z.string().describe("input"),
|
|
103
|
+
}),
|
|
98
104
|
outputSchema: z.string(),
|
|
99
105
|
};
|
|
100
106
|
// First register the tool
|
|
@@ -114,7 +120,9 @@ describe("TamboRegistryProvider", () => {
|
|
|
114
120
|
name: "new-tool",
|
|
115
121
|
description: "New tool",
|
|
116
122
|
tool: jest.fn().mockResolvedValue("new-tool-result"),
|
|
117
|
-
inputSchema: z.
|
|
123
|
+
inputSchema: z.object({
|
|
124
|
+
input: z.string().describe("input"),
|
|
125
|
+
}),
|
|
118
126
|
outputSchema: z.string(),
|
|
119
127
|
};
|
|
120
128
|
expect(() => {
|
|
@@ -194,7 +202,9 @@ describe("TamboRegistryProvider", () => {
|
|
|
194
202
|
name: "invalid tool name", // Contains spaces
|
|
195
203
|
description: "Tool with spaces in name",
|
|
196
204
|
tool: jest.fn().mockResolvedValue("result"),
|
|
197
|
-
inputSchema: z.
|
|
205
|
+
inputSchema: z.object({
|
|
206
|
+
input: z.string(),
|
|
207
|
+
}),
|
|
198
208
|
outputSchema: z.string(),
|
|
199
209
|
};
|
|
200
210
|
expect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-registry-provider.test.js","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,qCAAqC;AACrC,MAAM,eAAe,GAAG,GAAgB,EAAE,CAAC;IACzC,UAAU,CAAC;QACT,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,IAAI,CA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AC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YAErE,MAAM,eAAe,GAAG;gBACtB,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,YAAY;aAChB,CAAC;YAET,MAAM,CAAC,GAAG,EAAE;gBACV,GAAG,CAAC,GAAG,EAAE;oBACP,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;gBACnD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC/D,oBAAC,qBAAqB,QAAE,QAAQ,CAAyB,CAC1D,CAAC;YAEF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YAErE,MAAM,eAAe,GAAG;gBACtB,GAAG,EAAE,iBAAiB;gBACtB,QAAQ,EAAE,YAAY;aAChB,CAAC;YAET,MAAM,CAAC,GAAG,EAAE;gBACV,GAAG,CAAC,GAAG,EAAE;oBACP,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;gBACnD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,CACR,8DAA8D,CAC/D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zodInternalAlias\";\nimport { TamboComponent, TamboTool } from \"../model/component-metadata\";\nimport { defineTool } from \"../util/registry\";\nimport {\n TamboRegistryProvider,\n useTamboRegistry,\n} from \"./tambo-registry-provider\";\n\n// Shared tool registry for all tests\nconst createMockTools = (): TamboTool[] => [\n defineTool({\n name: \"test-tool-1\",\n description: \"First test tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool-1-result\"),\n inputSchema: z.tuple([z.string().describe(\"input parameter\")]),\n outputSchema: z.string(),\n }),\n defineTool({\n name: \"test-tool-2\",\n description: \"Second test tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool-2-result\"),\n inputSchema: z.tuple([z.number().describe(\"number parameter\")]),\n outputSchema: z.string(),\n }),\n];\n\nconst createMockComponents = (tools: TamboTool[]): TamboComponent[] => [\n {\n name: \"TestComponent\",\n component: () => <div>TestComponent</div>,\n description: \"Test component\",\n propsSchema: z.object({\n test: z.string(),\n }),\n associatedTools: tools,\n },\n];\n\ndescribe(\"TamboRegistryProvider\", () => {\n const mockTools = createMockTools();\n const mockComponents = createMockComponents(mockTools);\n\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n describe(\"Component and tool registration\", () => {\n it(\"should register components and tools correctly\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.componentList).toHaveProperty(\"TestComponent\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-2\");\n expect(result.current.componentToolAssociations).toHaveProperty(\n \"TestComponent\",\n );\n expect(result.current.componentToolAssociations.TestComponent).toEqual([\n \"test-tool-1\",\n \"test-tool-2\",\n ]);\n });\n\n it(\"should provide onCallUnregisteredTool in context\", () => {\n const mockonCallUnregisteredTool = jest\n .fn()\n .mockResolvedValue(\"test-result\");\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n components={mockComponents}\n onCallUnregisteredTool={mockonCallUnregisteredTool}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // The onCallUnregisteredTool should be available in the context\n expect(result.current.onCallUnregisteredTool).toBeDefined();\n expect(typeof result.current.onCallUnregisteredTool).toBe(\"function\");\n });\n\n it(\"should handle tool registration and association\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Register a new tool\n act(() => {\n result.current.registerTool(mockTools[0]);\n });\n\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n\n // Register a new component\n act(() => {\n result.current.registerComponent(mockComponents[0]);\n });\n\n expect(result.current.componentList).toHaveProperty(\"TestComponent\");\n expect(result.current.componentToolAssociations).toHaveProperty(\n \"TestComponent\",\n );\n });\n\n it(\"should handle multiple tool registration\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Register multiple tools\n act(() => {\n result.current.registerTools(mockTools);\n });\n\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-2\");\n expect(Object.keys(result.current.toolRegistry)).toHaveLength(2);\n });\n\n it(\"should handle tool association with components\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Add a new tool association\n const newTool: TamboTool = {\n name: \"new-tool\",\n description: \"New tool\",\n tool: jest.fn().mockResolvedValue(\"new-tool-result\"),\n inputSchema: z.tuple([z.string().describe(\"input\")]),\n outputSchema: z.string(),\n };\n\n // First register the tool\n act(() => {\n result.current.registerTool(newTool);\n });\n\n // Then add the association\n act(() => {\n result.current.addToolAssociation(\"TestComponent\", newTool);\n });\n\n expect(result.current.componentToolAssociations.TestComponent).toContain(\n \"new-tool\",\n );\n });\n\n it(\"should throw error when adding tool association to non-existent component\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newTool: TamboTool = {\n name: \"new-tool\",\n description: \"New tool\",\n tool: jest.fn().mockResolvedValue(\"new-tool-result\"),\n inputSchema: z.tuple([z.string().describe(\"input\")]),\n outputSchema: z.string(),\n };\n\n expect(() => {\n act(() => {\n result.current.addToolAssociation(\"NonExistentComponent\", newTool);\n });\n }).toThrow(\"Component NonExistentComponent not found in registry\");\n });\n\n it(\"should validate tool schemas and throw error for invalid schemas\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidTool: TamboTool = {\n name: \"invalid-tool\",\n description: \"Invalid tool\",\n tool: jest.fn().mockResolvedValue(\"result\"),\n inputSchema: z.record(z.string(), z.string()), // This should cause validation to fail\n outputSchema: z.string(),\n };\n\n // This should throw during registration due to invalid schema\n expect(() => {\n act(() => {\n result.current.registerTool(invalidTool);\n });\n }).toThrow(\n 'Record types (objects with dynamic keys) are not supported in inputSchema of tool \"invalid-tool\". Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should validate component schemas and throw error for invalid schemas\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n propsSchema: z.record(z.string(), z.string()), // This should cause validation to fail\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // This should throw during registration due to invalid schema\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n 'Record types (objects with dynamic keys) are not supported in propsSchema of component \"InvalidComponent\"',\n );\n });\n\n it(\"should throw error when component has both propsSchema and propsDefinition\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n propsSchema: z.object({ test: z.string() }),\n propsDefinition: { test: \"string\" }, // Both defined - should throw\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n \"Component InvalidComponent cannot have both propsSchema and propsDefinition defined\",\n );\n });\n\n it(\"should throw error when component has neither propsSchema nor propsDefinition\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n // Neither propsSchema nor propsDefinition defined - should throw\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n \"Component InvalidComponent must have either propsSchema (recommended) or propsDefinition defined\",\n );\n });\n\n it(\"should throw error when tool name contains spaces\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidTool: TamboTool = {\n name: \"invalid tool name\", // Contains spaces\n description: \"Tool with spaces in name\",\n tool: jest.fn().mockResolvedValue(\"result\"),\n inputSchema: z.tuple([z.string()]),\n outputSchema: z.string(),\n };\n\n expect(() => {\n act(() => {\n result.current.registerTool(invalidTool);\n });\n }).toThrow(\n 'tool \"invalid tool name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should throw error when component name contains spaces\", () => {\n const invalidComponent: TamboComponent = {\n name: \"Invalid Component Name\", // Contains spaces\n component: () => <div>Invalid</div>,\n description: \"Component with spaces in name\",\n propsSchema: z.object({ test: z.string() }),\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n 'component \"Invalid Component Name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n });\n\n describe(\"Tool call handling\", () => {\n it(\"should provide onCallUnregisteredTool callback for handling unknown tools\", async () => {\n const mockonCallUnregisteredTool = jest\n .fn()\n .mockResolvedValue(\"unknown-tool-result\");\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n components={mockComponents}\n onCallUnregisteredTool={mockonCallUnregisteredTool}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Verify the callback is available\n expect(result.current.onCallUnregisteredTool).toBeDefined();\n expect(typeof result.current.onCallUnregisteredTool).toBe(\"function\");\n\n // Simulate calling the unknown tool handler\n const toolName = \"unknown-tool\";\n const args = [{ parameterName: \"input\", parameterValue: \"test-input\" }];\n\n await act(async () => {\n if (result.current.onCallUnregisteredTool) {\n await result.current.onCallUnregisteredTool(toolName, args);\n }\n });\n\n expect(mockonCallUnregisteredTool).toHaveBeenCalledWith(toolName, args);\n });\n\n it(\"should handle onCallUnregisteredTool being undefined\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.onCallUnregisteredTool).toBeUndefined();\n });\n });\n\n describe(\"Resource registration\", () => {\n it(\"should register static resources via props\", () => {\n const staticResources = [\n {\n uri: \"file:///local/doc.txt\",\n name: \"Local Document\",\n mimeType: \"text/plain\",\n },\n {\n uri: \"file:///local/image.png\",\n name: \"Local Image\",\n mimeType: \"image/png\",\n },\n ];\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider resources={staticResources}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.resources).toHaveLength(2);\n expect(result.current.resources[0].uri).toBe(\"file:///local/doc.txt\");\n expect(result.current.resources[1].uri).toBe(\"file:///local/image.png\");\n });\n\n it(\"should register resources dynamically via registerResource\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newResource = {\n uri: \"file:///dynamic/doc.txt\",\n name: \"Dynamic Document\",\n mimeType: \"text/plain\",\n };\n\n act(() => {\n result.current.registerResource(newResource);\n });\n\n expect(result.current.resources).toHaveLength(1);\n expect(result.current.resources[0].uri).toBe(\"file:///dynamic/doc.txt\");\n });\n\n it(\"should register multiple resources via registerResources\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newResources = [\n {\n uri: \"file:///batch/doc1.txt\",\n name: \"Batch Document 1\",\n mimeType: \"text/plain\",\n },\n {\n uri: \"file:///batch/doc2.txt\",\n name: \"Batch Document 2\",\n mimeType: \"text/plain\",\n },\n ];\n\n act(() => {\n result.current.registerResources(newResources);\n });\n\n expect(result.current.resources).toHaveLength(2);\n expect(result.current.resources[0].uri).toBe(\"file:///batch/doc1.txt\");\n expect(result.current.resources[1].uri).toBe(\"file:///batch/doc2.txt\");\n });\n\n it(\"should register resource source via props\", () => {\n const mockListResources = jest.fn().mockResolvedValue([]);\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"\", mimeType: \"text/plain\", text: \"\" }],\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n listResources={mockListResources}\n getResource={mockGetResource}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.resourceSource).not.toBeNull();\n expect(result.current.resourceSource?.listResources).toBe(\n mockListResources,\n );\n expect(result.current.resourceSource?.getResource).toBe(mockGetResource);\n });\n\n it(\"should register resource source via registerResourceSource\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const mockListResources = jest.fn().mockResolvedValue([]);\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"\", mimeType: \"text/plain\", text: \"\" }],\n });\n\n act(() => {\n result.current.registerResourceSource({\n listResources: mockListResources,\n getResource: mockGetResource,\n });\n });\n\n expect(result.current.resourceSource).not.toBeNull();\n expect(result.current.resourceSource?.listResources).toBe(\n mockListResources,\n );\n expect(result.current.resourceSource?.getResource).toBe(mockGetResource);\n });\n\n it(\"should throw error when only listResources is provided\", () => {\n const mockListResources = jest.fn().mockResolvedValue([]);\n\n expect(() => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider listResources={mockListResources}>\n {children}\n </TamboRegistryProvider>\n );\n renderHook(() => useTamboRegistry(), { wrapper });\n }).toThrow(\n \"Both listResources and getResource must be provided together\",\n );\n });\n\n it(\"should throw error when only getResource is provided\", () => {\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"\", mimeType: \"text/plain\", text: \"\" }],\n });\n\n expect(() => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider getResource={mockGetResource}>\n {children}\n </TamboRegistryProvider>\n );\n renderHook(() => useTamboRegistry(), { wrapper });\n }).toThrow(\n \"Both listResources and getResource must be provided together\",\n );\n });\n\n it(\"should validate resource has required uri field\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidResource = {\n name: \"Document without URI\",\n mimeType: \"text/plain\",\n } as any;\n\n expect(() => {\n act(() => {\n result.current.registerResource(invalidResource);\n });\n }).toThrow(\"Resource must have a 'uri' field\");\n });\n\n it(\"should validate resource has required name field\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidResource = {\n uri: \"file:///doc.txt\",\n mimeType: \"text/plain\",\n } as any;\n\n expect(() => {\n act(() => {\n result.current.registerResource(invalidResource);\n });\n }).toThrow(\n \"Resource with URI 'file:///doc.txt' must have a 'name' field\",\n );\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-registry-provider.test.js","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,qCAAqC;AACrC,MAAM,eAAe,GAAG,GAAgB,EAAE,CAAC;IACzC,UAAU,CAAC;QACT,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,oBAAoB,CAAC;QACvD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ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eAAe,GAAG;gBACtB,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,YAAY;aAChB,CAAC;YAET,MAAM,CAAC,GAAG,EAAE;gBACV,GAAG,CAAC,GAAG,EAAE;oBACP,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;gBACnD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC/D,oBAAC,qBAAqB,QAAE,QAAQ,CAAyB,CAC1D,CAAC;YAEF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YAErE,MAAM,eAAe,GAAG;gBACtB,GAAG,EAAE,iBAAiB;gBACtB,QAAQ,EAAE,YAAY;aAChB,CAAC;YAET,MAAM,CAAC,GAAG,EAAE;gBACV,GAAG,CAAC,GAAG,EAAE;oBACP,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;gBACnD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,CACR,8DAA8D,CAC/D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { TamboComponent, TamboTool } from \"../model/component-metadata\";\nimport { defineTool } from \"../util/registry\";\nimport {\n TamboRegistryProvider,\n useTamboRegistry,\n} from \"./tambo-registry-provider\";\n\n// Shared tool registry for all tests\nconst createMockTools = (): TamboTool[] => [\n defineTool({\n name: \"test-tool-1\",\n description: \"First test tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool-1-result\"),\n inputSchema: z.object({\n input: z.string().describe(\"input parameter\"),\n }),\n outputSchema: z.string(),\n }),\n defineTool({\n name: \"test-tool-2\",\n description: \"Second test tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool-2-result\"),\n inputSchema: z.object({\n value: z.number().describe(\"number parameter\"),\n }),\n outputSchema: z.string(),\n }),\n];\n\nconst createMockComponents = (tools: TamboTool[]): TamboComponent[] => [\n {\n name: \"TestComponent\",\n component: () => <div>TestComponent</div>,\n description: \"Test component\",\n propsSchema: z.object({\n test: z.string(),\n }),\n associatedTools: tools,\n },\n];\n\ndescribe(\"TamboRegistryProvider\", () => {\n const mockTools = createMockTools();\n const mockComponents = createMockComponents(mockTools);\n\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n describe(\"Component and tool registration\", () => {\n it(\"should register components and tools correctly\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.componentList).toHaveProperty(\"TestComponent\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-2\");\n expect(result.current.componentToolAssociations).toHaveProperty(\n \"TestComponent\",\n );\n expect(result.current.componentToolAssociations.TestComponent).toEqual([\n \"test-tool-1\",\n \"test-tool-2\",\n ]);\n });\n\n it(\"should provide onCallUnregisteredTool in context\", () => {\n const mockonCallUnregisteredTool = jest\n .fn()\n .mockResolvedValue(\"test-result\");\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n components={mockComponents}\n onCallUnregisteredTool={mockonCallUnregisteredTool}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // The onCallUnregisteredTool should be available in the context\n expect(result.current.onCallUnregisteredTool).toBeDefined();\n expect(typeof result.current.onCallUnregisteredTool).toBe(\"function\");\n });\n\n it(\"should handle tool registration and association\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Register a new tool\n act(() => {\n result.current.registerTool(mockTools[0]);\n });\n\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n\n // Register a new component\n act(() => {\n result.current.registerComponent(mockComponents[0]);\n });\n\n expect(result.current.componentList).toHaveProperty(\"TestComponent\");\n expect(result.current.componentToolAssociations).toHaveProperty(\n \"TestComponent\",\n );\n });\n\n it(\"should handle multiple tool registration\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Register multiple tools\n act(() => {\n result.current.registerTools(mockTools);\n });\n\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-2\");\n expect(Object.keys(result.current.toolRegistry)).toHaveLength(2);\n });\n\n it(\"should handle tool association with components\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Add a new tool association\n const newTool: TamboTool = {\n name: \"new-tool\",\n description: \"New tool\",\n tool: jest.fn().mockResolvedValue(\"new-tool-result\"),\n inputSchema: z.object({\n input: z.string().describe(\"input\"),\n }),\n outputSchema: z.string(),\n };\n\n // First register the tool\n act(() => {\n result.current.registerTool(newTool);\n });\n\n // Then add the association\n act(() => {\n result.current.addToolAssociation(\"TestComponent\", newTool);\n });\n\n expect(result.current.componentToolAssociations.TestComponent).toContain(\n \"new-tool\",\n );\n });\n\n it(\"should throw error when adding tool association to non-existent component\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newTool: TamboTool = {\n name: \"new-tool\",\n description: \"New tool\",\n tool: jest.fn().mockResolvedValue(\"new-tool-result\"),\n inputSchema: z.object({\n input: z.string().describe(\"input\"),\n }),\n outputSchema: z.string(),\n };\n\n expect(() => {\n act(() => {\n result.current.addToolAssociation(\"NonExistentComponent\", newTool);\n });\n }).toThrow(\"Component NonExistentComponent not found in registry\");\n });\n\n it(\"should validate tool schemas and throw error for invalid schemas\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidTool: TamboTool = {\n name: \"invalid-tool\",\n description: \"Invalid tool\",\n tool: jest.fn().mockResolvedValue(\"result\"),\n inputSchema: z.record(z.string(), z.string()), // This should cause validation to fail\n outputSchema: z.string(),\n };\n\n // This should throw during registration due to invalid schema\n expect(() => {\n act(() => {\n result.current.registerTool(invalidTool);\n });\n }).toThrow(\n 'Record types (objects with dynamic keys) are not supported in inputSchema of tool \"invalid-tool\". Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should validate component schemas and throw error for invalid schemas\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n propsSchema: z.record(z.string(), z.string()), // This should cause validation to fail\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // This should throw during registration due to invalid schema\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n 'Record types (objects with dynamic keys) are not supported in propsSchema of component \"InvalidComponent\"',\n );\n });\n\n it(\"should throw error when component has both propsSchema and propsDefinition\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n propsSchema: z.object({ test: z.string() }),\n propsDefinition: { test: \"string\" }, // Both defined - should throw\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n \"Component InvalidComponent cannot have both propsSchema and propsDefinition defined\",\n );\n });\n\n it(\"should throw error when component has neither propsSchema nor propsDefinition\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n // Neither propsSchema nor propsDefinition defined - should throw\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n \"Component InvalidComponent must have either propsSchema (recommended) or propsDefinition defined\",\n );\n });\n\n it(\"should throw error when tool name contains spaces\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidTool: TamboTool = {\n name: \"invalid tool name\", // Contains spaces\n description: \"Tool with spaces in name\",\n tool: jest.fn().mockResolvedValue(\"result\"),\n inputSchema: z.object({\n input: z.string(),\n }),\n outputSchema: z.string(),\n };\n\n expect(() => {\n act(() => {\n result.current.registerTool(invalidTool);\n });\n }).toThrow(\n 'tool \"invalid tool name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should throw error when component name contains spaces\", () => {\n const invalidComponent: TamboComponent = {\n name: \"Invalid Component Name\", // Contains spaces\n component: () => <div>Invalid</div>,\n description: \"Component with spaces in name\",\n propsSchema: z.object({ test: z.string() }),\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n 'component \"Invalid Component Name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n });\n\n describe(\"Tool call handling\", () => {\n it(\"should provide onCallUnregisteredTool callback for handling unknown tools\", async () => {\n const mockonCallUnregisteredTool = jest\n .fn()\n .mockResolvedValue(\"unknown-tool-result\");\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n components={mockComponents}\n onCallUnregisteredTool={mockonCallUnregisteredTool}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Verify the callback is available\n expect(result.current.onCallUnregisteredTool).toBeDefined();\n expect(typeof result.current.onCallUnregisteredTool).toBe(\"function\");\n\n // Simulate calling the unknown tool handler\n const toolName = \"unknown-tool\";\n const args = [{ parameterName: \"input\", parameterValue: \"test-input\" }];\n\n await act(async () => {\n if (result.current.onCallUnregisteredTool) {\n await result.current.onCallUnregisteredTool(toolName, args);\n }\n });\n\n expect(mockonCallUnregisteredTool).toHaveBeenCalledWith(toolName, args);\n });\n\n it(\"should handle onCallUnregisteredTool being undefined\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.onCallUnregisteredTool).toBeUndefined();\n });\n });\n\n describe(\"Resource registration\", () => {\n it(\"should register static resources via props\", () => {\n const staticResources = [\n {\n uri: \"file:///local/doc.txt\",\n name: \"Local Document\",\n mimeType: \"text/plain\",\n },\n {\n uri: \"file:///local/image.png\",\n name: \"Local Image\",\n mimeType: \"image/png\",\n },\n ];\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider resources={staticResources}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.resources).toHaveLength(2);\n expect(result.current.resources[0].uri).toBe(\"file:///local/doc.txt\");\n expect(result.current.resources[1].uri).toBe(\"file:///local/image.png\");\n });\n\n it(\"should register resources dynamically via registerResource\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newResource = {\n uri: \"file:///dynamic/doc.txt\",\n name: \"Dynamic Document\",\n mimeType: \"text/plain\",\n };\n\n act(() => {\n result.current.registerResource(newResource);\n });\n\n expect(result.current.resources).toHaveLength(1);\n expect(result.current.resources[0].uri).toBe(\"file:///dynamic/doc.txt\");\n });\n\n it(\"should register multiple resources via registerResources\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newResources = [\n {\n uri: \"file:///batch/doc1.txt\",\n name: \"Batch Document 1\",\n mimeType: \"text/plain\",\n },\n {\n uri: \"file:///batch/doc2.txt\",\n name: \"Batch Document 2\",\n mimeType: \"text/plain\",\n },\n ];\n\n act(() => {\n result.current.registerResources(newResources);\n });\n\n expect(result.current.resources).toHaveLength(2);\n expect(result.current.resources[0].uri).toBe(\"file:///batch/doc1.txt\");\n expect(result.current.resources[1].uri).toBe(\"file:///batch/doc2.txt\");\n });\n\n it(\"should register resource source via props\", () => {\n const mockListResources = jest.fn().mockResolvedValue([]);\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"\", mimeType: \"text/plain\", text: \"\" }],\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n listResources={mockListResources}\n getResource={mockGetResource}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.resourceSource).not.toBeNull();\n expect(result.current.resourceSource?.listResources).toBe(\n mockListResources,\n );\n expect(result.current.resourceSource?.getResource).toBe(mockGetResource);\n });\n\n it(\"should register resource source via registerResourceSource\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const mockListResources = jest.fn().mockResolvedValue([]);\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"\", mimeType: \"text/plain\", text: \"\" }],\n });\n\n act(() => {\n result.current.registerResourceSource({\n listResources: mockListResources,\n getResource: mockGetResource,\n });\n });\n\n expect(result.current.resourceSource).not.toBeNull();\n expect(result.current.resourceSource?.listResources).toBe(\n mockListResources,\n );\n expect(result.current.resourceSource?.getResource).toBe(mockGetResource);\n });\n\n it(\"should throw error when only listResources is provided\", () => {\n const mockListResources = jest.fn().mockResolvedValue([]);\n\n expect(() => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider listResources={mockListResources}>\n {children}\n </TamboRegistryProvider>\n );\n renderHook(() => useTamboRegistry(), { wrapper });\n }).toThrow(\n \"Both listResources and getResource must be provided together\",\n );\n });\n\n it(\"should throw error when only getResource is provided\", () => {\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"\", mimeType: \"text/plain\", text: \"\" }],\n });\n\n expect(() => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider getResource={mockGetResource}>\n {children}\n </TamboRegistryProvider>\n );\n renderHook(() => useTamboRegistry(), { wrapper });\n }).toThrow(\n \"Both listResources and getResource must be provided together\",\n );\n });\n\n it(\"should validate resource has required uri field\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidResource = {\n name: \"Document without URI\",\n mimeType: \"text/plain\",\n } as any;\n\n expect(() => {\n act(() => {\n result.current.registerResource(invalidResource);\n });\n }).toThrow(\"Resource must have a 'uri' field\");\n });\n\n it(\"should validate resource has required name field\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidResource = {\n uri: \"file:///doc.txt\",\n mimeType: \"text/plain\",\n } as any;\n\n expect(() => {\n act(() => {\n result.current.registerResource(invalidResource);\n });\n }).toThrow(\n \"Resource with URI 'file:///doc.txt' must have a 'name' field\",\n );\n });\n });\n});\n"]}
|