@eeacms/volto-eea-chatbot 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.eslintrc.js +6 -6
  2. package/CHANGELOG.md +20 -0
  3. package/artifacts/ONYX_V3_INTEGRATION.md +34 -0
  4. package/jest-addon.config.js +2 -1
  5. package/package.json +1 -1
  6. package/src/ChatBlock/ChatBlockEdit.jsx +2 -1
  7. package/src/ChatBlock/chat/AIMessage.tsx +36 -16
  8. package/src/ChatBlock/chat/ChatMessage.tsx +1 -1
  9. package/src/ChatBlock/chat/ChatWindow.tsx +13 -11
  10. package/src/ChatBlock/chat/UserMessage.tsx +4 -4
  11. package/src/ChatBlock/components/AutoResizeTextarea.jsx +1 -1
  12. package/src/ChatBlock/components/ChatMessageFeedback.jsx +2 -2
  13. package/src/ChatBlock/components/EmptyState.jsx +1 -1
  14. package/src/ChatBlock/components/FeedbackModal.jsx +1 -1
  15. package/src/ChatBlock/components/HalloumiFeedback.jsx +2 -2
  16. package/src/ChatBlock/components/Source.jsx +2 -2
  17. package/src/ChatBlock/components/UserActionsToolbar.jsx +3 -3
  18. package/src/ChatBlock/components/WebResultIcon.tsx +2 -2
  19. package/src/ChatBlock/components/markdown/ClaimModal.jsx +3 -3
  20. package/src/ChatBlock/components/markdown/ClaimSegments.jsx +4 -4
  21. package/src/ChatBlock/components/markdown/{index.js → index.jsx} +1 -1
  22. package/src/ChatBlock/hooks/useChatController.ts +67 -14
  23. package/src/ChatBlock/hooks/useChatStreaming.ts +4 -4
  24. package/src/ChatBlock/hooks/useToolDisplayTiming.ts +2 -1
  25. package/src/ChatBlock/packets/MultiToolRenderer.tsx +86 -56
  26. package/src/ChatBlock/packets/RendererComponent.tsx +13 -5
  27. package/src/ChatBlock/packets/renderers/CustomToolRenderer.tsx +3 -3
  28. package/src/ChatBlock/packets/renderers/FetchToolRenderer.tsx +3 -3
  29. package/src/ChatBlock/packets/renderers/ImageToolRenderer.tsx +3 -3
  30. package/src/ChatBlock/packets/renderers/MessageTextRenderer.tsx +14 -9
  31. package/src/ChatBlock/packets/renderers/ReasoningRenderer.tsx +6 -5
  32. package/src/ChatBlock/packets/renderers/SearchToolRenderer.tsx +30 -21
  33. package/src/ChatBlock/{schema.js → schema.jsx} +13 -0
  34. package/src/ChatBlock/services/messageProcessor.ts +72 -17
  35. package/src/ChatBlock/services/packetUtils.ts +13 -3
  36. package/src/ChatBlock/services/streamingService.ts +155 -68
  37. package/src/ChatBlock/types/streamingModels.ts +47 -2
  38. package/src/ChatBlock/utils/citations.ts +1 -1
  39. package/src/halloumi/filtering.test.js +199 -1
  40. package/src/middleware.js +18 -1
  41. package/src/middleware.test.js +14 -0
  42. package/src/ChatBlock/tests/AIMessage.test.jsx +0 -95
  43. package/src/ChatBlock/tests/AutoResizeTextarea.test.jsx +0 -49
  44. package/src/ChatBlock/tests/BlinkingDot.test.jsx +0 -71
  45. package/src/ChatBlock/tests/ChatMessage.test.jsx +0 -75
  46. package/src/ChatBlock/tests/ChatMessageFeedback.test.jsx +0 -73
  47. package/src/ChatBlock/tests/Citation.test.jsx +0 -107
  48. package/src/ChatBlock/tests/ClaimModal.test.jsx +0 -136
  49. package/src/ChatBlock/tests/ClaimSegments.test.jsx +0 -206
  50. package/src/ChatBlock/tests/CustomToolRenderer.test.jsx +0 -241
  51. package/src/ChatBlock/tests/EmptyState.test.jsx +0 -137
  52. package/src/ChatBlock/tests/FeedbackModal.test.jsx +0 -138
  53. package/src/ChatBlock/tests/FetchToolRenderer.test.jsx +0 -161
  54. package/src/ChatBlock/tests/HalloumiFeedback.test.jsx +0 -94
  55. package/src/ChatBlock/tests/ImageToolRenderer.test.jsx +0 -178
  56. package/src/ChatBlock/tests/MessageTextRenderer.test.jsx +0 -227
  57. package/src/ChatBlock/tests/MultiToolRenderer.test.jsx +0 -134
  58. package/src/ChatBlock/tests/QualityCheckToggle.test.jsx +0 -105
  59. package/src/ChatBlock/tests/ReasoningRenderer.test.jsx +0 -163
  60. package/src/ChatBlock/tests/RelatedQuestions.test.jsx +0 -215
  61. package/src/ChatBlock/tests/RenderClaimView.test.jsx +0 -191
  62. package/src/ChatBlock/tests/RendererComponent.test.jsx +0 -139
  63. package/src/ChatBlock/tests/SearchToolRenderer.test.jsx +0 -295
  64. package/src/ChatBlock/tests/Source.test.jsx +0 -79
  65. package/src/ChatBlock/tests/SourceChip.test.jsx +0 -108
  66. package/src/ChatBlock/tests/Spinner.test.jsx +0 -18
  67. package/src/ChatBlock/tests/UserActionsToolbar.test.jsx +0 -135
  68. package/src/ChatBlock/tests/UserMessage.test.jsx +0 -83
  69. package/src/ChatBlock/tests/WebResultIcon.test.jsx +0 -61
  70. package/src/ChatBlock/tests/citations.test.js +0 -114
  71. package/src/ChatBlock/tests/index.test.js +0 -51
  72. package/src/ChatBlock/tests/messageProcessor.test.jsx +0 -438
  73. package/src/ChatBlock/tests/packetUtils.test.js +0 -158
  74. package/src/ChatBlock/tests/schema.test.js +0 -166
  75. package/src/ChatBlock/tests/streamingService.test.js +0 -467
  76. package/src/ChatBlock/tests/useChatController.test.jsx +0 -268
  77. package/src/ChatBlock/tests/useChatStreaming.test.jsx +0 -163
  78. package/src/ChatBlock/tests/useDeepCompareMemoize.test.js +0 -107
  79. package/src/ChatBlock/tests/useMarked.test.jsx +0 -107
  80. package/src/ChatBlock/tests/useQualityMarkers.test.jsx +0 -150
  81. package/src/ChatBlock/tests/useScrollonStream.test.jsx +0 -121
  82. package/src/ChatBlock/tests/useToolDisplayTiming.test.jsx +0 -151
  83. package/src/ChatBlock/tests/utils.test.jsx +0 -241
  84. package/src/ChatBlock/tests/withOnyxData.test.jsx +0 -81
