@copilotkit/vue 1.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +50 -0
- package/CHANGELOG.md +13 -0
- package/PARITY.md +434 -0
- package/README.md +396 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +20 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +3 -0
- package/dist/components/copilot-provider/index.d.ts.map +1 -0
- package/dist/components/copilot-provider/types.d.ts +22 -0
- package/dist/components/copilot-provider/types.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +27 -0
- package/dist/hooks/use-copilot-action.d.ts.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +20 -0
- package/dist/hooks/use-copilot-readable.d.ts.map +1 -0
- package/dist/hooks/use-frontend-tool.d.ts +21 -0
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +252 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs +85 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -0
- package/dist/use-render-activity-message-CqtxiFSs.js +8927 -0
- package/dist/use-render-activity-message-CqtxiFSs.js.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +9 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +16 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +7 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts +6 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +18 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts +88 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +154 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +19 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +16 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts +62 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts.map +1 -0
- package/dist/v2/components/a2ui/adapter.d.ts +38 -0
- package/dist/v2/components/a2ui/adapter.d.ts.map +1 -0
- package/dist/v2/components/a2ui/catalog.d.ts +29 -0
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -0
- package/dist/v2/components/a2ui/index.d.ts +5 -0
- package/dist/v2/components/a2ui/index.d.ts.map +1 -0
- package/dist/v2/components/a2ui/utils.d.ts +18 -0
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +12 -0
- package/dist/v2/components/a2ui.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +164 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts +7 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +290 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +72 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +65 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts +27 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts +26 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts +17 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +21 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts +34 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +106 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts +15 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +48 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +62 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +53 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/audioRecorder.d.ts +11 -0
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +682 -0
- package/dist/v2/components/chat/index.d.ts.map +1 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts +29 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts.map +1 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +3 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +380 -0
- package/dist/v2/components/chat/types.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +2 -0
- package/dist/v2/components/icons/index.d.ts.map +1 -0
- package/dist/v2/components/index.d.ts +8 -0
- package/dist/v2/components/index.d.ts.map +1 -0
- package/dist/v2/hooks/index.d.ts +24 -0
- package/dist/v2/hooks/index.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent-context.d.ts +24 -0
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent.d.ts +53 -0
- package/dist/v2/hooks/use-agent.d.ts.map +1 -0
- package/dist/v2/hooks/use-attachments.d.ts +21 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -0
- package/dist/v2/hooks/use-capabilities.d.ts +16 -0
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -0
- package/dist/v2/hooks/use-component.d.ts +13 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts +24 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +14 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts +19 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +19 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/hooks/use-interrupt.d.ts +36 -0
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -0
- package/dist/v2/hooks/use-katex-styles.d.ts +22 -0
- package/dist/v2/hooks/use-katex-styles.d.ts.map +1 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts +33 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts +28 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts +21 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts +27 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-tool.d.ts +36 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-suggestions.d.ts +26 -0
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-threads.d.ts +42 -0
- package/dist/v2/hooks/use-threads.d.ts.map +1 -0
- package/dist/v2/index.cjs +2 -0
- package/dist/v2/index.cjs.map +1 -0
- package/dist/v2/index.d.cts +9 -0
- package/dist/v2/index.d.mts +9 -0
- package/dist/v2/index.d.ts +9 -0
- package/dist/v2/index.d.ts.map +1 -0
- package/dist/v2/index.mjs +75 -0
- package/dist/v2/index.mjs.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +3 -0
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -0
- package/dist/v2/lib/shallow-stable.d.ts +7 -0
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -0
- package/dist/v2/lib/transcription-client.d.ts +19 -0
- package/dist/v2/lib/transcription-client.d.ts.map +1 -0
- package/dist/v2/lib/vue-core.d.ts +47 -0
- package/dist/v2/lib/vue-core.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts +15 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts +17 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +61 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +37 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts +4 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts.map +1 -0
- package/dist/v2/providers/index.d.ts +13 -0
- package/dist/v2/providers/index.d.ts.map +1 -0
- package/dist/v2/providers/keys.d.ts +17 -0
- package/dist/v2/providers/keys.d.ts.map +1 -0
- package/dist/v2/providers/license-context.d.ts +7 -0
- package/dist/v2/providers/license-context.d.ts.map +1 -0
- package/dist/v2/providers/types.d.ts +38 -0
- package/dist/v2/providers/types.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts +4 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotKit.d.ts +2 -0
- package/dist/v2/providers/useCopilotKit.d.ts.map +1 -0
- package/dist/v2/providers/useLicenseContext.d.ts +14 -0
- package/dist/v2/providers/useLicenseContext.d.ts.map +1 -0
- package/dist/v2/types/a2ui.d.ts +5 -0
- package/dist/v2/types/a2ui.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +15 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/types/frontend-tool.d.ts +6 -0
- package/dist/v2/types/frontend-tool.d.ts.map +1 -0
- package/dist/v2/types/human-in-the-loop.d.ts +29 -0
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/types/index.d.ts +10 -0
- package/dist/v2/types/index.d.ts.map +1 -0
- package/dist/v2/types/interrupt.d.ts +14 -0
- package/dist/v2/types/interrupt.d.ts.map +1 -0
- package/dist/v2/types/sandbox-function.d.ts +8 -0
- package/dist/v2/types/sandbox-function.d.ts.map +1 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts +18 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts +19 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts +37 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -0
- package/env.d.ts +7 -0
- package/eslint.config.mjs +42 -0
- package/package.json +130 -0
- package/scripts/scope-preflight.mjs +100 -0
- package/src/components/copilot-provider/CopilotKit.vue +18 -0
- package/src/components/copilot-provider/index.ts +2 -0
- package/src/components/copilot-provider/types.ts +24 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/use-copilot-action.ts +168 -0
- package/src/hooks/use-copilot-readable.ts +75 -0
- package/src/hooks/use-frontend-tool.ts +76 -0
- package/src/index.ts +12 -0
- package/src/styles/globals.css +314 -0
- package/src/v2/__tests__/exports.test.ts +35 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +5 -0
- package/src/v2/__tests__/setup.ts +141 -0
- package/src/v2/__tests__/utils/agents.ts +391 -0
- package/src/v2/__tests__/utils/mount.ts +83 -0
- package/src/v2/__tests__/utils/test-helpers.ts +712 -0
- package/src/v2/components/A2UIMessageRenderer.ts +125 -0
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +186 -0
- package/src/v2/components/CopilotKitInspector.vue +42 -0
- package/src/v2/components/InlineFeatureWarning.vue +35 -0
- package/src/v2/components/LicenseWarningBanner.vue +196 -0
- package/src/v2/components/MCPAppsActivityRenderer.ts +778 -0
- package/src/v2/components/OpenGenerativeUIRenderer.ts +550 -0
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +271 -0
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +57 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.e2e.test.ts +851 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.test.ts +237 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +516 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +295 -0
- package/src/v2/components/a2ui/A2UICatalogContext.ts +190 -0
- package/src/v2/components/a2ui/VueSurface.ts +144 -0
- package/src/v2/components/a2ui/adapter.ts +156 -0
- package/src/v2/components/a2ui/catalog.ts +858 -0
- package/src/v2/components/a2ui/index.ts +7 -0
- package/src/v2/components/a2ui/utils.ts +67 -0
- package/src/v2/components/a2ui.ts +30 -0
- package/src/v2/components/chat/CopilotChat.vue +777 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +891 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +411 -0
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +87 -0
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +269 -0
- package/src/v2/components/chat/CopilotChatInput.vue +1271 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +476 -0
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +247 -0
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +56 -0
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +93 -0
- package/src/v2/components/chat/CopilotChatToggleButton.vue +145 -0
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +17 -0
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +18 -0
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +161 -0
- package/src/v2/components/chat/CopilotChatUserMessage.vue +322 -0
- package/src/v2/components/chat/CopilotChatView.vue +740 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +73 -0
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +38 -0
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +22 -0
- package/src/v2/components/chat/CopilotPopup.vue +182 -0
- package/src/v2/components/chat/CopilotPopupView.vue +168 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +453 -0
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +140 -0
- package/src/v2/components/chat/CopilotSidebar.vue +178 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +172 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +366 -0
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +142 -0
- package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts +237 -0
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +1240 -0
- package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +138 -0
- package/src/v2/components/chat/__tests__/CopilotChat.onError.test.ts +85 -0
- package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +652 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +683 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +768 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +1108 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.ts +87 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +277 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentRenderer.test.ts +124 -0
- package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.ts +230 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.bottomAnchored.test.ts +83 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +1139 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +1051 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +494 -0
- package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.ts +181 -0
- package/src/v2/components/chat/__tests__/CopilotChatReasoningMessage.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +674 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.test.ts +91 -0
- package/src/v2/components/chat/__tests__/CopilotChatToggleButton.test.ts +93 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.test.ts +382 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +1019 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +516 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.ts +701 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.test.ts +337 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.ts +135 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +278 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.ts +1082 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +166 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.ts +1145 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.test.ts +374 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +636 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +725 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.ts +603 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +214 -0
- package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.ts +394 -0
- package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.ts +82 -0
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +39 -0
- package/src/v2/components/chat/audioRecorder.ts +15 -0
- package/src/v2/components/chat/index.ts +52 -0
- package/src/v2/components/chat/last-user-message-context.ts +39 -0
- package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
- package/src/v2/components/chat/types.ts +481 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +86 -0
- package/src/v2/components/icons/index.ts +22 -0
- package/src/v2/components/index.ts +7 -0
- package/src/v2/hooks/__tests__/standard-schema-types.test.ts +149 -0
- package/src/v2/hooks/__tests__/standard-schema.test.ts +315 -0
- package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.ts +144 -0
- package/src/v2/hooks/__tests__/use-agent-context.test.ts +271 -0
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +64 -0
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +268 -0
- package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.ts +433 -0
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +747 -0
- package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +187 -0
- package/src/v2/hooks/__tests__/use-agent.test.ts +126 -0
- package/src/v2/hooks/__tests__/use-attachments.test.ts +181 -0
- package/src/v2/hooks/__tests__/use-component.test.ts +145 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.ts +527 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +399 -0
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +214 -0
- package/src/v2/hooks/__tests__/use-frontend-tool-available.test.ts +220 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +2320 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.test.ts +648 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +1379 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +282 -0
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +345 -0
- package/src/v2/hooks/__tests__/use-katex-styles.test.ts +69 -0
- package/src/v2/hooks/__tests__/use-keyboard-height.test.ts +199 -0
- package/src/v2/hooks/__tests__/use-pin-to-send.test.ts +363 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +329 -0
- package/src/v2/hooks/__tests__/use-suggestions.e2e.test.ts +397 -0
- package/src/v2/hooks/__tests__/use-suggestions.test.ts +198 -0
- package/src/v2/hooks/__tests__/use-threads.test.ts +1041 -0
- package/src/v2/hooks/__tests__/zod-regression.test.ts +339 -0
- package/src/v2/hooks/index.ts +29 -0
- package/src/v2/hooks/use-agent-context.ts +55 -0
- package/src/v2/hooks/use-agent.ts +345 -0
- package/src/v2/hooks/use-attachments.ts +261 -0
- package/src/v2/hooks/use-capabilities.ts +30 -0
- package/src/v2/hooks/use-component.ts +46 -0
- package/src/v2/hooks/use-configure-suggestions.ts +252 -0
- package/src/v2/hooks/use-default-render-tool.ts +130 -0
- package/src/v2/hooks/use-frontend-tool.ts +68 -0
- package/src/v2/hooks/use-human-in-the-loop.ts +90 -0
- package/src/v2/hooks/use-interrupt.ts +257 -0
- package/src/v2/hooks/use-katex-styles.ts +44 -0
- package/src/v2/hooks/use-keyboard-height.ts +87 -0
- package/src/v2/hooks/use-pin-to-send.ts +160 -0
- package/src/v2/hooks/use-render-activity-message.ts +92 -0
- package/src/v2/hooks/use-render-custom-messages.ts +129 -0
- package/src/v2/hooks/use-render-tool.ts +128 -0
- package/src/v2/hooks/use-suggestions.ts +98 -0
- package/src/v2/hooks/use-threads.ts +208 -0
- package/src/v2/index.ts +11 -0
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +84 -0
- package/src/v2/lib/__tests__/transcription-client.test.ts +65 -0
- package/src/v2/lib/processPartialHtml.ts +21 -0
- package/src/v2/lib/shallow-stable.ts +54 -0
- package/src/v2/lib/transcription-client.ts +151 -0
- package/src/v2/lib/vue-core.ts +161 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.types.ts +15 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +95 -0
- package/src/v2/providers/CopilotKitProvider.types.ts +66 -0
- package/src/v2/providers/CopilotKitProvider.vue +653 -0
- package/src/v2/providers/SandboxFunctionsContext.ts +11 -0
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +309 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.debug.test.ts +295 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.license.test.ts +110 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.ts +67 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.ts +901 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +141 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.ts +871 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +603 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts +104 -0
- package/src/v2/providers/index.ts +21 -0
- package/src/v2/providers/keys.ts +25 -0
- package/src/v2/providers/license-context.ts +16 -0
- package/src/v2/providers/types.ts +40 -0
- package/src/v2/providers/useCopilotChatConfiguration.ts +11 -0
- package/src/v2/providers/useCopilotKit.ts +11 -0
- package/src/v2/providers/useLicenseContext.ts +21 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +157 -0
- package/src/v2/types/a2ui.ts +5 -0
- package/src/v2/types/defineToolCallRenderer.ts +32 -0
- package/src/v2/types/frontend-tool.ts +8 -0
- package/src/v2/types/human-in-the-loop.ts +38 -0
- package/src/v2/types/index.ts +9 -0
- package/src/v2/types/interrupt.ts +15 -0
- package/src/v2/types/sandbox-function.ts +8 -0
- package/src/v2/types/vue-activity-message-renderer.ts +22 -0
- package/src/v2/types/vue-custom-message-renderer.ts +24 -0
- package/src/v2/types/vue-tool-call-renderer.ts +44 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +49 -0
- package/vitest.config.ts +23 -0
|
@@ -0,0 +1,1082 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from "@testing-library/vue";
|
|
2
|
+
import { defineComponent, ref } from "vue";
|
|
3
|
+
import { describe, it, expect, vi } from "vitest";
|
|
4
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
5
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
6
|
+
import CopilotChatView from "../CopilotChatView.vue";
|
|
7
|
+
import CopilotChatInput from "../CopilotChatInput.vue";
|
|
8
|
+
import CopilotChatMessageView from "../CopilotChatMessageView.vue";
|
|
9
|
+
import CopilotChatAssistantMessage from "../CopilotChatAssistantMessage.vue";
|
|
10
|
+
import CopilotChatUserMessage from "../CopilotChatUserMessage.vue";
|
|
11
|
+
import CopilotChatSuggestionView from "../CopilotChatSuggestionView.vue";
|
|
12
|
+
|
|
13
|
+
const createMessages = () => [
|
|
14
|
+
{ id: "1", role: "user" as const, content: "Hello" },
|
|
15
|
+
{ id: "2", role: "assistant" as const, content: "Hi there! How can I help?" },
|
|
16
|
+
{ id: "3", role: "user" as const, content: "Tell me a joke" },
|
|
17
|
+
{
|
|
18
|
+
id: "4",
|
|
19
|
+
role: "assistant" as const,
|
|
20
|
+
content: "Why did the chicken cross the road?",
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const createSuggestions = () => [
|
|
25
|
+
{
|
|
26
|
+
title: "Tell me more",
|
|
27
|
+
message: "Tell me more about that",
|
|
28
|
+
isLoading: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: "Another topic",
|
|
32
|
+
message: "Let's talk about something else",
|
|
33
|
+
isLoading: false,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
function renderInWrapper(component: ReturnType<typeof defineComponent>) {
|
|
38
|
+
const Host = defineComponent({
|
|
39
|
+
components: {
|
|
40
|
+
CopilotKitProvider,
|
|
41
|
+
CopilotChatConfigurationProvider,
|
|
42
|
+
UnderTest: component,
|
|
43
|
+
},
|
|
44
|
+
template: `
|
|
45
|
+
<CopilotKitProvider>
|
|
46
|
+
<CopilotChatConfigurationProvider thread-id="test-thread">
|
|
47
|
+
<div style="height: 400px;">
|
|
48
|
+
<UnderTest />
|
|
49
|
+
</div>
|
|
50
|
+
</CopilotChatConfigurationProvider>
|
|
51
|
+
</CopilotKitProvider>
|
|
52
|
+
`,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return render(Host);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe("CopilotChatView onClick Handlers - Drill-Down E2E Tests", () => {
|
|
59
|
+
describe("Level 1: CopilotChatView Direct Slots", () => {
|
|
60
|
+
describe("scrollToBottomButton onClick (nested under scrollView)", () => {
|
|
61
|
+
it("should handle onClick on scrollToBottomButton via scrollView props", async () => {
|
|
62
|
+
const onClick = vi.fn();
|
|
63
|
+
const Host = defineComponent({
|
|
64
|
+
components: { CopilotChatView },
|
|
65
|
+
setup() {
|
|
66
|
+
return { messages: createMessages(), onClick };
|
|
67
|
+
},
|
|
68
|
+
template: `
|
|
69
|
+
<CopilotChatView :messages="messages">
|
|
70
|
+
<template #scroll-to-bottom-button="{ onClick: scrollClick }">
|
|
71
|
+
<button
|
|
72
|
+
data-testid="scroll-to-bottom-button"
|
|
73
|
+
@click="
|
|
74
|
+
onClick();
|
|
75
|
+
scrollClick();
|
|
76
|
+
"
|
|
77
|
+
>
|
|
78
|
+
scroll
|
|
79
|
+
</button>
|
|
80
|
+
</template>
|
|
81
|
+
</CopilotChatView>
|
|
82
|
+
`,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
renderInWrapper(Host);
|
|
86
|
+
const scrollBtn = screen.queryByTestId("scroll-to-bottom-button");
|
|
87
|
+
if (scrollBtn) {
|
|
88
|
+
await fireEvent.click(scrollBtn);
|
|
89
|
+
expect(onClick).toHaveBeenCalled();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("input onClick", () => {
|
|
95
|
+
it("should handle onClick on input via props object", async () => {
|
|
96
|
+
const onClick = vi.fn();
|
|
97
|
+
const Host = defineComponent({
|
|
98
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
99
|
+
setup() {
|
|
100
|
+
return { messages: createMessages(), onClick };
|
|
101
|
+
},
|
|
102
|
+
template: `
|
|
103
|
+
<CopilotChatView :messages="messages">
|
|
104
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
|
|
105
|
+
<div data-testid="input-slot" @click="onClick">
|
|
106
|
+
<CopilotChatInput
|
|
107
|
+
:model-value="modelValue"
|
|
108
|
+
@update:model-value="onUpdateModelValue"
|
|
109
|
+
@submit-message="onSubmitMessage"
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</template>
|
|
113
|
+
</CopilotChatView>
|
|
114
|
+
`,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
renderInWrapper(Host);
|
|
118
|
+
await fireEvent.click(screen.getByTestId("input-slot"));
|
|
119
|
+
expect(onClick).toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("suggestionView onClick", () => {
|
|
124
|
+
it("should handle onSelectSuggestion when suggestion is clicked", async () => {
|
|
125
|
+
const onSelectSuggestion = vi.fn();
|
|
126
|
+
const Host = defineComponent({
|
|
127
|
+
components: { CopilotChatView },
|
|
128
|
+
setup() {
|
|
129
|
+
return {
|
|
130
|
+
messages: createMessages(),
|
|
131
|
+
suggestions: createSuggestions(),
|
|
132
|
+
onSelectSuggestion,
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
template: `
|
|
136
|
+
<CopilotChatView
|
|
137
|
+
:messages="messages"
|
|
138
|
+
:suggestions="suggestions"
|
|
139
|
+
@select-suggestion="onSelectSuggestion"
|
|
140
|
+
/>
|
|
141
|
+
`,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
renderInWrapper(Host);
|
|
145
|
+
const suggestion = screen.queryByText("Tell me more");
|
|
146
|
+
if (suggestion) {
|
|
147
|
+
await fireEvent.click(suggestion);
|
|
148
|
+
expect(onSelectSuggestion).toHaveBeenCalled();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe("Level 2: CopilotChatInput Drill-Down", () => {
|
|
155
|
+
describe("input -> sendButton onClick", () => {
|
|
156
|
+
it("should handle onClick on sendButton via input props drill-down", async () => {
|
|
157
|
+
const onClick = vi.fn();
|
|
158
|
+
const Host = defineComponent({
|
|
159
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
160
|
+
setup() {
|
|
161
|
+
return { messages: createMessages(), onClick };
|
|
162
|
+
},
|
|
163
|
+
template: `
|
|
164
|
+
<CopilotChatView :messages="messages">
|
|
165
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
|
|
166
|
+
<CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
|
|
167
|
+
<template #send-button="{ onClick: defaultClick }">
|
|
168
|
+
<button
|
|
169
|
+
data-testid="send-button"
|
|
170
|
+
@click="
|
|
171
|
+
onClick();
|
|
172
|
+
defaultClick();
|
|
173
|
+
"
|
|
174
|
+
>
|
|
175
|
+
Send
|
|
176
|
+
</button>
|
|
177
|
+
</template>
|
|
178
|
+
</CopilotChatInput>
|
|
179
|
+
</template>
|
|
180
|
+
</CopilotChatView>
|
|
181
|
+
`,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
renderInWrapper(Host);
|
|
185
|
+
await fireEvent.click(screen.getByTestId("send-button"));
|
|
186
|
+
expect(onClick).toHaveBeenCalled();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe("input -> startTranscribeButton onClick", () => {
|
|
191
|
+
it("should handle onClick on startTranscribeButton via input props drill-down", async () => {
|
|
192
|
+
const onClick = vi.fn();
|
|
193
|
+
const onStartTranscribe = vi.fn();
|
|
194
|
+
const Host = defineComponent({
|
|
195
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
196
|
+
setup() {
|
|
197
|
+
return { messages: createMessages(), onClick, onStartTranscribe };
|
|
198
|
+
},
|
|
199
|
+
template: `
|
|
200
|
+
<CopilotChatView :messages="messages" @start-transcribe="onStartTranscribe">
|
|
201
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage, onStartTranscribe }">
|
|
202
|
+
<CopilotChatInput
|
|
203
|
+
:model-value="modelValue"
|
|
204
|
+
@update:model-value="onUpdateModelValue"
|
|
205
|
+
@submit-message="onSubmitMessage"
|
|
206
|
+
@start-transcribe="onStartTranscribe"
|
|
207
|
+
>
|
|
208
|
+
<template #start-transcribe-button="{ onClick: defaultClick }">
|
|
209
|
+
<button
|
|
210
|
+
data-testid="start-transcribe-button"
|
|
211
|
+
@click="
|
|
212
|
+
onClick();
|
|
213
|
+
defaultClick();
|
|
214
|
+
"
|
|
215
|
+
>
|
|
216
|
+
Start
|
|
217
|
+
</button>
|
|
218
|
+
</template>
|
|
219
|
+
</CopilotChatInput>
|
|
220
|
+
</template>
|
|
221
|
+
</CopilotChatView>
|
|
222
|
+
`,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
renderInWrapper(Host);
|
|
226
|
+
await fireEvent.click(screen.getByTestId("start-transcribe-button"));
|
|
227
|
+
expect(onClick).toHaveBeenCalled();
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe("input -> addMenuButton onClick", () => {
|
|
232
|
+
it("should handle onClick on addMenuButton via input props drill-down", async () => {
|
|
233
|
+
const onClick = vi.fn();
|
|
234
|
+
const toolsMenu = [{ label: "Action", action: vi.fn() }];
|
|
235
|
+
const Host = defineComponent({
|
|
236
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
237
|
+
setup() {
|
|
238
|
+
return { messages: createMessages(), onClick, toolsMenu };
|
|
239
|
+
},
|
|
240
|
+
template: `
|
|
241
|
+
<CopilotChatView :messages="messages" :input-tools-menu="toolsMenu">
|
|
242
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage, inputToolsMenu }">
|
|
243
|
+
<CopilotChatInput
|
|
244
|
+
:model-value="modelValue"
|
|
245
|
+
:tools-menu="inputToolsMenu"
|
|
246
|
+
@update:model-value="onUpdateModelValue"
|
|
247
|
+
@submit-message="onSubmitMessage"
|
|
248
|
+
>
|
|
249
|
+
<template #add-menu-button="{ toggleMenu }">
|
|
250
|
+
<button
|
|
251
|
+
data-testid="add-menu-button"
|
|
252
|
+
@click="
|
|
253
|
+
onClick();
|
|
254
|
+
toggleMenu();
|
|
255
|
+
"
|
|
256
|
+
>
|
|
257
|
+
Add
|
|
258
|
+
</button>
|
|
259
|
+
</template>
|
|
260
|
+
</CopilotChatInput>
|
|
261
|
+
</template>
|
|
262
|
+
</CopilotChatView>
|
|
263
|
+
`,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
renderInWrapper(Host);
|
|
267
|
+
await fireEvent.click(screen.getByTestId("add-menu-button"));
|
|
268
|
+
expect(onClick).toHaveBeenCalled();
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe("input -> textArea onFocus/onBlur", () => {
|
|
273
|
+
it("should handle onFocus on textArea via input props drill-down", async () => {
|
|
274
|
+
const onFocus = vi.fn();
|
|
275
|
+
const Host = defineComponent({
|
|
276
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
277
|
+
setup() {
|
|
278
|
+
return { messages: createMessages(), onFocus };
|
|
279
|
+
},
|
|
280
|
+
template: `
|
|
281
|
+
<CopilotChatView :messages="messages">
|
|
282
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
|
|
283
|
+
<CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
|
|
284
|
+
<template #text-area="{ value, onInput, onKeydown }">
|
|
285
|
+
<textarea
|
|
286
|
+
data-testid="custom-textarea"
|
|
287
|
+
:value="value"
|
|
288
|
+
@focus="onFocus"
|
|
289
|
+
@input="onInput"
|
|
290
|
+
@keydown="onKeydown"
|
|
291
|
+
/>
|
|
292
|
+
</template>
|
|
293
|
+
</CopilotChatInput>
|
|
294
|
+
</template>
|
|
295
|
+
</CopilotChatView>
|
|
296
|
+
`,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
renderInWrapper(Host);
|
|
300
|
+
await fireEvent.focus(screen.getByTestId("custom-textarea"));
|
|
301
|
+
expect(onFocus).toHaveBeenCalled();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it("should handle onBlur on textArea via input props drill-down", async () => {
|
|
305
|
+
const onBlur = vi.fn();
|
|
306
|
+
const Host = defineComponent({
|
|
307
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
308
|
+
setup() {
|
|
309
|
+
return { messages: createMessages(), onBlur };
|
|
310
|
+
},
|
|
311
|
+
template: `
|
|
312
|
+
<CopilotChatView :messages="messages">
|
|
313
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
|
|
314
|
+
<CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
|
|
315
|
+
<template #text-area="{ value, onInput, onKeydown }">
|
|
316
|
+
<textarea
|
|
317
|
+
data-testid="custom-textarea-blur"
|
|
318
|
+
:value="value"
|
|
319
|
+
@blur="onBlur"
|
|
320
|
+
@input="onInput"
|
|
321
|
+
@keydown="onKeydown"
|
|
322
|
+
/>
|
|
323
|
+
</template>
|
|
324
|
+
</CopilotChatInput>
|
|
325
|
+
</template>
|
|
326
|
+
</CopilotChatView>
|
|
327
|
+
`,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
renderInWrapper(Host);
|
|
331
|
+
const textarea = screen.getByTestId("custom-textarea-blur");
|
|
332
|
+
await fireEvent.focus(textarea);
|
|
333
|
+
await fireEvent.blur(textarea);
|
|
334
|
+
expect(onBlur).toHaveBeenCalled();
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
describe("Level 2: CopilotChatMessageView Drill-Down", () => {
|
|
340
|
+
describe("messageView -> assistantMessage onClick", () => {
|
|
341
|
+
it("should handle onClick on assistantMessage container via messageView drill-down", async () => {
|
|
342
|
+
const onClick = vi.fn();
|
|
343
|
+
const Host = defineComponent({
|
|
344
|
+
components: {
|
|
345
|
+
CopilotChatView,
|
|
346
|
+
CopilotChatMessageView,
|
|
347
|
+
CopilotChatAssistantMessage,
|
|
348
|
+
},
|
|
349
|
+
setup() {
|
|
350
|
+
return { messages: createMessages(), onClick };
|
|
351
|
+
},
|
|
352
|
+
template: `
|
|
353
|
+
<CopilotChatView :messages="messages">
|
|
354
|
+
<template #message-view="{ messages, isRunning }">
|
|
355
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
356
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
357
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
|
|
358
|
+
<template #message-renderer="{ content }">
|
|
359
|
+
<div data-testid="assistant-click-target" @click="onClick">{{ content }}</div>
|
|
360
|
+
</template>
|
|
361
|
+
</CopilotChatAssistantMessage>
|
|
362
|
+
</template>
|
|
363
|
+
</CopilotChatMessageView>
|
|
364
|
+
</template>
|
|
365
|
+
</CopilotChatView>
|
|
366
|
+
`,
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
renderInWrapper(Host);
|
|
370
|
+
await fireEvent.click(
|
|
371
|
+
screen.getAllByTestId("assistant-click-target")[0],
|
|
372
|
+
);
|
|
373
|
+
expect(onClick).toHaveBeenCalled();
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
describe("messageView -> userMessage onClick", () => {
|
|
378
|
+
it("should handle onClick on userMessage container via messageView drill-down", async () => {
|
|
379
|
+
const onClick = vi.fn();
|
|
380
|
+
const Host = defineComponent({
|
|
381
|
+
components: {
|
|
382
|
+
CopilotChatView,
|
|
383
|
+
CopilotChatMessageView,
|
|
384
|
+
CopilotChatUserMessage,
|
|
385
|
+
},
|
|
386
|
+
setup() {
|
|
387
|
+
return { messages: createMessages(), onClick };
|
|
388
|
+
},
|
|
389
|
+
template: `
|
|
390
|
+
<CopilotChatView :messages="messages">
|
|
391
|
+
<template #message-view="{ messages, isRunning }">
|
|
392
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
393
|
+
<template #user-message="{ message }">
|
|
394
|
+
<CopilotChatUserMessage :message="message">
|
|
395
|
+
<template #message-renderer="{ content }">
|
|
396
|
+
<div data-testid="user-click-target" @click="onClick">{{ content }}</div>
|
|
397
|
+
</template>
|
|
398
|
+
</CopilotChatUserMessage>
|
|
399
|
+
</template>
|
|
400
|
+
</CopilotChatMessageView>
|
|
401
|
+
</template>
|
|
402
|
+
</CopilotChatView>
|
|
403
|
+
`,
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
renderInWrapper(Host);
|
|
407
|
+
await fireEvent.click(screen.getAllByTestId("user-click-target")[0]);
|
|
408
|
+
expect(onClick).toHaveBeenCalled();
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
describe("Level 3: CopilotChatAssistantMessage Toolbar Drill-Down", () => {
|
|
414
|
+
describe("messageView -> assistantMessage -> copyButton onClick", () => {
|
|
415
|
+
it("should handle onClick on copyButton via deep drill-down", async () => {
|
|
416
|
+
const onClick = vi.fn();
|
|
417
|
+
const Host = defineComponent({
|
|
418
|
+
components: {
|
|
419
|
+
CopilotChatView,
|
|
420
|
+
CopilotChatMessageView,
|
|
421
|
+
CopilotChatAssistantMessage,
|
|
422
|
+
},
|
|
423
|
+
setup() {
|
|
424
|
+
return { messages: createMessages(), onClick };
|
|
425
|
+
},
|
|
426
|
+
template: `
|
|
427
|
+
<CopilotChatView :messages="messages">
|
|
428
|
+
<template #message-view="{ messages, isRunning }">
|
|
429
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
430
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
431
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
|
|
432
|
+
<template #copy-button="{ onCopy }">
|
|
433
|
+
<button data-testid="copy-button" @click="onClick(); onCopy();">Copy</button>
|
|
434
|
+
</template>
|
|
435
|
+
</CopilotChatAssistantMessage>
|
|
436
|
+
</template>
|
|
437
|
+
</CopilotChatMessageView>
|
|
438
|
+
</template>
|
|
439
|
+
</CopilotChatView>
|
|
440
|
+
`,
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
renderInWrapper(Host);
|
|
444
|
+
await fireEvent.click(screen.getAllByTestId("copy-button")[0]);
|
|
445
|
+
expect(onClick).toHaveBeenCalled();
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
describe("messageView -> assistantMessage -> thumbsUpButton onClick", () => {
|
|
450
|
+
it("should handle onClick on thumbsUpButton via deep drill-down", async () => {
|
|
451
|
+
const onClick = vi.fn();
|
|
452
|
+
const onThumbsUp = vi.fn();
|
|
453
|
+
const Host = defineComponent({
|
|
454
|
+
components: {
|
|
455
|
+
CopilotChatView,
|
|
456
|
+
CopilotChatMessageView,
|
|
457
|
+
CopilotChatAssistantMessage,
|
|
458
|
+
},
|
|
459
|
+
setup() {
|
|
460
|
+
return { messages: createMessages(), onClick, onThumbsUp };
|
|
461
|
+
},
|
|
462
|
+
template: `
|
|
463
|
+
<CopilotChatView :messages="messages">
|
|
464
|
+
<template #message-view="{ messages, isRunning }">
|
|
465
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
466
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
467
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning" @thumbs-up="onThumbsUp">
|
|
468
|
+
<template #thumbs-up-button="{ onThumbsUp: action }">
|
|
469
|
+
<button data-testid="thumbs-up-button" @click="onClick(); action();">Up</button>
|
|
470
|
+
</template>
|
|
471
|
+
</CopilotChatAssistantMessage>
|
|
472
|
+
</template>
|
|
473
|
+
</CopilotChatMessageView>
|
|
474
|
+
</template>
|
|
475
|
+
</CopilotChatView>
|
|
476
|
+
`,
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
renderInWrapper(Host);
|
|
480
|
+
await fireEvent.click(screen.getAllByTestId("thumbs-up-button")[0]);
|
|
481
|
+
expect(onClick).toHaveBeenCalled();
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
describe("messageView -> assistantMessage -> thumbsDownButton onClick", () => {
|
|
486
|
+
it("should handle onClick on thumbsDownButton via deep drill-down", async () => {
|
|
487
|
+
const onClick = vi.fn();
|
|
488
|
+
const onThumbsDown = vi.fn();
|
|
489
|
+
const Host = defineComponent({
|
|
490
|
+
components: {
|
|
491
|
+
CopilotChatView,
|
|
492
|
+
CopilotChatMessageView,
|
|
493
|
+
CopilotChatAssistantMessage,
|
|
494
|
+
},
|
|
495
|
+
setup() {
|
|
496
|
+
return { messages: createMessages(), onClick, onThumbsDown };
|
|
497
|
+
},
|
|
498
|
+
template: `
|
|
499
|
+
<CopilotChatView :messages="messages">
|
|
500
|
+
<template #message-view="{ messages, isRunning }">
|
|
501
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
502
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
503
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning" @thumbs-down="onThumbsDown">
|
|
504
|
+
<template #thumbs-down-button="{ onThumbsDown: action }">
|
|
505
|
+
<button data-testid="thumbs-down-button" @click="onClick(); action();">Down</button>
|
|
506
|
+
</template>
|
|
507
|
+
</CopilotChatAssistantMessage>
|
|
508
|
+
</template>
|
|
509
|
+
</CopilotChatMessageView>
|
|
510
|
+
</template>
|
|
511
|
+
</CopilotChatView>
|
|
512
|
+
`,
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
renderInWrapper(Host);
|
|
516
|
+
await fireEvent.click(screen.getAllByTestId("thumbs-down-button")[0]);
|
|
517
|
+
expect(onClick).toHaveBeenCalled();
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
describe("messageView -> assistantMessage -> readAloudButton onClick", () => {
|
|
522
|
+
it("should handle onClick on readAloudButton via deep drill-down", async () => {
|
|
523
|
+
const onClick = vi.fn();
|
|
524
|
+
const onReadAloud = vi.fn();
|
|
525
|
+
const Host = defineComponent({
|
|
526
|
+
components: {
|
|
527
|
+
CopilotChatView,
|
|
528
|
+
CopilotChatMessageView,
|
|
529
|
+
CopilotChatAssistantMessage,
|
|
530
|
+
},
|
|
531
|
+
setup() {
|
|
532
|
+
return { messages: createMessages(), onClick, onReadAloud };
|
|
533
|
+
},
|
|
534
|
+
template: `
|
|
535
|
+
<CopilotChatView :messages="messages">
|
|
536
|
+
<template #message-view="{ messages, isRunning }">
|
|
537
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
538
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
539
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning" @read-aloud="onReadAloud">
|
|
540
|
+
<template #read-aloud-button="{ onReadAloud: action }">
|
|
541
|
+
<button data-testid="read-aloud-button" @click="onClick(); action();">Read</button>
|
|
542
|
+
</template>
|
|
543
|
+
</CopilotChatAssistantMessage>
|
|
544
|
+
</template>
|
|
545
|
+
</CopilotChatMessageView>
|
|
546
|
+
</template>
|
|
547
|
+
</CopilotChatView>
|
|
548
|
+
`,
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
renderInWrapper(Host);
|
|
552
|
+
await fireEvent.click(screen.getAllByTestId("read-aloud-button")[0]);
|
|
553
|
+
expect(onClick).toHaveBeenCalled();
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
describe("messageView -> assistantMessage -> regenerateButton onClick", () => {
|
|
558
|
+
it("should handle onClick on regenerateButton via deep drill-down", async () => {
|
|
559
|
+
const onClick = vi.fn();
|
|
560
|
+
const onRegenerate = vi.fn();
|
|
561
|
+
const Host = defineComponent({
|
|
562
|
+
components: {
|
|
563
|
+
CopilotChatView,
|
|
564
|
+
CopilotChatMessageView,
|
|
565
|
+
CopilotChatAssistantMessage,
|
|
566
|
+
},
|
|
567
|
+
setup() {
|
|
568
|
+
return { messages: createMessages(), onClick, onRegenerate };
|
|
569
|
+
},
|
|
570
|
+
template: `
|
|
571
|
+
<CopilotChatView :messages="messages">
|
|
572
|
+
<template #message-view="{ messages, isRunning }">
|
|
573
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
574
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
575
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning" @regenerate="onRegenerate">
|
|
576
|
+
<template #regenerate-button="{ onRegenerate: action }">
|
|
577
|
+
<button data-testid="regenerate-button" @click="onClick(); action();">Regenerate</button>
|
|
578
|
+
</template>
|
|
579
|
+
</CopilotChatAssistantMessage>
|
|
580
|
+
</template>
|
|
581
|
+
</CopilotChatMessageView>
|
|
582
|
+
</template>
|
|
583
|
+
</CopilotChatView>
|
|
584
|
+
`,
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
renderInWrapper(Host);
|
|
588
|
+
await fireEvent.click(screen.getAllByTestId("regenerate-button")[0]);
|
|
589
|
+
expect(onClick).toHaveBeenCalled();
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
describe("messageView -> assistantMessage -> toolbar onClick", () => {
|
|
594
|
+
it("should handle onClick on entire toolbar via deep drill-down", async () => {
|
|
595
|
+
const onClick = vi.fn();
|
|
596
|
+
const Host = defineComponent({
|
|
597
|
+
components: {
|
|
598
|
+
CopilotChatView,
|
|
599
|
+
CopilotChatMessageView,
|
|
600
|
+
CopilotChatAssistantMessage,
|
|
601
|
+
},
|
|
602
|
+
setup() {
|
|
603
|
+
return { messages: createMessages(), onClick };
|
|
604
|
+
},
|
|
605
|
+
template: `
|
|
606
|
+
<CopilotChatView :messages="messages">
|
|
607
|
+
<template #message-view="{ messages, isRunning }">
|
|
608
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
609
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
610
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
|
|
611
|
+
<template #toolbar>
|
|
612
|
+
<div data-testid="assistant-toolbar-click" @click="onClick">Toolbar</div>
|
|
613
|
+
</template>
|
|
614
|
+
</CopilotChatAssistantMessage>
|
|
615
|
+
</template>
|
|
616
|
+
</CopilotChatMessageView>
|
|
617
|
+
</template>
|
|
618
|
+
</CopilotChatView>
|
|
619
|
+
`,
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
renderInWrapper(Host);
|
|
623
|
+
await fireEvent.click(
|
|
624
|
+
screen.getAllByTestId("assistant-toolbar-click")[0],
|
|
625
|
+
);
|
|
626
|
+
expect(onClick).toHaveBeenCalled();
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
describe("Level 3: CopilotChatUserMessage Toolbar Drill-Down", () => {
|
|
632
|
+
describe("messageView -> userMessage -> copyButton onClick", () => {
|
|
633
|
+
it("should handle onClick on copyButton via deep drill-down", async () => {
|
|
634
|
+
const onClick = vi.fn();
|
|
635
|
+
const Host = defineComponent({
|
|
636
|
+
components: {
|
|
637
|
+
CopilotChatView,
|
|
638
|
+
CopilotChatMessageView,
|
|
639
|
+
CopilotChatUserMessage,
|
|
640
|
+
},
|
|
641
|
+
setup() {
|
|
642
|
+
return { messages: createMessages(), onClick };
|
|
643
|
+
},
|
|
644
|
+
template: `
|
|
645
|
+
<CopilotChatView :messages="messages">
|
|
646
|
+
<template #message-view="{ messages, isRunning }">
|
|
647
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
648
|
+
<template #user-message="{ message }">
|
|
649
|
+
<CopilotChatUserMessage :message="message">
|
|
650
|
+
<template #copy-button="{ onCopy }">
|
|
651
|
+
<button data-testid="user-copy-button" @click="onClick(); onCopy();">Copy</button>
|
|
652
|
+
</template>
|
|
653
|
+
</CopilotChatUserMessage>
|
|
654
|
+
</template>
|
|
655
|
+
</CopilotChatMessageView>
|
|
656
|
+
</template>
|
|
657
|
+
</CopilotChatView>
|
|
658
|
+
`,
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
renderInWrapper(Host);
|
|
662
|
+
await fireEvent.click(screen.getAllByTestId("user-copy-button")[0]);
|
|
663
|
+
expect(onClick).toHaveBeenCalled();
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
describe("messageView -> userMessage -> editButton onClick", () => {
|
|
668
|
+
it("should handle onClick on editButton via deep drill-down", async () => {
|
|
669
|
+
const onClick = vi.fn();
|
|
670
|
+
const onEditMessage = vi.fn();
|
|
671
|
+
const Host = defineComponent({
|
|
672
|
+
components: {
|
|
673
|
+
CopilotChatView,
|
|
674
|
+
CopilotChatMessageView,
|
|
675
|
+
CopilotChatUserMessage,
|
|
676
|
+
},
|
|
677
|
+
setup() {
|
|
678
|
+
return { messages: createMessages(), onClick, onEditMessage };
|
|
679
|
+
},
|
|
680
|
+
template: `
|
|
681
|
+
<CopilotChatView :messages="messages">
|
|
682
|
+
<template #message-view="{ messages, isRunning }">
|
|
683
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
684
|
+
<template #user-message="{ message }">
|
|
685
|
+
<CopilotChatUserMessage :message="message" @edit-message="onEditMessage">
|
|
686
|
+
<template #edit-button="{ onEdit }">
|
|
687
|
+
<button data-testid="user-edit-button" @click="onClick(); onEdit();">Edit</button>
|
|
688
|
+
</template>
|
|
689
|
+
</CopilotChatUserMessage>
|
|
690
|
+
</template>
|
|
691
|
+
</CopilotChatMessageView>
|
|
692
|
+
</template>
|
|
693
|
+
</CopilotChatView>
|
|
694
|
+
`,
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
renderInWrapper(Host);
|
|
698
|
+
await fireEvent.click(screen.getAllByTestId("user-edit-button")[0]);
|
|
699
|
+
expect(onClick).toHaveBeenCalled();
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
describe("Level 2: SuggestionView Drill-Down", () => {
|
|
705
|
+
describe("suggestionView -> container onClick", () => {
|
|
706
|
+
it("should handle onClick on suggestion container via drill-down", async () => {
|
|
707
|
+
const onClick = vi.fn();
|
|
708
|
+
const Host = defineComponent({
|
|
709
|
+
components: { CopilotChatView, CopilotChatSuggestionView },
|
|
710
|
+
setup() {
|
|
711
|
+
return {
|
|
712
|
+
messages: createMessages(),
|
|
713
|
+
suggestions: createSuggestions(),
|
|
714
|
+
onClick,
|
|
715
|
+
};
|
|
716
|
+
},
|
|
717
|
+
template: `
|
|
718
|
+
<CopilotChatView :messages="messages" :suggestions="suggestions">
|
|
719
|
+
<template #suggestion-view="{ suggestions, loadingIndexes, onSelectSuggestion }">
|
|
720
|
+
<div data-testid="suggestion-container" class="pointer-events-auto" @click="onClick">
|
|
721
|
+
<CopilotChatSuggestionView
|
|
722
|
+
:suggestions="suggestions"
|
|
723
|
+
:loading-indexes="loadingIndexes"
|
|
724
|
+
@select-suggestion="(s, i) => onSelectSuggestion(s, i)"
|
|
725
|
+
/>
|
|
726
|
+
</div>
|
|
727
|
+
</template>
|
|
728
|
+
</CopilotChatView>
|
|
729
|
+
`,
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
renderInWrapper(Host);
|
|
733
|
+
await fireEvent.click(screen.getByTestId("suggestion-container"));
|
|
734
|
+
expect(onClick).toHaveBeenCalled();
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
describe("suggestionView -> suggestion onClick", () => {
|
|
739
|
+
it("should handle onClick on individual suggestion pills via drill-down", async () => {
|
|
740
|
+
const onClick = vi.fn();
|
|
741
|
+
const Host = defineComponent({
|
|
742
|
+
components: { CopilotChatView, CopilotChatSuggestionView },
|
|
743
|
+
setup() {
|
|
744
|
+
return {
|
|
745
|
+
messages: createMessages(),
|
|
746
|
+
suggestions: createSuggestions(),
|
|
747
|
+
onClick,
|
|
748
|
+
};
|
|
749
|
+
},
|
|
750
|
+
template: `
|
|
751
|
+
<CopilotChatView :messages="messages" :suggestions="suggestions">
|
|
752
|
+
<template #suggestion-view="{ suggestions, loadingIndexes, onSelectSuggestion }">
|
|
753
|
+
<CopilotChatSuggestionView :suggestions="suggestions" :loading-indexes="loadingIndexes">
|
|
754
|
+
<template #suggestion="{ suggestion, index, onSelect }">
|
|
755
|
+
<button
|
|
756
|
+
:data-testid="'suggestion-pill-' + index"
|
|
757
|
+
@click="
|
|
758
|
+
onClick();
|
|
759
|
+
onSelect();
|
|
760
|
+
onSelectSuggestion(suggestion, index);
|
|
761
|
+
"
|
|
762
|
+
>
|
|
763
|
+
{{ suggestion.title }}
|
|
764
|
+
</button>
|
|
765
|
+
</template>
|
|
766
|
+
</CopilotChatSuggestionView>
|
|
767
|
+
</template>
|
|
768
|
+
</CopilotChatView>
|
|
769
|
+
`,
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
renderInWrapper(Host);
|
|
773
|
+
await fireEvent.click(screen.getByTestId("suggestion-pill-0"));
|
|
774
|
+
expect(onClick).toHaveBeenCalled();
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
describe("Function Render Slot Pattern", () => {
|
|
780
|
+
describe("input slot with render function", () => {
|
|
781
|
+
it("should support passing render function to input slot", () => {
|
|
782
|
+
const Host = defineComponent({
|
|
783
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
784
|
+
setup() {
|
|
785
|
+
return { messages: createMessages() };
|
|
786
|
+
},
|
|
787
|
+
template: `
|
|
788
|
+
<CopilotChatView :messages="messages">
|
|
789
|
+
<template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
|
|
790
|
+
<CopilotChatInput
|
|
791
|
+
:model-value="modelValue"
|
|
792
|
+
@update:model-value="onUpdateModelValue"
|
|
793
|
+
@submit-message="onSubmitMessage"
|
|
794
|
+
>
|
|
795
|
+
<template #send-button="{ onClick }">
|
|
796
|
+
<button class="custom-send-class" @click="onClick">Send</button>
|
|
797
|
+
</template>
|
|
798
|
+
</CopilotChatInput>
|
|
799
|
+
</template>
|
|
800
|
+
</CopilotChatView>
|
|
801
|
+
`,
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
renderInWrapper(Host);
|
|
805
|
+
expect(document.querySelector(".custom-send-class")).toBeDefined();
|
|
806
|
+
});
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
describe("messageView slot with render function", () => {
|
|
810
|
+
it("should support passing render function to messageView slot", () => {
|
|
811
|
+
const Host = defineComponent({
|
|
812
|
+
components: { CopilotChatView, CopilotChatMessageView },
|
|
813
|
+
setup() {
|
|
814
|
+
return { messages: createMessages() };
|
|
815
|
+
},
|
|
816
|
+
template: `
|
|
817
|
+
<CopilotChatView :messages="messages">
|
|
818
|
+
<template #message-view="{ messages, isRunning }">
|
|
819
|
+
<CopilotChatMessageView class="custom-message-view" :messages="messages" :is-running="isRunning" />
|
|
820
|
+
</template>
|
|
821
|
+
</CopilotChatView>
|
|
822
|
+
`,
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
renderInWrapper(Host);
|
|
826
|
+
expect(document.querySelector(".custom-message-view")).toBeDefined();
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
describe("Callback Propagation Through Slot Hierarchy", () => {
|
|
832
|
+
describe("onSubmitMessage propagation", () => {
|
|
833
|
+
it("should propagate onSubmitMessage through input slot", async () => {
|
|
834
|
+
const onSubmitMessage = vi.fn();
|
|
835
|
+
const Host = defineComponent({
|
|
836
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
837
|
+
setup() {
|
|
838
|
+
const input = ref("");
|
|
839
|
+
return { messages: createMessages(), onSubmitMessage, input };
|
|
840
|
+
},
|
|
841
|
+
template: `
|
|
842
|
+
<CopilotChatView :messages="messages" @submit-message="onSubmitMessage">
|
|
843
|
+
<template #input="{ onSubmitMessage, onUpdateModelValue }">
|
|
844
|
+
<button data-testid="submit-propagation" @click="onUpdateModelValue('Test message'); onSubmitMessage('Test message')">
|
|
845
|
+
submit
|
|
846
|
+
</button>
|
|
847
|
+
</template>
|
|
848
|
+
</CopilotChatView>
|
|
849
|
+
`,
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
renderInWrapper(Host);
|
|
853
|
+
await fireEvent.click(screen.getByTestId("submit-propagation"));
|
|
854
|
+
expect(onSubmitMessage).toHaveBeenCalledWith("Test message");
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
describe("onStop propagation", () => {
|
|
859
|
+
it("should propagate onStop through input slot", async () => {
|
|
860
|
+
const onStop = vi.fn();
|
|
861
|
+
const Host = defineComponent({
|
|
862
|
+
components: { CopilotChatView, CopilotChatInput },
|
|
863
|
+
setup() {
|
|
864
|
+
return { messages: createMessages(), onStop };
|
|
865
|
+
},
|
|
866
|
+
template: `
|
|
867
|
+
<CopilotChatView :messages="messages" :is-running="true" @stop="onStop">
|
|
868
|
+
<template #input="{ onStop }">
|
|
869
|
+
<button data-testid="stop-propagation" @click="onStop()">stop</button>
|
|
870
|
+
</template>
|
|
871
|
+
</CopilotChatView>
|
|
872
|
+
`,
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
renderInWrapper(Host);
|
|
876
|
+
await fireEvent.click(screen.getByTestId("stop-propagation"));
|
|
877
|
+
expect(onStop).toHaveBeenCalled();
|
|
878
|
+
});
|
|
879
|
+
});
|
|
880
|
+
|
|
881
|
+
describe("onThumbsUp/onThumbsDown propagation", () => {
|
|
882
|
+
it("should propagate onThumbsUp through messageView slot", async () => {
|
|
883
|
+
const onThumbsUp = vi.fn();
|
|
884
|
+
const Host = defineComponent({
|
|
885
|
+
components: {
|
|
886
|
+
CopilotChatView,
|
|
887
|
+
CopilotChatMessageView,
|
|
888
|
+
CopilotChatAssistantMessage,
|
|
889
|
+
},
|
|
890
|
+
setup() {
|
|
891
|
+
return { messages: createMessages(), onThumbsUp };
|
|
892
|
+
},
|
|
893
|
+
template: `
|
|
894
|
+
<CopilotChatView :messages="messages">
|
|
895
|
+
<template #message-view="{ messages, isRunning }">
|
|
896
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
897
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
898
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning" @thumbs-up="onThumbsUp">
|
|
899
|
+
<template #thumbs-up-button="{ onThumbsUp: action }">
|
|
900
|
+
<button data-testid="thumbs-up-propagation" @click="action()">up</button>
|
|
901
|
+
</template>
|
|
902
|
+
</CopilotChatAssistantMessage>
|
|
903
|
+
</template>
|
|
904
|
+
</CopilotChatMessageView>
|
|
905
|
+
</template>
|
|
906
|
+
</CopilotChatView>
|
|
907
|
+
`,
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
renderInWrapper(Host);
|
|
911
|
+
await fireEvent.click(
|
|
912
|
+
screen.getAllByTestId("thumbs-up-propagation")[0],
|
|
913
|
+
);
|
|
914
|
+
expect(onThumbsUp).toHaveBeenCalled();
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
it("should propagate onThumbsDown through messageView slot", async () => {
|
|
918
|
+
const onThumbsDown = vi.fn();
|
|
919
|
+
const Host = defineComponent({
|
|
920
|
+
components: {
|
|
921
|
+
CopilotChatView,
|
|
922
|
+
CopilotChatMessageView,
|
|
923
|
+
CopilotChatAssistantMessage,
|
|
924
|
+
},
|
|
925
|
+
setup() {
|
|
926
|
+
return { messages: createMessages(), onThumbsDown };
|
|
927
|
+
},
|
|
928
|
+
template: `
|
|
929
|
+
<CopilotChatView :messages="messages">
|
|
930
|
+
<template #message-view="{ messages, isRunning }">
|
|
931
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
932
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
933
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning" @thumbs-down="onThumbsDown">
|
|
934
|
+
<template #thumbs-down-button="{ onThumbsDown: action }">
|
|
935
|
+
<button data-testid="thumbs-down-propagation" @click="action()">down</button>
|
|
936
|
+
</template>
|
|
937
|
+
</CopilotChatAssistantMessage>
|
|
938
|
+
</template>
|
|
939
|
+
</CopilotChatMessageView>
|
|
940
|
+
</template>
|
|
941
|
+
</CopilotChatView>
|
|
942
|
+
`,
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
renderInWrapper(Host);
|
|
946
|
+
await fireEvent.click(
|
|
947
|
+
screen.getAllByTestId("thumbs-down-propagation")[0],
|
|
948
|
+
);
|
|
949
|
+
expect(onThumbsDown).toHaveBeenCalled();
|
|
950
|
+
});
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
describe("onEditMessage propagation", () => {
|
|
954
|
+
it("should propagate onEditMessage through messageView slot", async () => {
|
|
955
|
+
const onEditMessage = vi.fn();
|
|
956
|
+
const Host = defineComponent({
|
|
957
|
+
components: {
|
|
958
|
+
CopilotChatView,
|
|
959
|
+
CopilotChatMessageView,
|
|
960
|
+
CopilotChatUserMessage,
|
|
961
|
+
},
|
|
962
|
+
setup() {
|
|
963
|
+
return { messages: createMessages(), onEditMessage };
|
|
964
|
+
},
|
|
965
|
+
template: `
|
|
966
|
+
<CopilotChatView :messages="messages">
|
|
967
|
+
<template #message-view="{ messages, isRunning }">
|
|
968
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
969
|
+
<template #user-message="{ message }">
|
|
970
|
+
<CopilotChatUserMessage :message="message" @edit-message="onEditMessage">
|
|
971
|
+
<template #edit-button="{ onEdit }">
|
|
972
|
+
<button data-testid="edit-propagation" @click="onEdit()">edit</button>
|
|
973
|
+
</template>
|
|
974
|
+
</CopilotChatUserMessage>
|
|
975
|
+
</template>
|
|
976
|
+
</CopilotChatMessageView>
|
|
977
|
+
</template>
|
|
978
|
+
</CopilotChatView>
|
|
979
|
+
`,
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
renderInWrapper(Host);
|
|
983
|
+
await fireEvent.click(screen.getAllByTestId("edit-propagation")[0]);
|
|
984
|
+
expect(onEditMessage).toHaveBeenCalled();
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
describe("Combined Customization with onClick", () => {
|
|
990
|
+
it("should handle onClick alongside tailwind class customization", async () => {
|
|
991
|
+
const onClick = vi.fn();
|
|
992
|
+
const Host = defineComponent({
|
|
993
|
+
components: {
|
|
994
|
+
CopilotChatView,
|
|
995
|
+
CopilotChatMessageView,
|
|
996
|
+
CopilotChatAssistantMessage,
|
|
997
|
+
},
|
|
998
|
+
setup() {
|
|
999
|
+
return { messages: createMessages(), onClick };
|
|
1000
|
+
},
|
|
1001
|
+
template: `
|
|
1002
|
+
<CopilotChatView :messages="messages">
|
|
1003
|
+
<template #message-view="{ messages, isRunning }">
|
|
1004
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
1005
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
1006
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
|
|
1007
|
+
<template #copy-button="{ onCopy }">
|
|
1008
|
+
<button
|
|
1009
|
+
class="custom-copy-class"
|
|
1010
|
+
@click="
|
|
1011
|
+
onClick();
|
|
1012
|
+
onCopy();
|
|
1013
|
+
"
|
|
1014
|
+
>
|
|
1015
|
+
Copy
|
|
1016
|
+
</button>
|
|
1017
|
+
</template>
|
|
1018
|
+
</CopilotChatAssistantMessage>
|
|
1019
|
+
</template>
|
|
1020
|
+
</CopilotChatMessageView>
|
|
1021
|
+
</template>
|
|
1022
|
+
</CopilotChatView>
|
|
1023
|
+
`,
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
const { container } = renderInWrapper(Host);
|
|
1027
|
+
const copyBtn =
|
|
1028
|
+
container.querySelector(".custom-copy-class") ??
|
|
1029
|
+
container.querySelector('button[aria-label*="Copy"]');
|
|
1030
|
+
if (copyBtn) {
|
|
1031
|
+
await fireEvent.click(copyBtn);
|
|
1032
|
+
expect(onClick).toHaveBeenCalled();
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
it("should allow custom component with onClick handling", async () => {
|
|
1037
|
+
const customOnClick = vi.fn();
|
|
1038
|
+
const CustomCopyButton = defineComponent({
|
|
1039
|
+
emits: ["click"],
|
|
1040
|
+
template: `<button data-testid="custom-copy" @click="$emit('click')">Copy</button>`,
|
|
1041
|
+
});
|
|
1042
|
+
const Host = defineComponent({
|
|
1043
|
+
components: {
|
|
1044
|
+
CopilotChatView,
|
|
1045
|
+
CopilotChatMessageView,
|
|
1046
|
+
CopilotChatAssistantMessage,
|
|
1047
|
+
CustomCopyButton,
|
|
1048
|
+
},
|
|
1049
|
+
setup() {
|
|
1050
|
+
return { messages: createMessages(), customOnClick };
|
|
1051
|
+
},
|
|
1052
|
+
template: `
|
|
1053
|
+
<CopilotChatView :messages="messages">
|
|
1054
|
+
<template #message-view="{ messages, isRunning }">
|
|
1055
|
+
<CopilotChatMessageView :messages="messages" :is-running="isRunning">
|
|
1056
|
+
<template #assistant-message="{ message, messages, isRunning }">
|
|
1057
|
+
<CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
|
|
1058
|
+
<template #copy-button="{ onCopy }">
|
|
1059
|
+
<CustomCopyButton
|
|
1060
|
+
@click="
|
|
1061
|
+
customOnClick();
|
|
1062
|
+
onCopy();
|
|
1063
|
+
"
|
|
1064
|
+
/>
|
|
1065
|
+
</template>
|
|
1066
|
+
</CopilotChatAssistantMessage>
|
|
1067
|
+
</template>
|
|
1068
|
+
</CopilotChatMessageView>
|
|
1069
|
+
</template>
|
|
1070
|
+
</CopilotChatView>
|
|
1071
|
+
`,
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
renderInWrapper(Host);
|
|
1075
|
+
const customCopyButtons = screen.queryAllByTestId("custom-copy");
|
|
1076
|
+
if (customCopyButtons.length > 0) {
|
|
1077
|
+
await fireEvent.click(customCopyButtons[0]);
|
|
1078
|
+
expect(customOnClick).toHaveBeenCalled();
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1082
|
+
});
|