@@ -1,81 +0,0 @@
1
- import { render, screen, waitFor } from '@testing-library/react';
2
- import '@testing-library/jest-dom';
3
- import withOnyxData from '../hocs/withOnyxData';
4
-
5
- describe('withOnyxData', () => {
6
- it('shows loader initially', () => {
7
- const TestComponent = ({ data }) => <div>Data: {data}</div>;
8
- const callback = () => ['data', null, 'test'];
9
- const WrappedComponent = withOnyxData(callback)(TestComponent);
10
-
11
- render(<WrappedComponent />);
12
-
13
- // The Placeholder component should be rendered
14
- expect(screen.queryByText('Data:')).not.toBeInTheDocument();
15
- });
16
-
17
- it('renders component with fetched data', async () => {
18
- const TestComponent = ({ testData }) => <div>Data: {testData}</div>;
19
- const mockFetcher = Promise.resolve({ body: 'fetched value' });
20
- const callback = () => ['testData', mockFetcher, 'test-key'];
21
- const WrappedComponent = withOnyxData(callback)(TestComponent);
22
-
23
- render(<WrappedComponent />);
24
-
25
- await waitFor(() => {
26
- expect(screen.getByText('Data: fetched value')).toBeInTheDocument();
27
- });
28
- });
29
-
30
- it('passes original props to wrapped component', async () => {
31
- const TestComponent = ({ testData, originalProp }) => (
32
- <div>
33
- Data: {testData}, Original: {originalProp}
34
- </div>
35
- );
36
- const mockFetcher = Promise.resolve({ body: 'fetched value' });
37
- const callback = () => ['testData', mockFetcher, 'test-key'];
38
- const WrappedComponent = withOnyxData(callback)(TestComponent);
39
-
40
- render(<WrappedComponent originalProp="original value" />);
41
-
42
- await waitFor(() => {
43
- expect(
44
- screen.getByText('Data: fetched value, Original: original value'),
45
- ).toBeInTheDocument();
46
- });
47
- });
48
-
49
- it('handles null fetcher', async () => {
50
- const TestComponent = ({ data }) => <div>Data: {data || 'none'}</div>;
51
- const callback = () => ['data', null, 'test'];
52
- const WrappedComponent = withOnyxData(callback)(TestComponent);
53
-
54
- render(<WrappedComponent />);
55
-
56
- // Should stay in loading state
57
- await new Promise((resolve) => setTimeout(resolve, 100));
58
- expect(screen.queryByText('Data: none')).not.toBeInTheDocument();
59
- });
60
-
61
- it('refetches when depKey changes', async () => {
62
- const TestComponent = ({ testData }) => <div>Data: {testData}</div>;
63
- const callback = (props) => {
64
- const mockFetcher = Promise.resolve({ body: `value-${props.depKey}` });
65
- return ['testData', mockFetcher, props.depKey];
66
- };
67
- const WrappedComponent = withOnyxData(callback)(TestComponent);
68
-
69
- const { rerender } = render(<WrappedComponent depKey="key1" />);
70
-
71
- await waitFor(() => {
72
- expect(screen.getByText('Data: value-key1')).toBeInTheDocument();
73
- });
74
-
75
- rerender(<WrappedComponent depKey="key2" />);
76
-
77
- await waitFor(() => {
78
- expect(screen.getByText('Data: value-key2')).toBeInTheDocument();
79
- });
80
- });
81
- });